-
Notifications
You must be signed in to change notification settings - Fork 214
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Translated record gets random tx_flux_parent and may cause data loss #1176
Comments
Probably it should also be sorted by |
Holy crudbasket... I'm sorry about that Dmitry. Thanks for the excellent description and suggested fix, I hope to get some time one of the coming days to coordinate this along with #1163. |
We restored from the backup :) But we will make an xclass ext for all projects to avoid this issue. If you can fix it for the next release, it would be great :) |
Any Updates on this ? We ran into the same issue, delete one record and it wipes out all translations for 10 pages. |
Sorry guys, I'm under a bit of pressure from other tasks at the moment. I haven't forgotten. |
Is this issue valid for older flux versions as well or only the latest one? |
Hi all, it seems we ran into the same issue in two projects this year (both based on T3 7 LTS), using flux based content elements. One time in February using the actual version at the time (don't remember exactly which one). And just last Thursday (22nd Sep) using flux 7.3.0. Within 4 seconds all translated content elements from around 45 pages got deleted. That's indeed a tough one. Thanks for any efforts to fix this and Dmitry, thanks for that great analysis. I, so far, had no clue how to reproduce and debug the weird behavior. Best wishes |
Some old versions also. I think we discovered it in an old 6.2 project. |
While translating records the newly created record currently always gets assigned a flux parent record even if the origin had no parent record. When searching for the nonexisting parent record the database will return a rather random record. So any translated record without a flux parent got this random record assigned. If this random record is deleted by an editor TYPO3 will check for any related records and delete these as well. This may result in the deletion of all previously translated records. Test for the existence of a parent record value in the origin record to prevent the wrong relation. Refs FluidTYPO3#1176
While translating records the newly created record currently always gets assigned a flux parent record even if the origin had no parent record. When searching for the nonexisting parent record the database will return a rather random record. So any translated record without a flux parent got this random record assigned. If this random record is deleted by an editor TYPO3 will check for any related records and delete these as well. This may result in the deletion of all previously translated records. Test for the existence of a parent record value in the origin record to prevent the wrong relation. Refs FluidTYPO3#1176
Hey guys, I experienced this bug as well. It may cause data loss or permanent damanges to the dataset. I'll explain what happend, what our analysis was, send a pull request for a bugfix and how to fix existing installations. What happendClient tells us, that several translated records are missing since two days. Not all records however. Which sounds really odd. We investigate the issue and stumble upon the fact, that lots of record on a given example page got deleted on the same time. When I take a look at the TYPO3 log I see that 1168 records got deleted at once. The records had no relation to each other (like same type, pid, language, creation time, editor etc.). The only common thing was, that they are translations. But as I said, not all translations got deleted. Our analysisFortunately the editor did not do very much in the moment the bug occured and therefore remembered what he deleted first. I was able to reproduce the mass deletion, when I repeated his actions on a backup machine. We do use TYPO3 6.2 and Flux 7.2.3. When a record is deleted TYPO3 calls the »deleteRecord« method in »sysext/core/Classes/DataHandling/DataHandler.php«. This method reads the TCA of the current table and checks if the record has any references such as inline type or MM references. If so, these child records also to be deleted. In the debug trace the array of the elements to be deleted increased rapidly. The first loop had one field value in common: the same UID in the »tx_flux_parent« field. So we knew that not the delete method was wrong but our data. We then searched for methods were this field is set. The »initializeRecordByNewAndOldAndLanguageUids« method in »EXT:flux/Classes/Service/ContentService.php« was responsible. While translating a record this method looks for the latest version of a flux parent record. A Flux parent is assigned to every record which is nested into fluid content element (the parent). If the origin of the translated record has a reference to a flux parent, then the search will return a usefull result.
This will return a huge array of course. The method selects the first item in the array as parent (*¹). So the item is rather random (It may be the same for some while, but may change due to mysql updates or the moon phase due to missing MySQL sorting params). The method then assigns the wrong parent to the transalted record. In our case the wrong parent was assigned to almost 2000 records. Once this single, random record gets deleted TYPO3 will delete all of these records. The fact that not all got deleted in our installation is caused by the fact that the maximum execution time of the process was exceeded. Pull requestI have read Dmitrys buxfix draft (heads up, thank you again for your OS commitment btw), tested it, build a somewhat shorter patch and changed the relevant unit test. Example records in my test installation: Records in original langauge
Translated records without Bugfix
Translated records with Bugfix
Due to the impact of the bug I will send a PR for the master and legacy branch. Fix existing installationsOnly relevant for installations with translations.
The Bugfix is not enough, since records already may have faulty references to the random record. Once thhis random record is deleted by an editor, all references records will be deleted as well. To find all records which may have wrong references I used statements like these:
@NamelessCoder maybe a update script in the extension could do this automatically. But such a automatization may be risky as well. I would like to help, but I am not available until Monday. Please note as well: restoring a backup is the best method to restore the data if you are alerted soon enough. If you use the extension »recycler« in the TYPO3 backend, then you may restore items which had been deleted quite rightly previously. This is due to the fact that the receycler uses the timestamp of the record. During the unwantd mass deletion this timestamp get updated even if the child element was deleted previously. So this method is no safe way to restore the data, but creates inconsistent data and therefore new issues instead. Edit: *²
|
@pixelbrackets Double thumbs up for this one. Amazing Analysis! |
Hi together update tt_content set tx_flux_parent = null where tx_flux_parent > 0 and tx_flux_column = ''; This code assumes that a record that has a empty @NamelessCoder if that assumption is right, this may be sql for the update-script? |
From the quick look it seems to be identical to mine, not shorter. Just a condition change. |
While translating records the newly created record currently always gets assigned a flux parent record even if the origin had no parent record. When searching for the nonexisting parent record the database will return a rather random record. So any translated record without a flux parent got this random record assigned. If this random record is deleted by an editor TYPO3 will check for any related records and delete these as well. This may result in the deletion of all previously translated records. Test for the existence of a parent record value in the origin record to prevent the wrong relation. Refs FluidTYPO3#1176
Hey, I have edited the analysis and added two remarks (different flux parent in TYPO3 6.2 and 7, fix for existing dataset by @BenjaminBeck ). @dmitryd Yes, just the condition change. I did not include the enhanced search for translated parents in to the bugfix PR. @NamelessCoder / Team I realized, that I did develop against master and the contribution guidlines of flux require coding against the development branch. I copied my feature branch and applied a rebase to it: https://github.com/webit-de/typo3-flux/tree/20161013_prevent-random-parent-uid-for-translations-development-rebase Could you please give a feedback about the assumption in point *² of the analysis post. I would like to run this query as soon as possible on all my projects. |
@pixelbrackets sorry I haven't had time to go through all of it. But: Yes, please recreate this targeting the Yes, the assumption you make above is correct. Any live record (not just fluidcontent) with a Flux parent and without a column name would be incorrect. Yes, the proposed SQL fixes should work. Please integrate them as an extension update script option and add checks so it is only proposed if corrupt records are detected. Putting it here makes it a very conscious decision when to run it (so sysadmin can back up before). |
Cool, thanks for the feedback. I'll do so and send the proper PRs. Ah, thanks for the confirmation, that helps a lot. I will write such an update script and let you know about the progress. edit: update script done |
While translating records the newly created record currently always gets assigned a flux parent record even if the origin had no parent record. When searching for the nonexisting parent record the database will return a rather random record. So any translated record without a flux parent got this random record assigned. If this random record is deleted by an editor TYPO3 will check for any related records and delete these as well. This may result in the deletion of all previously translated records. Test for the existence of a parent record value in the origin record to prevent the wrong relation. Refs #1176
In case there is a release timeline that I just didn't find, I apologize for the question - but is there an outlook when this issue will be resolved in the TER upstream version? |
Notes are on https://fluidtypo3.org/blog/news/preparing-flux-750.html (you'd be forgiven for not keeping up with that feed, it gets very rare updates). |
Enable the update script, which may be run in the extension manager, to fix records with wrong references (wrongly assigned »flux parent«) automatically. Refs FluidTYPO3#1176
Enable the update script, which may be run in the extension manager, to fix records with wrong references (wrongly assigned »flux parent«) automatically. Refs FluidTYPO3#1176
While translating records the newly created record currently always gets assigned a flux parent record even if the origin had no parent record. When searching for the nonexisting parent record the database will return a rather random record. So any translated record without a flux parent got this random record assigned. If this random record is deleted by an editor TYPO3 will check for any related records and delete these as well. This may result in the deletion of all previously translated records. Test for the existence of a parent record value in the origin record to prevent the wrong relation. Refs FluidTYPO3#1176
Enable the update script, which may be run in the extension manager, to fix records with wrong references (wrongly assigned »flux parent«) automatically. Refs FluidTYPO3#1176
While translating records the newly created record currently always gets assigned a flux parent record even if the origin had no parent record. When searching for the nonexisting parent record the database will return a rather random record. So any translated record without a flux parent got this random record assigned. If this random record is deleted by an editor TYPO3 will check for any related records and delete these as well. This may result in the deletion of all previously translated records. Test for the existence of a parent record value in the origin record to prevent the wrong relation. Refs FluidTYPO3#1176
Enable the update script, which may be run in the extension manager, to fix records with wrong references (wrongly assigned »flux parent«) automatically. Refs FluidTYPO3#1176
While translating records the newly created record currently always gets assigned a flux parent record even if the origin had no parent record. When searching for the nonexisting parent record the database will return a rather random record. So any translated record without a flux parent got this random record assigned. If this random record is deleted by an editor TYPO3 will check for any related records and delete these as well. This may result in the deletion of all previously translated records. Test for the existence of a parent record value in the origin record to prevent the wrong relation. Refs FluidTYPO3#1176
Enable the update script, which may be run in the extension manager, to fix records with wrong references (wrongly assigned »flux parent«) automatically. Refs FluidTYPO3#1176
While translating records the newly created record currently always gets assigned a flux parent record even if the origin had no parent record. When searching for the nonexisting parent record the database will return a rather random record. So any translated record without a flux parent got this random record assigned. If this random record is deleted by an editor TYPO3 will check for any related records and delete these as well. This may result in the deletion of all previously translated records. Test for the existence of a parent record value in the origin record to prevent the wrong relation. Refs #1176
Enable the update script, which may be run in the extension manager, to fix records with wrong references (wrongly assigned »flux parent«) automatically. Refs #1176
PSA: Sorry for the long commit list appending to this issue, I have rebased the PR branch a couple of times (#1188). Claus cherry-picked and tweaked the commits into the development branch this night. 😃 ✅ |
While translating records the newly created record currently always gets assigned a flux parent record even if the origin had no parent record. When searching for the nonexisting parent record the database will return a rather random record. So any translated record without a flux parent got this random record assigned. If this random record is deleted by an editor TYPO3 will check for any related records and delete these as well. This may result in the deletion of all previously translated records. Test for the existence of a parent record value in the origin record to prevent the wrong relation. Refs FluidTYPO3#1176
While translating records the newly created record currently always gets assigned a flux parent record even if the origin had no parent record. When searching for the nonexisting parent record the database will return a rather random record. So any translated record without a flux parent got this random record assigned. If this random record is deleted by an editor TYPO3 will check for any related records and delete these as well. This may result in the deletion of all previously translated records. Test for the existence of a parent record value in the origin record to prevent the wrong relation. Refs FluidTYPO3#1176
Enable the update script, which may be run in the extension manager, to fix records with wrong references (wrongly assigned »flux parent«) automatically. Refs FluidTYPO3#1176
Enable the update script, which may be run in the extension manager, to fix records with wrong references (wrongly assigned »flux parent«) automatically. Refs FluidTYPO3#1176
* [FEATURE] Fix records references in EM update script Enable the update script, which may be run in the extension manager, to fix records with wrong references (wrongly assigned »flux parent«) automatically. Refs #1176 * [BUGFIX] Always cache TypoScript config in FluxService Previously, #getAllTypoScript did not cache the configuration when called from the frontend. This resulted in a rather large performance overhead, since #removeDotsFromTS was called repeatedly. This commit modifies the behaviour such that the configuration is always cached. Backport of commit:f876ffdcdf8e4e76eda1b62409138f6361e32bd1 for legacy branch Refs #1140 * [TASK] Add note about legacy branch * Add a hint how PRs for the legacy branch are handled. * Show in EM that this is a legacy branch version
FYI, for TYPO3 v8, the usage of the |
Any news when we can expect an bugfix for 7.6.X or is there any blocker that holds us back till upcoming release of 8 LTS ? |
I've just found the changelog for flux 8.0.0, there i can see the mentioned commit by pixelbrackets here as its tagged with 8.0.0 and also 8.0.1 this was already released ? So someone missed only to mention this bugfix and close this issue ? |
@verdure-peuser Yes, the fix was cherry-picked to the development branch in January, the development branch then was released on January 9th → https://github.com/FluidTYPO3/flux/releases/tag/8.0.0 (https://github.com/FluidTYPO3/flux/blob/development/Documentation/Changelog/8.0.0.md) So yes, this ticket may be closed. |
Related issues: #1125, #1163, #1120
The code in
ContentService::initializeRecordByNewAndOldAndLanguageUids
selects a random content element as a parent for translated content:That for each cycle only checks the language. Since
tx_flux_parent
is zero, it selects all content elements. So any content elements with a propersys_language_uid
field will be selected as a parent for the translated content element, which is obviously wrong.Now the worse part: delete that randomly selected parent and all translated elements that refer to it, will be also deleted because TYPO3 thinks they are inline children of that random parent element due to
$TCA
configuration oftx_flux_parent
. This way we lost 197 translated elements by deleting one hidden unused element on a hidden unused test page.I am not 100% sure if I did the right thing (so no PR) but the following seems to work for me:
The text was updated successfully, but these errors were encountered: