From 701c957f40696a17c1ee5d3804ffb21d6674090e Mon Sep 17 00:00:00 2001 From: Piotr Przybylski Date: Tue, 16 Aug 2011 20:23:15 +0200 Subject: [PATCH 1/4] Inline three one-line methods --- libraries/Tracker.class.php | 39 +++---------------------------------- 1 file changed, 3 insertions(+), 36 deletions(-) diff --git a/libraries/Tracker.class.php b/libraries/Tracker.class.php index 8a622aae69..e89c3fce92 100644 --- a/libraries/Tracker.class.php +++ b/libraries/Tracker.class.php @@ -130,39 +130,6 @@ class PMA_Tracker } } - /** - * Returns a simple DROP TABLE statement. - * - * @param string $tablename - * @return string - */ - static public function getStatementDropTable($tablename) - { - return 'DROP TABLE IF EXISTS ' . $tablename; - } - - /** - * Returns a simple DROP VIEW statement. - * - * @param string $viewname - * @return string - */ - static public function getStatementDropView($viewname) - { - return 'DROP VIEW IF EXISTS ' . $viewname; - } - - /** - * Returns a simple DROP DATABASE statement. - * - * @param string $dbname - * @return string - */ - static public function getStatementDropDatabase($dbname) - { - return 'DROP DATABASE IF EXISTS ' . $dbname; - } - /** * Parses the name of a table from a SQL statement substring. * @@ -303,13 +270,13 @@ class PMA_Tracker if (self::$add_drop_table == true && $is_view == false) { $create_sql .= self::getLogComment() . - self::getStatementDropTable(PMA_backquote($tablename)) . ";\n"; + 'DROP TABLE IF EXISTS ' . PMA_backquote($tablename) . ";\n"; } if (self::$add_drop_view == true && $is_view == true) { $create_sql .= self::getLogComment() . - self::getStatementDropView(PMA_backquote($tablename)) . ";\n"; + 'DROP VIEW IF EXISTS ' . PMA_backquote($tablename) . ";\n"; } $create_sql .= self::getLogComment() . @@ -399,7 +366,7 @@ class PMA_Tracker if (self::$add_drop_database == true) { $create_sql .= self::getLogComment() . - self::getStatementDropDatabase(PMA_backquote($dbname)) . ";\n"; + 'DROP DATABASE IF EXISTS ' . PMA_backquote($dbname) . ";\n"; } $create_sql .= self::getLogComment() . $query; From 726594645ccd3906e39c6d8be973b2ac2d4bffd2 Mon Sep 17 00:00:00 2001 From: Piotr Przybylski Date: Tue, 16 Aug 2011 22:17:23 +0200 Subject: [PATCH 2/4] Optimize tracking query, only the first row is needed --- libraries/Tracker.class.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/libraries/Tracker.class.php b/libraries/Tracker.class.php index e89c3fce92..aad5319480 100644 --- a/libraries/Tracker.class.php +++ b/libraries/Tracker.class.php @@ -563,7 +563,7 @@ class PMA_Tracker $sql_query .= " AND `table_name` = '" . PMA_sqlAddSlashes($tablename) ."' "; } $sql_query .= " AND `version` = '" . PMA_sqlAddSlashes($version) ."' ". - " ORDER BY `version` DESC "; + " ORDER BY `version` DESC LIMIT 1"; $mixed = PMA_DBI_fetch_array(PMA_query_as_controluser($sql_query)); From 6694352f0c5ae67f8b80df29ee319ea538874b39 Mon Sep 17 00:00:00 2001 From: Piotr Przybylski Date: Tue, 16 Aug 2011 22:18:08 +0200 Subject: [PATCH 3/4] Only PMA_DBI_fetch_assoc is needed here --- libraries/Tracker.class.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/libraries/Tracker.class.php b/libraries/Tracker.class.php index aad5319480..bff1f29e26 100644 --- a/libraries/Tracker.class.php +++ b/libraries/Tracker.class.php @@ -565,7 +565,7 @@ class PMA_Tracker $sql_query .= " AND `version` = '" . PMA_sqlAddSlashes($version) ."' ". " ORDER BY `version` DESC LIMIT 1"; - $mixed = PMA_DBI_fetch_array(PMA_query_as_controluser($sql_query)); + $mixed = PMA_DBI_fetch_assoc(PMA_query_as_controluser($sql_query)); // Parse log $log_schema_entries = explode('# log ', $mixed['schema_sql']); From 8c4530e338ba81851cc5f0e2c9b3708293efa4ec Mon Sep 17 00:00:00 2001 From: Piotr Przybylski Date: Tue, 16 Aug 2011 22:19:41 +0200 Subject: [PATCH 4/4] Simplify code --- libraries/Tracker.class.php | 10 +++------- 1 file changed, 3 insertions(+), 7 deletions(-) diff --git a/libraries/Tracker.class.php b/libraries/Tracker.class.php index bff1f29e26..de216ab9c5 100644 --- a/libraries/Tracker.class.php +++ b/libraries/Tracker.class.php @@ -531,13 +531,9 @@ class PMA_Tracker $sql_query .= " AND FIND_IN_SET('" . $statement . "',tracking) > 0" ; } $row = PMA_DBI_fetch_array(PMA_query_as_controluser($sql_query)); - if (isset($row[0])) { - $version = $row[0]; - } - if (! isset($version)) { - $version = -1; - } - return $version; + return isset($row[0]) + ? $row[0] + : -1; }