[wp-hackers] Allowing multiple plugins to hook into db.php
John Sessford
john at ikailo.com
Fri Aug 6 14:52:09 UTC 2010
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
More information about the wp-hackers
mailing list