mirror of
https://github.com/e107inc/e107.git
synced 2025-01-17 12:48:24 +01:00
Hotfix: Don't fatal error if core_image.php is corrupt
This commit is contained in:
parent
4e78b5e1ad
commit
a04db4e2c8
@ -1611,7 +1611,28 @@ class e107
|
||||
*/
|
||||
public static function getFileInspector($type = 'core')
|
||||
{
|
||||
return self::getObject('e_file_inspector_json_phar', e_ADMIN . "core_image.php");
|
||||
$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;
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -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)
|
||||
|
@ -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)
|
||||
|
@ -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()
|
||||
|
Loading…
x
Reference in New Issue
Block a user