diff --git a/ChangeLog b/ChangeLog
index 7a14f69867..7f30c2356d 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -49,6 +49,7 @@ VerboseMultiSubmit, ReplaceHelpImg
- bug #3534979 [interface] Copy Database Ajax feedback vanishes long before copying is done
- bug #3527531 [interface] GC-maxlifetime warning incorrectly displayed
- bug #3526916 [interface] Search fails with JS error when tooltips disabled
+- bug #3544366 [interface] Event comments not saved
3.5.2.0 (2012-07-07)
- bug #3521416 [interface] JS error when editing index
diff --git a/Documentation.html b/Documentation.html
index 1a120427bd..d23017b1b0 100644
--- a/Documentation.html
+++ b/Documentation.html
@@ -1561,7 +1561,7 @@ CREATE DATABASE,ALTER DATABASE,DROP DATABASE
$cfg['ShowTooltipAliasDB'] boolean
If tool-tips are enabled and a DB comment is set, this will flip the
- comment and the real name. That means that if you have a table called
+ comment and the real name. That means that if you have a database called
'user0001' and add the comment 'MyName' on it, you will see the name
'MyName' used consequently in the left frame and the tool-tip shows
the real name of the DB.
diff --git a/libraries/Advisor.class.php b/libraries/Advisor.class.php
index c12b749e0d..f4efd8622a 100644
--- a/libraries/Advisor.class.php
+++ b/libraries/Advisor.class.php
@@ -317,14 +317,14 @@ class Advisor
// Actually evaluate the code
ob_start();
- eval('$value = '.$expr.';');
+ eval('$value = ' . $expr . ';');
$err = ob_get_contents();
ob_end_clean();
// Error handling
if ($err) {
throw new Exception(
- strip_tags($err) . ' Executed code: $value = ' . $expr . ';'
+ strip_tags($err) . ' Executed code: $value = ' . htmlspecialchars($expr) . ';'
);
}
return $value;
diff --git a/libraries/CommonFunctions.class.php b/libraries/CommonFunctions.class.php
index 896f3429ee..6bbf8629a0 100644
--- a/libraries/CommonFunctions.class.php
+++ b/libraries/CommonFunctions.class.php
@@ -9,12 +9,12 @@
/**
* Misc functions used all over the scripts.
- *
+ *
* @package PhpMyAdmin
*/
class PMA_CommonFunctions
{
-
+
/**
* PMA_CommonFunctions instance
*
@@ -23,8 +23,8 @@ class PMA_CommonFunctions
* @var object
*/
private static $_instance;
-
-
+
+
/**
* Creates a new class instance
*
@@ -33,8 +33,8 @@ class PMA_CommonFunctions
private function __construct()
{
}
-
-
+
+
/**
* Returns the singleton PMA_CommonFunctions object
*
@@ -47,7 +47,7 @@ class PMA_CommonFunctions
}
return self::$_instance;
}
-
+
/**
* Detects which function to use for pow.
@@ -168,6 +168,10 @@ class PMA_CommonFunctions
public function getImage($image, $alternate = '', $attributes = array())
{
static $sprites; // cached list of available sprites (if any)
+ if (defined(TESTSUITE)) {
+ // prevent caching in testsuite
+ unset($sprites);
+ }
$url = '';
$is_sprite = false;
@@ -1306,10 +1310,10 @@ class PMA_CommonFunctions
$php_link = ' [' . $this->linkOrButton($php_link, $_message) . ']';
if (isset($GLOBALS['show_as_php'])) {
-
+
$runquery_link = 'import.php'
. PMA_generate_common_url($url_params);
-
+
$php_link .= ' ['
. $this->linkOrButton($runquery_link, __('Submit Query'))
. ']';
@@ -2172,7 +2176,7 @@ class PMA_CommonFunctions
* would have to check if the error message file is always available
*
* @param array $params The names of the parameters needed by the calling script
- * @param bool $request Whether to include this list in checking for
+ * @param bool $request Whether to include this list in checking for
* special params
*
* @return void
@@ -2348,19 +2352,19 @@ class PMA_CommonFunctions
} else {
$con_val = '= \''
. $this->sqlAddSlashes($row[$i], false, true) . '\'';
- }
+ }
}
if ($con_val != null) {
$condition .= $con_val . ' AND';
- if ($meta->primary_key > 0) {
+ if ($meta->primary_key > 0) {
$primary_key .= $condition;
- $primary_key_array[$con_key] = $con_val;
- } elseif ($meta->unique_key > 0) {
+ $primary_key_array[$con_key] = $con_val;
+ } elseif ($meta->unique_key > 0) {
$unique_key .= $condition;
- $unique_key_array[$con_key] = $con_val;
+ $unique_key_array[$con_key] = $con_val;
}
$nonprimary_condition .= $condition;
@@ -2373,18 +2377,18 @@ class PMA_CommonFunctions
// but use conjunction of all values if no primary key
$clause_is_unique = true;
- if ($primary_key) {
+ if ($primary_key) {
$preferred_condition = $primary_key;
$condition_array = $primary_key_array;
- } elseif ($unique_key) {
+ } elseif ($unique_key) {
$preferred_condition = $unique_key;
$condition_array = $unique_key_array;
- } elseif (! $force_unique) {
+ } elseif (! $force_unique) {
$preferred_condition = $nonprimary_condition;
$condition_array = $nonprimary_condition_array;
- $clause_is_unique = false;
+ $clause_is_unique = false;
}
$where_clause = trim(preg_replace('|\s?AND$|', '', $preferred_condition));
@@ -2636,7 +2640,7 @@ class PMA_CommonFunctions
. PMA_generate_common_url($_url_params) . '" target="'
. $frame . '">' . $caption1 . '';
- $_url_params['pos'] = $pos - $max_count;
+ $_url_params['pos'] = $pos - $max_count;
$list_navigator_html .= '' . $caption2 . '';
@@ -2758,8 +2762,8 @@ class PMA_CommonFunctions
*/
public function getExternalBug(
$functionality, $component, $minimum_version, $bugref
- ) {
- $ext_but_html = '';
+ ) {
+ $ext_but_html = '';
if (($component == 'mysql') && (PMA_MYSQL_INT_VERSION < $minimum_version)) {
$ext_but_html .= $this->showHint(
sprintf(
@@ -2768,7 +2772,7 @@ class PMA_CommonFunctions
PMA_linkURL('http://bugs.mysql.com/') . $bugref
)
);
- }
+ }
return $ext_but_html;
}
@@ -3447,7 +3451,7 @@ class PMA_CommonFunctions
/* Optional escaping */
if (! is_null($escape)) {
- foreach ($replace as $key => $val) {
+ foreach ($replace as $key => $val) {
$replace[$key] = ($escape == 'backquote')
? $this->$escape($val)
: $escape($val);
@@ -4198,7 +4202,7 @@ class PMA_CommonFunctions
return $values;
}
-
+
}
?>
diff --git a/libraries/DbSearch.class.php b/libraries/DbSearch.class.php
index 8e7f14cf0b..7c42982bbb 100644
--- a/libraries/DbSearch.class.php
+++ b/libraries/DbSearch.class.php
@@ -93,19 +93,6 @@ class PMA_DbSearch
$this->_setSearchParams();
}
- /**
- * Set CommmonFunctions
- *
- * @param PMA_CommonFunctions $commonFunctions
- *
- * @return void
- */
- public function setCommonFunctions(PMA_CommonFunctions $commonFunctions)
- {
- $this->_common_functions = $commonFunctions;
- }
-
-
/**
* Get CommmonFunctions
*
diff --git a/libraries/DisplayResults.class.php b/libraries/DisplayResults.class.php
index 3ecc853ef1..9fbde32e25 100644
--- a/libraries/DisplayResults.class.php
+++ b/libraries/DisplayResults.class.php
@@ -19,6 +19,7 @@ if (! defined('PHPMYADMIN')) {
class PMA_DisplayResults
{
+ // Define constants
const NO_EDIT_OR_DELETE = 'nn';
const UPDATE_ROW = 'ur';
const DELETE_ROW = 'dr';
@@ -29,6 +30,9 @@ class PMA_DisplayResults
const POSITION_BOTH = 'both';
const POSITION_NONE = 'none';
+ const PLACE_TOP_DIRECTION_DROPDOWN = 'top_direction_dropdown';
+ const PLACE_BOTTOM_DIRECTION_DROPDOWN = 'bottom_direction_dropdown';
+
const DISP_DIR_HORIZONTAL = 'horizontal';
const DISP_DIR_HORIZONTAL_FLIPPED = 'horizontalflipped';
const DISP_DIR_VERTICAL = 'vertical';
@@ -62,28 +66,126 @@ class PMA_DisplayResults
const TABLE_TYPE_INNO_DB = 'InnoDB';
const ALL_ROWS = 'all';
const QUERY_TYPE_SELECT = 'SELECT';
-
-
+
+
+ // Declare global fields
+ /** PMA_CommonFunctions object */
private $_common_functions;
- private $_db, $_table, $_goto, $_sql_query;
-
+ /** array with properties of the class */
+ private $_property_array = array(
+
+ /** string Database name */
+ '_db' => null,
+
+ /** string Table name */
+ '_table' => null,
+
+ /** string the URL to go back in case of errors */
+ '_goto' => null,
+
+ /** string the SQL query */
+ '_sql_query' => null,
+
+ /**
+ * integer the total number of rows returned by the SQL query without any
+ * appended "LIMIT" clause programmatically
+ */
+ '_unlim_num_rows' => null,
+
+ /** array meta information about fields */
+ '_fields_meta' => null,
+
+ /** boolean */
+ '_is_count' => null,
+
+ /** integer */
+ '_is_export' => null,
+
+ /** boolean */
+ '_is_func' => null,
+
+ /** integer */
+ '_is_analyse' => null,
+
+ /** integer the total number of rows returned by the SQL query */
+ '_num_rows' => null,
+
+ /** integer the total number of fields returned by the SQL query */
+ '_fields_cnt' => null,
+
+ /** double time taken for execute the SQL query */
+ '_querytime' => null,
+
+ /** string path for theme images directory */
+ '_pma_theme_image' => null,
+
+ /** string */
+ '_text_dir' => null,
+
+ /** boolean */
+ '_is_maint' => null,
+
+ /** boolean */
+ '_is_explain' => null,
+
+ /** boolean */
+ '_is_show' => null,
+
+ /** array table definitions */
+ '_showtable' => null,
+
+ /** string */
+ '_printview' => null,
+
+ /** string URL query */
+ '_url_query' => null,
+
+ /** array column names to highlight */
+ '_highlight_columns' => null,
+
+ /** array informations used with vertical display mode */
+ '_vertical_display' => null,
+
+ /** array mime types information of fields */
+ '_mime_map' => null
+ );
+
+
/**
- * Set CommmonFunctions
- *
- * @param PMA_CommonFunctions $commonFunctions
- *
+ * Get any property of this class
+ *
+ * @param string $property name of the property
+ *
+ * @return if property exist, value of the relavant property
+ */
+ public function __get($property)
+ {
+ if(array_key_exists($property, $this->_property_array)) {
+ return $this->_property_array[$property];
+ }
+ }
+
+
+ /**
+ * Set values for any property of this class
+ *
+ * @param string $property name of the property
+ * @param $value value to set
+ *
* @return void
*/
- public function setCommonFunctions(PMA_CommonFunctions $commonFunctions)
- {
- $this->_common_functions = $commonFunctions;
+ public function __set($property, $value)
+ {
+ if(array_key_exists($property, $this->_property_array)) {
+ $this->_property_array[$property] = $value;
+ }
}
-
-
+
+
/**
* Get CommmonFunctions
- *
+ *
* @return CommonFunctions object
*/
public function getCommonFunctions()
@@ -93,7 +195,7 @@ class PMA_DisplayResults
}
return $this->_common_functions;
}
-
+
/**
* Constructor for PMA_DisplayResults class
@@ -107,13 +209,67 @@ class PMA_DisplayResults
*/
public function __construct($db, $table, $goto, $sql_query)
{
- $this->_db = $db;
- $this->_table = $table;
- $this->_goto = $goto;
- $this->_sql_query = $sql_query;
+ $this->__set('_db', $db);
+ $this->__set('_table', $table);
+ $this->__set('_goto', $goto);
+ $this->__set('_sql_query', $sql_query);
}
+ /**
+ * Set properties which were not initialized at the constructor
+ *
+ * @param type $unlim_num_rows integer the total number of rows returned by
+ * the SQL query without any appended
+ * "LIMIT" clause programmatically
+ * @param type $fields_meta array meta information about fields
+ * @param type $is_count boolean
+ * @param type $is_export integer
+ * @param type $is_func boolean
+ * @param type $is_analyse integer
+ * @param type $num_rows integer total no. of rows returned by SQL query
+ * @param type $fields_cnt integer total no.of fields returned by SQL query
+ * @param type $querytime double time taken for execute the SQL query
+ * @param type $pmaThemeImage string path for theme images directory
+ * @param type $text_dir string
+ * @param type $is_maint boolean
+ * @param type $is_explain boolean
+ * @param type $is_show boolean
+ * @param type $showtable array table definitions
+ * @param type $printview string
+ * @param type $url_query string URL query
+ *
+ * @return void
+ *
+ * @see sql.php
+ */
+ public function setProperties(
+ $unlim_num_rows, $fields_meta, $is_count, $is_export, $is_func,
+ $is_analyse, $num_rows, $fields_cnt, $querytime, $pmaThemeImage, $text_dir,
+ $is_maint, $is_explain, $is_show, $showtable, $printview, $url_query
+ ) {
+
+ $this->__set('_unlim_num_rows', $unlim_num_rows);
+ $this->__set('_fields_meta', $fields_meta);
+ $this->__set('_is_count', $is_count);
+ $this->__set('_is_export', $is_export);
+ $this->__set('_is_func', $is_func);
+ $this->__set('_is_analyse', $is_analyse);
+ $this->__set('_num_rows', $num_rows);
+ $this->__set('_fields_cnt', $fields_cnt);
+ $this->__set('_querytime', $querytime);
+ $this->__set('_pma_theme_image', $pmaThemeImage);
+ $this->__set('_text_dir', $text_dir);
+ $this->__set('_is_maint', $is_maint);
+ $this->__set('_is_explain', $is_explain);
+ $this->__set('_is_show', $is_show);
+ $this->__set('_showtable', $showtable);
+ $this->__set('_printview', $printview);
+ $this->__set('_url_query', $url_query);
+
+ } // end of the 'setProperties()' function
+
+
/**
* Defines the display mode to use for the results of a SQL query
*
@@ -149,6 +305,14 @@ class PMA_DisplayResults
private function _setDisplayMode(&$the_disp_mode, &$the_total)
{
+ // Following variables are needed for use in isset/empty or
+ // use with array indexes or safe use in foreach
+ $db = $this->__get('_db');
+ $table = $this->__get('_table');
+ $unlim_num_rows = $this->__get('_unlim_num_rows');
+ $fields_meta = $this->__get('_fields_meta');
+ $printview = $this->__get('_printview');
+
// 1. Initializes the $do_display array
$do_display = array();
$do_display['edit_lnk'] = $the_disp_mode[0] . $the_disp_mode[1];
@@ -163,7 +327,8 @@ class PMA_DisplayResults
// 2. Display mode is not "false for all elements" -> updates the
// display mode
if ($the_disp_mode != 'nnnn000000') {
- if (isset($GLOBALS['printview']) && $GLOBALS['printview'] == '1') {
+
+ if (isset($printview) && ($printview == '1')) {
// 2.0 Print view -> set all elements to false!
$do_display['edit_lnk'] = self::NO_EDIT_OR_DELETE; // no edit link
$do_display['del_lnk'] = self::NO_EDIT_OR_DELETE; // no delete link
@@ -173,8 +338,9 @@ class PMA_DisplayResults
$do_display['bkm_form'] = (string) '0';
$do_display['text_btn'] = (string) '0';
$do_display['pview_lnk'] = (string) '0';
- } elseif ($GLOBALS['is_count'] || $GLOBALS['is_analyse']
- || $GLOBALS['is_maint'] || $GLOBALS['is_explain']
+
+ } elseif ($this->__get('_is_count') || $this->__get('_is_analyse')
+ || $this->__get('_is_maint') || $this->__get('_is_explain')
) {
// 2.1 Statement is a "SELECT COUNT", a
// "CHECK/ANALYZE/REPAIR/OPTIMIZE", an "EXPLAIN" one or
@@ -185,14 +351,15 @@ class PMA_DisplayResults
$do_display['nav_bar'] = (string) '0';
$do_display['ins_row'] = (string) '0';
$do_display['bkm_form'] = (string) '1';
- if ($GLOBALS['is_maint']) {
+
+ if ($this->__get('_is_maint')) {
$do_display['text_btn'] = (string) '1';
} else {
$do_display['text_btn'] = (string) '0';
}
$do_display['pview_lnk'] = (string) '1';
- } elseif ($GLOBALS['is_show']) {
+ } elseif ($this->__get('_is_show')) {
// 2.2 Statement is a "SHOW..."
/**
* 2.2.1
@@ -202,7 +369,7 @@ class PMA_DisplayResults
'@^SHOW[[:space:]]+(VARIABLES|(FULL[[:space:]]+)?'
. 'PROCESSLIST|STATUS|TABLE|GRANTS|CREATE|LOGS|DATABASES|FIELDS'
. ')@i',
- $GLOBALS['sql_query'], $which
+ $this->__get('_sql_query'), $which
);
if (isset($which[1])
&& (strpos(' ' . strtoupper($which[1]), 'PROCESSLIST') > 0)
@@ -225,21 +392,25 @@ class PMA_DisplayResults
$do_display['bkm_form'] = (string) '1';
$do_display['text_btn'] = (string) '1';
$do_display['pview_lnk'] = (string) '1';
+
} else {
// 2.3 Other statements (ie "SELECT" ones) -> updates
// $do_display['edit_lnk'], $do_display['del_lnk'] and
// $do_display['text_btn'] (keeps other default values)
- $prev_table = $GLOBALS['fields_meta'][0]->table;
+ $prev_table = $fields_meta[0]->table;
$do_display['text_btn'] = (string) '1';
- for ($i = 0; $i < $GLOBALS['fields_cnt']; $i++) {
+
+ for ($i = 0; $i < $this->__get('_fields_cnt'); $i++) {
+
$is_link = ($do_display['edit_lnk'] != self::NO_EDIT_OR_DELETE)
|| ($do_display['del_lnk'] != self::NO_EDIT_OR_DELETE)
|| ($do_display['sort_lnk'] != '0')
|| ($do_display['ins_row'] != '0');
+
// 2.3.2 Displays edit/delete/sort/insert links?
if ($is_link
- && (($GLOBALS['fields_meta'][$i]->table == '')
- || ($GLOBALS['fields_meta'][$i]->table != $prev_table))
+ && (($fields_meta[$i]->table == '')
+ || ($fields_meta[$i]->table != $prev_table))
) {
// don't display links
$do_display['edit_lnk'] = self::NO_EDIT_OR_DELETE;
@@ -254,21 +425,23 @@ class PMA_DisplayResults
break;
}
} // end if (2.3.2)
+
// 2.3.3 Always display print view link
$do_display['pview_lnk'] = (string) '1';
- $prev_table = $GLOBALS['fields_meta'][$i]->table;
+ $prev_table = $fields_meta[$i]->table;
+
} // end for
} // end if..elseif...else (2.1 -> 2.3)
} // end if (2)
// 3. Gets the total number of rows if it is unknown
- if (isset($GLOBALS['unlim_num_rows']) && $GLOBALS['unlim_num_rows'] != '') {
- $the_total = $GLOBALS['unlim_num_rows'];
+ if (isset($unlim_num_rows) && $unlim_num_rows != '') {
+ $the_total = $unlim_num_rows;
} elseif ((($do_display['nav_bar'] == '1')
|| ($do_display['sort_lnk'] == '1'))
- && (strlen($this->_db) && !empty($this->_table))
+ && (strlen($db) && !empty($table))
) {
- $the_total = PMA_Table::countRecords($this->_db, $this->_table);
+ $the_total = PMA_Table::countRecords($db, $table);
}
// 4. If navigation bar or sorting fields names URLs should be
@@ -280,9 +453,9 @@ class PMA_DisplayResults
// - For a VIEW we (probably) did not count the number of rows
// so don't test this number here, it would remove the possibility
// of sorting VIEW results.
- if (isset($GLOBALS['unlim_num_rows'])
- && $GLOBALS['unlim_num_rows'] < 2
- && ! PMA_Table::isView($this->_db, $this->_table)
+ if (isset($unlim_num_rows)
+ && ($unlim_num_rows < 2)
+ && ! PMA_Table::isView($db, $table)
) {
// force display of navbar for vertical/horizontal display-choice.
// $do_display['nav_bar'] = (string) '0';
@@ -302,19 +475,21 @@ class PMA_DisplayResults
* Return true if we are executing a query in the form of
* "SELECT * FROM ..."
*
+ * @param array $analyzed_sql the analyzed query
+ *
* @return boolean
*
* @access private
*
* @see _getTableHeaders(), _getColumnParams()
*/
- private function _isSelect()
+ private function _isSelect($analyzed_sql)
{
- return ! ($GLOBALS['is_count'] || $GLOBALS['is_export']
- || $GLOBALS['is_func'] || $GLOBALS['is_analyse'])
- && (count($GLOBALS['analyzed_sql'][0]['select_expr']) == 0)
- && isset($GLOBALS['analyzed_sql'][0]['queryflags']['select_from'])
- && (count($GLOBALS['analyzed_sql'][0]['table_ref']) == 1);
+ return ! ($this->__get('_is_count') || $this->__get('_is_export')
+ || $this->__get('_is_func') || $this->__get('_is_analyse'))
+ && (count($analyzed_sql[0]['select_expr']) == 0)
+ && isset($analyzed_sql[0]['queryflags']['select_from'])
+ && (count($analyzed_sql[0]['table_ref']) == 1);
}
@@ -357,11 +532,14 @@ class PMA_DisplayResults
return '