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.
If I got to ?q=taxonomy/term/5/edit/x
I get a spew of notices:
Notice: Trying to get property of non-object in taxonomy_form_term() (line 650 of modules/taxonomy/taxonomy.admin.inc).
This is because taxonomy_menu fails to set the last page argument )looking for NULL or an object), and allows a garbage string to be passed in from the path.
Comment | File | Size | Author |
---|---|---|---|
#20 | d7-1357710-20.patch | 1.49 KB | xjm |
#17 | 1357710-17.patch | 1.53 KB | xjm |
#17 | interdiff.txt | 693 bytes | xjm |
#16 | 1359710-16.patch | 1.5 KB | xjm |
#16 | interdiff.txt | 669 bytes | xjm |
Comments
Comment #1
pwolanin CreditAttribution: pwolanin commentedEasy fix - set the last page argument as NULL
Comment #2
pwolanin CreditAttribution: pwolanin commentedComment #4
pwolanin CreditAttribution: pwolanin commentedoops guess I missed the memo about the core/ patch going in :(
Comment #5
pwolanin CreditAttribution: pwolanin commentedComment #8
pwolanin CreditAttribution: pwolanin commentedHmm, keep messing up the prefix. Let's try this.
Comment #9
ksenzeeAt first I was a little unclear on why this was necessary, but eventually I figured out it's because taxonomy_form_term() takes two arguments past $form and $form_state - one for the term, the other for the vocabulary. The menu router entry should specify both those arguments, but it currently only specifies the term.
Comment #10
catchThis should be easy to write a test for, also the menu entry could use a comment as to why we're specifying NULL there.
Comment #11
pwolanin CreditAttribution: pwolanin commentedI don't understand what would be tested here - just that we don't provoke a notice with an extra path component?
Comment #12
catchYep.
Comment #13
xjmIt took me a few minutes to wrap my head around this as well. The extra argument it's expecting is the vocabulary machine name, for when the form builder is reused for:
admin/structure/taxonomy/%taxonomy_vocabulary_machine_name/add
(Added in #604980: taxonomy_term_edit() is useless.)
So despite that the argument for the function defaults to NULL, it has to be specified anyway in the menu hook to get around the feature that additional path components get passed in as additional args.
Edit: Never mind about that last bit; local environment problem. :P
Comment #14
xjmHere's a test for it. As a bonus, a message you don't see every day.
Comment #15
xjmOh, I missed where catch asked for a comment. Not sure how to say it concisely. How about:
Would that be sufficient? The API doc and signature for
taxonomy_form_term()
should explain the rest.Comment #16
xjmIncorporating #15.
Comment #17
xjmActually maybe this is a bit more clear.
Comment #18
sunThanks, looks good.
(yet another reason to use more query string parameters in Drupal)
Comment #19
catchThe new test and comment look good. committed/pushed to 8.x, moving back to 7.x, will need a quick re-roll.
Comment #20
xjmComment #21
webchickCommitted and pushed to 7.x. Thanks!