Make WordPress Core

Opened 15 years ago

Closed 15 years ago

#11241 closed defect (bug) (fixed)

Fix for undefined offset warning in do_action

Reported by: chrisjean's profile chrisjean Owned by: chrisbliss18's profile chrisbliss18
Milestone: 3.0 Priority: normal
Severity: normal Version: 3.0
Component: General Keywords: has-patch tested commit
Focuses: Cc:

Description

An unchecked index in the do_action function found in wp-includes/plugin.php can cause a huge flood of warnings depending on data feed to it.

I simply added an isset check to ensure that the use of the index doesn't occur unless something is at that array location.

Attachments (2)

plugin-array-index-warning.diff (462 bytes) - added by chrisbliss18 15 years ago.
show-do_action-warning.php (823 bytes) - added by chrisbliss18 15 years ago.
This plugin enables warnings and produces the warning at the top of the screen.

Download all attachments as: .zip

Change History (6)

@chrisbliss18
15 years ago

This plugin enables warnings and produces the warning at the top of the screen.

#1 @chrisbliss18
15 years ago

  • Keywords tested commit added
  • Owner set to chrisbliss18
  • Status changed from new to accepted
  • Version changed from 2.9 to 3.0

This problem is still in trunk as of r13402. I've added a plugin that shows how this warning can be produced. It's basically an unchecked potential $arg value that causes this.

The following criteria must be met for this warning to be produced:

  • The called action tag must have at least one function attached to it.
  • The second argument passed to the do_action function (the $arg value) must be an array with only one entry with an index other than 0.

When these criteria is met, the is_object($arg[0]) portion of the code throws a warning since the conditional has not confirmed that $arg[0] exists first.

My patch simply confirms that $arg[0] is set before checking it, thus removing the warning.

#2 @chrisbliss18
15 years ago

  • Milestone set to 3.0

#3 @westi
15 years ago

I can't reproduce the notice but I see no harm in the change.

#4 @westi
15 years ago

  • Resolution set to fixed
  • Status changed from accepted to closed

(In [13674]) Fix a possible undefined offset warning in do_action. Fixes #11241 props chrisbliss18.

Note: See TracTickets for help on using tickets.