Don't save non-changes to content history

Description

Background

When a default value for a document is different from the value in the database, the content history detects this as a change. But Doctrine doesn't write the change to the database.

This means it keeps generating records in the content history.

Example 1: phone number in database doesn't have a type

Example 2: reference has wrong db (it would be better to turn storage of $db off, this will be the default in Doctrine ODM 2, http://docs.doctrine-project.org/projects/doctrine-mongodb-odm/en/latest/reference/reference-mapping.html)

Note: also when the changeset is empty a record is sometimes written to the content history.

Requirements

  • $db

    • ignore in ArrayComparer

  • Empty values

    • Values that are not set, are set with "null", so this problem is not present for the first level. This does however not work for values with multiple levels, so this check should be recursive.

Technical tasks

None

Deployment actions

None

Activity

Show:
Marijn Otte
May 22, 2018, 10:35 AM
Edited

Go to: https://integrated-latest.e-activesites.nl/app_dev.php/admin/content/6f60e3d10ee431aea03c592406a0a55e

Enable en disable "Write channel" and "Enforced channel" + save a few times. 500 error:

[2018-05-22 12:30:35] request.CRITICAL: Uncaught PHP Exception MongoResultException: "invalid document for insert: keys cannot begin with "$": "$id"" at /home/integrated-latest/vendor/alcaeus/mongo-php-adapter/lib/Alcaeus/MongoDbAdapter/ExceptionConverter.php line 83 {"exception":"[object] (MongoResultException(code: 22): invalid document for insert: keys cannot begin with \"$\": \"$id\" at /home/integrated-latest/vendor/alcaeus/mongo-php-adapter/lib/Alcaeus/MongoDbAdapter/ExceptionConverter.php:83, MongoDB\\Driver\\Exception
InvalidArgumentException(code: 22): invalid document for insert: keys cannot begin with \"$\": \"$id\" at /home/integrated-latest/vendor/mongodb/mongodb/src/Operation/InsertMany.php:130)"} []

Marijn Otte
May 22, 2018, 10:42 AM
  • Remove the field "content" from the document. Open the document, do not change anything. Content is added to the changeset, but shouldn't.

  • When saving a document without changing anything, time fields like createdAt are added (while they have the same value)

Jeroen van Leeuwen
June 12, 2018, 5:02 AM

check!

Jeroen van Leeuwen
June 12, 2018, 6:20 AM

check again what should we do with this issue?

Gerben Bosch
June 19, 2018, 9:50 AM

Ik heb dit issue even op de radar om voor te bereiden voor de sprintreview. Volgens mij is dit het issue waar geen goede oplossing voor te vinden was en de gekozen oplossing werkte niet.

Heb jij wellicht nog wat input, hoe we kunnen voorkomen dat dit weer gebeurd en waarom jou oplossing niet werkte?

Assignee

Unassigned

External issue ID

None

Client

Integrated Marijn

Min. hours

11

Dev hour estimate

None

Epic Link

Sprint

None

Fix versions

Configure