Updated: Comment #0
Problem/Motivation
In-place editing of node titles should work, as of #1988612: Apply formatters and widgets to rendered entity base fields, starting with node.title. But it doesn't work completely yet. The hidden form to update the node title is served without problems, but when saving it, the following error occurs:
InvalidArgumentException: Invalid translation language () specified. in Drupal\Core\Entity\ContentEntityBase->getTranslation() (line 641 of /home/s5b4fd666056cbda/www/core/lib/Drupal/Core/Entity/ContentEntityBase.php).
Proposed resolution
Fix it.
Remaining tasks
Fix it.
User interface changes
None.
API changes
None.
Comment | File | Size | Author |
---|---|---|---|
#25 | edit-title-fix-25.patch | 6.08 KB | yched |
#16 | edit-title-fix-16.patch | 6.09 KB | Gábor Hojtsy |
#16 | edit-title-fix-16-test-only.patch | 4.85 KB | Gábor Hojtsy |
#13 | edit-title-fix-13.patch | 1.24 KB | effulgentsia |
#10 | edit-title-fix.patch | 517 bytes | Gábor Hojtsy |
Comments
Comment #1
Gábor HojtsyAdding D8MI tags.
Comment #2
Wim LeersCurrently working on other things, so unassigning.
Comment #3
Gábor HojtsyLooking into this.
Comment #4
Wim Leersnod_ has posted improved the JS changes that were made in #1988612 at #1988612-208: Apply formatters and widgets to rendered entity base fields, starting with node.title.
Comment #5
Gábor HojtsyAll right, the problem is the field_language() function (which is deprecated, but not clear in favor of what) will not return any value for non-configurable fields.
So Drupal\edit\EditController::fieldForm() uses the (not yet deprecated) field_view_field() which passes on the langcode given to (the deprecated) field_language(). That will see that a concrete field was passed in and would only return a non-NULL value if it was a configurable field. So for non-configurable fields, the field language would always come down to NULL. That is not very useful for rendering it :D Since non-configurable fields behave the same way for rendering that configurable fields are, I think we should use the same logic. This definitely makes it flawlessly work :) Expert entity API advise would be welcome nonetheless :) The fix is just one line.
Looking into providing test coverage by - I guess - duplicating what we have for body.
Comment #6
Gábor HojtsyComment #7
Gábor HojtsyComment #8
yched CreditAttribution: yched commentedHm, yeah - field_language() is totally not prepared to be called on base fields...
We really need to get rid of those field_language() calls in field_view_field(), and consider that callers of field_view_field() pass the $entity in the correct language.
Shouldn't be too complex, but probably better done as part of #2134887: move field_view_field() / field_view_value() to methods.
Meanwhile, if the patch fixes IPE of node title, it's fine by me.
Comment #9
Wim LeersThis seems more correct.
Comment #10
Gábor HojtsyDoh, the removal of return $display_langcodes; was not intended. This is really a one line patch :D
Comment #12
plachNot sure whether this will work with non-configurable fields but I guess we should at least match this change in the if-branch.
Comment #13
effulgentsia CreditAttribution: effulgentsia commentedI confirmed with manual testing that the bug as described exists in HEAD and is fixed by #10. This updated patch addresses #12. Given the new Entity Translation API, I see no reason to keep field_language() caring about isConfigurable(), so +1 to this fix.
I think all we need now is to enhance our functional tests in edit module. We have existing functional tests there that test a configurable field; we should add a nonconfigurable field to those tests as well. Such a test should fail without this patch and pass with it.
Comment #14
effulgentsia CreditAttribution: effulgentsia commentedRe #4: that's now in a separate issue: #2149933: Improve Edit module JS to use .find(...) instead of .is(':has(...)')
Comment #15
effulgentsia CreditAttribution: effulgentsia commentedGood to know that #13 passes current tests, but back to "needs work" for adding a test, and setting component to edit.module since that's where the test is needed.
Comment #16
Gábor HojtsyAdded tests modeled after the body tests. Retrieve the node title edit, ensure the JSON returned is proper, edit the title, submit the edit, ensure it is not yet saved, save, ensure it is saved. This should be a full circle test. It fails for me without the fix and passes with the fix too. :) Nothing changed in the actual patch, so the test only patch is also the interdiff :)
Comment #17
effulgentsia CreditAttribution: effulgentsia commentedThanks!
(the tests in #16 are done running, not sure why that hasn't been reported back to the issue, but they pass and fail as expected).
Comment #19
Wim Leers#14: thanks for creating that issue!
#16: wow, thank you for so quickly creating that test!
I can't believe how quickly this issue got resolved, thanks, all! :) RTBC++
Comment #20
webchickAwesome!
I was super bummed to see that node title editing didn't work despite all of our efforts. Confirmed this fixes the bug (although the title field is hard to hit atm). Great to see an RTBC patch for this *with* tests. :D
Committed and pushed to 8.x. Thanks!
Comment #21
webchickHm. Actually, something's up...
Must be conflicting with something else that was committed today. Sending for a re-test.
Comment #22
webchick16: edit-title-fix-16.patch queued for re-testing.
Comment #24
webchickI would, however, like to get this in by alpha7 so we can show this new capability off, so tagging for that.
Comment #25
yched CreditAttribution: yched commentedMethod names in removed hunks have changed in #2143263: Remove "Field" prefix from FieldDefinitionInterface methods.
Comment #26
Gábor HojtsyThanks for the reroll! Let's get this in! :)
Comment #27
catchCommitted/pushed to 8.x, thanks!
Comment #28
Gábor HojtsyGreat, thanks!
Comment #29
Wim LeersNow also backported to the Drupal 7 contrib module: http://drupalcode.org/project/edit.git/commit/a03fbb1.