Forums / Developer / eZContentOperationCollection vs content/updateobjectstate operation

eZContentOperationCollection vs content/updateobjectstate operation

Author Message

Marko Žmak

Wednesday 29 June 2011 3:13:50 pm

In kernel/state/assign.php we have this part of code:

if ( eZOperationHandler::operationIsAvailable( 'content_updateobjectstate' ) )
{
    $operationResult = eZOperationHandler::execute( 'content', 'updateobjectstate',
                                                    array( 'object_id'     => $objectID,
                                                           'state_id_list' => $selectedStateIDList ) );
}
else
{
    eZContentOperationCollection::updateObjectState( $objectID, $selectedStateIDList );
}

So there's a check if the content_updateobjectstate exists, and if ti doesn't then eZContentOperationCollection::updateObjectState() is used.

Why this amibguity? Why do we have the ability to use both ways and not only one?

And if I develop an extension that changes object state, what should I use? Which is the proper way of doing it?

--
Nothing is impossible. Not if you can imagine it!

Hubert Farnsworth

Damien Pobel

Thursday 30 June 2011 5:12:59 am

Hi Marko,

"

So there's a check if the content_updateobjectstate exists, and if ti doesn't then eZContentOperationCollection::updateObjectState() is used.

Why this amibguity? Why do we have the ability to use both ways and not only one?

"

It's not exactly a check against content_updateobjectstate existence but against wether the operation is activated or not in workflow.ini/[OperationSettings]/AvailableOperations

So both will do the job, but with the operation you can plug a workflow event type while without you can't.

This is done this way to avoid the performance penalty of always using the operation even if there's no workflow.

Cheers

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

Marko Žmak

Thursday 30 June 2011 5:27:25 am

"

This is done this way to avoid the performance penalty of always using the operation even if there's no workflow.

"

Any idea about how much is the penalty?

Is this pinciple, of avoiding using operations where there's no workflow, used consistently through the eZP code? Is it done like this in all parts where we can have/nothave operations and workflows?

--
Nothing is impossible. Not if you can imagine it!

Hubert Farnsworth

Damien Pobel

Friday 01 July 2011 10:30:19 am

I'm not sure about the performance penalty...

But, yes this is done like this for all operations that were added in 4.2 or 4.3 (I don't remember which version) :

$ grep -RH 'eZOperationHandler::operationIsAvailable' *
extension/ezjscore/classes/ezjscserverfunctionsnode.php:        if ( eZOperationHandler::operationIsAvailable( 'content_updatepriority' ) )
kernel/content/view.php:if ( eZOperationHandler::operationIsAvailable( 'content_read' ) )
kernel/content/translation.php:        if ( eZOperationHandler::operationIsAvailable( 'content_updateinitiallanguage' ) )
kernel/content/translation.php:    if ( eZOperationHandler::operationIsAvailable( 'content_updatealwaysavailable' ) )
kernel/content/translation.php:        if ( eZOperationHandler::operationIsAvailable( 'content_removetranslation' ) )
kernel/content/state_edit.php:            if ( eZOperationHandler::operationIsAvailable( 'content_updateobjectstate' ) )
kernel/content/action.php:    if ( eZOperationHandler::operationIsAvailable( 'content_sort' ) )
kernel/content/action.php:        if ( eZOperationHandler::operationIsAvailable( 'content_move' ) )
kernel/content/action.php:    if ( eZOperationHandler::operationIsAvailable( 'content_swap' ) )
kernel/content/action.php:            if ( eZOperationHandler::operationIsAvailable( 'content_updatemainassignment' ) )
kernel/content/action.php:        if ( eZOperationHandler::operationIsAvailable( 'content_addlocation' ) )
kernel/content/action.php:        if ( eZOperationHandler::operationIsAvailable( 'content_removelocation' ) )
kernel/content/action.php:        if ( eZOperationHandler::operationIsAvailable( 'content_updatepriority' ) )
kernel/content/action.php:            if ( eZOperationHandler::operationIsAvailable( 'content_createnodefeed' ) )
kernel/content/action.php:            if ( eZOperationHandler::operationIsAvailable( 'content_removenodefeed' ) )
kernel/content/removeobject.php:    if ( eZOperationHandler::operationIsAvailable( 'content_delete' ) )
kernel/content/removeobject.php:        if ( eZOperationHandler::operationIsAvailable( 'content_removelocation' ) )
kernel/content/section_edit.php:                            if ( eZOperationHandler::operationIsAvailable( 'content_updatesection' ) )
kernel/content/hide.php:if ( eZOperationHandler::operationIsAvailable( 'content_hide' ) )
kernel/state/assign.php:    if ( eZOperationHandler::operationIsAvailable( 'content_updateobjectstate' ) )
kernel/user/preferences.php:if ( eZOperationHandler::operationIsAvailable( 'user_preferences' ) )
kernel/user/ezuseroperationcollection.php:            if ( eZOperationHandler::operationIsAvailable( 'user_activation' ) )
kernel/user/password.php:                if ( eZOperationHandler::operationIsAvailable( 'user_password' ) )
kernel/user/forgotpassword.php:        if ( eZOperationHandler::operationIsAvailable( 'user_password' ) )
kernel/user/forgotpassword.php:            if ( eZOperationHandler::operationIsAvailable( 'user_forgotpassword' ) )
kernel/user/activate.php:    if ( eZOperationHandler::operationIsAvailable( 'user_activation' ) )
kernel/user/setting.php:    if ( eZOperationHandler::operationIsAvailable( 'user_setsettings' ) )

Cheers

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

Marko Žmak

Saturday 02 July 2011 5:31:20 am

So I guess disabling some of the available operations for which I don't need workflows could bring some performance improvements...

I wonder how much improvement would bring and is it worth the work?

--
Nothing is impossible. Not if you can imagine it!

Hubert Farnsworth