Image file cleanup

Author Message

Sebastiaan van der Vliet

Tuesday 02 June 2009 5:48:44 am

Hi,

It appears that the bin/php/flatten.php script to remove non-published versions of the object does not clean up the matching image files per removed object version. Is this a correct assumption, and if so, what function/script would be the best option to use to clean up the image files?

Thanks,
Sebastiaan

Certified eZ publish developer with over 9 years of eZ publish experience. Available for challenging eZ publish projects as a technical consultant, project manager, trouble shooter or strategic advisor.

Sebastiaan van der Vliet

Tuesday 02 June 2009 7:59:42 am

Hmm-what about this...

function deleteOldVersions( $eZObjectID )
{
	 global $cli;
	$eZObject = eZContentObject::fetch( $eZObjectID );
	$objectVersions = $eZObject->versions();
	
	$objectVersionID = $eZObject->attribute( 'current_version' );
	$cli->output(count($objectVersions)." versions");
	foreach ( $objectVersions as $version )
	{
		$versionID = $version->attribute('version');
		if ($objectVersionID != $versionID)
		{
			$contentObjectAttributes = $version->contentObjectAttributes();
			
			foreach ( $contentObjectAttributes as $contentObjectAttribute )
			{
				
				$classAttribute = $contentObjectAttribute->contentClassAttribute();
				$dataTypeString = $classAttribute->attribute( 'data_type_string' );

				if ($dataTypeString == "ezimage")
				{
					 eZImageAliasHandler::removeAllAliases( $contentObjectAttribute );
	 				$cli->output("deleting image");
				}
			}		    	
			$db = eZDB::instance();
			$db->begin();
			$version->removeThis();
			$cli->output("removing version ".$versionID);
			$db->commit();
		}
	}
	$objectVersions = $eZObject->versions();
	$cli->output(count($objectVersions)." versions remaining. Current version is ".$objectVersionID);
}

Certified eZ publish developer with over 9 years of eZ publish experience. Available for challenging eZ publish projects as a technical consultant, project manager, trouble shooter or strategic advisor.

Heath

Tuesday 02 June 2009 9:02:03 am

Sebastiaan,

I would recommend creating a new issue in the issue tracker to add this functionality into the default ezpublish releases. This seems like something that should be available by default.

Cheers,
Heath

Brookins Consulting | http://brookinsconsulting.com/
Certified | http://auth.ez.no/certification/verify/380350
Solutions | http://projects.ez.no/users/community/brookins_consulting
eZpedia community documentation project | http://ezpedia.org

Powered by eZ Publish™ CMS Open Source Web Content Management. Copyright © 1999-2014 eZ Systems AS (except where otherwise noted). All rights reserved.

eZ debug

Timing: Jan 18 2025 18:23:35
Script start
Timing: Jan 18 2025 18:23:35
Module start 'layout'
Timing: Jan 18 2025 18:23:35
Module start 'content'
Timing: Jan 18 2025 18:23:36
Module end 'content'
Timing: Jan 18 2025 18:23:36
Script end

Main resources:

Total runtime0.6402 sec
Peak memory usage4,096.0000 KB
Database Queries57

Timing points:

CheckpointStart (sec)Duration (sec)Memory at start (KB)Memory used (KB)
Script start 0.00000.0055 587.9141152.6250
Module start 'layout' 0.00560.0028 740.539139.4453
Module start 'content' 0.00840.6305 779.9844549.6250
Module end 'content' 0.63890.0012 1,329.609412.1719
Script end 0.6402  1,341.7813 

Time accumulators:

 Accumulator Duration (sec) Duration (%) Count Average (sec)
Ini load
Load cache0.00350.5517160.0002
Check MTime0.00140.2140160.0001
Mysql Total
Database connection0.00090.139010.0009
Mysqli_queries0.593892.7496570.0104
Looping result0.00050.0747550.0000
Template Total0.606894.820.3034
Template load0.00220.351520.0011
Template processing0.604594.424020.3022
Template load and register function0.00010.012810.0001
states
state_id_array0.00100.159810.0010
state_identifier_array0.00090.145920.0005
Override
Cache load0.00190.2937180.0001
Sytem overhead
Fetch class attribute can translate value0.00040.069620.0002
Fetch class attribute name0.00110.169750.0002
XML
Image XML parsing0.00090.134220.0004
class_abstraction
Instantiating content class attribute0.00000.001560.0000
General
dbfile0.00080.1297240.0000
String conversion0.00000.001140.0000
Note: percentages do not add up to 100% because some accumulators overlap

Templates used to render the page:

UsageRequested templateTemplateTemplate loadedEditOverride
1node/view/full.tplfull/forum_topic.tplextension/sevenx/design/simple/override/templates/full/forum_topic.tplEdit templateOverride template
3content/datatype/view/ezimage.tpl<No override>extension/sevenx/design/simple/templates/content/datatype/view/ezimage.tplEdit templateOverride template
3content/datatype/view/ezxmltext.tpl<No override>extension/community_design/design/suncana/templates/content/datatype/view/ezxmltext.tplEdit templateOverride template
5content/datatype/view/ezxmltags/paragraph.tpl<No override>extension/ezwebin/design/ezwebin/templates/content/datatype/view/ezxmltags/paragraph.tplEdit templateOverride template
2content/datatype/view/ezxmltags/line.tpl<No override>design/standard/templates/content/datatype/view/ezxmltags/line.tplEdit templateOverride template
1content/datatype/view/ezxmltags/literal.tpl<No override>extension/community/design/standard/templates/content/datatype/view/ezxmltags/literal.tplEdit templateOverride template
1print_pagelayout.tpl<No override>extension/community/design/community/templates/print_pagelayout.tplEdit templateOverride template
 Number of times templates used: 16
 Number of unique templates used: 7

Time used to render debug report: 0.0001 secs