Migrate install rewriting to new rewriters
This commit is contained in:
+14
-21
@@ -10,6 +10,7 @@
|
||||
*/
|
||||
|
||||
// This is required by class-wpdb so we must load it first
|
||||
require_once ABSPATH . '/wp-includes/version.php';
|
||||
require_once ABSPATH . '/wp-includes/cache.php';
|
||||
require_once ABSPATH . '/wp-includes/l10n.php';
|
||||
|
||||
@@ -20,39 +21,31 @@ if (!function_exists('wpsql_is_resource')) {
|
||||
}
|
||||
}
|
||||
|
||||
// Logs are put in the pg4wp directory
|
||||
define( 'PG4WP_LOG', PG4WP_ROOT.'/logs/');
|
||||
// Check if the logs directory is needed and exists or create it if possible
|
||||
if( (PG4WP_DEBUG || PG4WP_LOG_ERRORS) &&
|
||||
!file_exists( PG4WP_LOG) &&
|
||||
is_writable(dirname( PG4WP_LOG)))
|
||||
mkdir( PG4WP_LOG);
|
||||
|
||||
// Load the driver defined in 'db.php'
|
||||
require_once( PG4WP_ROOT.'/driver_'.DB_DRIVER.'.php');
|
||||
require_once(PG4WP_ROOT . '/driver_' . DB_DRIVER . '.php');
|
||||
|
||||
// This loads up the wpdb class applying appropriate changes to it
|
||||
$replaces = array(
|
||||
'define( ' => '// define( ',
|
||||
'class wpdb' => 'class wpdb2',
|
||||
'new wpdb' => 'new wpdb2',
|
||||
'mysql_' => 'wpsql_',
|
||||
'is_resource' => 'wpsql_is_resource',
|
||||
'<?php' => '',
|
||||
'?>' => '',
|
||||
'define( ' => '// define( ',
|
||||
'class wpdb' => 'class wpdb2',
|
||||
'new wpdb' => 'new wpdb2',
|
||||
'mysql_' => 'wpsql_',
|
||||
'is_resource' => 'wpsql_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);
|
||||
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");
|
||||
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
|
||||
if (! isset($wpdb) && defined('DB_USER')) {
|
||||
$wpdb = new wpdb2( DB_USER, DB_PASSWORD, DB_NAME, DB_HOST );
|
||||
}
|
||||
if (!isset($wpdb) && defined('DB_USER')) {
|
||||
$wpdb = new wpdb2(DB_USER, DB_PASSWORD, DB_NAME, DB_HOST);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user