Follow up for #1998600: Block config translation fails
Updated: Comment #0
Problem/Motivation
We added tests that check if the translate link (operation in dropbutton, or tab) is there for all the config lists, but we are missing tests that check if clicking on the link works. Sometimes that is page not found, or access denied, when the link should work.
Proposed resolution
Write tests.
These two test files will be helpful to look at:
ConfigTranslationListUITest.php http://drupalcode.org/project/config_translation.git/blob/HEAD:/lib/Drup...
ConfigTranslationViewListUITest.php
http://drupalcode.org/project/config_translation.git/blob/HEAD:/lib/Drup...
Remaining tasks
- Try a link in each kind of list, note which are broken.
- Write tests.
User interface changes
No.
API changes
No.
Related Issues
Comment | File | Size | Author |
---|---|---|---|
#37 | blocktest-2029029-37.patch | 1.07 KB | YesCT |
#34 | config_translation-check_translate_links_work-2029029-34.patch | 6.53 KB | YesCT |
#34 | interdiff-30-34.txt | 5.17 KB | YesCT |
#30 | config_translation-check_translate_links_work-2029029-30.patch | 6.42 KB | juanolalla |
#30 | interdiff-21-30.txt | 1.25 KB | juanolalla |
Comments
Comment #1
YesCT CreditAttribution: YesCT commented@juanolalla is working on this.
Comment #2
juanolalla CreditAttribution: juanolalla commentedI'll do it!
Comment #3
juanolalla CreditAttribution: juanolalla commentedI've manually tested all translate links, here are the results:
Block listing: admin/structure/block
System Help link: admin/structure/block/manage/bartik.help/translate
Access denied
Menu listing: admin/structure/menu
Administration link: admin/structure/menu/manage/admin/translate
OK
Taxonomy listing: admin/structure/taxonomy
Tags link: admin/structure/taxonomy/manage/tags/translate
OK
Custom block listing: admin/structure/custom-blocks
Basic block link: admin/structure/custom-blocks/manage/basic/translate
OK
Contact form listing: admin/structure/contact
Personal contact form link: admin/structure/contact/manage/personal/translate
OK
Format listing: admin/config/content/formats
Basic HTML link: admin/config/content/formats/manage/basic_html/translate
OK
Shortcut listing: admin/config/user-interface/shortcut
Default link: admin/config/user-interface/shortcut/manage/default/translate
Fatal error: Call to a member function getLanguageWithFallback() on a non-object in .../modules/config_translation/lib/Drupal/config_translation/Access/ConfigNameCheck.php on line 34
Role listing: admin/people/roles
Anonymous user link: admin/people/roles/manage/anonymous/translate
OK
Maintenance settings page: admin/config/development/maintenance
Translate tab: admin/config/development/maintenance/translate
OK
Site information settings page: admin/config/system/site-information
Translate tab: admin/config/system/site-information/translate
OK
Account settings page: admin/config/people/accounts
Translate tab: admin/config/people/accounts/translate
OK
Views listing: admin/structure/views
Content link: admin/structure/views/view/content/translate
OK
People link: admin/structure/views/view/user_admin_people/translate
Access denied
Comment #4
juanolalla CreditAttribution: juanolalla commentedI edited the previous comment to add a second views listing case which response is 403.
Comment #5
juanolalla CreditAttribution: juanolalla commentedI upload the patch for the test to check whether the linked page to translate is correct or not. I check if the response has the html
<th>Language</th>
. Is there a better way to identify that the page requested is the appropiate translation page?
Comment #7
juanolalla CreditAttribution: juanolalla commentedThe previous patch failed applying so I've had to re-roll it. At least two test should fail: 1 and 7 like in the #3 manual testing.
Comment #9
juanolalla CreditAttribution: juanolalla commentedAfter the update I've manually re-tested all translate links, here are the results:
Block listing: admin/structure/block
All links
Access denied
Menu listing: admin/structure/menu
All links
OK
Taxonomy listing: admin/structure/taxonomy
Tags link: admin/structure/taxonomy/manage/tags/translate
OK
Custom block listing: admin/structure/custom-blocks
Basic block link: admin/structure/custom-blocks/manage/basic/translate
OK
Contact form listing: admin/structure/contact
All links
OK
Format listing: admin/config/content/formats
All links
OK
Shortcut listing: admin/config/user-interface/shortcut
Default link: admin/config/user-interface/shortcut/manage/default/translate
Fatal error: Call to a member function getLanguageWithFallback() on a non-object in .../modules/config_translation/lib/Drupal/config_translation/Access/ConfigNameCheck.php on line 34
Role listing: admin/people/roles
All links
OK
Maintenance settings page: admin/config/development/Maintenance
Translate tab: admin/config/development/maintenance/translate
OK
Site information settings page: admin/config/system/site-information
Translate tab: admin/config/system/site-information/translate
OK
Account settings page: admin/config/people/accounts
Translate tab: admin/config/people/accounts/translate
OK
Views listing: admin/structure/views
Content link: admin/structure/views/view/content/translate
OK
People link: admin/structure/views/view/user_admin_people/translate
Access denied
Comment #10
juanolalla CreditAttribution: juanolalla commentedI've found that blocks translate links don't pass the test because the page response is 403 - Access denied, and that is because at the ConfigNameCheck::access method there was a hasSchema and hasTranslatable check. From my point of view this is not the appropriate place to check it because it's not a matter of access. It's just that the translate link or the translate route has no sense if whatever we are viewing is not translatable.
We should move this check to the routing implementation without affecting performance. It's not straightforward to do right know in the hook_menu because the we are managing either ConfigGroupMapper objects, that have the hasTranslatable() method, and ConfigEntityMapper objects, that needs to be loaded to check its translatability.
Also, the config_translation_find_translatable function in config_translation.module, has a @todo comment regarding to update the code of the function, we should make an issue about it.
I'll continue working to fix the error thrown at admin/config/user-interface/shortcut/manage/default/translate
Comment #11
juanolalla CreditAttribution: juanolalla commentedI've found that blocks translate links don't pass the test because the page response is 403 - Access denied, and that is because at the ConfigNameCheck::access method there was a hasSchema and hasTranslatable check. From my point of view this is not the appropriate place to check it because it's not a matter of access. It's just that the translate link or the translate route has no sense if whatever we are viewing is not translatable.
We should move this check to the routing implementation without affecting performance. It's not straightforward to do right know in the hook_menu because the we are managing either ConfigGroupMapper objects, that have the hasTranslatable() method, and ConfigEntityMapper objects, that needs to be loaded to check its translatability.
Also, the config_translation_find_translatable function in config_translation.module, has a @todo comment regarding to update the code of the function, we should make an issue about it.
I'll continue working to fix the error thrown at admin/config/user-interface/shortcut/manage/default/translate
Comment #13
Gábor HojtsyWell, we need to somewhere check if they have schema and are translatable because otherwise the translate link does not make sense on the item. So putting a translate tab on or making a translation operation appear in an operations dropdown in a list will just not lead to anything useful.
We cannot add routes per item, we can only add them wholesale for all items with entity type name wildcards in the path. So the only way to make tabs not appear is if they cannot be accessed. If they can be accessed, they will display, resulting in translate tabs on things that don't make sense.
Eg. you have a single language German website. All the shipped menus coming from Drupal core are English, so they *need* a translate tab. All the menus you created don't make sense to have a translate tab, because you have a single German language website, so you don't have any other language to translate to. It would be UI litter with options you cannot use or do anything with. And then the only way to not make the tab appear on a per item basis is the access check returning no access, in which case, the UI becomes nice.
I think the operations dropdowns should also check for translatability and schema. The trick is schema is per entity type, translatability is per entity. So we need to cache some stuff maybe to make it fast. But a first pass approach at it can be just to do the check in the entity operations alter for now without caching and then we can see if its really slow.
Comment #14
juanolalla CreditAttribution: juanolalla commentedThanks for the explanation! So I restore the translatability check at the access method, and check the translatability of each block before creating the link at config_translation_form_alter(). So now the link is not created, the test should fail at shortcut translate link check.
I've also re-rolled the patch.
Comment #15
juanolalla CreditAttribution: juanolalla commentedThe translate page admin/config/user-interface/shortcut/manage/default/translate throw an error:
Fatal error: Call to a member function getLanguageWithFallback() on a non-object in .../modules/config_translation/lib/Drupal/config_translation/Access/ConfigNameCheck.php on line 34
I fixed by replacing the base path pattern at config_translation_config_translation_group_info, who had {shortcut_es} by putting {shortcut} instead, according to the pattern in shortcut.routing.yml in shortcut module. I think it might be a mistake made because of the label (@label shortcut set).
The tests should all pass now
Comment #16
juanolalla CreditAttribution: juanolalla commentedNeed review!
Comment #18
YesCT CreditAttribution: YesCT commentedNaaa. Mmmmm. [edit: no worries. I'll check it later.]
Comment #19
juanolalla CreditAttribution: juanolalla commentedI left an old line when I re-rolled the patch that made tests fail, I've fixed it.
I also add to the test the same condition before testing the block link and route: is this block translatable?
Comment #20
Gábor HojtsyHa, good find!
Ok, we don't have the same translatability check on any of the other entities. In the operations alter hook for example.... There are two things we should note about this:
1. Blocks should be translatable in core. We should not need this workaround if the blocks are properly written in core.
2. We should do the translatability checking anyway on all entities and have specific test coverage creating non-translatable entities for that. I think this point should be a followup.
So that the blocks are not translatable seems to be a bug to me. Don't work around that!
Comment #21
juanolalla CreditAttribution: juanolalla commentedThank you. I'm agree with you regarding the blocks workaround, I didn't do it at hook_entity_operation_alter because it hasn't work for blocks yet #2027857: Blocks operations cannot be altered. So checking translatability for all entities using that hook and providing tests for that, could be a different issue, depending on the "fixing the hook" issue. Should we open a issue for that? Or should we postpone the current issue?
I've removed the blocks translatability workaround so the test fail for this translate page example. Anything else I should do for the moment?
Comment #22
juanolalla CreditAttribution: juanolalla commentedComment #23
juanolalla CreditAttribution: juanolalla commentedI've forgotten to switch it to needs review
Comment #25
Gábor Hojtsy#21: config_translation-check_translate_links_work-2029029-21.patch queued for re-testing.
Comment #26
Gábor HojtsySent for retest due to #2031255: Update for new languages as config entities.
Comment #29
Gábor HojtsyIt would be great to:
- comment out the block thing because it is a core related fail; add a @todo on the core patch (if there is one) that deals with it
- add a commented out language test (language has a bug with operations altering too, see the code and @todo added in #2031207: Create EntityMapper for language config entity)
So we would have two @todo's added with this. That is fine for now.
Comment #30
juanolalla CreditAttribution: juanolalla commentedI've just commented the block tests function.
Comment #32
Gábor HojtsyDo not comment out the whole method. Just comment the new part. The old part works. Also ensures once we remove the ugly altering for it, it still works.
I looked hard if we can have something more useful to assert for, but does not seem to be. We should test for '
' though (make language translate as applicable).
Same at all places where this is applied.
Comment #33
YesCT CreditAttribution: YesCT commentedI talked with @juanolalla that I would try this.
I think these might have been taken out by accident.
I'm putting them back and doing the other feedback asked for.
Comment #34
YesCT CreditAttribution: YesCT commentedhere the concerns are addressed (some asserts commented out, and t()).
Comment #35
YesCT CreditAttribution: YesCT commented#34: config_translation-check_translate_links_work-2029029-34.patch queued for re-testing.
Comment #36
YesCT CreditAttribution: YesCT commentedhttp://drupalcode.org/project/config_translation.git/commit/8ce10bd
Comment #37
YesCT CreditAttribution: YesCT commentedI took out one too many tests. This block test is ok, because we still have the ugly alter.
Comment #38
YesCT CreditAttribution: YesCT commentedhttp://drupalcode.org/project/config_translation.git/commit/5d688f0