Support for Drupal 7 is ending on 5 January 2025—it’s time to migrate to Drupal 10! Learn about the many benefits of Drupal 10 and find migration tools in our resource center.
Problem/Motivation
MenuLinkDefaultForm::extractFormValues() is documented as returning the plugin definition, but the ID (part of the definition) is not included.
Proposed resolution
Make sure the returned definition includes a value for ID and every other definition key.
Remaining tasks
\Drupal\Core\Menu\Form\MenuLinkFormInterface::extractFormValues
should document that it has to return the plugin ID as well- Write some unit test for
\Drupal\Core\Menu\Form\MenuLinkDefaultForm::extractFormValues
to ensure the plugin ID is returned
User interface changes
n/a
API changes
n/a
Data model changes
Additional array keys present in return value
Comment | File | Size | Author |
---|---|---|---|
#12 | 2660486-12.patch | 4.47 KB | dawehner |
Comments
Comment #2
pwolanin CreditAttribution: pwolanin as a volunteer commentedComment #3
Wim LeersComment #4
pwolanin CreditAttribution: pwolanin as a volunteer commentedSmall fix to make sure the ID is consistent.
Comment #5
pwolanin CreditAttribution: pwolanin as a volunteer commentedPlus some code comments
Comment #6
dawehnerI'm wondering whether we can have some form of test coverage to ensure this is actually working as expected?
Comment #7
dawehnerNote: We should also make it clear in the documentation that the method is supposed to return the plugin ID as well.
Comment #8
dawehnerLinked the related issue.
Comment #9
dawehnerComment #10
jibranWe also need tests.
Comment #11
rrrob CreditAttribution: rrrob at Chapter Three commentedAdd
\Drupal\Core\Menu\Form\MenuLinkFormInterface::extractFormValues
documentation.Comment #12
dawehnerAdded a test as well
Comment #13
jibranThanks for the tests.
Comment #14
catchCommitted/pushed to 8.1.x and cherry-picked to 8.0.x. Thanks!
Comment #17
rrrob CreditAttribution: rrrob at Chapter Three commented@pwolanin in my tests,
$form_state->getValue('id')
is sometimesnull
, overwriting$new_definition['id']
which actually has a validid
.In what cases were you seeing
$new_definition['id']
not being present?