bug fixes and make compatible with WP Slimstat

git-svn-id: https://plugins.svn.wordpress.org/sqlite-integration/trunk@899667 b8457f37-d9ea-0310-8a92-e5e31aec5664
This commit is contained in:
kjmtsh 2014-04-21 19:39:09 +00:00
parent f6859effd2
commit 4c4d7022a9
7 changed files with 144 additions and 22 deletions

1
db.php
View File

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

Binary file not shown.

View File

@ -1313,3 +1313,31 @@ msgstr "ヌル"
msgid "Default"
msgstr "デフォルト"
msgid ""
"Upgrading Notice: To finish upgrading, please activate SQLite Integration "
"and go Setting >> SQLite Integration >> Miscellaneous, and click the button "update" at"
" the bottom of the page. Or else replace wp-content/db.php with the one in sqlite-integration "
"directory manually."
msgstr ""
"注意: アップグレードを完了するには、SQLite Integration を有効化して、設定 >> SQLite Integration >> いろいろ "
"ページに移り、ページの最下段にある「更新」ボタンをクリックしてください。あるいは、wp-content/db.php を sqlite-integration "
"ディレクトリにある db.php で上書きしてください。"
msgid "Update db.php"
msgstr "db.php のアップデート"
msgid "Replace the old db.php with the new one."
msgstr "古い db.php を新しいファイルと入れ替えます。"
msgid "Update"
msgstr "更新"
msgid "Are you sure to update this file?\n\nClick [Cancel] to stop, [OK] to continue."
msgstr "このファイルを更新してもいいですか。\n\nやめるなら [Cancel] を、続けるなら [OK] をクリックしてください。"
msgid "Your db.php is updated."
msgstr "db.php がアップデートされました。"
msgid "Couldn"t update db.php file. Please replace it manually."
msgstr "db.php ファイルをアップデートできませんでした。手動で置き換えてください。"

View File

@ -161,6 +161,12 @@ query_posts() や WP_Query() を使うときに、オプションの一部が機
== Changelog ==
= 1.6.1 (2014-04-22) =
* WP Slimstat を使うために、いくつかのバグを修正しました。
* 古い db.php を使い続けている場合は、ダッシュボードに注意を表示するようにしました(必要な場合のみ)。
* 古い db.php を新しいものを置き換えるユーティリティを追加しました。
* 日本語カタログファイルをアップデートしました。
= 1.6 (2014-04-17) =
* 未対応のクエリに対するエラーメッセージのコントロールができていないのを修正しました。
* SQL_CALC_FOUND_ROW ステートメントのバグを修正しました。メインクエリと WP_Query、WP_Meta_Query などのページング情報に関連したものです。

View File

@ -7,7 +7,7 @@ Author: Kojima Toshiyasu
Author URI: http://dogwood.skr.jp/
Requires at least: 3.3
Tested up to: 3.9
Stable tag: 1.6
Stable tag: 1.6.1
License: GPLv2
License URI: http://www.gnu.org/licenses/gpl-2.0.html
@ -155,10 +155,16 @@ This plugin doesn't support 'WP_PLUGIN_URL' constant.
== Upgrade Notice ==
When query_posts() or WP_Query() is used, some options didn't work properly. When you post comments, the back quotes in the content was removed. These bugs and some minor ones are fixed. Documentations and doc strings are revised. WordPress 3.9 beta was tested. When auto upgrading fails, please try manual upgrade via FTP.
When query_posts() or WP_Query() is used, some options didn't work properly. When you post comments, the back quotes in the content was removed. These bugs and some minor ones are fixed. Documentations and doc strings are revised. WordPress 3.9 was tested. When auto upgrading fails, please try manual upgrade via FTP.
== Changelog ==
= 1.6.1 (2014-04-22) =
* 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).
* Add the feature for replacing the old db.php file with the button click.
* Fixed the Japanese translation catalog file.
= 1.6 (2014-04-17) =
* Fixed the bug of error messaging control for the unknown query.
* Fixed the bug for 'SQL_CALC_FOUND_ROW' statement. This is for the main query, WP_Query class and WP_Meta_Query concerning paging information.

View File

@ -4,14 +4,14 @@ Plugin Name: 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.
Author: Kojima Toshiyasu
Version: 1.6
Version: 1.6.1
Author URI: http://dogwood.skr.jp
Text Domain: sqlite-integration
Domain Path: /languages
License: GPL2 or later
*/
/* Copyright 2013 Kojima Toshiyasu (email: kjm@dogwood.skr.jp)
/* Copyright 2013-2014 Kojima Toshiyasu (email: kjm@dogwood.skr.jp)
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License, version 2, as
published by the Free Software Foundation.
@ -44,6 +44,7 @@ $siteurl = get_option('siteurl');
/*
* Defines basic constants.
*/
define('SQLITE_INTEGRATION_VERSION', '1.6.1');
define('SQLiteDir', dirname(plugin_basename(__FILE__)));
define('SQLiteFilePath', dirname(__FILE__));
define('SQLiteDirName', basename(SQLiteFilePath));
@ -114,8 +115,10 @@ class SQLiteIntegration {
}
if (function_exists('is_multisite') && is_multisite()) {
add_action('network_admin_menu', array($this, 'add_network_pages'));
add_action('network_admin_notices', array('SQLiteIntegrationUtils', 'show_admin_notice'));
} else {
add_action('admin_menu', array($this, 'add_pages'));
add_action('admin_notices', array('SQLiteIntegrationUtils', 'show_admin_notice'));
}
// See the docstring for download_backup_db() in utilities/utility.php
// We need this registration process.

View File

@ -25,6 +25,37 @@ class SQLiteIntegrationUtils {
function __construct() {
}
/**
* Method to display update notice on the admin dashboard.
*
* Check if db.php file is replaced with the apropriate version,
* and if not, display notice.
*
*
*/
public static function show_admin_notice() {
$notice_string = __('Upgrading Notice: To finish upgrading, please activate SQLite Integration and go Setting >> SQLite Integration >> Miscellaneous, and click the button "update" 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 : '';
if (version_compare($current_version, '1.6.1', '=')) return;
$version = '';
if (defined('WP_CONTENT_DIR')) {
$path = WP_CONTENT_DIR . '/db.php';
} else {
$path = ABSPATH . 'wp-content/db.php';
}
if (!$file_handle = @fopen($path, 'r')) return;
while (($buffer = fgets($file_handle)) !== false) {
if (stripos($buffer, '@version') !== false) {
$version = str_ireplace('*@version ', '', $buffer);
$version = trim($version);
break;
}
}
fclose($file_handle);
if (empty($version) || version_compare($version, $current_version, '<')) {
echo '<div class="updated sqlite-notice" style="padding:10px;line-height:150%;font-size:12px"><span>'.$notice_string.'</span></div>';
}
}
/**
* Method to read a error log file and returns its contents.
*
@ -176,7 +207,7 @@ class SQLiteIntegrationUtils {
*
* If this file is not existent, shows message and returns false.
*
* @return string|boolean
* @return string
* @access private
*/
private function show_db_php() {
@ -188,14 +219,14 @@ class SQLiteIntegrationUtils {
if (file_exists($file)) {
if (is_readable($file)) {
$contents = file_get_contents($file);
echo $contents;
return $contents;
} else {
echo 'file is not readable';
$contents = 'file is not readable';
}
} else {
echo 'file doesn\'t exist';
return false;
$contents = 'file doesn\'t exist';
}
return $contents;
}
/**
* Method to get the textarea content and write it to db.php file.
@ -224,6 +255,37 @@ class SQLiteIntegrationUtils {
fclose($fh);
return true;
}
/**
* Method to replace the old db.php with the new one.
*
* @return boolean
* @access private
*/
private function update_db_file() {
$new_file = PDODIR . 'db.php';
if (file_exists($new_file) && is_readable($new_file)) {
$contents = file_get_contents($new_file);
} else {
return false;
}
if (defined('WP_CONTENT_DIR')) {
$path = WP_CONTENT_DIR . '/db.php';
} else {
$path = ABSPATH . 'wp-content/db.php';
}
if (($handle = @fopen($path, 'w+')) && flock($handle, LOCK_EX)) {
if (fwrite($handle, $contents) == false) {
flock($handle, LOCK_UN);
fclose($handle);
return false;
}
flock($handle, LOCK_UN);
fclose($handle);
} else {
return false;
}
return true;
}
/**
* Method to optimize SQLite database.
*
@ -863,6 +925,19 @@ class SQLiteIntegrationUtils {
echo '<div id="message" class="updated fade">' . $message . '</div>';
}
}
if (isset($_POST['sqliteintegration_update_db_file'])) {
check_admin_referer('sqliteintegration-db-update-stats');
$result = $this->update_db_file();
if ($result === false) {
$message = __('Couldn&quot;t update db.php file. Please replace it manually.', $domain);
echo '<div id="message" class="updated fade">'.$message.'</div>';
} else {
echo
'<script type="text/javascript">(function() {jQuery(".sqlite-notice").addClass("hidden");})(jQuery);</script>';
$message = __('Your db.php is updated.', $domain);
echo '<div id="message" class="updated fade">'.$message.'</div>';
}
}
if (isset($_GET['page']) && $_GET['page'] == 'setting-file') :?>
<div class="navigation">
<ul class="navi-menu">
@ -937,22 +1012,18 @@ class SQLiteIntegrationUtils {
wp_nonce_field('sqlitewordpress-log-reset-stats');
}
?>
<textarea name="errorlog" id="errorlog" cols="70" rows="10">
<?php $ret_val = $this->show_error_log();
if ($ret_val === false || empty($ret_val)) {
$message = __('No error messages are found', $domain);
echo $message;
} else {
echo $ret_val;
$ret_val = __('No error messages are found', $domain);
}
?>
</textarea>
<textarea name="errorlog" id="errorlog" cols="70" rows="10"><?php echo $ret_val;?></textarea>
<p>
<input type="submit" name="sqlitewordpress_log_reset" value="<?php _e('Clear Log', $domain)?>" onclick="return confirm('<?php _e('Are you sure to clear Log?\n\nClick [Cancel] to stop, [OK] to continue.', $domain);?>')" class="button-primary">
</p>
</form>
<?php if (!(defined('DISALLOW_FILE_EDIT') && DISALLOW_FILE_EDIT) || !(defined('DISALLOW_FILE_DODS') && DISALLOW_FILE_MODS)) : ?>
<?php if (!(defined('DISALLOW_FILE_EDIT') && DISALLOW_FILE_EDIT) || !(defined('DISALLOW_FILE_MODS') && DISALLOW_FILE_MODS)) : ?>
<?php echo '<h3>';?>
<?php _e('Edit Initial File (wp-content/db.php)', $domain)?>
<?php echo '</h3><p>'; ?>
@ -962,13 +1033,20 @@ class SQLiteIntegrationUtils {
<?php if (function_exists('wp_nonce_field')) {
wp_nonce_field('sqlitewordpress-db-save-stats');
}?>
<?php echo '<textarea name="dbfile" id="dbfile" cols="70" rows="10">'; ?>
<?php $this->show_db_php();?>
<?php echo '</textarea><p>'; ?>
<?php sprintf('<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 $db_contents = $this->show_db_php();?>
<?php echo '<textarea name="dbfile" id="dbfile" cols="70" rows="10">'.$db_contents.'</textarea><p>'; ?>
<?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 endif;?>
<h3><?php __('Update db.php', $domain);?></h3>
<p><?php __('Replace the old db.php with the new one.', $domain);?></p>
<form action="" method="post">
<?php if (function_exists('wp_nonce_field')) {
wp_nonce_field('sqliteintegration-db-update-stats');
}
?>
<p><?php printf('<input type="submit" name="sqliteintegration_update_db_file" value="%s" onclick="return confirm(\'%s\')" class="button-primary">', __('Update', $domain), __('Are you sure to update this file?\n\nClick [Cancel] to stop, [OK] to continue.', $domain));?></p>
</form>
</div>
<?php endif;
}