Make WordPress Core

Opened 17 years ago

Closed 17 years ago

#5941 closed defect (bug) (invalid)

PHP error "Missing argument..." occurs in update_option_ action

Reported by: softwud's profile softwud Owned by:
Milestone: Priority: normal
Severity: major Version:
Component: General Keywords:
Focuses: Cc:

Description

Hello,

I'm trying to create a plugin that captures update_option_X action. However I am getting the "Missing argument..." error as described in Ticket #3125 which claims to have been fixed.

I've modified the code in the wp-includes/functions.php file to see what is happening, and found that the $oldvalue and $_newvalue variables both contain the correct information, however this information when sent via do_action() doesn't arrive at my function (hence the missing argument 2 error).

FYI $_newvalue should contain an array with the changed contents of the 'sidebars_widgets' WP option.

Has this problem truely been fixed, and if so in what version? If not then is there a patch I can apply to make this work?

Thanks,
Paolo (SoftWUD)

Change History (3)

#1 follow-up: @DD32
17 years ago

how are you defining your hook?

Are you specifying that your hook accepts 2 params?

 add_action ( 'hook_name', 'your_function_name', [priority], [accepted_args] );

So, If you want to accept 2 args:

 add_action ( 'update_option_XX', 'funcName', 10, 2 );

#2 in reply to: ↑ 1 @softwud
17 years ago

Thanks DD32, I was just working through the source and came to the same conclusion... boy do I feel red faced! I read the documentation on the action that says that it passes two arguments... I didn't stop to think that I needed to tell it how many options to pass. Sorry for being such an idiot. It's obviously no longer a problem.

Regards,
Paolo

Replying to DD32:

how are you defining your hook?

Are you specifying that your hook accepts 2 params?

 add_action ( 'hook_name', 'your_function_name', [priority], [accepted_args] );

So, If you want to accept 2 args:

 add_action ( 'update_option_XX', 'funcName', 10, 2 );

#3 @darkdragon
17 years ago

  • Milestone 2.6 deleted
  • Resolution set to invalid
  • Status changed from new to closed
  • Version 2.3.2 deleted

Closing as invalid from the previous comments.

Note: See TracTickets for help on using tickets.