diff --git a/classes/ezdbistoragecker.php b/classes/ezdbistoragecker.php index 122b56d..aa77eba 100644 --- a/classes/ezdbistoragecker.php +++ b/classes/ezdbistoragecker.php @@ -18,7 +18,7 @@ class ezdbiStorageChecker extends ezdbiBaseChecker protected $checks = array( 'Images' => 'checks for any image file in the storage dir which are not in the ezimage table', 'Files' => 'checks for any binary file in the storage dir which are not in the ezmedia or ezbinaryfile tables', - 'ImagesAliases' => 'checks for any image alias file in the _aliases dir whithout original image file', + 'eZPlatformImageAliases' => 'checks for any image file in the _aliases dir without its original image file (as used by eZPlatform)', ); public function __construct( $dsn='' ) @@ -60,8 +60,8 @@ public function check( $type, $doDelete=false, $returnData=false ) return $this->checkImages( $doDelete, $returnData ); case 'Files': return $this->checkFiles( $doDelete, $returnData ); - case 'ImagesAliases': - return $this->checkImageAliases( $doDelete, $returnData ); + case 'eZPlatformImageAliases': + return $this->checkEzPlatformImageAliases( $doDelete, $returnData ); default: throw new \Exception( "Unsupported type: '$type'" ); } @@ -157,7 +157,7 @@ public function checkFiles( $doDelete=false, $returnData=false ) continue; } - foreach ( glob( $storageDir . '/*') as $storageFile ) + foreach ( glob( $storageDir . '/*' ) as $storageFile ) { if ( !is_file( $storageFile ) ) { @@ -192,9 +192,9 @@ public function checkFiles( $doDelete=false, $returnData=false ) $violations['violatingFiles'][] = $storageFile; } - if ($doDelete) + if ( $doDelete ) { - unlink($storageFile); + unlink( $storageFile ); } } /*else @@ -207,11 +207,16 @@ public function checkFiles( $doDelete=false, $returnData=false ) return $violations; } - public function checkImageAliases( $doDelete = false, $returnData = false ) + public function checkEzPlatformImageAliases( $doDelete = false, $returnData = false ) { $violations = array(); $ini = eZINI::instance( 'image.ini' ); + if ( !$ini->hasVariable( 'FileSettings', 'PublishedImages' ) ) + { + return $violations; + } + $pDir = $this->clusterizeDir( eZSys::storageDirectory() . '/' . $ini->variable( 'FileSettings', 'PublishedImages' ) ); $aliasDir = realpath( $pDir . '/_aliases' ); @@ -251,11 +256,15 @@ public function checkImageAliases( $doDelete = false, $returnData = false ) $violations['violatingFiles'][] = $aliasFileName; } - if ($doDelete) + if ( $doDelete ) { - unlink($aliasFileName); + unlink( $aliasFileName ); } } + /*else + { + echo "OK: $aliasFileName\n"; + }*/ } } } diff --git a/doc/changelogs/changelog-0.22.0-to-0.23.0 b/doc/changelogs/changelog-0.22.0-to-0.23.0 index ad85b9d..1a7473c 100644 --- a/doc/changelogs/changelog-0.22.0-to-0.23.0 +++ b/doc/changelogs/changelog-0.22.0-to-0.23.0 @@ -2,4 +2,7 @@ changelog from version 0.22.0 to 0.23.0 . fixed: do not report as invalid the image variations file created from eZPlatform onwards, as they are not tied to the ezimagefile table. Thanks @blankse + +. new: added a check for eZPlatform image variations, as part of the `checkstorage.php` command + . fixed php warnings reported by @blankse diff --git a/extension.xml b/extension.xml index 165abd1..2337457 100644 --- a/extension.xml +++ b/extension.xml @@ -2,7 +2,7 @@ eZ DB Integrity extension - 0.22.0 + 0.23.0 Copyright (C) 2014-2020 Gaetano Giunta GNU General Public License v2.0 diff --git a/ezinfo.php b/ezinfo.php index a0127f5..561e5ea 100644 --- a/ezinfo.php +++ b/ezinfo.php @@ -6,7 +6,7 @@ static function info() { return array( 'Name' => "eZ DB Integrity extension", - 'Version' => "0.22.0", + 'Version' => "0.23.0", 'Copyright' => "Copyright (C) 2014-2020 Gaetano Giunta", 'License' => "GNU General Public License v2.0" );