Uploaded image for project: 'eZ Publish / Platform'
  1. eZ Publish / Platform
  2. EZP-14642

eZContentObject::fetchByNodeID is producing fatal errors

    XMLWordPrintable

Details

    • Icon: Bug Bug
    • Resolution: Fixed
    • Icon: Medium Medium
    • 4.1.1
    • 4.0.3, 4.1.0
    • Misc
    • None

    Description

      Hi,

      here is a tricky one. ez 4.0.3 and 4.1 is affected.

      Some days ago, a client reported a fatal error message (ez 4.0.3), the error happened in one of my extensions.

      I was using these code lines:

      $obj = eZContentObject::fetchByNodeID( $nodeID );
      $obj->attribute()...

      The 2nd line produced the fatal error because fetchByNodeID returned null.

      Well, I added an is_object check, the problem was solved I believed.

      Today, I tried to delete an object at one 4.1 ez installation. I got the fatal error msg:

      Fatal error: Call to a member function attribute() on a non-object in kernel/content/action.php on line 1224
      Fatal error: eZ Publish did not finish its request

      1223 + 1224 are:
      $object = eZContentObject::fetchByNodeID( $contentNodeID);
      eZSection::setGlobalID( $object->attribute( 'section_id' ) );

      I turned on the debugger. The query was:

      SELECT ezcontentobject.* , ezcontentobject_name.name as name, ezcontentobject_name.real_translation
      FROM
      ezcontentobject,
      ezcontentobject_tree
      , ezcontentobject_name
      WHERE
      ezcontentobject_tree.node_id=55389 AND
      ezcontentobject.id=ezcontentobject_tree.contentobject_id AND
      ezcontentobject.current_version=ezcontentobject_tree.contentobject_version
      and ezcontentobject.id = ezcontentobject_name.contentobject_id and
      ezcontentobject.current_version = ezcontentobject_name.content_version and
      ( ezcontentobject_name.language_id & ezcontentobject.language_mask > 0 AND
      ( ( ezcontentobject.language_mask - ( ezcontentobject.language_mask & ezcontentobject_name.language_id ) ) & 1 )
      + ( ( ( ezcontentobject.language_mask - ( ezcontentobject.language_mask & ezcontentobject_name.language_id ) ) & 2 ) )
      <
      ( ezcontentobject_name.language_id & 1 )
      + ( ( ezcontentobject_name.language_id & 2 ) )
      )

      The query was ok, but the database entries were not.

      The node 55389 exists and the object entry exists. But ezcontentobject_tree.contentobject_version was 3 and ezcontentobject.current_version was 2.

      The big question is: How can this happen?

      I tried:
      SELECT *
      FROM ezcontentobject a, ezcontentobject_tree b
      WHERE a.id = b.contentobject_id
      AND a.current_version != b.contentobject_version

      The result: 140 entries found (of: 15607 contentobjects)

      I can "repair" the version number with an sql query, but this makes no sense because it will happen again.

      So:

      The code of fetchByNodeID needs to be rewritten because it produces object cache entries but doesn't use the cache.

      A mapping array could be introduced to use the object cache like
      $eZNodeObjectMappingCache[$nodeID] = $objectArray['id'];

      Line 892 (version 4.1):
      $useVersionName = true;
      if ( $useVersionName )
      {
      ...
      }
      This is senseless...

      line 924
      eZDebug::writeError( 'Object not found', 'eZContentObject::fetch()' );
      Please add the searched node id in the error message to give more info

      ===

      All in all this won't solve my problem. So in my case it's very important that deleting of an object doesn't fail.

      So a rewrite of the action.php can solve this:

      $object = eZContentObject::fetch( $contentObjectID );
      eZSection::setGlobalID( $object->attribute( 'section_id' ) );
      $section = eZSection::fetch( $object->attribute( 'section_id' ) );

      new:

      $section = false;
      $object = eZContentObject::fetch( $contentObjectID );
      if ( $object )
      {
      eZSection::setGlobalID( $object->attribute( 'section_id' ) );
      $section = eZSection::fetch( $object->attribute( 'section_id' ) );
      }

      This belongs to line 936 and 1224 - the code is used twice in action.php.

      Best wishes,
      Georg.

      Attachments

        Activity

          People

            andre1 andre1
            emil.webber emil.webber
            Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved: