[wp-hackers] Is get_plugin_data "expensive"?

Stephen Rider wp-hackers at striderweb.com
Wed Jul 16 15:04:25 GMT 2008


Hi all --

Question for more experienced PHP users:

I'm working on a function whereby a plugin stores the version of  
itself that was last used.  This way, if it has been updated it can  
(for example) set the defaults on any new options that have been added  
since the last version.

The plugin's settings are stored in an array in the options table, and  
the "last used version" is part of that, so there is no extra call to  
the DB since the array is being read out anyway.

However, to do the comparison, I have to get the current version of  
the plugin too, and to do that I need to use get_plugin_data().

The question is:  Is that a bad idea?  get_plugin_data() reads the  
actual plugin file for its info -- is that an "expensive" function in  
terms of performance?  Would it be bad if several plugins were doing it?

(BTW, yes I know I could just hook this to the activation hook, but  
when people upgrade plugins by simple upload, that doesn't trigger  
deactivate/activate.)

Thanks,
Stephen


More information about the wp-hackers mailing list