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

Wrong default parameter value in eZContentClass::instantiate, causing fatal error upon further object edition.

    XMLWordPrintable

    Details

    • Type: Bug
    • Status: Closed
    • Priority: Medium
    • Resolution: Fixed
    • Affects Version/s: 4.2011, 4.4.0, 4.5.0alpha, 4.5.0beta1, 4.5.0beta2
    • Fix Version/s: None
    • Labels:
      None

      Description

      The signature of eZContentClass::instantiate() is as follows (4.4 until 4.2011 ):

          function instantiate( $userID = false, $sectionID = 0, $versionNumber = false, $languageCode = false, $versionStatus = eZContentObjectVersion::STATUS_INTERNAL_DRAFT )
      
      

      The default value for $sectionID is 0. $sectionID is solely used when calling eZContentObject::create, passed/forced as 4th argument. 0 is not a valid section number (the "Standard" section is 1), while the default value for the $sectionID parameter in eZContentObject::create is 1, the default section.

      The default value for $sectionID in eZContentClass::instantiate() should be 1, the Standard section.

      In the current state, some custom code using eZContentClass::instantiate() with no parameter causes Fatal error upon further object edition (in attribute_edit.php, line 472 when setting the 'section' override key).

      Steps to reproduce

      From a custom module, the following code would lead to a crash :

      $replyClass = eZContentClass::fetchByIdentifier( 'forum_reply' );
      $reply = $replyClass->instantiate();
      $replyObjectID = $reply->attribute( 'id' );
      
      $nodeAssignment = eZNodeAssignment::create( array( 'contentobject_id' => $replyObjectID,
                                                         'contentobject_version' => 1,
                                                         'parent_node' => $parentNodeID,
                                                         'is_main' => 1 ) );
      $nodeAssignment->store();
      
      return $module->redirectTo( "content/edit/$replyObjectID/1" );
      

        Attachments

          Issue Links

            Activity

              People

              Assignee:
              nfrp Nicolas Pastorino
              Reporter:
              nfrp Nicolas Pastorino
              Votes:
              0 Vote for this issue
              Watchers:
              0 Start watching this issue

                Dates

                Created:
                Updated:
                Resolved: