some bug fixes

git-svn-id: https://plugins.svn.wordpress.org/sqlite-integration/trunk@908000 b8457f37-d9ea-0310-8a92-e5e31aec5664
This commit is contained in:
kjmtsh 2014-05-05 03:38:15 +00:00
parent 4c4d7022a9
commit 7d94787d40
10 changed files with 44 additions and 24 deletions

2
db.php
View File

@ -5,7 +5,7 @@
* This file must be placed in the directory wordpress/wp-content/db.php. * This file must be placed in the directory wordpress/wp-content/db.php.
* WordPress loads this file automatically. * WordPress loads this file automatically.
* *
* @version 1.6.1 * @version 1.6.2
* @package SQLite Integration * @package SQLite Integration
* @author Kojima Toshiyasu * @author Kojima Toshiyasu
* *

View File

@ -200,6 +200,8 @@ class PDODB extends wpdb {
$this->bail(sprintf(__("<h1>Error establlishing a database connection</h1><p>We have been unable to connect to the specified database. <br />The error message received was %s"), $this->dbh->errorInfo())); $this->bail(sprintf(__("<h1>Error establlishing a database connection</h1><p>We have been unable to connect to the specified database. <br />The error message received was %s"), $this->dbh->errorInfo()));
return; return;
} }
$is_enabled_foreign_keys = @$this->get_var('PRAGMA foreign_keys');
if ($is_enabled_foreign_keys == '0') @$this->query('PRAGMA foreign_keys = ON');
$this->ready = true; $this->ready = true;
} }
/** /**
@ -333,7 +335,5 @@ class PDODB extends wpdb {
if (!isset($wpdb)) { if (!isset($wpdb)) {
global $wpdb; global $wpdb;
$wpdb = new PDODB(); $wpdb = new PDODB();
$is_enabled_foreign_keys = @$wpdb->get_var('PRAGMA foreign_keys');
if ($is_enabled_foreign_keys == '0') @$wpdb->query('PRAGMA foreign_keys = ON');
} }
?> ?>

View File

@ -781,9 +781,9 @@ class PDOEngine extends PDO {
if (stripos($this->query_type, 'show') !== false) { if (stripos($this->query_type, 'show') !== false) {
if (stripos($this->query_type, 'show table status') !== false) { if (stripos($this->query_type, 'show table status') !== false) {
$this->query_type = 'showstatus'; $this->query_type = 'showstatus';
} elseif (stripos($this->query_type, 'show tables') !== false) { } elseif (stripos($this->query_type, 'show tables') !== false || stripos($this->query_type, 'show full tables') !== false) {
$this->query_type = 'show'; $this->query_type = 'show';
} elseif (stripos($this->query_type, 'show columns') !== false || stripos($this->query_type, 'show fields') !== false) { } elseif (stripos($this->query_type, 'show columns') !== false || stripos($this->query_type, 'show fields') !== false || stripos($this->query_type, 'show full columns') !== false) {
$this->query_type = 'showcolumns'; $this->query_type = 'showcolumns';
} elseif (stripos($this->query_type, 'show index') !== false || stripos($this->query_type, 'show indexes') !== false || stripos($this->query_type, 'show keys') !== false) { } elseif (stripos($this->query_type, 'show index') !== false || stripos($this->query_type, 'show indexes') !== false || stripos($this->query_type, 'show keys') !== false) {
$this->query_type = 'showindex'; $this->query_type = 'showindex';

View File

@ -146,7 +146,7 @@ class PDOSQLiteDriver {
* @access private * @access private
*/ */
private function parse_query() { private function parse_query() {
$tokens = preg_split("/(''|')/s", $this->_query, -1, PREG_SPLIT_DELIM_CAPTURE); $tokens = preg_split("/(\\\'|''|')/s", $this->_query, -1, PREG_SPLIT_DELIM_CAPTURE);
$literal = false; $literal = false;
$query_string = ''; $query_string = '';
foreach ($tokens as $token) { foreach ($tokens as $token) {
@ -161,10 +161,10 @@ class PDOSQLiteDriver {
if (strpos($token, '`') !== false) { if (strpos($token, '`') !== false) {
$token = str_replace('`', '', $token); $token = str_replace('`', '', $token);
} }
if (stripos($token, 'TRUE') !== false) { if (preg_match('/\\bTRUE\\b/i', $token)) {
$token = str_ireplace('TRUE', '1', $token); $token = str_ireplace('TRUE', '1', $token);
} }
if (stripos($token, 'FALSE') !== false) { if (preg_match('/\\bFALSE\\b/i', $token)) {
$token = str_ireplace('FALSE', '0', $token); $token = str_ireplace('FALSE', '0', $token);
} }
if (stripos($token, 'SQL_CALC_FOUND_ROWS') !== false) { if (stripos($token, 'SQL_CALC_FOUND_ROWS') !== false) {
@ -197,6 +197,7 @@ class PDOSQLiteDriver {
* @access private * @access private
*/ */
private function handle_show_query(){ private function handle_show_query(){
$this->_query = str_ireplace(' FULL', '', $this->_query);
$table_name = ''; $table_name = '';
$pattern = '/^\\s*SHOW\\s*TABLES\\s*.*?(LIKE\\s*(.*))$/im'; $pattern = '/^\\s*SHOW\\s*TABLES\\s*.*?(LIKE\\s*(.*))$/im';
if (preg_match($pattern, $this->_query, $matches)) { if (preg_match($pattern, $this->_query, $matches)) {
@ -538,6 +539,7 @@ class PDOSQLiteDriver {
* @access private * @access private
*/ */
private function handle_show_columns_query() { private function handle_show_columns_query() {
$this->_query = str_ireplace(' FULL', '', $this->_query);
$pattern_like = '/^\\s*SHOW\\s*(COLUMNS|FIELDS)\\s*FROM\\s*(.*)?\\s*LIKE\\s*(.*)?/i'; $pattern_like = '/^\\s*SHOW\\s*(COLUMNS|FIELDS)\\s*FROM\\s*(.*)?\\s*LIKE\\s*(.*)?/i';
$pattern = '/^\\s*SHOW\\s*(COLUMNS|FIELDS)\\s*FROM\\s*(.*)?/i'; $pattern = '/^\\s*SHOW\\s*(COLUMNS|FIELDS)\\s*FROM\\s*(.*)?/i';
if (preg_match($pattern_like, $this->_query, $matches)) { if (preg_match($pattern_like, $this->_query, $matches)) {

View File

@ -70,6 +70,7 @@ class CreateQuery{
// we don't use it for now. // we don't use it for now.
return $this->_query; return $this->_query;
} }
$this->strip_backticks();
$this->get_table_name(); $this->get_table_name();
$this->rewrite_comments(); $this->rewrite_comments();
$this->rewrite_field_types(); $this->rewrite_field_types();
@ -84,7 +85,6 @@ class CreateQuery{
$this->rewrite_set(); $this->rewrite_set();
$this->rewrite_key(); $this->rewrite_key();
$this->add_if_not_exists(); $this->add_if_not_exists();
$this->strip_backticks();
return $this->post_process(); return $this->post_process();
} }

View File

@ -7,7 +7,7 @@ Author: Kojima Toshiyasu
Author URI: http://dogwood.skr.jp/ Author URI: http://dogwood.skr.jp/
Requires at least: 3.3 Requires at least: 3.3
Tested up to: 3.9 Tested up to: 3.9
Stable tag: 1.6 Stable tag: 1.6.2
License: GPLv2 License: GPLv2
License URI: http://www.gnu.org/licenses/gpl-2.0.html License URI: http://www.gnu.org/licenses/gpl-2.0.html
@ -161,6 +161,10 @@ query_posts() や WP_Query() を使うときに、オプションの一部が機
== Changelog == == Changelog ==
= 1.6.2 (2014-05-05) =
* 正規表現に関するバグを修正しました。
* 管理画面のドキュメント(表示されていなかった)を修正しました。
= 1.6.1 (2014-04-22) = = 1.6.1 (2014-04-22) =
* WP Slimstat を使うために、いくつかのバグを修正しました。 * WP Slimstat を使うために、いくつかのバグを修正しました。
* 古い db.php を使い続けている場合は、ダッシュボードに注意を表示するようにしました(必要な場合のみ)。 * 古い db.php を使い続けている場合は、ダッシュボードに注意を表示するようにしました(必要な場合のみ)。

View File

@ -7,7 +7,7 @@ Author: Kojima Toshiyasu
Author URI: http://dogwood.skr.jp/ Author URI: http://dogwood.skr.jp/
Requires at least: 3.3 Requires at least: 3.3
Tested up to: 3.9 Tested up to: 3.9
Stable tag: 1.6.1 Stable tag: 1.6.2
License: GPLv2 License: GPLv2
License URI: http://www.gnu.org/licenses/gpl-2.0.html License URI: http://www.gnu.org/licenses/gpl-2.0.html
@ -159,6 +159,10 @@ When query_posts() or WP_Query() is used, some options didn't work properly. Whe
== Changelog == == Changelog ==
= 1.6.2 (2014-05-05) =
* Fixed some bugs for the regular expression.
* Fixed the documents on the admin dashboard.
= 1.6.1 (2014-04-22) = = 1.6.1 (2014-04-22) =
* Fixed some bugs for using with WP Slimstat plugin. * Fixed some bugs for using with WP Slimstat plugin.
* Display admin notice when not replacing the old db.php with the new one (when necessary). * Display admin notice when not replacing the old db.php with the new one (when necessary).

View File

@ -4,7 +4,7 @@ Plugin Name: SQLite Integration
Plugin URI: http://dogwood.skr.jp/wordpress/sqlite-integration/ Plugin URI: http://dogwood.skr.jp/wordpress/sqlite-integration/
Description: SQLite Integration is the plugin that enables WordPress to use SQLite. If you don't have MySQL and want to build a WordPress website, it's for you. Description: SQLite Integration is the plugin that enables WordPress to use SQLite. If you don't have MySQL and want to build a WordPress website, it's for you.
Author: Kojima Toshiyasu Author: Kojima Toshiyasu
Version: 1.6.1 Version: 1.6.2
Author URI: http://dogwood.skr.jp Author URI: http://dogwood.skr.jp
Text Domain: sqlite-integration Text Domain: sqlite-integration
Domain Path: /languages Domain Path: /languages
@ -44,7 +44,7 @@ $siteurl = get_option('siteurl');
/* /*
* Defines basic constants. * Defines basic constants.
*/ */
define('SQLITE_INTEGRATION_VERSION', '1.6.1'); define('SQLITE_INTEGRATION_VERSION', '1.6.2');
define('SQLiteDir', dirname(plugin_basename(__FILE__))); define('SQLiteDir', dirname(plugin_basename(__FILE__)));
define('SQLiteFilePath', dirname(__FILE__)); define('SQLiteFilePath', dirname(__FILE__));
define('SQLiteDirName', basename(SQLiteFilePath)); define('SQLiteDirName', basename(SQLiteFilePath));

View File

@ -101,8 +101,10 @@
{ {
"name":"Broken Link Checker", "name":"Broken Link Checker",
"compat":"Checked", "compat":"Needs Patch",
"class":"compatible" "patch_url":"http://dogwood.skr.jp/wordpress/plugins/",
"reason":"MySQL function",
"class":"workaround"
}, },
{ {

View File

@ -31,12 +31,15 @@ class SQLiteIntegrationUtils {
* Check if db.php file is replaced with the apropriate version, * Check if db.php file is replaced with the apropriate version,
* and if not, display notice. * and if not, display notice.
* *
* This is not required for now. So this method only returns and
* do nothing.
* *
*/ */
public static function show_admin_notice() { public static function show_admin_notice() {
return;
$notice_string = __('Upgrading Notice: To finish upgrading, please activate SQLite Integration and go Setting >> SQLite Integration >> Miscellaneous, and click the button &quot;update&quot; at the bottom of the page. Or else replace wp-content/db.php with the one in sqlite-integration directory manually.', 'sqlite-integration'); $notice_string = __('Upgrading Notice: To finish upgrading, please activate SQLite Integration and go Setting >> SQLite Integration >> Miscellaneous, and click the button &quot;update&quot; at the bottom of the page. Or else replace wp-content/db.php with the one in sqlite-integration directory manually.', 'sqlite-integration');
$current_version = defined('SQLITE_INTEGRATION_VERSION') ? SQLITE_INTEGRATION_VERSION : ''; $current_version = defined('SQLITE_INTEGRATION_VERSION') ? SQLITE_INTEGRATION_VERSION : '';
if (version_compare($current_version, '1.6.1', '=')) return; if (version_compare($current_version, '1.6.2', '=')) return;
$version = ''; $version = '';
if (defined('WP_CONTENT_DIR')) { if (defined('WP_CONTENT_DIR')) {
$path = WP_CONTENT_DIR . '/db.php'; $path = WP_CONTENT_DIR . '/db.php';
@ -932,8 +935,13 @@ class SQLiteIntegrationUtils {
$message = __('Couldn&quot;t update db.php file. Please replace it manually.', $domain); $message = __('Couldn&quot;t update db.php file. Please replace it manually.', $domain);
echo '<div id="message" class="updated fade">'.$message.'</div>'; echo '<div id="message" class="updated fade">'.$message.'</div>';
} else { } else {
echo echo <<<JS
'<script type="text/javascript">(function() {jQuery(".sqlite-notice").addClass("hidden");})(jQuery);</script>'; <script type="text/javascript">
//<![CDATA[
(function() {jQuery(".sqlite-notice").addClass("hidden");})(jQuery);
//]]>
</script>
JS;
$message = __('Your db.php is updated.', $domain); $message = __('Your db.php is updated.', $domain);
echo '<div id="message" class="updated fade">'.$message.'</div>'; echo '<div id="message" class="updated fade">'.$message.'</div>';
} }
@ -1038,8 +1046,8 @@ class SQLiteIntegrationUtils {
<?php printf('<input type="submit" name="sqlitewordpress_db_save" value="%s" onclick="return confirm(\'%s\')" class="button-primary">', __('Save', $domain), __('Are you sure to save this file?\n\nClick [Cancel] to stop, [OK] to continue.', $domain)); ?> <?php printf('<input type="submit" name="sqlitewordpress_db_save" value="%s" onclick="return confirm(\'%s\')" class="button-primary">', __('Save', $domain), __('Are you sure to save this file?\n\nClick [Cancel] to stop, [OK] to continue.', $domain)); ?>
<?php echo '</p></form>'; ?> <?php echo '</p></form>'; ?>
<?php endif;?> <?php endif;?>
<h3><?php __('Update db.php', $domain);?></h3> <h3><?php _e('Update db.php', $domain);?></h3>
<p><?php __('Replace the old db.php with the new one.', $domain);?></p> <p><?php _e('Replace the old db.php with the new one.', $domain);?></p>
<form action="" method="post"> <form action="" method="post">
<?php if (function_exists('wp_nonce_field')) { <?php if (function_exists('wp_nonce_field')) {
wp_nonce_field('sqliteintegration-db-update-stats'); wp_nonce_field('sqliteintegration-db-update-stats');