Forums / Developer / eZContentObjectTreeNode::subTreeByNodeID don't fetch all nodes

eZContentObjectTreeNode::subTreeByNodeID don't fetch all nodes

Author Message

Damien MARTIN

Wednesday 03 August 2011 1:58:05 am

Hi there,

I encounter a little problem with this code :

require_once( 'autoload.php' );

$params = array(

                'Limit' => 1000,
                'Depth' => 100,
                'ClassFilterType' => 'include',
                'ClassFilterArray' => array( 'actu_video' )

);
$videos = eZContentObjectTreeNode::subTreeByNodeID( $params, 2);

$cli->output( count( $videos ) );

foreach ( $videos as $video )
{

  $dm = $video->DataMap();

  $cli->output( $video->Name );

  unset( $dm );

}

It only grab 54 results but there is 143 instances of actu_video.

It looks like it only take the olders one and a very few of them.

Am I doing something wrong ?

Damien Pobel

Wednesday 03 August 2011 2:09:47 am

Hi Damien,

I see two possible reasons :

  • some "actu_video" may not be visible or may be hidden, if you want to fetch hidden nodes as well, you have to add the IgnoreVisibility => true option in the $params array
  • the anonymous user may not have the right to view those objects, to bypass the permission you can add Limitation => array() option in the $param array

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

Damien MARTIN

Wednesday 03 August 2011 2:17:22 am

Hi Damien,

  • I already verified for hidden nodes, but they are all visibles.
  • All the nodes I want to fetch are visible by anonymous, because they are visible on the front office without needed to log in.

For informations, as I know it is a buggy version, the website is under eZ 4.0.0.

Damien Pobel

Wednesday 03 August 2011 2:32:07 am

eZ Publish 4.0.0 !? Oh my fucking god :-) this is the worst version ever :-/

Question: are you able to list the all actu_video objects  in a template with a fetch( content, tree ) call ? if not, I suspect that the database has some integrity issues.

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

Mark Simon

Wednesday 03 August 2011 2:49:13 am

The class name "actu_video" makes me think that some or most of those objects may be located in the media section, not in the content section. This would be node id 43 and is NOT located in a subtree of node id 2.

Try this:

 eZContentObjectTreeNode::subTreeByNodeID($params, 43);

That would fetch all actu_video's from media.

Or:

eZContentObjectTreeNode::subTreeByNodeID($params, 1);

That would fetch all in the whlose system.

www.all2e.com

Damien MARTIN

Wednesday 03 August 2011 2:49:33 am

This piece of code works from the front :

{*?template charset=utf-8?*}
{def $videos = fetch(
                        content, list, 
                        hash(
                            parent_node_id, 2, 
                            depth, 100,
                            limit, 1000,
                            class_filter_type, include, 
                            class_filter_array, array('actu_video')
                            )
                    )}

Il y a {$videos|count} vidéos

And all the objects are available from the admin too.

Damien MARTIN

Wednesday 03 August 2011 2:50:37 am

"

The class name "actu_video" makes me think that some or most of those objects may be located in the media section, not in the content section. This would be node id 43 and is NOT located in a subtree of node id 2.

Try this:

<span style="color: #ff0000;">$videos</span> <span style="color: #66cc66;">=</span> eZContentObjectTreeNode<span style="color: #66cc66;">::</span><span style="color: #006600;">subTreeByNodeID</span><span style="color: #66cc66;">(</span> <span style="color: #ff0000;">$params</span><span style="color: #66cc66;">,</span> <span style="color: #cc66cc;">43</span><span style="color: #66cc66;">)</span><span style="color: #66cc66;">;</span>

That would fetch all actu_video's from media.

Or:

<span style="color: #ff0000;">$videos</span> <span style="color: #66cc66;">=</span> eZContentObjectTreeNode<span style="color: #66cc66;">::</span><span style="color: #006600;">subTreeByNodeID</span><span style="color: #66cc66;">(</span> <span style="color: #ff0000;">$params</span><span style="color: #66cc66;">,</span> <span style="color: #cc66cc;">1</span><span style="color: #66cc66;">)</span><span style="color: #66cc66;">;</span>

That would fetch all in the whlose system.

"

For sure, the objects are not in media.

Damien Pobel

Wednesday 03 August 2011 5:04:32 am

The fetch content tree and list use eZContentObjectTreeNode::subTreeByNodeID() internally (see eZContentFunctionCollection::fetchObjectTree()) so you can try to see what parameters are used when using the template fetch function.

However, I wonder if your issue is not related too the fact that in your script no user is logged in. Perhaps you can try to add the following lines before calling eZContentObjectTreeNode::subTreeByNodeID() :

$user = eZUser::fetch( 10 ); // 10 = anonymous, you can try 14 for admin
$user->loginCurrent();

or I also realize that your script misses the necessary initialization (with eZScript class). Instead of executing it directly, you can use ezexec.php wrapper :

php bin/php/ezexec.php path/to/your/script.php

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

Damien MARTIN

Wednesday 03 August 2011 5:34:52 am

"

The fetch content tree and list use eZContentObjectTreeNode::subTreeByNodeID() internally (see eZContentFunctionCollection::fetchObjectTree()) so you can try to see what parameters are used when using the template fetch function.

However, I wonder if your issue is not related too the fact that in your script no user is logged in. Perhaps you can try to add the following lines before calling eZContentObjectTreeNode::subTreeByNodeID() :

$user = eZUser::fetch( 10 ); // 10 = anonymous, you can try 14 for admin
$user->loginCurrent();

or I also realize that your script misses the necessary initialization (with eZScript class). Instead of executing it directly, you can use ezexec.php wrapper :

php bin/php/ezexec.php path/to/your/script.php

Cheers

"

The script is runned as a cronjob : php runcronjobs.php export

I tryed to change the user. 10 or 14, it is the same result... 54 objects instead of 143...

Mark Simon

Thursday 04 August 2011 1:46:39 am

Are the actu_videos imported objects? Or also creaded with php?

I had the problem once that on an old eZ Version imported objectes did not complete the creation complete.
My Problem has been: The created objectets did not had a value in "published".

Even if they had a node (= visible in admin) the could not be fetched. Having published not set reacts like still being a draft.

So try to check the data in the database tables or the accouint of drafts.

www.all2e.com

Damien MARTIN

Thursday 04 August 2011 1:56:38 am

"

Are the actu_videos imported objects? Or also creaded with php?

I had the problem once that on an old eZ Version imported objectes did not complete the creation complete.
My Problem has been: The created objectets did not had a value in "published".

Even if they had a node (= visible in admin) the could not be fetched. Having published not set reacts like still being a draft.

So try to check the data in the database tables or the accouint of drafts.

"

Note imported,

They all have been created by hand in the administration interface...

I looked at drafts and the list is empty.

I'll take a look at the database.

Damien MARTIN

Thursday 04 August 2011 2:23:05 am

I don't know the eZ database, but I suppose that I should be able to fetch a specific node with the "ezcontentobject" table.

For a node who is not fetched : node_id = 690 ; object_id = 1232

And with the following SQL request :

SELECT * FROM ezcontentobject WHERE id = 1232

There is no results...

Is it normal ?

Mark Simon

Thursday 04 August 2011 4:16:16 am

That is not normal.

You cannot find a node in ezcontentobject, only the object itsself.
Though the Query IS correct.

SELECT * FROM ezcontentobject WHERE id = 1232

should fetch a row vor every accessible object by id = ObjectID

You can try to fetch the node.

SELECT * FROM ezcontentobject_tree WHERE id = 690

If that gets a result, with ezcontentobject_tree.contentobject_id is 1232
You database may be corrupt

www.all2e.com

Damien MARTIN

Friday 05 August 2011 2:20:55 am

SELECT * FROM ezcontentobject_tree WHERE node_id = 690

Doesn't work either...

Is there a procedure to fix a database ?

eZ debug

Timing: Jan 17 2025 22:41:14
Script start
Timing: Jan 17 2025 22:41:14
Module start 'content'
Timing: Jan 17 2025 22:41:15
Module end 'content'
Timing: Jan 17 2025 22:41:15
Script end

Main resources:

Total runtime0.8063 sec
Peak memory usage4,096.0000 KB
Database Queries229

Timing points:

CheckpointStart (sec)Duration (sec)Memory at start (KB)Memory used (KB)
Script start 0.00000.0071 589.0859180.8047
Module start 'content' 0.00710.6769 769.8906760.6875
Module end 'content' 0.68400.1221 1,530.5781361.2734
Script end 0.8062  1,891.8516 

Time accumulators:

 Accumulator Duration (sec) Duration (%) Count Average (sec)
Ini load
Load cache0.00410.5082210.0002
Check MTime0.00140.1788210.0001
Mysql Total
Database connection0.00080.105110.0008
Mysqli_queries0.679984.32162290.0030
Looping result0.00280.34332270.0000
Template Total0.776496.320.3882
Template load0.00230.282820.0011
Template processing0.774196.013720.3871
Template load and register function0.00010.014910.0001
states
state_id_array0.00140.172910.0014
state_identifier_array0.00100.122020.0005
Override
Cache load0.00240.29281160.0000
Sytem overhead
Fetch class attribute can translate value0.00130.158340.0003
Fetch class attribute name0.00120.1478170.0001
XML
Image XML parsing0.00340.420340.0008
class_abstraction
Instantiating content class attribute0.00010.0090280.0000
General
dbfile0.00420.5222390.0001
String conversion0.00000.000930.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
14content/datatype/view/ezimage.tpl<No override>extension/sevenx/design/simple/templates/content/datatype/view/ezimage.tplEdit templateOverride template
14content/datatype/view/ezxmltext.tpl<No override>extension/community_design/design/suncana/templates/content/datatype/view/ezxmltext.tplEdit templateOverride template
35content/datatype/view/ezxmltags/paragraph.tpl<No override>extension/ezwebin/design/ezwebin/templates/content/datatype/view/ezxmltags/paragraph.tplEdit templateOverride template
14content/datatype/view/ezxmltags/literal.tpl<No override>extension/community/design/standard/templates/content/datatype/view/ezxmltags/literal.tplEdit templateOverride template
2content/datatype/view/ezxmltags/li.tpl<No override>design/standard/templates/content/datatype/view/ezxmltags/li.tplEdit templateOverride template
2content/datatype/view/ezxmltags/ul.tpl<No override>design/standard/templates/content/datatype/view/ezxmltags/ul.tplEdit templateOverride template
3content/datatype/view/ezxmltags/quote.tpldatatype/ezxmltext/quote.tplextension/ezwebin/design/ezwebin/override/templates/datatype/ezxmltext/quote.tplEdit templateOverride template
4content/datatype/view/ezxmltags/line.tpl<No override>design/standard/templates/content/datatype/view/ezxmltags/line.tplEdit templateOverride template
1pagelayout.tpl<No override>extension/sevenx/design/simple/templates/pagelayout.tplEdit templateOverride template
 Number of times templates used: 90
 Number of unique templates used: 10

Time used to render debug report: 0.0002 secs