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

Relationlist contains wrong content after content removal

    Details

      Description

      Steps to reproduce

      Prepare the environment:

      1. Prepare eZ Publish 4.7 installation, fully patched;
      2. Duplicate "article" class, and add a new "object relations" attribute to the new class. Class is called "article 2", attribute is called "related articles";
      3. Create the following content structure:

      Home
      	Tests (folder)
      	Tests 2 (folder)
      

      Reproduce the issue:

      1. Create 2 new "article" objects under /Tests:

      Article 1 (node_id: 125, object_id: 120)
      Article 2 (node_id: 126, object_id: 121)

      2. Create new "article 2" object also under /Tests, and add both "Article 1" and "Article 2" to object relations field:

      13151 Test article (node_id: 127, object_id: 122)

      3. Check content of 'ezcontentobject_attribute' table:

      SELECT * FROM ezcontentobject_attribute WHERE contentobject_id = 122 AND contentclassattribute_id = 307;
      +-----------------------+--------------------------+------------------+------------+----------+----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+----------------------+-----+---------------+-------------+--------------+-----------------+---------+
      | attribute_original_id | contentclassattribute_id | contentobject_id | data_float | data_int | data_text                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                        | data_type_string     | id  | language_code | language_id | sort_key_int | sort_key_string | version |
      +-----------------------+--------------------------+------------------+------------+----------+----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+----------------------+-----+---------------+-------------+--------------+-----------------+---------+
      |                     0 |                      307 |              122 |          0 |     NULL | <?xml version="1.0" encoding="utf-8"?><related-objects><relation-list><relation-item priority="1" contentobject-id="120" contentobject-version="1" node-id="125" parent-node-id="103" contentclass-id="16" contentclass-identifier="article" contentobject-remote-id="fe79d4dcc39a5111fc604ba9e169e6f3"/><relation-item priority="2" contentobject-id="121" contentobject-version="1" node-id="126" parent-node-id="103" contentclass-id="16" contentclass-identifier="article" contentobject-remote-id="f3fa332a108f22a9ada2e0bbd3c27977"/></relation-list></related-objects>   | ezobjectrelationlist | 755 | eng-GB        |           2 |            0 |                 |       1 |
      +-----------------------+--------------------------+------------------+------------+----------+----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+----------------------+-----+---------------+-------------+--------------+-----------------+---------+
      1 row in set (0.00 sec)
      

      Note: "contentclassattribute_id = 307" refers to the Id of the "Related articles" attribute for the new class "article 2".

      4. Add a new location - "Tests 2" folder - to "Article 1" and "Article 2", and make that the main location. Content structure is now:

      Home
      	Tests
      		Article 1 (node_id: 125, object_id: 120)
      		Article 2 (node_id: 126, object_id: 121)
      		13151 Test article (node_id: 127, object_id: 122)
      	Tests 2
      		Article 1 (node_id: 128, object_id: 120, main location)
      		Article 2 (node_id: 129, object_id: 121, main location)
      

      5. Check content of 'ezcontentobject_attribute' table. Results are the same as the ones in step 3;
      6. Remove the firt location - "Tests" folder - from "Article 1";
      7. Check content of 'ezcontentobject_attribute' table. Results are the same as the ones in step 3. That's not correct, as XML structure in "data_text" now contains a dead node - /Tests/Article 1.

      Additional test:

      8. Remove "Article 2" from both locations;
      9. Check content of 'ezcontentobject_attribute' table:

      SELECT * FROM ezcontentobject_attribute WHERE contentobject_id = 122 AND contentclassattribute_id = 307;
      +-----------------------+--------------------------+------------------+------------+----------+-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+----------------------+-----+---------------+-------------+--------------+-----------------+---------+
      | attribute_original_id | contentclassattribute_id | contentobject_id | data_float | data_int | data_text                                                                                                                                                                                                                                                                                                                                     | data_type_string     | id  | language_code | language_id | sort_key_int | sort_key_string | version |
      +-----------------------+--------------------------+------------------+------------+----------+-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+----------------------+-----+---------------+-------------+--------------+-----------------+---------+
      |                     0 |                      307 |              122 |          0 |     NULL | <?xml version="1.0" encoding="utf-8"?><related-objects><relation-list><relation-item priority="1" contentobject-id="120" contentobject-version="1" node-id="125" parent-node-id="103" contentclass-id="16" contentclass-identifier="article" contentobject-remote-id="fe79d4dcc39a5111fc604ba9e169e6f3"/></relation-list></related-objects>   | ezobjectrelationlist | 755 | eng-GB        |           2 |            0 |                 |       1 |
      +-----------------------+--------------------------+------------------+------------+----------+-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+----------------------+-----+---------------+-------------+--------------+-----------------+---------+
      1 row in set (0.00 sec)
      

      The removed node is completely removed from the relation list as it should, but there was no update for the "/Tests/Article 1" dead node. As a sidenote, this can not be solved by republishing the "13151 Test article" object.

        Activity

        Hide
        Gunnstein Lye added a comment -

        Closing as invalid. The documentation makes it clear that this XML can not be relied upon to always be updated. Most values are only set when the object relation is modified.
        https://doc.ez.no/eZ-Publish/Technical-manual/4.x/Reference/Datatypes/Object-relations
        "Raw output
        The .content of an ezcontentobjectattribute object using this datatype returns a hash containing one element called relation_list."
        (...)
        "node_id (string): The ID number of the node at the time when the relation was modified."

        Show
        Gunnstein Lye added a comment - Closing as invalid. The documentation makes it clear that this XML can not be relied upon to always be updated. Most values are only set when the object relation is modified. https://doc.ez.no/eZ-Publish/Technical-manual/4.x/Reference/Datatypes/Object-relations "Raw output The .content of an ezcontentobjectattribute object using this datatype returns a hash containing one element called relation_list." (...) "node_id (string): The ID number of the node at the time when the relation was modified."
        Hide
        Gunnstein Lye added a comment - - edited

        I went with the proposal of setting the <related-objects> xml to point to the main node id. This was not approved in review, due to existing documentation and danger of complications. (The attached EZP-24030-custom.diff contains the fix.)

        Show
        Gunnstein Lye added a comment - - edited I went with the proposal of setting the <related-objects> xml to point to the main node id. This was not approved in review, due to existing documentation and danger of complications. (The attached EZP-24030 -custom.diff contains the fix.)
        Hide
        Gunnstein Lye added a comment - - edited

        This is logically difficult to solve. What should the "correct" behaviour be?

        • The owner object is linked to article1 by an OBJECT relation. This relation remains after the first node of article1 is removed, precisely because it's an OBJECT relation. And the object still exists. In the ezcontentobject_link table, all is fine and well.
        • But the complication is that in the <related-objects> xml in ezcontentobject_attribute, in addition to the object reference, there is ALSO a node reference. The object reference remains correct, while the node doesn't exist anymore.
        • If we agree that the node reference should be updated when the node is removed, what should it be set to? The object may have many nodes. The main node, perhaps?

        Also, I don't see any actual bug in the admin interface. The relation link keeps working, because it is an object level link, and it links to the main node.

        I have asked the original reporter to comment on this.

        Show
        Gunnstein Lye added a comment - - edited This is logically difficult to solve. What should the "correct" behaviour be? The owner object is linked to article1 by an OBJECT relation. This relation remains after the first node of article1 is removed, precisely because it's an OBJECT relation. And the object still exists. In the ezcontentobject_link table, all is fine and well. But the complication is that in the <related-objects> xml in ezcontentobject_attribute, in addition to the object reference, there is ALSO a node reference. The object reference remains correct, while the node doesn't exist anymore. If we agree that the node reference should be updated when the node is removed, what should it be set to? The object may have many nodes. The main node, perhaps? Also, I don't see any actual bug in the admin interface. The relation link keeps working, because it is an object level link, and it links to the main node. I have asked the original reporter to comment on this.
        Hide
        Gunnstein Lye added a comment - - edited

        Confirmed on fully patched 4.7. However, when looking at the object of class "Article 2" in the admin backend, the object relation correctly links to the one node that still exists. So it is apparently reading from a different source than ezcontentobject_attribute. Presumably from ezcontentobject_link, which links by object ID, not node ID, so it is unaffected.

        Show
        Gunnstein Lye added a comment - - edited Confirmed on fully patched 4.7. However, when looking at the object of class "Article 2" in the admin backend, the object relation correctly links to the one node that still exists. So it is apparently reading from a different source than ezcontentobject_attribute. Presumably from ezcontentobject_link, which links by object ID, not node ID, so it is unaffected.

          People

          • Assignee:
            Unassigned
            Reporter:
            Nuno Oliveira (Inactive)
          • Votes:
            0 Vote for this issue
            Watchers:
            4 Start watching this issue

            Dates

            • Created:
              Updated:
              Resolved:

              Time Tracking

              Estimated:
              Original Estimate - Not Specified
              Not Specified
              Remaining:
              Remaining Estimate - 0 minutes
              0m
              Logged:
              Time Spent - 1 day, 2 hours, 5 minutes
              1d 2h 5m