[wp-hackers] Allowing multiple plugins to hook into db.php
Peter Westwood
peter.westwood at ftwr.co.uk
Sat Aug 7 06:40:44 UTC 2010
On 6 Aug 2010, at 15:52, John Sessford 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.
I'm not sure how this would fly and how often it is really needed.
The way we currently implement this the single db.php (and single advanced-cache.php) are pulled in earlier than any plugin could configure anything with any of these hook functions you suggest.
If you want all these db plugins to interact they are likely going to have to have specific code in them to perform that interaction and I don't think this is something we need in core at the moment.
Cheers
--
Peter Westwood
http://blog.ftwr.co.uk | http://westi.wordpress.com
C53C F8FC 8796 8508 88D6 C950 54F4 5DCD A834 01C5
More information about the wp-hackers
mailing list