Skip to content

Commit

Permalink
Merge pull request #55 from PostgreSQL-For-Wordpress/switch-to-mysqli
Browse files Browse the repository at this point in the history
WIP: Switch to mysqli
  • Loading branch information
mattbucci authored Nov 10, 2023
2 parents e3f3682 + 3d164e1 commit bf2ef7f
Show file tree
Hide file tree
Showing 6 changed files with 1,997 additions and 399 deletions.
Binary file added docs/images/pg4wp_design.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
22 changes: 5 additions & 17 deletions pg4wp/core.php
Original file line number Diff line number Diff line change
Expand Up @@ -14,13 +14,6 @@
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');

Expand All @@ -29,20 +22,15 @@ function wpsql_is_resource($object)
'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
Expand Down
6 changes: 0 additions & 6 deletions pg4wp/db.php
Original file line number Diff line number Diff line change
Expand Up @@ -28,12 +28,6 @@
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')) {
Expand Down
Loading

0 comments on commit bf2ef7f

Please sign in to comment.