Skip to content

Commit

Permalink
cleanup of ImageAliases check
Browse files Browse the repository at this point in the history
  • Loading branch information
gggeek committed Dec 4, 2020
1 parent 3e890b3 commit aa3a750
Show file tree
Hide file tree
Showing 4 changed files with 23 additions and 11 deletions.
27 changes: 18 additions & 9 deletions classes/ezdbistoragecker.php
Original file line number Diff line number Diff line change
Expand Up @@ -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='' )
Expand Down Expand Up @@ -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'" );
}
Expand Down Expand Up @@ -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 ) )
{
Expand Down Expand Up @@ -192,9 +192,9 @@ public function checkFiles( $doDelete=false, $returnData=false )
$violations['violatingFiles'][] = $storageFile;
}

if ($doDelete)
if ( $doDelete )
{
unlink($storageFile);
unlink( $storageFile );
}
}
/*else
Expand All @@ -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' );

Expand Down Expand Up @@ -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";
}*/
}
}
}
Expand Down
3 changes: 3 additions & 0 deletions doc/changelogs/changelog-0.22.0-to-0.23.0
Original file line number Diff line number Diff line change
Expand Up @@ -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
2 changes: 1 addition & 1 deletion extension.xml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
<software>
<metadata>
<name>eZ DB Integrity extension</name>
<version>0.22.0</version>
<version>0.23.0</version>
<copyright>Copyright (C) 2014-2020 Gaetano Giunta</copyright>
<license>GNU General Public License v2.0</license>
</metadata>
Expand Down
2 changes: 1 addition & 1 deletion ezinfo.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ static function info()
{
return array(
'Name' => "<a href=\"http://projects.ez.no/ezdbintegrity\">eZ DB Integrity extension</a>",
'Version' => "0.22.0",
'Version' => "0.23.0",
'Copyright' => "Copyright (C) 2014-2020 Gaetano Giunta",
'License' => "GNU General Public License v2.0"
);
Expand Down

0 comments on commit aa3a750

Please sign in to comment.