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.

Support from Acquia helps fund testing for Drupal Acquia logo

Comments

pwolanin’s picture

Status: Active » Needs review
FileSize
603 bytes

Easy fix - set the last page argument as NULL

pwolanin’s picture

Issue tags: +Needs backport to D7

Status: Needs review » Needs work

The last submitted patch, 1359710-1.patch, failed testing.

pwolanin’s picture

FileSize
603 bytes
613 bytes

oops guess I missed the memo about the core/ patch going in :(

pwolanin’s picture

Status: Needs work » Needs review

Status: Needs review » Needs work

The last submitted patch, 1359710-3.patch, failed testing.

pwolanin’s picture

Status: Needs work » Needs review
FileSize
623 bytes

Hmm, keep messing up the prefix. Let's try this.

ksenzee’s picture

Title: taxonomy_menu passes invalid arguemnts into taxonomy_form_term() » taxonomy_menu passes invalid arguments into taxonomy_form_term()
Status: Needs review » Reviewed & tested by the community

At 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.

catch’s picture

Status: Reviewed & tested by the community » Needs work
Issue tags: +Needs tests

This should be easy to write a test for, also the menu entry could use a comment as to why we're specifying NULL there.

pwolanin’s picture

I don't understand what would be tested here - just that we don't provoke a notice with an extra path component?

catch’s picture

Yep.

xjm’s picture

It 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

xjm’s picture

Status: Needs work » Needs review
FileSize
2.67 KB
1.37 KB
783 bytes

Here's a test for it. As a bonus, a message you don't see every day.
test-run-finished.png

xjm’s picture

Oh, I missed where catch asked for a comment. Not sure how to say it concisely. How about:

Ensure that additional path components are not passed to taxonomy_form_term() as the vocabulary machine name argument.

Would that be sufficient? The API doc and signature for taxonomy_form_term() should explain the rest.

xjm’s picture

FileSize
669 bytes
1.5 KB

Incorporating #15.

xjm’s picture

FileSize
693 bytes
1.53 KB

Actually maybe this is a bit more clear.

sun’s picture

Status: Needs review » Reviewed & tested by the community

Thanks, looks good.

(yet another reason to use more query string parameters in Drupal)

catch’s picture

Version: 8.x-dev » 7.x-dev
Status: Reviewed & tested by the community » Patch (to be ported)

The new test and comment look good. committed/pushed to 8.x, moving back to 7.x, will need a quick re-roll.

xjm’s picture

Status: Patch (to be ported) » Reviewed & tested by the community
FileSize
1.49 KB
webchick’s picture

Status: Reviewed & tested by the community » Fixed

Committed and pushed to 7.x. Thanks!

Automatically closed -- issue fixed for 2 weeks with no activity.