summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGreg Roach <fisharebest@gmail.com>2018-01-18 09:50:07 +0000
committerGreg Roach <fisharebest@gmail.com>2018-01-18 09:57:52 +0000
commit2361dfe8758e06aedeb092542c4d83e845ee213f (patch)
tree9bd809a74399ba8adff7add800a208f8792ad015
parentf0195b9095dabe8ab8a9d33943d49645c652d329 (diff)
downloadwebtrees-2361dfe8758e06aedeb092542c4d83e845ee213f.tar.gz
webtrees-2361dfe8758e06aedeb092542c4d83e845ee213f.tar.bz2
webtrees-2361dfe8758e06aedeb092542c4d83e845ee213f.zip
Replace PHP5 ErrorException with PHP7 Throwable
-rw-r--r--app/File.php8
-rw-r--r--app/Http/Controllers/AdminController.php3
-rw-r--r--app/Http/Controllers/MediaFileController.php6
-rw-r--r--app/MediaFile.php6
-rw-r--r--app/Schema/Migration22.php3
-rw-r--r--includes/session.php9
-rw-r--r--setup.php6
7 files changed, 14 insertions, 27 deletions
diff --git a/app/File.php b/app/File.php
index bcb095547b..078ebd3fd0 100644
--- a/app/File.php
+++ b/app/File.php
@@ -15,6 +15,8 @@
*/
namespace Fisharebest\Webtrees;
+use Throwable;
+
/**
* File manipulation utilities.
*/
@@ -37,7 +39,7 @@ class File {
closedir($dir);
try {
rmdir($path);
- } catch (\ErrorException $ex) {
+ } catch (Throwable $ex) {
DebugBar::addThrowable($ex);
// Continue, in case there are other files/folders that we can delete.
@@ -45,7 +47,7 @@ class File {
} else {
try {
unlink($path);
- } catch (\ErrorException $ex) {
+ } catch (Throwable $ex) {
DebugBar::addThrowable($ex);
// Continue, in case there are other files/folders that we can delete.
@@ -73,7 +75,7 @@ class File {
mkdir($path);
return true;
- } catch (\ErrorException $ex) {
+ } catch (Throwable $ex) {
DebugBar::addThrowable($ex);
return false;
diff --git a/app/Http/Controllers/AdminController.php b/app/Http/Controllers/AdminController.php
index db6568cda4..dd11e0a8e0 100644
--- a/app/Http/Controllers/AdminController.php
+++ b/app/Http/Controllers/AdminController.php
@@ -18,7 +18,6 @@ declare(strict_types=1);
namespace Fisharebest\Webtrees\Http\Controllers;
use DirectoryIterator;
-use ErrorException;
use FilesystemIterator;
use Fisharebest\Algorithm\MyersDiff;
use Fisharebest\Webtrees\Auth;
@@ -1875,7 +1874,7 @@ class AdminController extends BaseController {
if (getimagesize($original) === false) {
return 0;
}
- } catch (ErrorException $ex) {
+ } catch (Throwable $ex) {
// If the first file is not an image then the thumbnail .
// Response with an exact mismatch, so the GUI will recommend importing it.
return 0;
diff --git a/app/Http/Controllers/MediaFileController.php b/app/Http/Controllers/MediaFileController.php
index dbf1945874..7f77a90b51 100644
--- a/app/Http/Controllers/MediaFileController.php
+++ b/app/Http/Controllers/MediaFileController.php
@@ -17,7 +17,6 @@ declare(strict_types=1);
namespace Fisharebest\Webtrees\Http\Controllers;
-use ErrorException;
use Fisharebest\Webtrees\Media;
use Fisharebest\Webtrees\MediaFile;
use Fisharebest\Webtrees\Site;
@@ -34,6 +33,7 @@ use League\Glide\Signatures\SignatureFactory;
use Symfony\Component\HttpFoundation\RedirectResponse;
use Symfony\Component\HttpFoundation\Request;
use Symfony\Component\HttpFoundation\Response;
+use Throwable;
/**
* Controller for the media page and displaying images.
@@ -103,7 +103,7 @@ class MediaFileController extends BaseController {
return $this->httpStatusAsImage(Response::HTTP_NOT_FOUND);
} catch (NotReadableException $ex) {
return $this->httpStatusAsImage(Response::HTTP_INTERNAL_SERVER_ERROR);
- } catch (ErrorException $ex) {
+ } catch (Throwable $ex) {
return $this->httpStatusAsImage(Response::HTTP_INTERNAL_SERVER_ERROR);
}
}
@@ -136,7 +136,7 @@ class MediaFileController extends BaseController {
return $this->httpStatusAsImage(Response::HTTP_FORBIDDEN);
} catch (FileNotFoundException $ex) {
return $this->httpStatusAsImage(Response::HTTP_NOT_FOUND);
- } catch (ErrorException $ex) {
+ } catch (Throwable $ex) {
return $this->httpStatusAsImage(Response::HTTP_INTERNAL_SERVER_ERROR);
}
}
diff --git a/app/MediaFile.php b/app/MediaFile.php
index a9d21df2b0..96e8b9084b 100644
--- a/app/MediaFile.php
+++ b/app/MediaFile.php
@@ -15,8 +15,8 @@
*/
namespace Fisharebest\Webtrees;
-use ErrorException;
use League\Glide\Urls\UrlBuilderFactory;
+use Throwable;
/**
* A GEDCOM media file. A media object can contain many media files,
@@ -265,7 +265,7 @@ class MediaFile {
private function fileSizeBytes(): int {
try {
return filesize($this->folder() . $this->multimedia_file_refn);
- } catch (ErrorException $ex) {
+ } catch (Throwable $ex) {
DebugBar::addThrowable($ex);
return 0;
@@ -320,7 +320,7 @@ class MediaFile {
$imgsize['WxH'] = /* I18N: image dimensions, width × height */
I18N::translate('%1$s × %2$s pixels', I18N::number($imgsize['0']), I18N::number($imgsize['1']));
}
- } catch (ErrorException $ex) {
+ } catch (Throwable $ex) {
DebugBar::addThrowable($ex);
// Not an image, or not a valid image?
diff --git a/app/Schema/Migration22.php b/app/Schema/Migration22.php
index e264c24806..1c8554785f 100644
--- a/app/Schema/Migration22.php
+++ b/app/Schema/Migration22.php
@@ -18,6 +18,7 @@ namespace Fisharebest\Webtrees\Schema;
use Fisharebest\Webtrees\Database;
use Fisharebest\Webtrees\DebugBar;
use Fisharebest\Webtrees\File;
+use Throwable;
/**
* Upgrade the database schema from version 22 to version 23.
@@ -79,7 +80,7 @@ class Migration22 implements MigrationInterface {
) {
try {
rename(WT_ROOT . $_cfg->media_directory, $WT_DATA_DIR . $_cfg->media_directory);
- } catch (\ErrorException $ex) {
+ } catch (Throwable $ex) {
DebugBar::addThrowable($ex);
// Cannot move the folder?
diff --git a/includes/session.php b/includes/session.php
index 27dddd56d3..7d0ac50fbb 100644
--- a/includes/session.php
+++ b/includes/session.php
@@ -16,7 +16,6 @@
namespace Fisharebest\Webtrees;
use DateTime;
-use ErrorException;
use Fisharebest\Webtrees\Theme\AdministrationTheme;
use League\Flysystem\Adapter\Local;
use League\Flysystem\Filesystem;
@@ -120,14 +119,6 @@ define('WT_BASE_URL', $base_uri);
// What is the name of the requested script.
define('WT_SCRIPT_NAME', basename(Filter::server('SCRIPT_NAME')));
-// Convert PHP errors into exceptions
-set_error_handler(function ($errno, $errstr, $errfile, $errline) {
- // Ignore errors thar are silenced with '@'
- if (error_reporting() & $errno) {
- throw new ErrorException($errfile . ':' . $errline . ' ' . $errstr, $errno);
- }
-});
-
set_exception_handler(function (Throwable $ex) {
$message = $ex->getFile() . ':' . $ex->getLine() . ' ' . $ex->getMessage() . PHP_EOL;
diff --git a/setup.php b/setup.php
index 8245a431e4..389327af96 100644
--- a/setup.php
+++ b/setup.php
@@ -15,7 +15,6 @@
*/
namespace Fisharebest\Webtrees;
-use ErrorException;
use Fisharebest\Webtrees\Http\Controllers\SetupController;
use Symfony\Component\HttpFoundation\RedirectResponse;
use Symfony\Component\HttpFoundation\Request;
@@ -40,11 +39,6 @@ define('WT_ROOT', '');
// PHP requires a time zone to be set. We'll set a better one later on.
date_default_timezone_set('UTC');
-// Convert PHP errors into exceptions
-set_error_handler(function ($errno, $errstr, $errfile, $errline) {
- throw new ErrorException($errstr, 0, $errno, $errfile, $errline);
-});
-
define('WT_LOCALE', I18N::init('en-US'));
// The HTTP request.