[wp-hackers] Is get_plugin_data "expensive"?

Otto otto at ottodestruct.com
Wed Jul 16 15:15:34 GMT 2008


Well, it's certainly more expensive than simply having a variable
which you update every time you release a new plugin...

$my_version = 1.2;

:)

On Wed, Jul 16, 2008 at 10:04 AM, Stephen Rider
<wp-hackers at striderweb.com> wrote:
> 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
> _______________________________________________
> wp-hackers mailing list
> wp-hackers at lists.automattic.com
> http://lists.automattic.com/mailman/listinfo/wp-hackers
>


More information about the wp-hackers mailing list