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!

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 29 2025 13:40:07
Script start
Timing: Jan 29 2025 13:40:07
Module start 'layout'
Timing: Jan 29 2025 13:40:07
Module start 'content'
Timing: Jan 29 2025 13:40:07
Module end 'content'
Timing: Jan 29 2025 13:40:07
Script end

Main resources:

Total runtime0.0111 sec
Peak memory usage2,048.0000 KB
Database Queries3

Timing points:

CheckpointStart (sec)Duration (sec)Memory at start (KB)Memory used (KB)
Script start 0.00000.0043 588.1328151.2109
Module start 'layout' 0.00430.0019 739.343836.6563
Module start 'content' 0.00610.0036 776.0000106.7031
Module end 'content' 0.00970.0013 882.703141.9766
Script end 0.0110  924.6797 

Time accumulators:

 Accumulator Duration (sec) Duration (%) Count Average (sec)
Ini load
Load cache0.002219.4729140.0002
Check MTime0.00108.9817140.0001
Mysql Total
Database connection0.00065.267110.0006
Mysqli_queries0.001715.599030.0006
Looping result0.00000.081810.0000
Template Total0.00119.710.0011
Template load0.00087.153510.0008
Template processing0.00032.528010.0003
Override
Cache load0.00065.058210.0006
General
dbfile0.00021.561280.0000
String conversion0.00000.017240.0000
Note: percentages do not add up to 100% because some accumulators overlap

Templates used to render the page:

UsageRequested templateTemplateTemplate loadedEditOverride
1print_pagelayout.tpl<No override>extension/community/design/community/templates/print_pagelayout.tplEdit templateOverride template
 Number of times templates used: 1
 Number of unique templates used: 1

Time used to render debug report: 0.0001 secs