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

eZContentOperationCollection::deleteObject() gives error if param contains all nodes of object

    XMLWordPrintable

Details

    Description

      Summary is self explanatory

      Have a look at 'steps to reproduce'

      Steps to reproduce

      Hi

      I wanted to delete at once (or move to trash according to user's wish) an object having several locations
      (http://share.ez.no/forums/developer/delete-an-object-move-it-to-trash-that-has-several-locations)

      So, as ActionRemove in kernel/content/action.php doesn't support the feature of indicating many contentNode to delete, I've added some line of codes in it around line 1230 to test if it could work (I could then code a new action in my extension)

      in kernel/content/action.php, after:
      if ( $object instanceof eZContentObject )

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

      I've added:
      // HACK
      // DOESN'T work, it doesn't work if DeleteIDArray contains the main node...
      if ( $http->hasPostVariable( 'CompleteRemove' ) )
      {
      // Looking for all nodes of this object
      $publishedAssignedID = array();
      $publishedAssigned = $object->assignedNodes( false );
      foreach ( $publishedAssigned as $element )

      { $publishedAssignedID[] = $element['node_id']; }

      $http->setSessionVariable( 'DeleteIDArray', $publishedAssignedID );
      }
      // END OF HACK

      But then I get a php error:
      Call to a member function attribute() on a non-object in kernel/content/ezcontentoperationcollection.php on line 951

      In fact at these lines:
      $allNodes = $objectIdList[$objectId]->assignedNodes();
      // Registering node that will be promoted as 'main'
      $mainNodeChanged[$objectId] = $allNodes[0];
      eZContentObjectTreeNode::updateMainNodeID( $allNodes[0]>attribute( 'node_id' ), $objectId, false, $allNodes[0]>attribute( 'parent_node_id' ) );

      $allNodes is empty, therefore this php error

      Afterwards, if I add a check:
      if (!empty($allNodes))

      { $mainNodeChanged[$objectId] = $allNodes[0]; eZContentObjectTreeNode::updateMainNodeID( $allNodes[0]->attribute( 'node_id' ), $objectId, false, $allNodes[0]->attribute( 'parent_node_id' ) ); }

      Then all work well, my object has been deleted, every node deleted.
      But the problem is that I don't have the choice anymore, object isn't put into trash (removeobject doesn't ask me confirmation to move to trash), object is completely deleted...

      Hope this helps

      Attachments

        Activity

          People

            unknown unknown
            enzo enzo
            Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

            Dates

              Created:
              Updated: