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

createAndPublishObject shouldn't try to create the object if some errors are detected in fromString calls

    XMLWordPrintable

Details

    Description

      hi. as said in the title, i've got some problems with createAndPublishObject method.
      i'm trying to import users from another system and so i created a process that get the list of users in the old system and import them to ez publish day by day.

      i'm using createAndPublishObject method for this, but i realized that some users are created without any account_information at all.

      i think the reason is how createAndPublishObject works. it goes for all the attribs in the object and call fromString method.

      foreach( $attributes as $attribute ) 
      {
                         [...]
      
                                  $attribute->fromString( $dataString );
                                  $attribute->store();
      }
      
      $db->commit();
      
                      $operationResult = eZOperationHandler::execute( 'content', 'publish', array( 'object_id' => $contentObject->attribute( 'id' ),
                                                                                                   'version' => 1 ) );                      
      

      it my happens fromString can return false or error, as the one for ezusertype does if it finds another user with the same email.

      IMHO, if this is the case, publish operation shouldn't be executed and a rollback should be applied in order to not store all the other attributes of the object.

      What do you think?

      Steps to reproduce

      try to import users from a php script usign the method. this csv can be used for the source

      Name1;Surname1;foo|foo@ez.no|1234|md5_password|0
      Name2;Surname2;foo|foo@ez.no|1234|md5_password|0

      you'll probaby see how user2 is created with first and last name filled, but with nothing in the ezuser_account information.

      Attachments

        Activity

          People

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

            Dates

              Created:
              Updated: