Forums / Extensions / eZ Find / Bug in eZFind 2.3, objects + mainNode, ezsolr line 357

Bug in eZFind 2.3, objects + mainNode, ezsolr line 357

Author Message

Christian Rößler

Thursday 07 October 2010 2:40:17 am

Currently I am facing multiple issues regarding the new eZFind 2.3 and indexing/updating objects that are not within the table 'ezcontentobject_tree' thus have no node-object in its attribute 'main_node'.

When having such objects in your database and using eZFind 2.3 (official stable release) the cronjob fails with:

Fatal error: Call to a member function attribute() on a non-object in 
...../extension/ezfind/search/plugins/ezsolr/ezsolr.php on line 357

After poking in the code, I found the glitch that has been introduced in 2.3. 2.2 does not have this issue:

355: // Get global object values
356: $mainNode = $contentObject->attribute( 'main_node' );
357: $mainNodePathArray = $mainNode->attribute( 'path_array' );

Line 357 failes, because the return value $mainNode from line 356 is not checked before calling methods on this object (or in my case it's not an object, it is null).

I have this patch to provide a workaround and continue state to index other objects that are 'valid' and have a main-node ...

# This patch file was generated by NetBeans IDE
# It uses platform neutral UTF-8 encoding and \n newlines.
--- Base (BASE)
+++ Locally Modified (Based On LOCAL)
@@ -354,7 +354,7 @@
         }
         // Get global object values
         $mainNode = $contentObject->attribute( 'main_node' );
-        $mainNodePathArray = $mainNode->attribute( 'path_array' );
+        
         // initialize array of parent node path ids, needed for multivalued path field and subtree filters
         $nodePathArray = array();
         if ( !$mainNode )
@@ -362,6 +362,9 @@
             eZDebug::writeError( 'Unable to fetch main node for object: ' . $contentObject->attribute( 'id' ), 'eZSolr::addObject()' );
             return false;
         }
+        // get main-node contentobject-tree-node
+        $mainNodePathArray = $mainNode->attribute( 'path_array' );
+        
         //included in $nodePathArray
         //$pathArray = $mainNode->attribute( 'path_array' );
         $currentVersion = $contentObject->currentVersion();

But I am also curious. What is the reason, that i got contentobjects floating around without any node/tree attachment? What may be the possible initial cause for those ghost-objects?

Thanks,

chris

PS: eZPublish 4.2, imported content using the data_import extension, ezFind 2.2 manually updated to 2.3 due to 'date null import errors' in eZFind 2.2.

Hannover, Germany
eZ-Certified http://auth.ez.no/certification/verify/395613

Carlos Revillo

Thursday 07 October 2010 7:07:35 am

Hi. Probably is not the case, but one possible way to have these objects without nodes is the use of objectrelationbrowse extension. (don't know if the same goes for objectrelation list).

so, suppose you have an article class with a objectrelationbrowse attribute. if you want, you can add the option of adding new objects while you are filling all other attributes from the article. And you can also say that this objects will not be placed under any of the nodes of the content tree...

Don't know if this is the case, but yes, it's posible we can reach in something similar.

But, at the end, ezfind will return eZFindSearchResultsNodes, with their path and all of the usual ezcontentobjecttreenode objects. don't know if having those 'orphan' objects indexed can also leads in error while buidling the list of result nodes...

Christian Rößler

Thursday 07 October 2010 8:16:23 am

Thanks for your input Carlos,

well... we do not use the mentioned extension - but nice to know, thanks :-) May be useful sometime.

The site is a relatively new one, based on ezp 4.2.0, filled with approx 150.000 content-nodes and about 5000 users, all in about 15 languages. All the content-nodes have been imported in a 'import' folder. The customer now moves the imported articles from import-folder to the location he/she wants them to be.

In the process of moving, translating and adding related-objects to those articles, somehow the 'ghost-objects' appear. I just stumbled over them because the ezfindexcontent-cronjob was hardly quitting at one of such object which was in the 'pending_tasks' table about to be indexed using 'delayed indexing'.

 don't know if having those 'orphan' objects indexed can also leads in error while buidling the list of result nodes...

In eZFind 2.2 such ghost objects would never make it into ezfind. In eZF 2.3 the indexer crashes. So either way a search would never return such objects. So its no problem on this side. Returned nodes are all good.

Thanks again for your thoughts.

Chris

Hannover, Germany
eZ-Certified http://auth.ez.no/certification/verify/395613

Georg Franz

Wednesday 13 October 2010 3:58:35 am

Hi Chris,

as far as I know there are only two reasons why there is no mainnode:
a) the object isn't published (first version, first draft)
b) the object is deleted

But maybe your database is corrupted (failed transactions or something like that). You can check this with my "zombie check script":
http://issues.ez.no/IssueView.php?Id=16052&activeItem=2

Best wishes,

Georg.

Best wishes,
Georg.

--
http://www.schicksal.com Horoskop website which uses eZ Publish since 2004

Luca Realdi

Monday 21 March 2011 7:54:39 am

A trashed item loses the main_node_id. The cronjob ezfindexcontent verifies the content object, not if his node exsists.

In solr.php (ezFind 2.3.0) the main_node check - if ( !$mainNode ) - should be moved to the line 355 otherwise the $mainNodePathArray = $mainNode->attribute( 'path_array' ) generates error.

from

354 $mainNode = $contentObject->attribute( 'main_node' );
355 $mainNodePathArray = $mainNode->attribute( 'path_array' );
356 // initialize array of parent node path ids, needed for multivalued path field and subtree filters
357 $nodePathArray = array();
358 if ( !$mainNode )
359 {
360     eZDebug::writeError( 'Unable to fetch main node for object: ' . $contentObject->attribute( 'id' ), 'eZSolr::addObject()' );
361     return false;
362 }

to

354 $mainNode = $contentObject->attribute( 'main_node' );
355 if ( !$mainNode )
356 {
357     eZDebug::writeError( 'Unable to fetch main node for object: ' . $contentObject->attribute( 'id' ), 'eZSolr::addObject()' );
358     return false;
359 }
360 $mainNodePathArray = $mainNode->attribute( 'path_array' );
361 // initialize array of parent node path ids, needed for multivalued path field and subtree filters
362 $nodePathArray = array();

Bertrand Dunogier

Monday 21 March 2011 8:32:36 am

This is already fixed in ezfind/master:

https://github.com/ezsystems/ezfind/blob/master/search/plugins/ezsolr/ezsolr.php#L371

This will be part of the upcoming eZ Find 2.4 release: https://github.com/ezsystems/ezfind/commit/78edf846c84608fc80d784539cba18264216c05e.

Bertrand Dunogier
eZ Systems Engineering, Lyon
http://twitter.com/bdunogier
http://gplus.to/BertrandDunogier

eZ debug

Timing: Jan 17 2025 23:38:16
Script start
Timing: Jan 17 2025 23:38:16
Module start 'content'
Timing: Jan 17 2025 23:38:16
Module end 'content'
Timing: Jan 17 2025 23:38:16
Script end

Main resources:

Total runtime0.5894 sec
Peak memory usage4,096.0000 KB
Database Queries212

Timing points:

CheckpointStart (sec)Duration (sec)Memory at start (KB)Memory used (KB)
Script start 0.00000.0062 587.9844180.7656
Module start 'content' 0.00620.4774 768.7500721.6875
Module end 'content' 0.48360.1057 1,490.4375344.4063
Script end 0.5893  1,834.8438 

Time accumulators:

 Accumulator Duration (sec) Duration (%) Count Average (sec)
Ini load
Load cache0.00390.6534210.0002
Check MTime0.00140.2445210.0001
Mysql Total
Database connection0.00100.161910.0010
Mysqli_queries0.508786.31542120.0024
Looping result0.00190.32032100.0000
Template Total0.563895.720.2819
Template load0.00200.344920.0010
Template processing0.561795.307820.2809
Template load and register function0.00010.022410.0001
states
state_id_array0.00040.060410.0004
state_identifier_array0.00070.116920.0003
Override
Cache load0.00180.3058540.0000
Sytem overhead
Fetch class attribute can translate value0.00150.259560.0003
Fetch class attribute name0.00100.172690.0001
XML
Image XML parsing0.00190.327060.0003
class_abstraction
Instantiating content class attribute0.00000.002890.0000
General
dbfile0.00440.7428390.0001
String conversion0.00000.001030.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
6content/datatype/view/ezxmltext.tpl<No override>extension/community_design/design/suncana/templates/content/datatype/view/ezxmltext.tplEdit templateOverride template
15content/datatype/view/ezxmltags/paragraph.tpl<No override>extension/ezwebin/design/ezwebin/templates/content/datatype/view/ezxmltags/paragraph.tplEdit templateOverride template
6content/datatype/view/ezxmltags/literal.tpl<No override>extension/community/design/standard/templates/content/datatype/view/ezxmltags/literal.tplEdit templateOverride template
3content/datatype/view/ezimage.tpl<No override>extension/sevenx/design/simple/templates/content/datatype/view/ezimage.tplEdit templateOverride template
2content/datatype/view/ezxmltags/line.tpl<No override>design/standard/templates/content/datatype/view/ezxmltags/line.tplEdit templateOverride template
2content/datatype/view/ezxmltags/link.tpl<No override>design/standard/templates/content/datatype/view/ezxmltags/link.tplEdit templateOverride template
1pagelayout.tpl<No override>extension/sevenx/design/simple/templates/pagelayout.tplEdit templateOverride template
 Number of times templates used: 36
 Number of unique templates used: 8

Time used to render debug report: 0.0002 secs