Forums / Discussions / Finding double-published items

Wednesday 29 June 2011 2:48:00 pm - 7 replies

Introduction

I had to find objects that had multiple locations for a client.  This is what I came up with:

» Read full blog post

Author Message

Marko Žmak

Thursday 30 June 2011 3:53:08 am

Just out of curiosity, did you have to find the objects which got multiple locations by error, or was it for some other reason?

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

Hubert Farnsworth

Steven E. Bailey

Thursday 30 June 2011 4:11:06 pm

I was trying to track down wether smart view caching was only clearing the parent node/siblings of the main node.

Unintended double-publishing, haven't heard anything about that?

Certified eZPublish developer
http://ez.no/certification/verify/396111

Available for ezpublish troubleshooting, hosting and custom extension development: http://www.leidentech.com

Marko Žmak

Thursday 30 June 2011 4:35:04 pm

"

Unintended double-publishing, haven't heard anything about that?

"

I ment like half published objects because of DB error etc. Or double published objects because of some buggy script.

Some other toughts...

- why did yu use getParentNodeIdListByContentObjectID() instead of assigned_nodes?

- for sites with a lot of content, limit and offset should be used with subTreeByNodeID() so that you can check smaller amounts of node at a time and avoid breaking of the script.

- note that by using 2 as top node id, you will miss the nodes in other parts of the node tree (images, files, users)

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

Hubert Farnsworth

Steven E. Bailey

Friday 01 July 2011 3:09:28 pm

I think I tried assigned nodes but it didn't work for some reason... not sure why now.  But it wasn't more than a quick decision on the fly.

Yeah, limit and offset - I tend not to think of those until the script breaks.  This one hasn't broken for me yet.

Node 2 - I tend to use node 2 by default because I tend to want that content without users, media, etc. but that's why the topNodeID is a parameter.  I could see this being an easy way to see what groups users are in without having to access the user class.

Certified eZPublish developer
http://ez.no/certification/verify/396111

Available for ezpublish troubleshooting, hosting and custom extension development: http://www.leidentech.com

Steven E. Bailey

Friday 01 July 2011 3:39:32 pm

I think this adresses all your points - only takes twice as long but at least it shouldn't fatal:

 <?php
require 'autoload.php';
$limit=200;
$cli = eZCLI::instance();
$script = eZScript::instance( array(  'description' => (
                                      "finds double-published objects" ),
                                      'use-session' => false,
                                      'use-modules' => false,
                                      'use-extensions' => false ) );

$script->startup();

$options = $script->getOptions( "", "[topNodeID]", array() );
$script->initialize();

$topNodeID = ctype_digit($options["arguments"][0]) ? $options["arguments"][0] : 1;
$params['MainNodeOnly'] = true;
$params['IgnoreVisibility'] = true;
$nodecount = eZContentObjectTreeNode::subTreeCountByNodeID( $params, $topNodeID );

for($offset=0;$offset<=$nodecount;$offset=$offset+$limit) {
        $params['Offset']=$offset;
        $params['Limit'] = $limit;
        $nodes = eZContentObjectTreeNode::subTreeByNodeID( $params, $topNodeID );
        foreach($nodes as $node) {
                if (count($node->object()->attribute( 'assigned_nodes' )) != 1 ) {
                        echo $node->attribute( 'path_identification_string')."\n";
                }
        }
}
$script->shutdown();
?>

Edit: don't need the session/module/extension in the script call either.

Edit: changed Object to object.

Certified eZPublish developer
http://ez.no/certification/verify/396111

Available for ezpublish troubleshooting, hosting and custom extension development: http://www.leidentech.com

Marko Žmak

Saturday 02 July 2011 5:38:32 am

Correction, "Object" should be all small caps. So like this:

if (count($node->object()->attribute( 'assigned_nodes' )) != 1 ) {

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

Hubert Farnsworth

Steven E. Bailey

Saturday 02 July 2011 2:05:58 pm

In php user defined classes and functions are case-insensitive .  Both will work.  But whatever.

Certified eZPublish developer
http://ez.no/certification/verify/396111

Available for ezpublish troubleshooting, hosting and custom extension development: http://www.leidentech.com

You must be logged in to post messages in this topic!

eZ debug

Timing: Jan 17 2025 21:00:45
Script start
Timing: Jan 17 2025 21:00:45
Module start 'content'
Timing: Jan 17 2025 21:00:45
Module end 'content'
Timing: Jan 17 2025 21:00:45
Script end

Main resources:

Total runtime0.2376 sec
Peak memory usage4,096.0000 KB
Database Queries218

Timing points:

CheckpointStart (sec)Duration (sec)Memory at start (KB)Memory used (KB)
Script start 0.00000.0057 596.0469180.8438
Module start 'content' 0.00570.1253 776.8906794.7656
Module end 'content' 0.13110.1065 1,571.6563348.5938
Script end 0.2375  1,920.2500 

Time accumulators:

 Accumulator Duration (sec) Duration (%) Count Average (sec)
Ini load
Load cache0.00391.6268210.0002
Check MTime0.00140.5943210.0001
Mysql Total
Database connection0.00060.268010.0006
Mysqli_queries0.144160.63252180.0007
Looping result0.00180.75862160.0000
Template Total0.213589.820.1067
Template load0.00180.768420.0009
Template processing0.211689.059120.1058
Template load and register function0.00010.048510.0001
states
state_id_array0.00110.464920.0006
state_identifier_array0.00080.343830.0003
Override
Cache load0.00150.6489390.0000
Sytem overhead
Fetch class attribute name0.00110.4676100.0001
Fetch class attribute can translate value0.00120.512130.0004
class_abstraction
Instantiating content class attribute0.00010.0259150.0000
XML
Image XML parsing0.00120.523830.0004
General
dbfile0.00281.1824360.0001
String conversion0.00000.002930.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.tplforum_topic/full.tplextension/community_design/design/suncana/override/templates/forum_topic/full.tplEdit templateOverride template
8content/datatype/view/ezxmltext.tpl<No override>extension/community_design/design/suncana/templates/content/datatype/view/ezxmltext.tplEdit templateOverride template
10content/datatype/view/ezxmltags/paragraph.tpl<No override>extension/ezwebin/design/ezwebin/templates/content/datatype/view/ezxmltags/paragraph.tplEdit templateOverride template
7content/datatype/view/ezimage.tpl<No override>extension/sevenx/design/simple/templates/content/datatype/view/ezimage.tplEdit templateOverride template
1content/datatype/view/ezxmltags/quote.tpldatatype/ezxmltext/quote.tplextension/ezwebin/design/ezwebin/override/templates/datatype/ezxmltext/quote.tplEdit templateOverride template
2content/datatype/view/ezxmltags/literal.tpl<No override>extension/community/design/standard/templates/content/datatype/view/ezxmltags/literal.tplEdit templateOverride template
1content/datatype/view/ezxmltags/anchor.tpl<No override>design/standard/templates/content/datatype/view/ezxmltags/anchor.tplEdit templateOverride template
1pagelayout.tpl<No override>extension/sevenx/design/simple/templates/pagelayout.tplEdit templateOverride template
 Number of times templates used: 31
 Number of unique templates used: 8

Time used to render debug report: 0.0002 secs