[wp-hackers] Is get_plugin_data "expensive"?
Stephen Rider
wp-hackers at striderweb.com
Wed Jul 16 16:42:05 GMT 2008
Heh. Yeah, I know. Sometimes I go to extremes with the whole "never
repeat data" rule. I hate duplicating this kind of thing, because
inevitably you do an update and forget that one variable further down
that _also_ needs to be changed.
Actually, for my purposes, I may only have to update the variable when
there's a change to the defaults (such as a new option introduced).
Kind of like $wp_db_version in WP....
Stephen
On Jul 16, 2008, at 10:15 AM, Otto wrote:
> 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
>>
> _______________________________________________
> 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