kyamagu
Forum Replies Created
-
Forum: Plugins
In reply to: [PDO (SQLite) For Wordpress] PDO plugin: Fixing errors in the sqlite driverActually I further needed to do the following:
In wp-content/pdo/PDOEngine.php, the fix shown above doesn’t work. Use the following function instead:
private function parseMultipleInserts($values){ $tokens = preg_split("/(''|'|\),)/",$values,-1,PREG_SPLIT_DELIM_CAPTURE); $explodedParts = array(); $part = ''; $literal = FALSE; foreach ($tokens as $tok) { switch ($tok) { case "),": if (!$literal) { $explodedParts[] = $part; $part = ''; } else { $part = $part.$tok; } break; case "'": if ($literal) { $literal = FALSE; } else { $literal = TRUE; } $part = $part.$tok; break; default: $part = $part.$tok; } } if (!empty($part)) { $explodedParts[] = $part; } return $explodedParts; }
In wp-content/pdo/driver_sqlite/schema.php: line 25: Maybe not needed:
//$query = "create table modTimes (modFile text not null primary key, modTime text not null default '0000-00-00 00:00:00')";
In wp-content/pdo/driver_sqlite/pdo_sqlite_driver.php: after line 63: insert this:
$this->rewriteBoolean();
and add the following method in the same file:
/** * method to rewrite the use of the true/false expression for use in sqlite * * sqlite doesn't recognize true or false as expression and necessary to be * converted to 0:false or 1:true */ private function rewriteBoolean(){ $query = $this->istrreplace('true', "1", $this->_query); $query = $this->istrreplace('false', "0", $this->_query); $this->_query = $query; }
In wp-content/pdo/db.php: change _real_escape()
function _real_escape($string) { //return addslashes( $string ); return addslashes($this->escape( $string )); }
In wp-content/pdo/db.php: change escape()
function escape($string) { if ( is_array($string) ) { foreach ($string as &$value) { $value = sqlite_escape_string($value); } return $string; } else { return sqlite_escape_string($string); } }
In wp-content/db.php: lines 153-155: comment out
//if (version_compare($v, "2.4") == -1){ // changeFiles_2_4(); //}
In wp-content/pdo/wp_install.php: Maybe better to rewrite up-to-date version of wp-install:
function wp_install( $blog_title, $user_name, $user_email, $public, $deprecated = '', $user_password = '' ) { global $wp_rewrite, $wpdb; if ( !empty( $deprecated ) ) _deprecated_argument( __FUNCTION__, '2.6' ); //wp_check_mysql_version(); wp_cache_flush(); /**** changes start here ***/ switch (DB_TYPE): case 'sqlite': require PDODIR . '/driver_sqlite/schema.php'; installdb(); break; case 'mysql': make_db_current_silent(); break; endswitch; /**** changes end ***/ populate_options(); populate_roles(); update_option('blogname', $blog_title); update_option('admin_email', $user_email); update_option('blog_public', $public); $guessurl = wp_guess_url(); update_option('siteurl', $guessurl); // If not a public blog, don't ping. if ( ! $public ) update_option('default_pingback_flag', 0); // Create default user. If the user already exists, the user tables are // being shared among blogs. Just set the role in that case. $user_id = username_exists($user_name); $user_password = trim($user_password); $email_password = false; if ( !$user_id && empty($user_password) ) { $user_password = wp_generate_password( 12, false ); $message = __('<strong><em>Note that password</em></strong> carefully! It is a <em>random</em> password that was generated just for you.'); $user_id = wp_create_user($user_name, $user_password, $user_email); update_user_option($user_id, 'default_password_nag', true, true); $email_password = true; } else if ( !$user_id ) { // Password has been provided $message = '<em>'.__('Your chosen password.').'</em>'; $user_id = wp_create_user($user_name, $user_password, $user_email); } else { $message = __('User already exists. Password inherited.'); } $user = new WP_User($user_id); $user->set_role('administrator'); wp_install_defaults($user_id); $wp_rewrite->flush_rules(); wp_new_blog_notification($blog_title, $guessurl, $user_id, ($email_password ? $user_password : __('The password you chose during the install.') ) ); wp_cache_flush(); return array('url' => $guessurl, 'user_id' => $user_id, 'password' => $user_password, 'password_message' => $message); }
Forum: Plugins
In reply to: [Plugin: PDO (SQLite) For WordPress] Errors in error_log and debug.txtThe problem seems to be the sql statement incompatible with sqlite. I looked at the query:
INSERT INTO 'wp_options' ('option_name', 'option_value', 'autoload') VALUES ('_transient_feed_0ff4b43bd116a9d8720d689c80e7dfd4', '...', 'no') ON DUPLICATE KEY UPDATE 'option_name'= VALUES('option_name'), 'option_value'= VALUES('option_value'), 'autoload'= VALUES('autoload')
Apparently ON DUPLICATE KEY UPDATE syntax is not supported under sqlite. I don’t know how I can fix this.