From 30e0dc70ccef1b817868bd5c5f04fef7eb1a8878 Mon Sep 17 00:00:00 2001 From: Hugues Peccatte Date: Sat, 9 Aug 2014 23:11:36 +0200 Subject: [PATCH 1/7] Coding style modifications. Remove unused variables. PHPDoc update. Signed-off-by: Hugues Peccatte --- import.php | 12 +++++++----- libraries/schema/Dia_Relation_Schema.class.php | 7 +++++-- libraries/schema/Eps_Relation_Schema.class.php | 3 ++- libraries/schema/Pdf_Relation_Schema.class.php | 3 ++- libraries/schema/Svg_Relation_Schema.class.php | 3 ++- libraries/schema/TableStats.class.php | 8 +++++--- test/classes/gis/PMA_GIS_Geom_test.php | 2 +- test/libraries/PMA_PMD_common_test.php | 3 ++- user_password.php | 4 ++-- 9 files changed, 28 insertions(+), 17 deletions(-) diff --git a/import.php b/import.php index 0d01f223a5..046b08bc59 100644 --- a/import.php +++ b/import.php @@ -31,15 +31,17 @@ if (isset($_REQUEST['simulate_dml'])) { // If it's a refresh console bookmarks request if (isset($_REQUEST['console_bookmark_refresh'])) { $response = PMA_Response::getInstance(); - $response->addJSON('console_message_bookmark', PMA_Console::getBookmarkContent()); + $response->addJSON( + 'console_message_bookmark', PMA_Console::getBookmarkContent() + ); exit; } // If it's a console bookmark add request if (isset($_REQUEST['console_bookmark_add'])) { $response = PMA_Response::getInstance(); - if(isset($_REQUEST['label']) && isset($_REQUEST['db']) - && isset($_REQUEST['bookmark_query']) && isset($_REQUEST['shared'])) - { + if (isset($_REQUEST['label']) && isset($_REQUEST['db']) + && isset($_REQUEST['bookmark_query']) && isset($_REQUEST['shared']) + ) { $cfgBookmark = PMA_Bookmark_getParams(); $bookmarkFields = array( 'bkm_database' => $_REQUEST['db'], @@ -48,7 +50,7 @@ if (isset($_REQUEST['console_bookmark_add'])) { 'bkm_label' => $_REQUEST['label'] ); $isShared = ($_REQUEST['shared'] == 'true' ? true : false); - if(PMA_Bookmark_save($bookmarkFields, $isShared)) { + if (PMA_Bookmark_save($bookmarkFields, $isShared)) { $response->addJSON('message', __('Succeeded')); $response->addJSON('data', $bookmarkFields); $response->addJSON('isShared', $isShared); diff --git a/libraries/schema/Dia_Relation_Schema.class.php b/libraries/schema/Dia_Relation_Schema.class.php index 2f67a43cd3..6583e8307e 100644 --- a/libraries/schema/Dia_Relation_Schema.class.php +++ b/libraries/schema/Dia_Relation_Schema.class.php @@ -214,6 +214,7 @@ class Table_Stats_Dia extends TableStats * @param integer $pageNumber The current page number (from the * $cfg['Servers'][$i]['table_coords'] table) * @param boolean $showKeys Whether to display ONLY keys or not + * @param boolean $offline Load without query * * @global object $dia The current dia document * @global array $cfgRelation The relations settings @@ -223,8 +224,10 @@ class Table_Stats_Dia extends TableStats */ function __construct($tableName, $pageNumber, $showKeys = false, $offline = false) { - global $dia, $cfgRelation, $db; - parent::__construct($dia, $db, $pageNumber, $tableName, $showKeys, false, $offline); + global $dia, $db; + parent::__construct( + $dia, $db, $pageNumber, $tableName, $showKeys, false, $offline + ); /** * Every object in Dia document needs an ID to identify diff --git a/libraries/schema/Eps_Relation_Schema.class.php b/libraries/schema/Eps_Relation_Schema.class.php index aea5607cde..fa044b3df5 100644 --- a/libraries/schema/Eps_Relation_Schema.class.php +++ b/libraries/schema/Eps_Relation_Schema.class.php @@ -327,6 +327,7 @@ class Table_Stats_Eps extends TableStats * @param integer &$same_wide_width The max width among tables * @param boolean $showKeys Whether to display keys or not * @param boolean $showInfo Whether to display table position or not + * @param boolean $offline Load without query * * @global object $eps The current eps document * @global integer The current page number (from the @@ -342,7 +343,7 @@ class Table_Stats_Eps extends TableStats $tableName, $font, $fontSize, $pageNumber, &$same_wide_width, $showKeys = false, $showInfo = false, $offline = false ) { - global $eps, $cfgRelation, $db; + global $eps, $db; parent::__construct( $eps, $db, $pageNumber, $tableName, $showKeys, $showInfo, $offline ); diff --git a/libraries/schema/Pdf_Relation_Schema.class.php b/libraries/schema/Pdf_Relation_Schema.class.php index 04f34013ad..a3e720f18c 100644 --- a/libraries/schema/Pdf_Relation_Schema.class.php +++ b/libraries/schema/Pdf_Relation_Schema.class.php @@ -418,6 +418,7 @@ class Table_Stats_Pdf extends TableStats * @param integer &$sameWideWidth The max. with among tables * @param boolean $showKeys Whether to display keys or not * @param boolean $showInfo Whether to display table position or not + * @param boolean $offline Load without query * * @global object $pdf The current PDF document * @global array $cfgRelation The relations settings @@ -429,7 +430,7 @@ class Table_Stats_Pdf extends TableStats function __construct($tableName, $fontSize, $pageNumber, &$sameWideWidth, $showKeys = false, $showInfo = false, $offline = false ) { - global $pdf, $cfgRelation, $db; + global $pdf, $db; parent::__construct( $pdf, $db, $pageNumber, $tableName, $showKeys, $showInfo, $offline ); diff --git a/libraries/schema/Svg_Relation_Schema.class.php b/libraries/schema/Svg_Relation_Schema.class.php index c46f0be5da..01d3a6675b 100644 --- a/libraries/schema/Svg_Relation_Schema.class.php +++ b/libraries/schema/Svg_Relation_Schema.class.php @@ -293,6 +293,7 @@ class Table_Stats_Svg extends TableStats * @param integer &$same_wide_width The max. with among tables * @param boolean $showKeys Whether to display keys or not * @param boolean $showInfo Whether to display table position or not + * @param boolean $offline Load without query * * @global object $svg The current SVG image document * @global integer The current page number (from the @@ -309,7 +310,7 @@ class Table_Stats_Svg extends TableStats $tableName, $font, $fontSize, $pageNumber, &$same_wide_width, $showKeys = false, $showInfo = false, $offline = false ) { - global $svg, $cfgRelation, $db; + global $svg, $db; parent::__construct( $svg, $db, $pageNumber, $tableName, $showKeys, $showInfo, $offline ); diff --git a/libraries/schema/TableStats.class.php b/libraries/schema/TableStats.class.php index f9e6f1e06a..e5a4ef4ed7 100644 --- a/libraries/schema/TableStats.class.php +++ b/libraries/schema/TableStats.class.php @@ -48,6 +48,7 @@ abstract class TableStats * @param string $tableName table name * @param boolean $showKeys whether to display keys or not * @param boolean $showInfo whether to display table position or not + * @param boolean $offline load without query */ public function __construct( $diagram, $db, $pageNumber, $tableName, $showKeys, $showInfo, $offline @@ -122,10 +123,10 @@ abstract class TableStats { global $cfgRelation; - if ($this->offline){ + if ($this->offline) { $tbl_coords = json_decode($GLOBALS['tbl_coords']); foreach ($tbl_coords as $tbl) { - if( $this->tableName === $tbl->table_name){ + if ($this->tableName === $tbl->table_name) { $this->x = (double) $tbl->x; $this->y = (double) $tbl->y; break; @@ -136,7 +137,8 @@ abstract class TableStats . PMA_Util::backquote($GLOBALS['cfgRelation']['db']) . "." . PMA_Util::backquote($cfgRelation['table_coords']) . " WHERE db_name = '" . PMA_Util::sqlAddSlashes($this->db) . "'" - . " AND table_name = '" . PMA_Util::sqlAddSlashes($this->tableName) . "'" + . " AND table_name = '" . PMA_Util::sqlAddSlashes($this->tableName) + . "'" . " AND pdf_page_number = " . $this->pageNumber; $result = PMA_queryAsControlUser( $sql, false, PMA_DatabaseInterface::QUERY_STORE diff --git a/test/classes/gis/PMA_GIS_Geom_test.php b/test/classes/gis/PMA_GIS_Geom_test.php index d7b0fa3e2a..93cefaf878 100644 --- a/test/classes/gis/PMA_GIS_Geom_test.php +++ b/test/classes/gis/PMA_GIS_Geom_test.php @@ -61,7 +61,7 @@ abstract class PMA_GIS_GeomTest extends PHPUnit_Framework_TestCase /** * Tests whether content is a valid image. * - * @param object $image Image + * @param object $object Image * * @return void */ diff --git a/test/libraries/PMA_PMD_common_test.php b/test/libraries/PMA_PMD_common_test.php index 2420a7ac81..b8c1b440be 100644 --- a/test/libraries/PMA_PMD_common_test.php +++ b/test/libraries/PMA_PMD_common_test.php @@ -57,7 +57,8 @@ class PMA_PMD_CommonTest extends PHPUnit_Framework_TestCase $dbi->expects($this->at(0)) ->method('fetchResult') - ->with(" + ->with( + " SELECT CONCAT_WS('.', `db_name`, `table_name`) AS `name`, `x` AS `X`, `y` AS `Y`, diff --git a/user_password.php b/user_password.php index cabad4bb67..7a2dd739e2 100644 --- a/user_password.php +++ b/user_password.php @@ -181,8 +181,8 @@ function PMA_changePassUrlParamsAndSubmitQuery( /** * Display the page * - * @param string $message Message - * @param string $sql_query SQL query + * @param string $message Message + * @param string $sql_query SQL query * * @return void */ From 8558047094c5b9036fd1ea2eacf65c225abaa28e Mon Sep 17 00:00:00 2001 From: Hugues Peccatte Date: Sat, 9 Aug 2014 23:21:13 +0200 Subject: [PATCH 2/7] Coding style modifications. Signed-off-by: Hugues Peccatte --- test/classes/PMA_Error_test.php | 5 +- .../auth/PMA_AuthenticationCookie_test.php | 7 +- test/libraries/PMA_escapeJsString_test.php | 5 +- test/libraries/PMA_ip_allow_deny_test.php | 18 ++- test/libraries/PMA_prettyPrint_test.php | 4 +- test/libraries/common/PMA_cache_test.php | 20 +++- .../rte/PMA_RTN_getEditorForm_test.php | 4 +- .../select_lang/PMA_langDetails_test.php | 105 +++++++++++++++--- 8 files changed, 138 insertions(+), 30 deletions(-) diff --git a/test/classes/PMA_Error_test.php b/test/classes/PMA_Error_test.php index 8940ee973e..fcd7acfba3 100644 --- a/test/classes/PMA_Error_test.php +++ b/test/classes/PMA_Error_test.php @@ -162,7 +162,10 @@ class PMA_Error_Test extends PHPUnit_Framework_TestCase { $this->object->setBacktrace(array('bt1','bt2','bt3','bt4')); // case: full backtrace - $this->assertEquals(array('bt1','bt2','bt3','bt4'), $this->object->getBacktrace()); + $this->assertEquals( + array('bt1','bt2','bt3','bt4'), + $this->object->getBacktrace() + ); // case: first 2 frames $this->assertEquals(array('bt1','bt2'), $this->object->getBacktrace(2)); diff --git a/test/classes/plugin/auth/PMA_AuthenticationCookie_test.php b/test/classes/plugin/auth/PMA_AuthenticationCookie_test.php index 4617798ea4..286e6a6642 100644 --- a/test/classes/plugin/auth/PMA_AuthenticationCookie_test.php +++ b/test/classes/plugin/auth/PMA_AuthenticationCookie_test.php @@ -137,7 +137,12 @@ class PMA_AuthenticationCookie_Test extends PHPUnit_Framework_TestCase $mockHeader = $this->getMockBuilder('PMA_Header') ->disableOriginalConstructor() ->setMethods( - array('setBodyId', 'setTitle', 'disableMenuAndConsole', 'disableWarnings') + array( + 'setBodyId', + 'setTitle', + 'disableMenuAndConsole', + 'disableWarnings' + ) ) ->getMock(); diff --git a/test/libraries/PMA_escapeJsString_test.php b/test/libraries/PMA_escapeJsString_test.php index 91cb02f2f3..96ad8e25ab 100644 --- a/test/libraries/PMA_escapeJsString_test.php +++ b/test/libraries/PMA_escapeJsString_test.php @@ -43,7 +43,10 @@ class PMA_EscapeJsString_Test extends PHPUnit_Framework_TestCase array('\\\';', '\';'), array('\r\n\\\'"), array('\\\';[XSS]', '\';[XSS]'), - array('[HTML]', '[HTML]'), + array( + '[HTML]', + '[HTML]' + ), array('\"\\\'\\\\\\\'\"', '"\'\\\'"'), array("\\\\\'\'\'\'\'\'\'\'\'\'\'\'\\\\", "\\''''''''''''\\") ); diff --git a/test/libraries/PMA_ip_allow_deny_test.php b/test/libraries/PMA_ip_allow_deny_test.php index 9d60cd4cb7..e204d6d8e4 100644 --- a/test/libraries/PMA_ip_allow_deny_test.php +++ b/test/libraries/PMA_ip_allow_deny_test.php @@ -32,13 +32,19 @@ class PMA_Ip_Allow_Deny_Test extends PHPUnit_Framework_TestCase public function setUp() { $GLOBALS['cfg']['Server']['user'] = "pma_username"; - $GLOBALS['cfg']['Server']['AllowDeny']['rules'][] = "allow % 255.255.255.0/4"; - $GLOBALS['cfg']['Server']['AllowDeny']['rules'][] = "allow % from 255.255.2.0/4"; - $GLOBALS['cfg']['Server']['AllowDeny']['rules'][] = "allow % from 2001:4998:c:a0d:0000:0000:4998:1020"; - $GLOBALS['cfg']['Server']['AllowDeny']['rules'][] = "allow % from 2001:4998:c:a0d:0000:0000:4998:[1001-2010]"; - $GLOBALS['cfg']['Server']['AllowDeny']['rules'][] = "allow % from 2001:4998:c:a0d:0000:0000:4998:3020/24"; + $GLOBALS['cfg']['Server']['AllowDeny']['rules'][] + = "allow % 255.255.255.0/4"; + $GLOBALS['cfg']['Server']['AllowDeny']['rules'][] + = "allow % from 255.255.2.0/4"; + $GLOBALS['cfg']['Server']['AllowDeny']['rules'][] + = "allow % from 2001:4998:c:a0d:0000:0000:4998:1020"; + $GLOBALS['cfg']['Server']['AllowDeny']['rules'][] + = "allow % from 2001:4998:c:a0d:0000:0000:4998:[1001-2010]"; + $GLOBALS['cfg']['Server']['AllowDeny']['rules'][] + = "allow % from 2001:4998:c:a0d:0000:0000:4998:3020/24"; $GLOBALS['cfg']['Server']['AllowDeny']['rules'][] = "deny % 255.255.0.0/8"; - $GLOBALS['cfg']['Server']['AllowDeny']['rules'][] = "deny % from 255.255.0.0/8"; + $GLOBALS['cfg']['Server']['AllowDeny']['rules'][] + = "deny % from 255.255.0.0/8"; include_once 'libraries/ip_allow_deny.lib.php'; } diff --git a/test/libraries/PMA_prettyPrint_test.php b/test/libraries/PMA_prettyPrint_test.php index 6c0ebc53d5..39168aa21e 100644 --- a/test/libraries/PMA_prettyPrint_test.php +++ b/test/libraries/PMA_prettyPrint_test.php @@ -40,7 +40,9 @@ class PMA_PrettyPrint_Test extends PHPUnit_Framework_TestCase { $this->assertEquals( "key[test0]: \"value0\"\nkey[test1]: \"value1\"\n", - PMA_prettyPrint(array('key' => array('test0' => 'value0', 'test1' => 'value1'))) + PMA_prettyPrint( + array('key' => array('test0' => 'value0', 'test1' => 'value1')) + ) ); } diff --git a/test/libraries/common/PMA_cache_test.php b/test/libraries/common/PMA_cache_test.php index ca7aa8f12c..6b0f808826 100644 --- a/test/libraries/common/PMA_cache_test.php +++ b/test/libraries/common/PMA_cache_test.php @@ -102,9 +102,15 @@ class PMA_Cache_Test extends PHPUnit_Framework_TestCase PMA_Util::cacheSet('test_data_2', 25); PMA_Util::cacheUnset('test_data'); - $this->assertArrayNotHasKey('test_data', $_SESSION['cache']['server_server']); + $this->assertArrayNotHasKey( + 'test_data', + $_SESSION['cache']['server_server'] + ); PMA_Util::cacheUnset('test_data_2'); - $this->assertArrayNotHasKey('test_data_2', $_SESSION['cache']['server_server']); + $this->assertArrayNotHasKey( + 'test_data_2', + $_SESSION['cache']['server_server'] + ); } /** @@ -116,10 +122,16 @@ class PMA_Cache_Test extends PHPUnit_Framework_TestCase { $GLOBALS['server'] = 'server'; PMA_Util::cacheSet('is_superuser', 'yes'); - $this->assertEquals('yes', $_SESSION['cache']['server_server']['is_superuser']); + $this->assertEquals( + 'yes', + $_SESSION['cache']['server_server']['is_superuser'] + ); PMA_Util::clearUserCache(); - $this->assertArrayNotHasKey('is_superuser', $_SESSION['cache']['server_server']); + $this->assertArrayNotHasKey( + 'is_superuser', + $_SESSION['cache']['server_server'] + ); } } ?> diff --git a/test/libraries/rte/PMA_RTN_getEditorForm_test.php b/test/libraries/rte/PMA_RTN_getEditorForm_test.php index 4fd9cdd615..8053596cac 100644 --- a/test/libraries/rte/PMA_RTN_getEditorForm_test.php +++ b/test/libraries/rte/PMA_RTN_getEditorForm_test.php @@ -500,7 +500,9 @@ class PMA_RTN_GetEditorForm_Test extends PHPUnit_Framework_TestCase { $GLOBALS['is_ajax_request'] = false; PMA_RTN_setGlobals(); - $this->assertTag($matcher, PMA_RTN_getEditorForm('edit', 'change', $data), false); + $this->assertTag( + $matcher, PMA_RTN_getEditorForm('edit', 'change', $data), false + ); } /** diff --git a/test/libraries/select_lang/PMA_langDetails_test.php b/test/libraries/select_lang/PMA_langDetails_test.php index 9cf1ab64dc..c6bb5c23ab 100644 --- a/test/libraries/select_lang/PMA_langDetails_test.php +++ b/test/libraries/select_lang/PMA_langDetails_test.php @@ -29,12 +29,32 @@ class PMA_LangDetails_Test extends PHPUnit_Framework_TestCase { return array( array('af|afrikaans', 'af', '', 'af'), - array('ar|arabic', 'ar', 'العربية', 'ar'), + array( + 'ar|arabic', + 'ar', + 'العربية', + 'ar' + ), array('az|azerbaijani', 'az', 'Azərbaycanca', 'az'), array('bn|bangla', 'bn', 'বাংলা', 'bn'), - array('be|belarusian', 'be', 'Беларуская', 'be'), - array('be[-_]lat|belarusian latin', 'be-lat', 'Biełaruskaja', 'be@latin'), - array('bg|bulgarian', 'bg', 'Български', 'bg'), + array( + 'be|belarusian', + 'be', + 'Беларуская', + 'be' + ), + array( + 'be[-_]lat|belarusian latin', + 'be-lat', + 'Biełaruskaja', + 'be@latin' + ), + array( + 'bg|bulgarian', + 'bg', + 'Български', + 'bg' + ), array('bs|bosnian', 'bs', 'Bosanski', 'bs'), array('br|breton', 'br', 'Brezhoneg', 'br'), array('ca|catalan', 'ca', 'Català', 'ca'), @@ -42,7 +62,12 @@ class PMA_LangDetails_Test extends PHPUnit_Framework_TestCase array('cy|welsh', 'cy', 'Cymraeg', 'cy'), array('da|danish', 'da', 'Dansk', 'da'), array('de|german', 'de', 'Deutsch', 'de'), - array('el|greek', 'el', 'Ελληνικά', 'el'), + array( + 'el|greek', + 'el', + 'Ελληνικά', + 'el' + ), array('en|english', 'en', '', 'en'), array('en[_-]gb|english (United Kingdom)', 'en-gb', '', 'en_GB'), array('es|spanish', 'es', 'Español', 'es'), @@ -53,44 +78,94 @@ class PMA_LangDetails_Test extends PHPUnit_Framework_TestCase array('fr|french', 'fr', 'Français', 'fr'), array('gl|galician', 'gl', 'Galego', 'gl'), array('he|hebrew', 'he', 'עברית', 'he'), - array('hi|hindi', 'hi', 'हिन्दी', 'hi'), + array( + 'hi|hindi', + 'hi', + 'हिन्दी', + 'hi' + ), array('hr|croatian', 'hr', 'Hrvatski', 'hr'), array('hu|hungarian', 'hu', 'Magyar', 'hu'), array('id|indonesian', 'id', 'Bahasa Indonesia', 'id'), array('it|italian', 'it', 'Italiano', 'it'), array('ja|japanese', 'ja', '日本語', 'ja'), array('ko|korean', 'ko', '한국어', 'ko'), - array('ka|georgian', 'ka', 'ქართული', 'ka'), + array( + 'ka|georgian', + 'ka', + 'ქართული', + 'ka' + ), array('lt|lithuanian', 'lt', 'Lietuvių', 'lt'), array('lv|latvian', 'lv', 'Latviešu', 'lv'), array('mk|macedonian', 'mk', 'Macedonian', 'mk'), - array('mn|mongolian', 'mn', 'Монгол', 'mn'), + array( + 'mn|mongolian', + 'mn', + 'Монгол', + 'mn' + ), array('ms|malay', 'ms', 'Bahasa Melayu', 'ms'), array('nl|dutch', 'nl', 'Nederlands', 'nl'), array('nb|norwegian', 'nb', 'Norsk', 'nb'), array('pl|polish', 'pl', 'Polski', 'pl'), - array('pt[-_]br|brazilian portuguese', 'pt-BR', 'Português', 'pt_BR'), + array( + 'pt[-_]br|brazilian portuguese', + 'pt-BR', + 'Português', + 'pt_BR' + ), array('pt|portuguese', 'pt', 'Português', 'pt'), array('ro|romanian', 'ro', 'Română', 'ro'), - array('ru|russian', 'ru', 'Русский', 'ru'), + array( + 'ru|russian', + 'ru', + 'Русский', + 'ru' + ), array('si|sinhala', 'si', 'සිංහල', 'si'), array('sk|slovak', 'sk', 'Slovenčina', 'sk'), array('sl|slovenian', 'sl', 'Slovenščina', 'sl'), array('sq|albanian', 'sq', 'Shqip', 'sq'), array('sr[-_]lat|serbian latin', 'sr-lat', 'Srpski', 'sr@latin'), - array('sr|serbian', 'sr', 'Српски', 'sr'), + array( + 'sr|serbian', + 'sr', + 'Српски', + 'sr' + ), array('sv|swedish', 'sv', 'Svenska', 'sv'), array('ta|tamil', 'ta', 'தமிழ்', 'ta'), array('te|telugu', 'te', 'తెలుగు', 'te'), - array('th|thai', 'th', 'ภาษาไทย', 'th'), + array( + 'th|thai', + 'th', + 'ภาษาไทย', + 'th' + ), array('tr|turkish', 'tr', 'Türkçe', 'tr'), array('tt|tatarish', 'tt', 'Tatarça', 'tt'), array('ug|uyghur', 'ug', 'ئۇيغۇرچە', 'ug'), - array('uk|ukrainian', 'uk', 'Українська', 'uk'), + array( + 'uk|ukrainian', + 'uk', + 'Українська', + 'uk' + ), array('ur|urdu', 'ur', 'اُردوُ', 'ur'), array('uz[-_]lat|uzbek-latin', 'uz-lat', 'O‘zbekcha', 'uz@latin'), - array('uz[-_]cyr|uzbek-cyrillic', 'uz-cyr', 'Ўзбекча', 'uz'), - array('zh[-_](tw|hk)|chinese traditional', 'zh-TW', '中文', 'zh_TW'), + array( + 'uz[-_]cyr|uzbek-cyrillic', + 'uz-cyr', + 'Ўзбекча', + 'uz' + ), + array( + 'zh[-_](tw|hk)|chinese traditional', + 'zh-TW', + '中文', + 'zh_TW' + ), array( 'zh(?![-_](tw|hk))([-_][[:alpha:]]{2,3})?|chinese simplified', 'zh', From e2bf49c96d9e423bf7c59df2cae04c6a308345c5 Mon Sep 17 00:00:00 2001 From: Hugues Peccatte Date: Sun, 10 Aug 2014 00:19:50 +0200 Subject: [PATCH 3/7] Coding style modifications. Signed-off-by: Hugues Peccatte --- libraries/bookmark.lib.php | 7 ++++--- libraries/server_status_monitor.lib.php | 25 +++++++++++++++++++++---- 2 files changed, 25 insertions(+), 7 deletions(-) diff --git a/libraries/bookmark.lib.php b/libraries/bookmark.lib.php index 1972d52688..62283e76fb 100644 --- a/libraries/bookmark.lib.php +++ b/libraries/bookmark.lib.php @@ -218,9 +218,10 @@ function PMA_Bookmark_save($bkm_fields, $all_users = false) $cfgBookmark = PMA_Bookmark_getParams(); - if (! (isset($bkm_fields['bkm_sql_query']) && isset($bkm_fields['bkm_label']) - && strlen($bkm_fields['bkm_sql_query']) > 0 && strlen($bkm_fields['bkm_label']) > 0) ) - { + if (!(isset($bkm_fields['bkm_sql_query']) && isset($bkm_fields['bkm_label']) + && strlen($bkm_fields['bkm_sql_query']) > 0 + && strlen($bkm_fields['bkm_label']) > 0) + ) { return false; } diff --git a/libraries/server_status_monitor.lib.php b/libraries/server_status_monitor.lib.php index 541fde4554..e2dd65f51d 100644 --- a/libraries/server_status_monitor.lib.php +++ b/libraries/server_status_monitor.lib.php @@ -657,6 +657,7 @@ function PMA_getJsonForLogDataTypeGeneral($start, $end) $return['sum'][$type] += $row['#']; switch($type) { + /** @noinspection PhpMissingBreakStatementInspection */ case 'insert': // Group inserts if selected if ($removeVars @@ -673,10 +674,10 @@ function PMA_getJsonForLogDataTypeGeneral($start, $end) // Add a ... to the end of this query to indicate that // there's been other queries $temp = $return['rows'][$insertTablesFirst]['argument']; - if ($temp[strlen($temp) - 1] != '.') { - $return['rows'][$insertTablesFirst]['argument'] - .= '
...'; - } + $return['rows'][$insertTablesFirst]['argument'] + .= PMA_getJsonForLogDataTypeGeneral_getSuspensionPoints( + $temp[strlen($temp) - 1] + ); // Group this value, thus do not add to the result list continue 2; @@ -720,6 +721,22 @@ function PMA_getJsonForLogDataTypeGeneral($start, $end) return $return; } + +/** + * Return suspension points if needed + * + * @param string $lastChar Last char + * + * @return null|string Return suspension points if needed + */ +function PMA_getJsonForLogDataTypeGeneral_getSuspensionPoints($lastChar) +{ + if ($lastChar != '.') { + return '
...'; + } + + return null; +} /** * Returns JSon for logging vars * From 68b98335ff457ebea1f895f1c36dade1f401b189 Mon Sep 17 00:00:00 2001 From: Hugues Peccatte Date: Sun, 10 Aug 2014 00:27:37 +0200 Subject: [PATCH 4/7] Coding style modifications. Signed-off-by: Hugues Peccatte --- libraries/server_status_monitor.lib.php | 1 - libraries/sqlparser.lib.php | 154 ++++++++++++++---------- 2 files changed, 90 insertions(+), 65 deletions(-) diff --git a/libraries/server_status_monitor.lib.php b/libraries/server_status_monitor.lib.php index e2dd65f51d..86d80d218e 100644 --- a/libraries/server_status_monitor.lib.php +++ b/libraries/server_status_monitor.lib.php @@ -791,7 +791,6 @@ function PMA_getJsonForQueryAnalyzer() $_REQUEST['query'] ); - $result = $GLOBALS['dbi']->tryQuery($query); $return['affectedRows'] = $GLOBALS['cached_affected_rows']; $result = $GLOBALS['dbi']->tryQuery('EXPLAIN ' . $query); diff --git a/libraries/sqlparser.lib.php b/libraries/sqlparser.lib.php index db7b082f08..b4dc56530e 100644 --- a/libraries/sqlparser.lib.php +++ b/libraries/sqlparser.lib.php @@ -2661,70 +2661,11 @@ function PMA_SQP_format( $before .= ' '; } - switch ($arr[$i]['data']) { - case 'CREATE': - case 'ALTER': - case 'DROP': - case 'RENAME'; - case 'TRUNCATE': - case 'ANALYZE': - case 'ANALYSE': - case 'OPTIMIZE': - if (!$in_priv_list) { - $space_punct_listsep = $html_line_break; - $space_alpha_reserved_word = ' '; - } - break; - case 'EVENT': - case 'TABLESPACE': - case 'TABLE': - case 'FUNCTION': - case 'INDEX': - case 'PROCEDURE': - case 'SERVER': - case 'TRIGGER': - case 'DATABASE': - case 'VIEW': - case 'GROUP': - break; - case 'SET': - if (!$in_priv_list) { - $space_punct_listsep = $html_line_break; - $space_alpha_reserved_word = ' '; - } - break; - case 'EXPLAIN': - case 'DESCRIBE': - case 'DELETE': - case 'SHOW': - case 'UPDATE': - if (!$in_priv_list) { - $space_punct_listsep = $html_line_break; - $space_alpha_reserved_word = ' '; - } - break; - case 'INSERT': - case 'REPLACE': - if (!$in_priv_list) { - $space_punct_listsep = $html_line_break; - $space_alpha_reserved_word = $html_line_break; - } - break; - case 'VALUES': - $space_punct_listsep = ' '; - $space_alpha_reserved_word = $html_line_break; - break; - case 'SELECT': - $space_punct_listsep = ' '; - $space_alpha_reserved_word = $html_line_break; - break; - case 'CALL': - case 'DO': - case 'HANDLER': - break; - default: - break; - } // end switch ($arr[$i]['data']) + list($space_punct_listsep, $space_alpha_reserved_word) + = PMA_SQP_format_getListsepAndReservedWord( + $arr[$i]['data'], $in_priv_list, $html_line_break, + $space_punct_listsep, $space_alpha_reserved_word + ); $after .= ' '; break; @@ -2807,6 +2748,91 @@ function PMA_SQP_format( return $str; } // end of the "PMA_SQP_format()" function +/** + * Define variables for PMA_SQP_format + * + * @param string $data Data to check + * @param boolean $in_priv_list In privilege list + * @param string $html_line_break HTML line break + * @param string $space_punct_listsep List separator + * @param string $space_alpha_reserved_word Space between reserved words + * + * @todo check definition of $space_punct_listsep and $space_alpha_reserved_word + * + * @return array Variables needed by PMA_SQP_format + */ +function PMA_SQP_format_getListsepAndReservedWord( + $data, $in_priv_list, $html_line_break, $space_punct_listsep, + $space_alpha_reserved_word +) +{ + switch ($data) { + case 'CREATE': + case 'ALTER': + case 'DROP': + case 'RENAME'; + case 'TRUNCATE': + case 'ANALYZE': + case 'ANALYSE': + case 'OPTIMIZE': + if (!$in_priv_list) { + $space_punct_listsep = $html_line_break; + $space_alpha_reserved_word = ' '; + } + break; + case 'EVENT': + case 'TABLESPACE': + case 'TABLE': + case 'FUNCTION': + case 'INDEX': + case 'PROCEDURE': + case 'SERVER': + case 'TRIGGER': + case 'DATABASE': + case 'VIEW': + case 'GROUP': + break; + case 'SET': + if (!$in_priv_list) { + $space_punct_listsep = $html_line_break; + $space_alpha_reserved_word = ' '; + } + break; + case 'EXPLAIN': + case 'DESCRIBE': + case 'DELETE': + case 'SHOW': + case 'UPDATE': + if (!$in_priv_list) { + $space_punct_listsep = $html_line_break; + $space_alpha_reserved_word = ' '; + } + break; + case 'INSERT': + case 'REPLACE': + if (!$in_priv_list) { + $space_punct_listsep = $html_line_break; + $space_alpha_reserved_word = $html_line_break; + } + break; + case 'VALUES': + $space_punct_listsep = ' '; + $space_alpha_reserved_word = $html_line_break; + break; + case 'SELECT': + $space_punct_listsep = ' '; + $space_alpha_reserved_word = $html_line_break; + break; + case 'CALL': + case 'DO': + case 'HANDLER': + break; + default: + break; + } + return array($space_punct_listsep, $space_alpha_reserved_word); +} + /** * Gets SQL queries with no format * From 50849a8757d3302c6d6c2aa5d0a669c4dcb7f732 Mon Sep 17 00:00:00 2001 From: Hugues Peccatte Date: Sun, 10 Aug 2014 00:41:44 +0200 Subject: [PATCH 5/7] Fix typos. Signed-off-by: Hugues Peccatte --- libraries/dbi/DBIDrizzle.class.php | 2 +- libraries/dbi/DBIMysql.class.php | 4 ++-- libraries/dbi/DBIMysqli.class.php | 4 ++-- libraries/dbi/drizzle-wrappers.lib.php | 4 ++-- libraries/gis/GIS_Geometry.class.php | 10 +++++----- libraries/gis/GIS_Geometrycollection.class.php | 6 +++--- libraries/gis/GIS_Linestring.class.php | 2 +- libraries/gis/GIS_Multilinestring.class.php | 4 ++-- libraries/sqlparser.lib.php | 10 +++++----- sql.php | 2 +- 10 files changed, 24 insertions(+), 24 deletions(-) diff --git a/libraries/dbi/DBIDrizzle.class.php b/libraries/dbi/DBIDrizzle.class.php index 58fb582619..9af757b1a0 100644 --- a/libraries/dbi/DBIDrizzle.class.php +++ b/libraries/dbi/DBIDrizzle.class.php @@ -439,7 +439,7 @@ class PMA_DBI_Drizzle implements PMA_DBI_Extension // array of DrizzleColumn $columns = $result->getColumns(); - // columns in a standarized format + // columns in a standardized format $std_columns = array(); foreach ($columns as $k => $column) { diff --git a/libraries/dbi/DBIMysql.class.php b/libraries/dbi/DBIMysql.class.php index 256085e36f..36e81e6404 100644 --- a/libraries/dbi/DBIMysql.class.php +++ b/libraries/dbi/DBIMysql.class.php @@ -32,7 +32,7 @@ class PMA_DBI_Mysql implements PMA_DBI_Extension * @param string $user mysql user name * @param string $password mysql user password * @param int $client_flags client flags of connection - * @param bool $persistent whether to use peristent connection + * @param bool $persistent whether to use persistent connection * * @return mixed false on error or a mysql connection resource on success */ @@ -66,7 +66,7 @@ class PMA_DBI_Mysql implements PMA_DBI_Extension * @param mysqli $link mysqli object * @param string $query multi query statement to execute * - * @return boolean false always false since mysql extention not support + * @return boolean false always false since mysql extension not support * for multi query executions */ public function realMultiQuery($link, $query) diff --git a/libraries/dbi/DBIMysqli.class.php b/libraries/dbi/DBIMysqli.class.php index ae6ef2ad43..4777ff0301 100644 --- a/libraries/dbi/DBIMysqli.class.php +++ b/libraries/dbi/DBIMysqli.class.php @@ -84,7 +84,7 @@ class PMA_DBI_Mysqli implements PMA_DBI_Extension * @param int $server_port server port * @param string $server_socket server socket * @param int $client_flags client flags of connection - * @param bool $persistent whether to use peristent connection + * @param bool $persistent whether to use persistent connection * * @return bool */ @@ -520,7 +520,7 @@ class PMA_DBI_Mysqli implements PMA_DBI_Extension $fields[$k]->_flags = $field->flags; $fields[$k]->flags = $this->fieldFlags($result, $k); - // Enhance the field objects for mysql-extension compatibilty + // Enhance the field objects for mysql-extension compatibility //$flags = explode(' ', $fields[$k]->flags); //array_unshift($flags, 'dummy'); $fields[$k]->multiple_key diff --git a/libraries/dbi/drizzle-wrappers.lib.php b/libraries/dbi/drizzle-wrappers.lib.php index aef9404eb2..444698cef5 100644 --- a/libraries/dbi/drizzle-wrappers.lib.php +++ b/libraries/dbi/drizzle-wrappers.lib.php @@ -60,7 +60,7 @@ class PMA_Drizzle extends Drizzle const BUFFER_ROW = 2; /** - * Creates a new database conection using TCP + * Creates a new database connection using TCP * * @param string $host Drizzle host * @param integer $port Drizzle port @@ -202,7 +202,7 @@ class PMA_DrizzleCon class PMA_DrizzleResult { /** - * Instamce of DrizzleResult class + * Instance of DrizzleResult class * @var DrizzleResult */ private $_dresult; diff --git a/libraries/gis/GIS_Geometry.class.php b/libraries/gis/GIS_Geometry.class.php index e6cb2ff820..f27640e37b 100644 --- a/libraries/gis/GIS_Geometry.class.php +++ b/libraries/gis/GIS_Geometry.class.php @@ -135,11 +135,11 @@ abstract class PMA_GIS_Geometry */ protected function setMinMax($point_set, $min_max) { - // Seperate each point + // Separate each point $points = explode(",", $point_set); foreach ($points as $point) { - // Extract cordinates of the point + // Extract coordinates of the point $cordinates = explode(" ", $point); $x = (float) $cordinates[0]; @@ -189,7 +189,7 @@ abstract class PMA_GIS_Geometry /** * Extracts points, scales and returns them as an array. * - * @param string $point_set string of comma sperated points + * @param string $point_set string of comma separated points * @param array $scale_data data related to scaling * @param boolean $linear if true, as a 1D array, else as a 2D array * @@ -200,11 +200,11 @@ abstract class PMA_GIS_Geometry { $points_arr = array(); - // Seperate each point + // Separate each point $points = explode(",", $point_set); foreach ($points as $point) { - // Extract cordinates of the point + // Extract coordinates of the point $cordinates = explode(" ", $point); if (isset($cordinates[0]) && trim($cordinates[0]) != '' diff --git a/libraries/gis/GIS_Geometrycollection.class.php b/libraries/gis/GIS_Geometrycollection.class.php index 09b04ed404..80cc225102 100644 --- a/libraries/gis/GIS_Geometrycollection.class.php +++ b/libraries/gis/GIS_Geometrycollection.class.php @@ -50,7 +50,7 @@ class PMA_GIS_Geometrycollection extends PMA_GIS_Geometry * * @param string $spatial spatial data of a row * - * @return array array containing the min, max values for x and y cordinates + * @return array array containing the min, max values for x and y coordinates * @access public */ public function scaleRow($spatial) @@ -73,7 +73,7 @@ class PMA_GIS_Geometrycollection extends PMA_GIS_Geometry } $scale_data = $gis_obj->scaleRow($sub_part); - // Upadate minimum/maximum values for x and y cordinates. + // Update minimum/maximum values for x and y coordinates. $c_maxX = (float) $scale_data['maxX']; if (! isset($min_max['maxX']) || $c_maxX > $min_max['maxX']) { $min_max['maxX'] = $c_maxX; @@ -141,7 +141,7 @@ class PMA_GIS_Geometrycollection extends PMA_GIS_Geometry * @param TCPDF $pdf TCPDF instance * * @return TCPDF the modified TCPDF instance - * @access pubilc + * @access public */ public function prepareRowAsPdf($spatial, $label, $color, $scale_data, $pdf) { diff --git a/libraries/gis/GIS_Linestring.class.php b/libraries/gis/GIS_Linestring.class.php index 2874de0636..3baac59067 100644 --- a/libraries/gis/GIS_Linestring.class.php +++ b/libraries/gis/GIS_Linestring.class.php @@ -50,7 +50,7 @@ class PMA_GIS_Linestring extends PMA_GIS_Geometry * * @param string $spatial spatial data of a row * - * @return array an array containing the min, max values for x and y cordinates + * @return array an array containing the min, max values for x and y coordinates * @access public */ public function scaleRow($spatial) diff --git a/libraries/gis/GIS_Multilinestring.class.php b/libraries/gis/GIS_Multilinestring.class.php index 1a74e2aa96..6b4785d7b5 100644 --- a/libraries/gis/GIS_Multilinestring.class.php +++ b/libraries/gis/GIS_Multilinestring.class.php @@ -50,7 +50,7 @@ class PMA_GIS_Multilinestring extends PMA_GIS_Geometry * * @param string $spatial spatial data of a row * - * @return array an array containing the min, max values for x and y cordinates + * @return array an array containing the min, max values for x and y coordinates * @access public */ public function scaleRow($spatial) @@ -59,7 +59,7 @@ class PMA_GIS_Multilinestring extends PMA_GIS_Geometry // Trim to remove leading 'MULTILINESTRING((' and trailing '))' $multilinestirng = substr($spatial, 17, (strlen($spatial) - 19)); - // Seperate each linestring + // Separate each linestring $linestirngs = explode("),(", $multilinestirng); foreach ($linestirngs as $linestring) { diff --git a/libraries/sqlparser.lib.php b/libraries/sqlparser.lib.php index b4dc56530e..f45d145c22 100644 --- a/libraries/sqlparser.lib.php +++ b/libraries/sqlparser.lib.php @@ -52,7 +52,7 @@ if (! isset($mysql_charsets)) { } /** - * Stores parsed elemented of query to array. + * Stores parsed elements of query to array. * * @param array &$arr Array to store element * @param string $type Type of element @@ -664,8 +664,8 @@ function PMA_SQP_parse($sql) $punct_data = $GLOBALS['PMA_String']->substr($sql, $count1, $l); } - // Special case, sometimes, althought two characters are - // adjectent directly, they ACTUALLY need to be seperate + // Special case, sometimes, although two characters are + // adjacent directly, they ACTUALLY need to be separate /* DEBUG echo '
';
             var_dump($l);
@@ -1012,7 +1012,7 @@ function PMA_SQP_analyze($arr)
      *
      * ['select_expr'] is filled with each expression, the key represents the
      * expression position in the list (0-based) (so we don't lose track of
-     * multiple occurences of the same column).
+     * multiple occurrences of the same column).
      *
      * ['table_ref'] is filled with each table ref, same thing for the key.
      *
@@ -1061,7 +1061,7 @@ function PMA_SQP_analyze($arr)
      * query clauses
      * -------------
      *
-     * The select is splitted in those clauses:
+     * The select is split in those clauses:
      * ['select_expr_clause']
      * ['from_clause']
      * ['group_by_clause']
diff --git a/sql.php b/sql.php
index ac3d90e811..25141ef975 100644
--- a/sql.php
+++ b/sql.php
@@ -40,7 +40,7 @@ if (isset($ajax_reload) && $ajax_reload['reload'] === true) {
 /**
  * Defines the url to return to in case of error in a sql statement
  */
-// Security checkings
+// Security checks
 if (! empty($goto)) {
     $is_gotofile     = preg_replace('@^([^?]+).*$@s', '\\1', $goto);
     if (! @file_exists('' . $is_gotofile)) {

From 3a69a24531adefe686b6aaa24f477a05874721aa Mon Sep 17 00:00:00 2001
From: Hugues Peccatte 
Date: Sun, 10 Aug 2014 00:45:08 +0200
Subject: [PATCH 6/7] Fix removed line.

Signed-off-by: Hugues Peccatte 
---
 libraries/server_status_monitor.lib.php | 1 +
 1 file changed, 1 insertion(+)

diff --git a/libraries/server_status_monitor.lib.php b/libraries/server_status_monitor.lib.php
index 86d80d218e..e2dd65f51d 100644
--- a/libraries/server_status_monitor.lib.php
+++ b/libraries/server_status_monitor.lib.php
@@ -791,6 +791,7 @@ function PMA_getJsonForQueryAnalyzer()
         $_REQUEST['query']
     );
 
+    $result = $GLOBALS['dbi']->tryQuery($query);
     $return['affectedRows'] = $GLOBALS['cached_affected_rows'];
 
     $result = $GLOBALS['dbi']->tryQuery('EXPLAIN ' . $query);

From a5473c2fe9e1329961fc7d44d61ad65465f8b47d Mon Sep 17 00:00:00 2001
From: Hugues Peccatte 
Date: Sun, 10 Aug 2014 00:56:41 +0200
Subject: [PATCH 7/7] Coding style modifications.

Signed-off-by: Hugues Peccatte 
---
 libraries/Console.class.php                   | 23 +++++++++++--------
 libraries/designer.lib.php                    |  2 +-
 libraries/pmd_common.php                      |  6 ++---
 .../schema/Pdf_Relation_Schema.class.php      |  6 ++---
 4 files changed, 21 insertions(+), 16 deletions(-)

diff --git a/libraries/Console.class.php b/libraries/Console.class.php
index df3a125c01..4e9afc2d5b 100644
--- a/libraries/Console.class.php
+++ b/libraries/Console.class.php
@@ -260,16 +260,21 @@ class PMA_Console
                     $output .= '
'; $output .= '
'; $output .= '
' - . '
' . __('Add bookmark') - . '
'; + . '
' + . __('Add bookmark') + . '
'; $output .= '
' - . '
' - . ' ' - . ' ' - . '' - . '' - . '
' // .options - . '
'; + . '
' + . ' ' + . ' ' + . '' + . '' + . '
' // .options + . '
' + . '
'; $output .= '
'; $output .= '
'; // Add bookmark card $output .= ''; // Bookmarks card diff --git a/libraries/designer.lib.php b/libraries/designer.lib.php index 880285a62e..c0e202ac03 100644 --- a/libraries/designer.lib.php +++ b/libraries/designer.lib.php @@ -35,7 +35,7 @@ function PMA_getHtmlForEditOrDeletePages($db, $operation) } $html .= ': '; $html .= '