[wp-hackers] Plugin API: Unique ID explanation

Jacob Santos wordpress at santosj.name
Fri Aug 7 22:19:18 UTC 2009

http://core.trac.wordpress.org/ticket/10535 is the correct link, I 
apologize for the confusion. The point is that people are using:

add_action('whatever', array(&$this, 'method'));

and people are attempting to make it to where if you do,

remove_action('whatever', array(&$this, 'method'));

that it will in fact remove the method from 'whatever'.

Currently, there are many use cases where it still does not. An attempt 
was made in October of 2007 to make it to where it does, however, the 
algorithm was flawed and only worked with a few use cases. The attempt 
is being made now, to extend the use cases that it works.

My contention was that instead of working around design flaws used by 
plugin developers that plugin developers should understand that 
functions and static methods do not suffer from the above. Every use 
case will work correctly. Furthermore, the hope to get the code to work 
on PHP4 is a fantasy, a farce.

It is a fun problem with an interesting solution, which is what peaked 
my curiosity. However, these two examples are far better as they don't 
suffer from WTF?s.

add_action('whatever', 'some_function');

add_action('whatever', array( 'some_class', 'some_function' ));

These two examples work with both PHP4 and PHP5.

I'll explain further that as many times as the function is used, it is a 
really bad idea to use the the first example as the overhead is quite a 
bit (overall it is small, but when you start to use it around 3000 to 
4000 times, the total time just from that function starts to exceed 1 
second (which is really, really just terrible). Good news is that most 
people will never get around that amount (or so we hope).

Jacob Santos

More information about the wp-hackers mailing list