mirror of
https://github.com/PostgreSQL-For-Wordpress/postgresql-for-wordpress.git
synced 2025-07-29 17:27:13 +02:00
Merge pull request #55 from PostgreSQL-For-Wordpress/switch-to-mysqli
WIP: Switch to mysqli
This commit is contained in:
BIN
docs/images/pg4wp_design.png
Normal file
BIN
docs/images/pg4wp_design.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 535 KiB |
@ -14,13 +14,6 @@ require_once ABSPATH . '/wp-includes/version.php';
|
||||
require_once ABSPATH . '/wp-includes/cache.php';
|
||||
require_once ABSPATH . '/wp-includes/l10n.php';
|
||||
|
||||
if (!function_exists('wpsql_is_resource')) {
|
||||
function wpsql_is_resource($object)
|
||||
{
|
||||
return $object !== false && $object !== null;
|
||||
}
|
||||
}
|
||||
|
||||
// Load the driver defined in 'db.php'
|
||||
require_once(PG4WP_ROOT . '/driver_' . DB_DRIVER . '.php');
|
||||
|
||||
@ -29,20 +22,15 @@ $replaces = array(
|
||||
'define( ' => '// define( ',
|
||||
'class wpdb' => 'class wpdb2',
|
||||
'new wpdb' => 'new wpdb2',
|
||||
'mysql_' => 'wpsql_',
|
||||
'is_resource' => 'wpsql_is_resource',
|
||||
'instanceof mysqli_result' => 'instanceof \PgSql\Result',
|
||||
'instanceof mysqli' => 'instanceof \PgSql\Connection',
|
||||
'$this->dbh->connect_errno' => 'wpsqli_connect_error()',
|
||||
'mysqli_' => 'wpsqli_',
|
||||
'is_resource' => 'wpsqli_is_resource',
|
||||
'<?php' => '',
|
||||
'?>' => '',
|
||||
);
|
||||
|
||||
// Ensure class uses the replaced mysql_ functions rather than mysqli_
|
||||
if (!defined('WP_USE_EXT_MYSQL')) {
|
||||
define('WP_USE_EXT_MYSQL', true);
|
||||
}
|
||||
if (WP_USE_EXT_MYSQL != true) {
|
||||
throw new \Exception("PG4SQL CANNOT BE ENABLED WITH MYSQLI, REMOVE ANY WP_USE_EXT_MYSQL configuration");
|
||||
}
|
||||
|
||||
eval(str_replace(array_keys($replaces), array_values($replaces), file_get_contents(ABSPATH . '/wp-includes/class-wpdb.php')));
|
||||
|
||||
// Create wpdb object if not already done
|
||||
|
@ -28,12 +28,6 @@ if(!defined('PG4WP_ROOT')) {
|
||||
define('PG4WP_LOG_ERRORS', true);
|
||||
}
|
||||
|
||||
if (!defined('PG4WP_INSECURE')) {
|
||||
// If you want to allow insecure configuration (from the author point of view) to work with PG4WP,
|
||||
// change this to true
|
||||
define('PG4WP_INSECURE', false);
|
||||
}
|
||||
|
||||
// This defines the directory where PG4WP files are loaded from
|
||||
// 3 places checked : wp-content, wp-content/plugins and the base directory
|
||||
if(file_exists(ABSPATH . 'wp-content/pg4wp')) {
|
||||
|
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
30
readme.md
30
readme.md
@ -1,23 +1,26 @@
|
||||
## PostgreSQL for WordPress (PG4WP)
|
||||
|
||||
### Contributors
|
||||
Code originally by Hawk__ (http://www.hawkix.net/)
|
||||
Modifications by @kevinoid and @mattbucci
|
||||
|
||||
PostgreSQL for WordPress is a special 'plugin' enabling WordPress to be used with a PostgreSQL database.
|
||||
|
||||
### Description
|
||||
|
||||
PostgreSQL for WordPress (PG4WP) gives you the possibility to install and use WordPress with a PostgreSQL database as a backend.
|
||||
It works by replacing calls to MySQL specific functions with generic calls that maps them to another database functions and rewriting SQL queries on the fly when needed.
|
||||
|
||||
If you want to use this plugin, you should be aware of the following :
|
||||
- WordPress with PG4WP is expected to be slower than the original WordPress with MySQL because PG4WP does much SQL rewriting for any page view
|
||||
- Some WordPress plugins should work 'out of the box' but many plugins won't because they would need specific code in PG4WP
|
||||
#### Use Cases
|
||||
|
||||
- Run Wordpress on your Existing Postgres Cluster
|
||||
- Run Wordpress with Georeplication with a Multi-Active Postgres instalation such as [EDB Postgres Distributed](https://www.enterprisedb.com/products/edb-postgres-distributed), or [CockroachDB](https://www.cockroachlabs.com/serverless/) for a [highly available](https://www.cockroachlabs.com/blog/brief-history-high-availability/) and resiliant Wordpress Infrastructure
|
||||
|
||||
### Design
|
||||
|
||||
PostgreSQL for Wordpress works by intercepting calls to the mysqli_ driver in wordpress's wpdb class.
|
||||
it replaces calls to mysqli_ with wpsqli_ which then are implemented by the driver files found in this plugin.
|
||||
|
||||

|
||||
|
||||
### Supported Wordpress Versions
|
||||
|
||||
This plugin has been tested against Wordpress 6.3.2
|
||||
This plugin has been tested against
|
||||
- Wordpress 6.4.1 (v3 branch)
|
||||
- Wordpress 6.3.2 (v2 branch)
|
||||
|
||||
### Supported PHP versions
|
||||
|
||||
@ -41,6 +44,7 @@ PG4WP 2.0 will have a mechanism to add plugin support.
|
||||
|
||||
| Theme | Version | Working |
|
||||
| ----------- | ----------- | --------- |
|
||||
| Twenty Twenty-Four | 1.0 | Confirmed |
|
||||
| Twenty Twenty-Three | 1.2 | Confirmed |
|
||||
| Twenty Twenty-Two | 1.5 | Confirmed |
|
||||
| Twenty Twenty-One | 1.9 | Confirmed |
|
||||
@ -79,3 +83,7 @@ If you find a failing scenario please add a test for it, A PR which fixes a scen
|
||||
PG4WP is provided "as-is" with no warranty in the hope it can be useful.
|
||||
|
||||
PG4WP is licensed under the [GNU GPL](http://www.gnu.org/licenses/gpl.html "GNU GPL") v2 or any newer version at your choice.
|
||||
|
||||
### Contributors
|
||||
Code originally by Hawk__ (http://www.hawkix.net/)
|
||||
Modifications by @kevinoid and @mattbucci
|
Reference in New Issue
Block a user