[5.x]: Nested entries missing from older revisions
What happened?
Description
Older revisions appear to be missing some nested entries (via a matrix field).
Steps to reproduce
We have not been able to consistently reproduce this behavior, but we have at least one instance of this on a live production site where a revision created post upgrading to Craft 5.5.8 appears to be missing (most of) its nested entries (via a matrix field).
There were also a large number of “Resaving entries” queue tasks running in parallel (due to the upgrade from 5.3.6 to 5.5.8) so unsure if this bug occurred due to some race condition between the resaving task and a user-initiated entry save operation.
While investigating this issue we noticed that revisions created on older versions of Craft (5.3.6) were also missing some nested entries, but reporting it as a new bug because this behavior still seems to be present in 5.5.8.
Expected behavior
Older revisions retain all the nested entries that belonged to the matrix field when the revision was created.
Actual behavior
Certain nested entries seem to be missing.
-
Revision 57 (screenshot from a backup taken at 2025-01-12 12:30pm)
-
Same revision 57 is missing the fourth nested entry (Our Voices, Upcoming Events) after a few edits were made. (screenshot from a backup taken one hour later at 2025-01-12 1:30pm)
-
Same revision 57 is missing 5 of the 6 nested entries after a few more edits were made, and the entry was also restored at one point from revision 60. (screenshot from current state on production)
Craft CMS version
5.5.8
PHP version
8.2.27
Operating system and version
Ubuntu 22.04 LTS
Database type and version
MariaDB 10.11.10
Image driver and version
Imagick 3.7.0 (ImageMagick 6.9.11-60)
Installed plugins and versions
- Calendar Links 4.0.0
- Child Me! 2.2.3
- CKEditor 4.4.0
- Colour Swatches 5.1.0
- Element Index Defaults 4.0.0
- Formie 3.0.16
- Hyper 2.2.2
- iCalendar 5.0.0
- Image Resizer 4.0.1
- Imager X 5.1.0
- LJ Dynamic Fields 5.0.1
- Minify 5.0.0
- No-Cache 3.0.4
- Obfuscator 1.2.0
- oEmbed 3.1.3
- Preparse 3.0.0-alpha.2
- Redirector dev-dev
- Redirects 5.0.4
- Retcon 3.2.1
- Router v1.x-dev
- SEOMate 3.1.1
- Single Cat 4.0.0
- Smith 3.1.0
- Store Hours 4.2.0
- Table Maker 5.0.3
- Transcoder 5.0.0
- Twig Perversion 5.0.1
- Typogrify 5.0.1
- Video Utils 3.0.2
- Webhooks 3.1.0
This sounds like the result of a bug we just fixed in Craft 5.5.10 (96ffcf66f89b24fb651982def18cba943e2f1cf0), where the utils/prune-revisions command was deleting nested entry revisions, when it shouldn’t have. Is it possible you or someone ran that command at some point?
No one would have run that command manually on the server. Could it have been triggered by Craft’s auto garbage collection routine(s)?
Garbage collection would only delete them if they had been soft-deleted already, but Craft never soft-deletes revisions.
we have at least one instance of this on a live production site where a revision created post upgrading to Craft 5.5.8 appears to be missing (most of) its nested entries (via a matrix field).
Were the revisions’ nested entries in tact before the update? If so, do you have a database backup you could send us, from before the update?
Were the revisions’ nested entries in tact before the update?
No, there were missing nested entries in the DB before the update as well. However, I assumed that might have been due to some pre-existing revision related bugs that I notice were fixed in 5.5.
If so, do you have a database backup you could send us, from before the update?
@brandonkelly Unfortunately we are unable to share the database backup at the moment. Not ideal I know, but I can provide more specific details about the DB state if needed.
@rungta in that case, please try to come up with specific steps to reproduce, from a clean Craft install.
@brandonkelly We just experienced this issue once again on production. I am trying to isolate the issue down to clearly reproducible steps. What we know so far is that the bug surfaces when the entry is restored to a previous revision. Regular edits do not seem to cause an issue, but after going through hourly backups of the DB, we can see that blocks went missing at the time when an author had reverted a previous version.
@rungta Are you still experiencing this issue? We are having this issue on a lot of our sites (v5.7.4), but finding it hard to replicate consistently... There seems to be something weird going on with the revisions for nested matrix entries. I will try to document some exact steps to replicate
FYI @brandonkelly
EDIT: I can replicate this consistently now when we have maxRevisions(5) in GeneralConfig. It seems like the Entries that haven't been edited within the last 5 revisions are being deleted entirely from the revision 🤔
I've attached a video of replicatiing this on a Fresh craft install. I incrementally add blocks to a Matrix, saving the Entry after adding each block (to create a revision). You can see that after I add the 6th block, the first block gets deleted from the revisions. https://www.loom.com/share/31e298a0a1c84cc982c2e39db0524705?sid=ee4e4a9d-87ce-46f4-b23c-9c06574de635
@iwingate-digistorm Yes, we continue to face this issue at our end and it is causing much distress. Thank you for sharing the steps to replicate. I will try and see if this matches the data loss that we’re experiencing as well.
Hi @brandonkelly , I know this is a stale ticket from January; however, we continue to experience the issue outlined. Could your team kindly verify whether you are able to replicate the problem as demonstrated in the video provided above? Thank you for your attention to this matter.
@brandonkelly We were also able to replicate the behaviour after reducing maxRevisions to 3. Please see: https://www.loom.com/share/9fc8d06056014fb485ee8c932d4a2bb1?sid=a6a3920e-6786-4911-9ce1-2971c7ac4dc4
While this has been able to successfully reproduce the bug where nested entries disappear from revisions, we are also experiencing nested entries disappearing from the live / current version of the entry. Haven’t managed to reliably reproduce that yet.
Thanks all! Craft 5.7.11 is out with a fix.
Thank you @brandonkelly