From 003ec4daf3d249e50e730aff2c58407fecad094e Mon Sep 17 00:00:00 2001 From: William Desportes Date: Sun, 10 Nov 2019 22:59:44 +0100 Subject: [PATCH 1/8] Fix #14809 - php error is_uploaded_file() expects parameter 1 to be string Fixes: #14809 Signed-off-by: William Desportes --- libraries/classes/File.php | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/libraries/classes/File.php b/libraries/classes/File.php index 5f509d73e4..5b80d285b3 100644 --- a/libraries/classes/File.php +++ b/libraries/classes/File.php @@ -225,7 +225,11 @@ class File */ public function isUploaded() { - return is_uploaded_file($this->getName()); + if (! is_string($this->getName())) { + return false; + } else { + return is_uploaded_file($this->getName()); + } } /** From f9bd58b0afb5e638664a791e634e7c8f2d7df22f Mon Sep 17 00:00:00 2001 From: William Desportes Date: Sun, 10 Nov 2019 23:00:55 +0100 Subject: [PATCH 2/8] Add ChangeLog entry for #14809 Signed-off-by: William Desportes --- ChangeLog | 1 + 1 file changed, 1 insertion(+) diff --git a/ChangeLog b/ChangeLog index e1f3b3817a..7562e2c90b 100644 --- a/ChangeLog +++ b/ChangeLog @@ -26,6 +26,7 @@ phpMyAdmin - ChangeLog - issue #14951 Fix moving columns with INT AND DEFAULT CURRENT_TIMESTAMP doesn't work on MariaDB - issue #12241 Fixed table alias is removed when exporting a query - issue #15316 Fixed cross join clause is removed on export +- issue #14809 Fix error "is_uploaded_file() expects parameter 1 to be string" when inserting blobs from files 4.9.1 (2019-09-20) - issue #15313 Added support for Twig 2 From e070256fe49260dddd0e0b30be4db6d954806136 Mon Sep 17 00:00:00 2001 From: William Desportes Date: Mon, 11 Nov 2019 11:44:24 +0100 Subject: [PATCH 3/8] Fix #13912 and #15123 - Tables of phpMyAdmin storage are not accessible Fixes: #13912 Fixes: #15123 Signed-off-by: William Desportes --- libraries/classes/Database/Designer.php | 8 +- .../classes/Database/Designer/Common.php | 10 +- .../classes/Navigation/Nodes/NodeDatabase.php | 2 +- libraries/classes/RecentFavoriteTable.php | 8 +- libraries/classes/Relation.php | 93 +++++++++++++++---- server_privileges.php | 2 +- server_user_groups.php | 4 +- 7 files changed, 94 insertions(+), 33 deletions(-) diff --git a/libraries/classes/Database/Designer.php b/libraries/classes/Database/Designer.php index 95e0701937..fe656d09e5 100644 --- a/libraries/classes/Database/Designer.php +++ b/libraries/classes/Database/Designer.php @@ -80,7 +80,12 @@ class Designer */ private function getPageIdsAndNames($db) { + $result = []; $cfgRelation = $this->relation->getRelationsParam(); + if (! $cfgRelation['pdfwork']) { + return $result; + } + $page_query = "SELECT `page_nr`, `page_descr` FROM " . Util::backquote($cfgRelation['db']) . "." . Util::backquote($cfgRelation['pdf_pages']) @@ -92,7 +97,6 @@ class Designer DatabaseInterface::QUERY_STORE ); - $result = []; while ($curr_page = $GLOBALS['dbi']->fetchAssoc($page_rs)) { $result[intval($curr_page['page_nr'])] = $curr_page['page_descr']; } @@ -195,7 +199,7 @@ class Designer $cfgRelation = $this->relation->getRelationsParam(); - if ($GLOBALS['cfgRelation']['designersettingswork']) { + if ($cfgRelation['designersettingswork']) { $query = 'SELECT `settings_data` FROM ' . Util::backquote($cfgRelation['db']) . '.' . Util::backquote($cfgRelation['designer_settings']) diff --git a/libraries/classes/Database/Designer/Common.php b/libraries/classes/Database/Designer/Common.php index 29157c7974..47b558bc64 100644 --- a/libraries/classes/Database/Designer/Common.php +++ b/libraries/classes/Database/Designer/Common.php @@ -456,9 +456,9 @@ class Common } $query = "DELETE FROM " - . Util::backquote($GLOBALS['cfgRelation']['db']) + . Util::backquote($cfgRelation['db']) . "." . Util::backquote( - $GLOBALS['cfgRelation']['table_coords'] + $cfgRelation['table_coords'] ) . " WHERE `pdf_page_number` = '" . $pageId . "'"; @@ -480,8 +480,8 @@ class Common } $query = "INSERT INTO " - . Util::backquote($GLOBALS['cfgRelation']['db']) . "." - . Util::backquote($GLOBALS['cfgRelation']['table_coords']) + . Util::backquote($cfgRelation['db']) . "." + . Util::backquote($cfgRelation['table_coords']) . " (`db_name`, `table_name`, `pdf_page_number`, `x`, `y`)" . " VALUES (" . "'" . $GLOBALS['dbi']->escapeString($DB) . "', " @@ -733,7 +733,7 @@ class Common { $cfgRelation = $this->relation->getRelationsParam(); $success = true; - if ($GLOBALS['cfgRelation']['designersettingswork']) { + if ($cfgRelation['designersettingswork']) { $cfgDesigner = array( 'user' => $GLOBALS['cfg']['Server']['user'], diff --git a/libraries/classes/Navigation/Nodes/NodeDatabase.php b/libraries/classes/Navigation/Nodes/NodeDatabase.php index 246000c49c..d9828a02f6 100644 --- a/libraries/classes/Navigation/Nodes/NodeDatabase.php +++ b/libraries/classes/Navigation/Nodes/NodeDatabase.php @@ -412,7 +412,7 @@ class NodeDatabase extends Node { $db = $this->real_name; $cfgRelation = $this->relation->getRelationsParam(); - if (empty($cfgRelation['navigationhiding'])) { + if (! $cfgRelation['navwork']) { return array(); } $navTable = Util::backquote($cfgRelation['db']) diff --git a/libraries/classes/RecentFavoriteTable.php b/libraries/classes/RecentFavoriteTable.php index 8f65dbe4e4..458d468a8b 100644 --- a/libraries/classes/RecentFavoriteTable.php +++ b/libraries/classes/RecentFavoriteTable.php @@ -383,13 +383,17 @@ class RecentFavoriteTable } /** - * Reutrn the name of the configuration storage table + * Return the name of the configuration storage table * - * @return string pma table name + * @return string|null pma table name */ private function _getPmaTable() { $cfgRelation = $this->relation->getRelationsParam(); + if (! $cfgRelation['recentwork']) { + return null; + } + if (! empty($cfgRelation['db']) && ! empty($cfgRelation[$this->_tableType]) ) { diff --git a/libraries/classes/Relation.php b/libraries/classes/Relation.php index 6209457e61..ff622b19a9 100644 --- a/libraries/classes/Relation.php +++ b/libraries/classes/Relation.php @@ -574,74 +574,112 @@ class Relation $GLOBALS['dbi']->freeResult($tab_rs); if (isset($cfgRelation['relation'])) { - $cfgRelation['relwork'] = true; + if ($this->canAccessStorageTable($cfgRelation['relation'])) { + $cfgRelation['relwork'] = true; + } } if (isset($cfgRelation['relation']) && isset($cfgRelation['table_info'])) { - $cfgRelation['displaywork'] = true; + if ($this->canAccessStorageTable($cfgRelation['table_info'])) { + $cfgRelation['displaywork'] = true; + } } if (isset($cfgRelation['table_coords']) && isset($cfgRelation['pdf_pages'])) { - $cfgRelation['pdfwork'] = true; + if ($this->canAccessStorageTable($cfgRelation['table_coords'])) { + if ($this->canAccessStorageTable($cfgRelation['pdf_pages'])) { + $cfgRelation['pdfwork'] = true; + } + } } if (isset($cfgRelation['column_info'])) { - $cfgRelation['commwork'] = true; - // phpMyAdmin 4.3+ - // Check for input transformations upgrade. - $cfgRelation['mimework'] = $this->tryUpgradeTransformations(); + if ($this->canAccessStorageTable($cfgRelation['column_info'])) { + $cfgRelation['commwork'] = true; + // phpMyAdmin 4.3+ + // Check for input transformations upgrade. + $cfgRelation['mimework'] = $this->tryUpgradeTransformations(); + } } if (isset($cfgRelation['history'])) { - $cfgRelation['historywork'] = true; + if ($this->canAccessStorageTable($cfgRelation['history'])) { + $cfgRelation['historywork'] = true; + } } if (isset($cfgRelation['recent'])) { - $cfgRelation['recentwork'] = true; + if ($this->canAccessStorageTable($cfgRelation['recent'])) { + $cfgRelation['recentwork'] = true; + } } if (isset($cfgRelation['favorite'])) { - $cfgRelation['favoritework'] = true; + if ($this->canAccessStorageTable($cfgRelation['favorite'])) { + $cfgRelation['favoritework'] = true; + } } if (isset($cfgRelation['table_uiprefs'])) { - $cfgRelation['uiprefswork'] = true; + if ($this->canAccessStorageTable($cfgRelation['table_uiprefs'])) { + $cfgRelation['uiprefswork'] = true; + } } if (isset($cfgRelation['tracking'])) { - $cfgRelation['trackingwork'] = true; + if ($this->canAccessStorageTable($cfgRelation['tracking'])) { + $cfgRelation['trackingwork'] = true; + } } if (isset($cfgRelation['userconfig'])) { - $cfgRelation['userconfigwork'] = true; + if ($this->canAccessStorageTable($cfgRelation['userconfig'])) { + $cfgRelation['userconfigwork'] = true; + } } if (isset($cfgRelation['bookmark'])) { - $cfgRelation['bookmarkwork'] = true; + if ($this->canAccessStorageTable($cfgRelation['bookmark'])) { + $cfgRelation['bookmarkwork'] = true; + } } if (isset($cfgRelation['users']) && isset($cfgRelation['usergroups'])) { - $cfgRelation['menuswork'] = true; + if ($this->canAccessStorageTable($cfgRelation['users'])) { + if ($this->canAccessStorageTable($cfgRelation['usergroups'])) { + $cfgRelation['menuswork'] = true; + } + } } if (isset($cfgRelation['navigationhiding'])) { - $cfgRelation['navwork'] = true; + if ($this->canAccessStorageTable($cfgRelation['navigationhiding'])) { + $cfgRelation['navwork'] = true; + } } if (isset($cfgRelation['savedsearches'])) { - $cfgRelation['savedsearcheswork'] = true; + if ($this->canAccessStorageTable($cfgRelation['savedsearches'])) { + $cfgRelation['savedsearcheswork'] = true; + } } if (isset($cfgRelation['central_columns'])) { - $cfgRelation['centralcolumnswork'] = true; + if ($this->canAccessStorageTable($cfgRelation['central_columns'])) { + $cfgRelation['centralcolumnswork'] = true; + } } if (isset($cfgRelation['designer_settings'])) { - $cfgRelation['designersettingswork'] = true; + if ($this->canAccessStorageTable($cfgRelation['designer_settings'])) { + $cfgRelation['designersettingswork'] = true; + } } if (isset($cfgRelation['export_templates'])) { - $cfgRelation['exporttemplateswork'] = true; + if ($this->canAccessStorageTable($cfgRelation['export_templates'])) { + $cfgRelation['exporttemplateswork'] = true; + } } $allWorks = true; @@ -676,6 +714,21 @@ class Relation return $cfgRelation; } + /** + * Check if the table is accessible + * + * @param string $tableDbName The table or table.db + * @return boolean The table is accessible + */ + public function canAccessStorageTable($tableDbName) { + $result = $this->queryAsControlUser( + 'SELECT NULL FROM ' . $tableDbName . ' LIMIT 0', + false, + DatabaseInterface::QUERY_STORE + ); + return $result !== false; + } + /** * Check whether column_info table input transformation * upgrade is required and try to upgrade silently diff --git a/server_privileges.php b/server_privileges.php index a0fcc00dc9..fda9a5b134 100644 --- a/server_privileges.php +++ b/server_privileges.php @@ -39,7 +39,7 @@ $scripts->addFile('vendor/zxcvbn.js'); if ((isset($_GET['viewing_mode']) && $_GET['viewing_mode'] == 'server') - && $GLOBALS['cfgRelation']['menuswork'] + && $cfgRelation['menuswork'] ) { $response->addHTML('
'); $response->addHTML(Users::getHtmlForSubMenusOnUsersPage('server_privileges.php')); diff --git a/server_user_groups.php b/server_user_groups.php index 2cd8feff62..bf5e92d787 100644 --- a/server_user_groups.php +++ b/server_user_groups.php @@ -13,8 +13,8 @@ use PhpMyAdmin\Server\Users; require_once 'libraries/common.inc.php'; $relation = new Relation(); -$relation->getRelationsParam(); -if (! $GLOBALS['cfgRelation']['menuswork']) { +$cfgRelation = $relation->getRelationsParam(); +if (! $cfgRelation['menuswork']) { exit; } From 64d0cd8ec37b1eb9f6371aaa3e6e83b933fd4343 Mon Sep 17 00:00:00 2001 From: Ankush Patil Date: Sun, 6 Oct 2019 19:53:40 +0530 Subject: [PATCH 4/8] Fixes #15127: adding padding, fixed positioning to floating_menubar Signed-off-by: Ankush Patil removed unrequired appends Signed-off-by: Ankush Patil --- js/navigation.js | 20 ++++++++++++++++++-- 1 file changed, 18 insertions(+), 2 deletions(-) diff --git a/js/navigation.js b/js/navigation.js index 6f0d05b89f..4e43d8d726 100644 --- a/js/navigation.js +++ b/js/navigation.js @@ -1128,8 +1128,24 @@ var ResizeHandler = function () { var windowWidth = $(window).width(); $('#pma_navigation').width(pos); $('body').css('margin-' + this.left, pos + 'px'); - // Issue #15127 - $('#floating_menubar, #pma_console') + // Issue #15127 : Adding fixed positioning to menubar + $('#floating_menubar') + .css('margin-' + this.left, $('#pma_navigation').width() + $('#pma_navigation_resizer').width()) + .css(this.left, 0) + .css({ + 'position': 'fixed', + 'top': 0, + 'width': '100%', + 'z-index': 99 + }) + // Allow the DOM to render, then adjust the padding on the body + setTimeout(function () { + $('body').css( + 'padding-top', + $('#floating_menubar').outerHeight(true) + ); + }, 2); + $('#pma_console') .css('margin-' + this.left, (pos + resizer_width) + 'px'); $resizer.css(this.left, pos + 'px'); if (pos === 0) { From 89e3249881b5ca31300fd8a90ab08317827996ef Mon Sep 17 00:00:00 2001 From: William Desportes Date: Mon, 11 Nov 2019 16:28:37 +0100 Subject: [PATCH 5/8] Add ChangeLog entry for #15127 Signed-off-by: William Desportes --- ChangeLog | 1 + 1 file changed, 1 insertion(+) diff --git a/ChangeLog b/ChangeLog index 7562e2c90b..105a4a2307 100644 --- a/ChangeLog +++ b/ChangeLog @@ -27,6 +27,7 @@ phpMyAdmin - ChangeLog - issue #12241 Fixed table alias is removed when exporting a query - issue #15316 Fixed cross join clause is removed on export - issue #14809 Fix error "is_uploaded_file() expects parameter 1 to be string" when inserting blobs from files +- issue #15127 Fix white square when refreshing designer or browsing other pages 4.9.1 (2019-09-20) - issue #15313 Added support for Twig 2 From 5b3ea74fd614a3aa272c7d1866bd2970256edbca Mon Sep 17 00:00:00 2001 From: William Desportes Date: Mon, 11 Nov 2019 16:34:32 +0100 Subject: [PATCH 6/8] Add ChangeLog entry for #15127 and #13912 Signed-off-by: William Desportes --- ChangeLog | 1 + 1 file changed, 1 insertion(+) diff --git a/ChangeLog b/ChangeLog index 105a4a2307..36bbe61453 100644 --- a/ChangeLog +++ b/ChangeLog @@ -28,6 +28,7 @@ phpMyAdmin - ChangeLog - issue #15316 Fixed cross join clause is removed on export - issue #14809 Fix error "is_uploaded_file() expects parameter 1 to be string" when inserting blobs from files - issue #15127 Fix white square when refreshing designer or browsing other pages +- issue #13912 Detect when phpMyAdmin storage tables are not accessible, help users browse corrupt DBs 4.9.1 (2019-09-20) - issue #15313 Added support for Twig 2 From 9362bde02d0535a2f8cb74a18797249cb734c4b0 Mon Sep 17 00:00:00 2001 From: William Desportes Date: Mon, 11 Nov 2019 17:02:36 +0100 Subject: [PATCH 7/8] Revert a redirect link change Ref: fa2f887703d3971395286e4382c4abf90c983799 Signed-off-by: William Desportes --- doc/two_factor.rst | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/doc/two_factor.rst b/doc/two_factor.rst index aaf9062a5b..2ac004e7aa 100644 --- a/doc/two_factor.rst +++ b/doc/two_factor.rst @@ -51,7 +51,7 @@ tokens. There are several manufacturers of these tokens, for example: -* `youbico FIDO U2F Security Key `_ +* `youbico FIDO U2F Security Key `_ * `HyperFIDO `_ * `Trezor Hardware Wallet `_ can act as an `U2F token `_ * `List of Two Factor Auth (2FA) Dongles `_ From b91e734662f2e4f03e34cf67aa40cb01277dc699 Mon Sep 17 00:00:00 2001 From: William Desportes Date: Mon, 11 Nov 2019 19:30:05 +0100 Subject: [PATCH 8/8] Fix selenium TrackingTest Signed-off-by: William Desportes --- test/selenium/TrackingTest.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/test/selenium/TrackingTest.php b/test/selenium/TrackingTest.php index 70dbcff916..29d4a62236 100644 --- a/test/selenium/TrackingTest.php +++ b/test/selenium/TrackingTest.php @@ -190,7 +190,7 @@ class TrackingTest extends TestBase $ele = $this->waitForElement( 'byCssSelector', - 'table#versions tbody tr:nth-child(1) td:nth-child(7)' + 'table#versions tbody tr:nth-child(1) td:nth-child(7) a' ); $this->moveto($ele); $this->click();