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

eZ debug

Timing: Jan 17 2025 21:21:09
Script start
Timing: Jan 17 2025 21:21:09
Module start 'content'
Timing: Jan 17 2025 21:21:10
Module end 'content'
Timing: Jan 17 2025 21:21:10
Script end

Main resources:

Total runtime0.8425 sec
Peak memory usage4,096.0000 KB
Database Queries200

Timing points:

CheckpointStart (sec)Duration (sec)Memory at start (KB)Memory used (KB)
Script start 0.00000.0057 597.4531180.8047
Module start 'content' 0.00570.7307 778.2578637.0625
Module end 'content' 0.73640.1059 1,415.3203345.5703
Script end 0.8424  1,760.8906 

Time accumulators:

 Accumulator Duration (sec) Duration (%) Count Average (sec)
Ini load
Load cache0.00360.4258210.0002
Check MTime0.00130.1576210.0001
Mysql Total
Database connection0.00080.094710.0008
Mysqli_queries0.768891.26142000.0038
Looping result0.00170.20741980.0000
Template Total0.820397.420.4102
Template load0.00180.213320.0009
Template processing0.818597.155720.4093
Template load and register function0.00010.013810.0001
states
state_id_array0.00070.083710.0007
state_identifier_array0.00060.073120.0003
Override
Cache load0.00150.1780350.0000
Sytem overhead
Fetch class attribute can translate value0.00140.162530.0005
Fetch class attribute name0.00090.111570.0001
XML
Image XML parsing0.00160.184930.0005
class_abstraction
Instantiating content class attribute0.00000.0023100.0000
General
dbfile0.00220.2554350.0001
String conversion0.00000.000830.0000
Note: percentages do not add up to 100% because some accumulators overlap

CSS/JS files loaded with "ezjscPacker" during request:

CacheTypePacklevelSourceFiles
CSS0extension/community/design/community/stylesheets/ext/jquery.autocomplete.css
extension/community_design/design/suncana/stylesheets/scrollbars.css
extension/community_design/design/suncana/stylesheets/tabs.css
extension/community_design/design/suncana/stylesheets/roadmap.css
extension/community_design/design/suncana/stylesheets/content.css
extension/community_design/design/suncana/stylesheets/star-rating.css
extension/community_design/design/suncana/stylesheets/syntax_and_custom_tags.css
extension/community_design/design/suncana/stylesheets/buttons.css
extension/community_design/design/suncana/stylesheets/tweetbox.css
extension/community_design/design/suncana/stylesheets/jquery.fancybox-1.3.4.css
extension/bcsmoothgallery/design/standard/stylesheets/magnific-popup.css
extension/sevenx/design/simple/stylesheets/star_rating.css
extension/sevenx/design/simple/stylesheets/libs/fontawesome/css/all.min.css
extension/sevenx/design/simple/stylesheets/main.v02.css
extension/sevenx/design/simple/stylesheets/main.v02.res.css
JS0extension/ezjscore/design/standard/lib/yui/3.17.2/build/yui/yui-min.js
extension/ezjscore/design/standard/javascript/jquery-3.7.0.min.js
extension/community_design/design/suncana/javascript/jquery.ui.core.min.js
extension/community_design/design/suncana/javascript/jquery.ui.widget.min.js
extension/community_design/design/suncana/javascript/jquery.easing.1.3.js
extension/community_design/design/suncana/javascript/jquery.ui.tabs.js
extension/community_design/design/suncana/javascript/jquery.hoverIntent.min.js
extension/community_design/design/suncana/javascript/jquery.popmenu.js
extension/community_design/design/suncana/javascript/jScrollPane.js
extension/community_design/design/suncana/javascript/jquery.mousewheel.js
extension/community_design/design/suncana/javascript/jquery.cycle.all.js
extension/sevenx/design/simple/javascript/jquery.scrollTo.js
extension/community_design/design/suncana/javascript/jquery.cookie.js
extension/community_design/design/suncana/javascript/ezstarrating_jquery.js
extension/community_design/design/suncana/javascript/jquery.initboxes.js
extension/community_design/design/suncana/javascript/app.js
extension/community_design/design/suncana/javascript/twitterwidget.js
extension/community_design/design/suncana/javascript/community.js
extension/community_design/design/suncana/javascript/roadmap.js
extension/community_design/design/suncana/javascript/ez.js
extension/community_design/design/suncana/javascript/ezshareevents.js
extension/sevenx/design/simple/javascript/main.js

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
5content/datatype/view/ezimage.tpl<No override>extension/sevenx/design/simple/templates/content/datatype/view/ezimage.tplEdit templateOverride template
5content/datatype/view/ezxmltext.tpl<No override>extension/community_design/design/suncana/templates/content/datatype/view/ezxmltext.tplEdit templateOverride template
9content/datatype/view/ezxmltags/paragraph.tpl<No override>extension/ezwebin/design/ezwebin/templates/content/datatype/view/ezxmltags/paragraph.tplEdit templateOverride template
2content/datatype/view/ezxmltags/literal.tpl<No override>extension/community/design/standard/templates/content/datatype/view/ezxmltags/literal.tplEdit templateOverride template
2content/datatype/view/ezxmltags/quote.tpldatatype/ezxmltext/quote.tplextension/ezwebin/design/ezwebin/override/templates/datatype/ezxmltext/quote.tplEdit templateOverride template
1pagelayout.tpl<No override>extension/sevenx/design/simple/templates/pagelayout.tplEdit templateOverride template
 Number of times templates used: 25
 Number of unique templates used: 7

Time used to render debug report: 0.0001 secs