Problem/Motivation
Before installing this module I had my site set up to show the administration interface always in the same language using the language detection option "Account administration pages". After installing this module, whatever I tried I never got the list of prior revisions to delete as well. Until I enabled Xdebug and noticed that "$langcode" in the function "getPreviousRevisions" was getting the wrong current language.
It took a while to figure out why until I disabled that language detection option.
Now I'm not sure: is this a "node_revision_delete" bug or a core bug because one would expect when using languageManager->getCurrentLanguage() you would actually get the language set in the URL and not the current interface language (which can be manipulated by that language detection method "Account administration pages").
Steps to reproduce
- Install site using languages and translations. Install at least one extra language.
- Activate the language detection feature "Account administration pages" and make sure it's positioned at the top of the list. Also this language detection only works if you also set the preferred language in the user profile.
- Create a node with several revisions
- Install this module and try to delete a revision which has older revisions as well.
- Notice it will not display the details box with prior revisions to delete.
Proposed resolution
TBD: fix module or move issue to core issue queue
Remaining tasks
User interface changes
API changes
Data model changes
| Comment | File | Size | Author |
|---|---|---|---|
| #11 | apply-patch.png | 18.41 KB | himanshu raj |
| #11 | after-apply-patch.png | 57.14 KB | himanshu raj |
| #10 | befor-apply-patch.png | 68.18 KB | himanshu raj |
| #9 | after.png | 59.75 KB | angel_devoeted |
| #7 | 3167246-delete-previous-revisions-fix-7.patch | 1.09 KB | sumit saini |
Issue fork node_revision_delete-3167246
Show commands
Start within a Git clone of the project using the version control instructions.
Or, if you do not have SSH keys set up on git.drupalcode.org:
Comments
Comment #2
adriancidThanks for reporting and for use the issue summary template, I will try to take a look to this in the next days.
Comment #3
aimevpI was able to solve my problem using following patch. By default getCurrentLanguage() uses "LanguageInterface::TYPE_INTERFACE" which is the interface language. Using "LanguageInterface::TYPE_URL" assures we have the language set in the url (which works for me since I'm using the language detection method URL).
This certainly needs review however because I'm unsure it's to safe to just assume that TYPE_URL is active on every multilingual Drupal setup. Extra logic may be needed to detect the real current language.
Comment #4
adriancidClosing because the current development is being made in branch 2.x
Comment #5
sumit saini commentedThis issue is still reproducible in 2.x version when negotiation for content language is different from interface language.
Comment #7
sumit saini commentedpatch file of the MR incase someone needs the same fix.
Comment #8
sumit saini commentedComment #9
angel_devoeted commentedHi @sumit saini , thanks for the fix!
Tested MR !54 and it works as ecpected. The missing "Delete prior revisions" option shows up again as expected and the code change looks solid to me.
Screenshot attached.
Comment #10
himanshu rajHi @sumit saini , thanks for the fix!
I was able to reproduce the issue on a multilingual setup with the "Account administration pages" language detection enabled.
Steps performed:
- Enabled multiple languages and set French as the administration language.
- Enabled "Account administration pages" language detection.
- Created a node with multiple revisions.
- Attempted to delete a revision.
Before applying the patch:
- The revision delete page only displayed the default confirmation screen.
- The section for deleting prior revisions was not shown.
After applying the patch(MR !54):
- The "Delete prior revisions" section is now displayed correctly.
- Previous revisions are properly listed and can be selected.
Conclusion:
The patch resolves the issue and works as expected.
Comment #11
himanshu rajComment #12
alexpottI think we need to allow the langcode to be passed into \Drupal\node_revision_delete\NodeRevisionDeleteInterface::getPreviousRevisions() as this is called from a Drush command too so I'm not sure what the we'd expect to happen there. The drush command needs to allow the user to specify a language code and I think we should also pass the langcode into the batch as well.
Plus we can update the entity to select based on the langcode, revision id and revision translation affected and not have to any entity revision loading which will make this must more performant.
Comment #14
alexpottComment #17
alexpott