1
0
mirror of https://github.com/e107inc/e107.git synced 2025-01-17 04:38:27 +01:00

Hotfix: Don't fatal error if core_image.php is corrupt

This commit is contained in:
Nick Liu 2020-03-29 13:49:18 -05:00
parent 4e78b5e1ad
commit a04db4e2c8
No known key found for this signature in database
GPG Key ID: 1167C5F9C9897637
4 changed files with 26 additions and 5 deletions

View File

@ -1609,9 +1609,30 @@ class e107
*
* @return e_file_inspector
*/
public static function getFileInspector($type = 'core')
{
return self::getObject('e_file_inspector_json_phar', e_ADMIN . "core_image.php");
public static function getFileInspector($type = 'core')
{
$fileInspectorPath = realpath(e_ADMIN . "core_image.php");
/** @var e_file_inspector $fileInspector */
$fileInspector = self::getObject('e_file_inspector_json_phar', $fileInspectorPath);
try
{
$fileInspector->loadDatabase();
}
catch (Exception $e)
{
// TODO: LAN
self::getMessage()->addWarning(
"The core integrity image is corrupt. " .
"File Inspector will be inoperative. " .
"Resolve this issue by uploading a good copy of the core image to " .
escapeshellarg($fileInspectorPath) . ". " .
"Error message: " .
$e->getMessage()
);
}
return $fileInspector;
}
/**

View File

@ -61,7 +61,6 @@ abstract class e_file_inspector implements e_file_inspector_interface
public function __construct($database)
{
$this->database = $database;
$this->loadDatabase();
$appRoot = e107::getInstance()->file_path;
$this->undeterminable = array_map(function ($path)

View File

@ -40,7 +40,7 @@ class e_file_inspector_json extends e_file_inspector
*/
public function getPathIterator($version = null)
{
$result = $this->coreImage;
$result = $this->coreImage ? $this->coreImage : [];
if (!empty($version))
{
$result = array_filter($result, function ($value) use ($version)

View File

@ -19,6 +19,7 @@ class e_file_inspectorTest extends \Codeception\Test\Unit
require_once(e_HANDLER . "e_file_inspector_json_phar.php");
// TODO: Make test databases; don't hard-code e107_admin/core_image.php and hope it has the expected content.
$this->e_integrity = new e_file_inspector_json_phar(e_ADMIN . "core_image.php");
$this->e_integrity->loadDatabase();
}
public function testGetChecksums()