From c197c3fba58a6c4fe4d801e9609408bd1339d6db Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Michal=20=C4=8Ciha=C5=99?= Date: Mon, 4 Jan 2016 16:54:06 +0100 Subject: [PATCH 1/3] Fix handling of databases with dot in a name MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit We do not need to concatenate and parse the items, the cache backend accepts array directly. Fixes #11798 Signed-off-by: Michal Čihař --- ChangeLog | 1 + libraries/DatabaseInterface.class.php | 16 ++++++------- libraries/Table.class.php | 28 +++++++++++----------- libraries/db_table_exists.lib.php | 2 +- test/classes/PMA_Table_test.php | 16 ++++++------- test/libraries/PMA_display_export_test.php | 2 +- 6 files changed, 32 insertions(+), 33 deletions(-) diff --git a/ChangeLog b/ChangeLog index 8df3482379..1cd8fac5c9 100644 --- a/ChangeLog +++ b/ChangeLog @@ -16,6 +16,7 @@ phpMyAdmin - ChangeLog - issue Undefined index: host - issue #11810 'Add to central columns' (per column button) does nothing - issue #11727 SQL duplicate entry error trying to INSERT in designer_settings table +- issue #11798 Fix handling of databases with dot in a name 4.5.3.1 (2015-12-25) - issue #11774 Undefined offset 2 diff --git a/libraries/DatabaseInterface.class.php b/libraries/DatabaseInterface.class.php index e782b4a405..7af15599cd 100644 --- a/libraries/DatabaseInterface.class.php +++ b/libraries/DatabaseInterface.class.php @@ -99,8 +99,8 @@ class PMA_DatabaseInterface /** * Get a cached value from table cache. * - * @param string $contentPath Dot notation of the target value - * @param mixed $default Return value on cache miss + * @param array $contentPath Array of the name of the target value + * @param mixed $default Return value on cache miss * * @return mixed cached value or default */ @@ -112,8 +112,8 @@ class PMA_DatabaseInterface /** * Set an item in table cache using dot notation. * - * @param string $contentPath Dot notation of the target path - * @param mixed $value Target value + * @param array $contentPath Array with the target path + * @param mixed $value Target value * * @return void */ @@ -126,10 +126,8 @@ class PMA_DatabaseInterface return; } - $keys = explode('.', $contentPath); - - while (count($keys) > 1) { - $key = array_shift($keys); + while (count($contentPath) > 1) { + $key = array_shift($contentPath); // If the key doesn't exist at this depth, we will just create an empty array // to hold the next value, allowing us to create the arrays to hold final @@ -140,7 +138,7 @@ class PMA_DatabaseInterface $loc = &$loc[$key]; } - $loc[array_shift($keys)] = $value; + $loc[array_shift($contentPath)] = $value; } /** diff --git a/libraries/Table.class.php b/libraries/Table.class.php index 6a51f794e3..40d9ceea05 100644 --- a/libraries/Table.class.php +++ b/libraries/Table.class.php @@ -169,7 +169,7 @@ class PMA_Table } // use cached data or load information with SHOW command - if ($this->_dbi->getCachedTableContent("${db}.${table}") != null + if ($this->_dbi->getCachedTableContent(array($db, $table)) != null || $GLOBALS['cfg']['Server']['DisableIS'] ) { $type = $this->getStatusInfo('TABLE_TYPE'); @@ -314,14 +314,14 @@ class PMA_Table // sometimes there is only one entry (ExactRows) so // we have to get the table's details - if ($this->_dbi->getCachedTableContent("${db}.${table}") == null + if ($this->_dbi->getCachedTableContent(array($db, $table)) == null || $force_read - || count($this->_dbi->getCachedTableContent("${db}.${table}")) == 1 + || count($this->_dbi->getCachedTableContent(array($db, $table))) == 1 ) { $this->_dbi->getTablesFull($db, $table); } - if ($this->_dbi->getCachedTableContent("${db}.${table}") == null) { + if ($this->_dbi->getCachedTableContent(array($db, $table)) == null) { // happens when we enter the table creation dialog // or when we really did not get any status info, for example // when $table == 'TABLE_NAMES' after the user tried SHOW TABLES @@ -329,12 +329,12 @@ class PMA_Table } if (null === $info) { - return $this->_dbi->getCachedTableContent("${db}.${table}"); + return $this->_dbi->getCachedTableContent(array($db, $table)); } // array_key_exists allows for null values if (!array_key_exists( - $info, $this->_dbi->getCachedTableContent("${db}.${table}") + $info, $this->_dbi->getCachedTableContent(array($db, $table)) ) ) { if (! $disable_error) { @@ -346,7 +346,7 @@ class PMA_Table return false; } - return $this->_dbi->getCachedTableContent("${db}.${table}.${info}"); + return $this->_dbi->getCachedTableContent(array($db, $table, $info)); } /** @@ -495,29 +495,29 @@ class PMA_Table $db = $this->_db_name; $table = $this->_name; - if ($this->_dbi->getCachedTableContent("${db}.${table}.ExactRows") != null) { + if ($this->_dbi->getCachedTableContent(array($db, $table, 'ExactRows')) != null) { $row_count = $this->_dbi->getCachedTableContent( - "${db}.${table}.ExactRows" + array($db, $table, 'ExactRows') ); return $row_count; } $row_count = false; if (! $force_exact) { - if (($this->_dbi->getCachedTableContent("${db}.${table}.Rows") == null) + if (($this->_dbi->getCachedTableContent(array($db, $table, 'Rows')) == null) && !$is_view ) { $tmp_tables = $this->_dbi->getTablesFull($db, $table); if (isset($tmp_tables[$table])) { $this->_dbi->cacheTableContent( - "${db}.${table}", + array($db, $table), $tmp_tables[$table] ); } } - if ($this->_dbi->getCachedTableContent("${db}.${table}.Rows") != null) { + if ($this->_dbi->getCachedTableContent(array($db, $table, 'Rows')) != null) { $row_count = $this->_dbi->getCachedTableContent( - "${db}.${table}.Rows" + array($db, $table, 'Rows') ); } else { $row_count = false; @@ -567,7 +567,7 @@ class PMA_Table } } if ($row_count) { - $this->_dbi->cacheTableContent("${db}.${table}.ExactRows", $row_count); + $this->_dbi->cacheTableContent(array($db, $table, 'ExactRows'), $row_count); } return $row_count; diff --git a/libraries/db_table_exists.lib.php b/libraries/db_table_exists.lib.php index b95f227593..540bedd0bb 100644 --- a/libraries/db_table_exists.lib.php +++ b/libraries/db_table_exists.lib.php @@ -57,7 +57,7 @@ if (empty($is_table) // Not a valid table name -> back to the db_sql.php if (/*overload*/mb_strlen($table)) { - $is_table = $GLOBALS['dbi']->getCachedTableContent("${db}.${table}", false); + $is_table = $GLOBALS['dbi']->getCachedTableContent(array($db, $table), false); if (! $is_table) { $_result = $GLOBALS['dbi']->tryQuery( diff --git a/test/classes/PMA_Table_test.php b/test/classes/PMA_Table_test.php index 1fd6469d2c..3462eb3bea 100644 --- a/test/classes/PMA_Table_test.php +++ b/test/classes/PMA_Table_test.php @@ -620,8 +620,8 @@ class PMA_Table_Test extends PHPUnit_Framework_TestCase public function testIsMergeCase2() { $map = array( - array('PMA.PMA_BookMark', null, array('ENGINE' => "MERGE")), - array('PMA.PMA_BookMark.ENGINE', null, "MERGE") + array(array('PMA', 'PMA_BookMark'), null, array('ENGINE' => "MERGE")), + array(array('PMA', 'PMA_BookMark', 'ENGINE'), null, "MERGE") ); $GLOBALS['dbi']->expects($this->any()) ->method('getCachedTableContent') @@ -642,8 +642,8 @@ class PMA_Table_Test extends PHPUnit_Framework_TestCase public function testIsMergeCase3() { $map = array( - array('PMA.PMA_BookMark', null, array('ENGINE' => "MRG_MYISAM")), - array('PMA.PMA_BookMark.ENGINE', null, "MRG_MYISAM") + array(array('PMA', 'PMA_BookMark'), null, array('ENGINE' => "MRG_MYISAM")), + array(array('PMA', 'PMA_BookMark', 'ENGINE'), null, "MRG_MYISAM") ); $GLOBALS['dbi']->expects($this->any()) ->method('getCachedTableContent') @@ -664,8 +664,8 @@ class PMA_Table_Test extends PHPUnit_Framework_TestCase public function testIsMergeCase4() { $map = array( - array('PMA.PMA_BookMark', null, array('ENGINE' => "ISDB")), - array('PMA.PMA_BookMark.ENGINE', null, "ISDB") + array(array('PMA', 'PMA_BookMark'), null, array('ENGINE' => "ISDB")), + array(array('PMA', 'PMA_BookMark', 'ENGINE'), null, "ISDB") ); $GLOBALS['dbi']->expects($this->any()) ->method('getCachedTableContent') @@ -988,11 +988,11 @@ class PMA_Table_Test extends PHPUnit_Framework_TestCase { $map = array( array( - 'PMA.PMA_BookMark', + array('PMA', 'PMA_BookMark'), null, array('Comment' => "Comment222", 'TABLE_TYPE' => "VIEW"), ), - array('PMA.PMA_BookMark.TABLE_TYPE', null, 'VIEW'), + array(array('PMA', 'PMA_BookMark', 'TABLE_TYPE'), null, 'VIEW'), ); $GLOBALS['dbi']->expects($this->any()) ->method('getCachedTableContent') diff --git a/test/libraries/PMA_display_export_test.php b/test/libraries/PMA_display_export_test.php index 349fd8b68a..49286223e8 100644 --- a/test/libraries/PMA_display_export_test.php +++ b/test/libraries/PMA_display_export_test.php @@ -139,7 +139,7 @@ class PMA_DisplayExport_Test extends PHPUnit_Framework_TestCase $num_tables_str = "10"; $unlim_num_rows_str = "unlim_num_rows_str"; $single_table = "single_table"; - $GLOBALS['dbi']->cacheTableContent("${db}.${table}.ENGINE", 'MERGE'); + $GLOBALS['dbi']->cacheTableContent(array($db, $table, 'ENGINE'), 'MERGE'); $columns_info = array( 'test_column1' => array( From b16bec706a99b3058a14baffeef58470e59200a9 Mon Sep 17 00:00:00 2001 From: Kiguda Kosuru Date: Tue, 5 Jan 2016 01:39:52 +0100 Subject: [PATCH 2/3] Translated using Weblate (Japanese) Currently translated at 66.7% (2143 of 3210 strings) [CI skip] --- po/ja.po | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/po/ja.po b/po/ja.po index dbcb381366..58c0f94b81 100644 --- a/po/ja.po +++ b/po/ja.po @@ -4,8 +4,8 @@ msgstr "" "Project-Id-Version: phpMyAdmin 4.5.3-dev\n" "Report-Msgid-Bugs-To: translators@phpmyadmin.net\n" "POT-Creation-Date: 2015-12-16 07:59+0100\n" -"PO-Revision-Date: 2015-12-18 18:33+0000\n" -"Last-Translator: Masahiro Nishi \n" +"PO-Revision-Date: 2016-01-05 01:39+0000\n" +"Last-Translator: Kiguda Kosuru \n" "Language-Team: Japanese " "\n" "Language: ja\n" @@ -891,10 +891,9 @@ msgid "Delete tracking data for these tables?" msgstr "これらテーブルに対しての追跡データを削除しますか?" #: js/messages.php:51 -#, fuzzy #| msgid "Delete tracking data for this table" msgid "Delete tracking data for this version?" -msgstr "このテーブルに対しての追跡データを削除しますか?" +msgstr "このバージョンに対しての追跡データを削除しますか?" #: js/messages.php:52 msgid "Delete tracking data for these versions?" @@ -979,6 +978,8 @@ msgid "" "collation; in this case we suggest you revert to the original collation and " "refer to the tips at " msgstr "" +"この操作はあなたのデータを新しい文字ソート順序に変換しようとします。まれなことですが、新しい文字ソート順序に定義されていない文字があった場合、不正なデータ" +"が現れる可能性があります。そうなった場合は、操作を撤回するようにお知らせし、ヒントを参照 " #: js/messages.php:74 msgid "Garbled Data" From e9d3ef465f67ae70f7ba708c58531b963865c286 Mon Sep 17 00:00:00 2001 From: Masahiro Nishi Date: Tue, 5 Jan 2016 02:11:26 +0100 Subject: [PATCH 3/3] Translated using Weblate (Japanese) Currently translated at 67.4% (2166 of 3210 strings) [CI skip] --- po/ja.po | 51 ++++++++++++++------------------------------------- 1 file changed, 14 insertions(+), 37 deletions(-) diff --git a/po/ja.po b/po/ja.po index 58c0f94b81..361d74cad5 100644 --- a/po/ja.po +++ b/po/ja.po @@ -4,8 +4,8 @@ msgstr "" "Project-Id-Version: phpMyAdmin 4.5.3-dev\n" "Report-Msgid-Bugs-To: translators@phpmyadmin.net\n" "POT-Creation-Date: 2015-12-16 07:59+0100\n" -"PO-Revision-Date: 2016-01-05 01:39+0000\n" -"Last-Translator: Kiguda Kosuru \n" +"PO-Revision-Date: 2016-01-05 02:11+0000\n" +"Last-Translator: Masahiro Nishi \n" "Language-Team: Japanese " "\n" "Language: ja\n" @@ -930,14 +930,11 @@ msgid "Do you really want to delete the search \"%s\"?" msgstr "本当に検索「%s」の削除を実行しますか?" #: js/messages.php:60 -#, fuzzy #| msgid "" #| "You have edited some data and they have not been saved. Are you sure you " #| "want to leave this page before saving the data?" msgid "You have unsaved changes; are you sure you want to leave this page?" -msgstr "" -"データの一部を変更しましたが保存していません。データを保存せずにこのページか" -"ら移動してもよろしいですか?" +msgstr "保存していない編集がありますが、このページを離れますか?" #: js/messages.php:61 msgid "Do you really want to revoke the selected user(s) ?" @@ -1132,26 +1129,23 @@ msgid "Close" msgstr "閉じる" #: js/messages.php:130 -#, fuzzy #| msgid "The number of pages created." msgid "Template was created." -msgstr "作成されたページ数。" +msgstr "テンプレートが作成されました。" #: js/messages.php:131 msgid "Template was loaded." msgstr "" #: js/messages.php:132 -#, fuzzy #| msgid "The profile has been updated." msgid "Template was updated." -msgstr "プロファイルを更新しました。" +msgstr "テンプレートを更新しました。" #: js/messages.php:133 -#, fuzzy #| msgid "The row has been deleted." msgid "Template was deleted." -msgstr "行を削除しました" +msgstr "テンプレートを削除しました。" #. l10n: Other, small valued, queries #: js/messages.php:136 libraries/ServerStatusData.class.php:133 @@ -1203,7 +1197,6 @@ msgid "Query cache used" msgstr "使用されているクエリキャッシュ" #: js/messages.php:152 -#, fuzzy #| msgid "System CPU Usage" msgid "System CPU usage" msgstr "システム CPU の使用状況" @@ -1241,25 +1234,21 @@ msgid "Used memory" msgstr "使用中メモリ" #: js/messages.php:163 -#, fuzzy #| msgid "Total Swap" msgid "Total swap" msgstr "総スワップ領域" #: js/messages.php:164 -#, fuzzy #| msgid "Cached Swap" msgid "Cached swap" msgstr "キャッシュ割り当てスワップ領域" #: js/messages.php:165 -#, fuzzy #| msgid "Used Swap" msgid "Used swap" msgstr "使用中スワップ領域" #: js/messages.php:166 -#, fuzzy #| msgid "Free Swap" msgid "Free swap" msgstr "空きスワップ領域" @@ -1676,7 +1665,6 @@ msgid "No files available on server for import!" msgstr "" #: js/messages.php:276 -#, fuzzy #| msgid "Analyse Query" msgid "Analyse query" msgstr "クエリを解析する" @@ -1744,7 +1732,6 @@ msgid "Loading…" msgstr "読み込み中…" #: js/messages.php:302 -#, fuzzy #| msgid "Request Aborted!!" msgid "Request aborted!!" msgstr "リクエストを中止しました!!" @@ -1756,10 +1743,9 @@ msgid "Processing request" msgstr "要求を処理しています" #: js/messages.php:304 -#, fuzzy #| msgid "Request Aborted!!" msgid "Request failed!!" -msgstr "リクエストを中止しました!!" +msgstr "リクエストは失敗しました!!" #: js/messages.php:305 #, fuzzy @@ -1783,7 +1769,6 @@ msgid "No databases selected." msgstr "データベースが選択されていません。" #: js/messages.php:309 -#, fuzzy #| msgid "Dropping Column" msgid "Dropping column" msgstr "カラムを削除しています" @@ -1809,28 +1794,24 @@ msgid "Click to dismiss this notification" msgstr "クリックすると、この通知を破棄します" #: js/messages.php:315 -#, fuzzy #| msgid "Renaming Databases" msgid "Renaming databases" msgstr "データベースの名称を変更しています" #: js/messages.php:316 -#, fuzzy #| msgid "Copying Database" msgid "Copying database" msgstr "データベースをコピーしています" #: js/messages.php:317 -#, fuzzy #| msgid "Changing Charset" msgid "Changing charset" msgstr "文字セットを変更しています" #: js/messages.php:321 libraries/Util.class.php:3232 -#, fuzzy #| msgid "Disable foreign key checks" msgid "Enable foreign key checks" -msgstr "外部キーのチェックを無効にする" +msgstr "外部キーのチェックを有効にする" #: js/messages.php:324 #, fuzzy @@ -1893,7 +1874,6 @@ msgid "Values for a new column" msgstr "新しいカラムに対しての値" #: js/messages.php:341 -#, fuzzy #| msgid "Enter each value in a separate field" msgid "Enter each value in a separate field." msgstr "個々の入力欄にそれぞれ値を入力してください" @@ -1961,10 +1941,10 @@ msgid "No auto-saved query" msgstr "" #: js/messages.php:355 -#, fuzzy, php-format +#, php-format #| msgid "Variable" msgid "Variable %d:" -msgstr "変数" +msgstr "変数 %d:" #: js/messages.php:358 libraries/normalization.lib.php:886 msgid "Pick" @@ -1990,10 +1970,9 @@ msgid "" msgstr "" #: js/messages.php:362 -#, fuzzy #| msgid "Free memory" msgid "See more" -msgstr "空きメモリ" +msgstr "もっと見る" #: js/messages.php:363 msgid "Are you sure?" @@ -2003,23 +1982,21 @@ msgstr "" msgid "" "This action may change some of the columns definition.
Are you sure you " "want to continue?" -msgstr "" +msgstr "この操作はいくつかのカラム定義を変更します。
本当に続けますか?" #: js/messages.php:365 -#, fuzzy #| msgid "Contribute" msgid "Continue" -msgstr "phpMyAdmin に協力するには" +msgstr "続ける" #: js/messages.php:368 msgid "Add primary key" msgstr "主キーを追加する" #: js/messages.php:369 -#, fuzzy #| msgid "A primary key has been added on %s." msgid "Primary key added." -msgstr "%s に主キーを追加しました" +msgstr "主キーを追加しました。" #: js/messages.php:370 libraries/normalization.lib.php:191 #, fuzzy