Forums / Developer / cli script slow / Comment48512

Author Topic

Damien Pobel

Thursday 06 September 2007 8:13:19 am

Comment48512

Hi Oliver,

you can also replace this part :

foreach( $version->contentObjectAttributes() as $attr )
{
    $attr_datatype = $attr->attribute( 'data_type_string' );
    $attr_id = $attr->attribute('contentclass_attribute_identifier');
    if ($attr_id == 'date_publish') {
        $date = strftime("%d.%b %Y", $newtime);
        print "setting date of ".$article->attribute('name')." to ".$date."\n";
        $attr->fromString($newtime);
        $attr->store();
    }
}

by something like this :

$dataMap = $version->dataMap();
if ( array_key_exists( 'date_publish', $dataMap ) )
{
    $date = strftime("%d.%b %Y", $newtime);
    print "setting date of ".$article->attribute('name')." to ".$date."\n";
    $dataMap['date_publish']->fromString( $newtime );
    $dataMap['date_publish']->store();
}

It avoids looping on content attributes whereas you know its identifier...

Damien
Planet eZ Publish.fr : http://www.planet-ezpublish.fr
Certification : http://auth.ez.no/certification/verify/372448
Publications about eZ Publish : http://pwet.fr/tags/keywords/weblog/ez_publish