Skip to content

Commit bf2ef7f

Browse files
authored
Merge pull request #55 from PostgreSQL-For-Wordpress/switch-to-mysqli
WIP: Switch to mysqli
2 parents e3f3682 + 3d164e1 commit bf2ef7f

6 files changed

Lines changed: 1997 additions & 399 deletions

File tree

docs/images/pg4wp_design.png

535 KB
Loading

pg4wp/core.php

Lines changed: 5 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -14,13 +14,6 @@
1414
require_once ABSPATH . '/wp-includes/cache.php';
1515
require_once ABSPATH . '/wp-includes/l10n.php';
1616

17-
if (!function_exists('wpsql_is_resource')) {
18-
function wpsql_is_resource($object)
19-
{
20-
return $object !== false && $object !== null;
21-
}
22-
}
23-
2417
// Load the driver defined in 'db.php'
2518
require_once(PG4WP_ROOT . '/driver_' . DB_DRIVER . '.php');
2619

@@ -29,20 +22,15 @@ function wpsql_is_resource($object)
2922
'define( ' => '// define( ',
3023
'class wpdb' => 'class wpdb2',
3124
'new wpdb' => 'new wpdb2',
32-
'mysql_' => 'wpsql_',
33-
'is_resource' => 'wpsql_is_resource',
25+
'instanceof mysqli_result' => 'instanceof \PgSql\Result',
26+
'instanceof mysqli' => 'instanceof \PgSql\Connection',
27+
'$this->dbh->connect_errno' => 'wpsqli_connect_error()',
28+
'mysqli_' => 'wpsqli_',
29+
'is_resource' => 'wpsqli_is_resource',
3430
'<?php' => '',
3531
'?>' => '',
3632
);
3733

38-
// Ensure class uses the replaced mysql_ functions rather than mysqli_
39-
if (!defined('WP_USE_EXT_MYSQL')) {
40-
define('WP_USE_EXT_MYSQL', true);
41-
}
42-
if (WP_USE_EXT_MYSQL != true) {
43-
throw new \Exception("PG4SQL CANNOT BE ENABLED WITH MYSQLI, REMOVE ANY WP_USE_EXT_MYSQL configuration");
44-
}
45-
4634
eval(str_replace(array_keys($replaces), array_values($replaces), file_get_contents(ABSPATH . '/wp-includes/class-wpdb.php')));
4735

4836
// Create wpdb object if not already done

pg4wp/db.php

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -28,12 +28,6 @@
2828
define('PG4WP_LOG_ERRORS', true);
2929
}
3030

31-
if (!defined('PG4WP_INSECURE')) {
32-
// If you want to allow insecure configuration (from the author point of view) to work with PG4WP,
33-
// change this to true
34-
define('PG4WP_INSECURE', false);
35-
}
36-
3731
// This defines the directory where PG4WP files are loaded from
3832
// 3 places checked : wp-content, wp-content/plugins and the base directory
3933
if(file_exists(ABSPATH . 'wp-content/pg4wp')) {

0 commit comments

Comments
 (0)