[wp-hackers] Allowing multiple plugins to hook into db.php
Jacob Santos
wordpress at santosj.name
Fri Aug 6 14:59:41 UTC 2010
I once floated around the idea of an adapter model instead of replacing or
extending wpdb directly. If the idea is simply to add additional functions,
then implementing a call and including a class plugin model would make sense
as well.
The problem with my idea is that I don't believe the core devs would be up
for such a drastic refactoring of wpdb class.
Your idea might work, but the ticket one will not.
Jacob Santos
On Fri, Aug 6, 2010 at 9:52 AM, John Sessford <john at ikailo.com> wrote:
> Just wanted to float this by the Hackers before putting any major effort
> into it.
>
> Db.php has an inherent issue, which is that only one plugin using the
> db.php
> can be loaded at any given time. The problem is that since a some of these
> plugins have unique and/or different functions, it is hard to have them
> work
> together without manually modifying db.php. Installing a new db plugin can
> overwrite the existing db.php file, rendering existing plugins partialy
> de-activated.
>
> In an optimal situation, one plugin could create a new $wpdb class for
> back-end-load sharing or for a database other than MySql. A separate
> caching
> plugin could extend a $wpdb class to improve performance, while still
> another could check the database and do some work prior to creating the
> table vars.
>
> The way I see it is two functions: add_db_hook($filename, $priority) and
> remove_db_hook($filename). These functions would marshal the filenames into
> an array stored in a text file such as "db_list.php", while "db.php" would
> get the list and load each file sequentially.
>
> This would allow more flexibility for users as to which db plugins they can
> use and would promote better compatibility between these plugins. Plugin
> authors will also have more control over their db.php code since they can
> leave the file in their own plugin directory, resulting in only one copy of
> the file and ensuring it is updated when the plugin is updated.
>
> Thoughts?
>
> John Sessford
> _______________________________________________
> 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