content_taxonomy_token_values() is sometimes invoked on empty fields. In such a case, the foreach() ends without initializing $vid or $terms, and later references to them for token generation throw warnings in PHP5.3, as:

- if ($vid) tests undefined variable $vid
- $terms[0] tries to access a non existent array key

Comments

fgm’s picture

Status: Active » Needs review
StatusFileSize
new1.19 KB

Suggested patch fixes this.

DeFr’s picture

Status: Needs review » Needs work

The reset are nice and avoid a test; technically, they change the behavior, reset will return FALSE on an empty array instead of the NULL you get when accessing a key that doesn't exist. The token are only supposed to be used for string concatenation, so that shouldn't be all that important.

Could you reroll the pass initializing $vid to FALSE before before the foreach loop, which would allow to drop both the empty and isset check ? I could do it myself, but then I wouldn't be able to RTBC it...

DeFr’s picture

Version: 6.x-1.0-rc2 » 6.x-1.x-dev
Status: Needs work » Needs review
StatusFileSize
new1.32 KB

Attaching a new version of the patch with the suggested change.

adamdicarlo’s picture

Status: Needs review » Reviewed & tested by the community

Patch works for me.

  • DamienMcKenna committed 5f878c5 on 6.x-1.x
    Issue #1294408 by fgm, DeFr: PHP 5.3 compatibility bugs in...
damienmckenna’s picture

Issue summary: View changes
Status: Reviewed & tested by the community » Fixed
Issue tags: -php5.3 +PHP 5.3

Committed. Thanks.

Status: Fixed » Closed (fixed)

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