diff --git a/ChangeLog b/ChangeLog index bd9c1decab..5f7320da3a 100644 --- a/ChangeLog +++ b/ChangeLog @@ -25,7 +25,7 @@ phpMyAdmin - ChangeLog - [core] Dropped support for PHP 5.2. + rfe #487 and rfe #1405 Find and Replacing column wise + rfe #1373 Use same create view dialog for editing a view -+ rfe #316 Configurable menus; allow user groups with customized menus per group ++ rfe #316 Configurable menus; allow user groups with customized menus per group- bug #4024 Editing field a record is selected by makes pma load forever 4.0.5.0 (not yet released) - bug #3977 Not detected configuration storage diff --git a/db_qbe.php b/db_qbe.php index 940758cccf..003b2fe033 100644 --- a/db_qbe.php +++ b/db_qbe.php @@ -11,6 +11,9 @@ */ require_once 'libraries/common.inc.php'; require_once 'libraries/DBQbe.class.php'; +require_once 'libraries/bookmark.lib.php'; +require_once 'libraries/sql.lib.php'; + $response = PMA_Response::getInstance(); // Gets the relation settings @@ -25,8 +28,15 @@ if (isset($_REQUEST['submit_sql']) && ! empty($sql_query)) { $message_to_display = true; } else { $goto = 'db_sql.php'; - include 'sql.php'; - exit; + + // Parse and analyze the query + require_once 'libraries/parse_analyze.inc.php'; + + PMA_executeQueryAndSendQueryResponse( + $analyzed_sql_results, false, $_REQUEST['db'], null, null, null, null, + false, null, null, null, null, $goto, $pmaThemeImage, null, null, null, + $sql_query, null, null + ); } } diff --git a/import_status.php b/import_status.php index 9b79f3fff6..f2e661ce24 100644 --- a/import_status.php +++ b/import_status.php @@ -63,24 +63,11 @@ if (defined('SESSIONUPLOAD')) { } } -/** - * Sets globals from $_GET - */ -$get_params = array( - 'message', - 'id' -); -foreach ($get_params as $one_get_param) { - if (isset($_GET[$one_get_param])) { - $GLOBALS[$one_get_param] = $_GET[$one_get_param]; - } -} - // AJAX requests can't be cached! PMA_noCacheHeader(); -// $GLOBALS["message"] is used for asking for an import message -if (isset($GLOBALS["message"]) && $GLOBALS["message"]) { +// $_GET["message"] is used for asking for an import message +if (isset($_GET["message"]) && $_GET["message"]) { header('Content-type: text/html'); @@ -100,6 +87,6 @@ if (isset($GLOBALS["message"]) && $GLOBALS["message"]) { echo ''."\n"; } else { - PMA_importAjaxStatus($GLOBALS["id"]); + PMA_importAjaxStatus($_GET["id"]); } ?> diff --git a/js/chart.js b/js/chart.js index 895d051d9b..dcd08cc2ae 100644 --- a/js/chart.js +++ b/js/chart.js @@ -170,7 +170,7 @@ var ColumnType = { }; /******************************************************************************* - * JQPlot specifc code + * JQPlot specific code ******************************************************************************/ /** diff --git a/js/server_status_monitor.js b/js/server_status_monitor.js index c093fea83a..9da93e2e39 100644 --- a/js/server_status_monitor.js +++ b/js/server_status_monitor.js @@ -1201,6 +1201,19 @@ AJAX.registerOnload('server_status_monitor.js', function () { settings.axes.yaxis.tickOptions = { formatter: $.jqplot.byteFormatter(1) // KiB }; + } else if (settings.title === PMA_messages.strQuestions + || settings.title === PMA_messages.strConnections + ) { + settings.axes.yaxis.tickOptions = { + formatter: function(format, val) { + if (Math.abs(val) >= 1000000) + return $.jqplot.sprintf("%.3g M", val/1000000); + else if (Math.abs(val) >= 1000) + return $.jqplot.sprintf("%.3g k", val/1000); + else + return $.jqplot.sprintf("%d", val); + } + }; } settings.series = chartObj.series; diff --git a/js/sql.js b/js/sql.js index e561ba5bf5..18c26d4296 100644 --- a/js/sql.js +++ b/js/sql.js @@ -364,7 +364,7 @@ AJAX.registerOnload('sql.js', function () { $("#resultsForm.ajax .mult_submit[value=edit]").live('click', function (event) { event.preventDefault(); - /*Check whether atleast one row is selected for change*/ + /*Check whether at least one row is selected*/ if ($("#table_results tbody tr, #table_results tbody tr td").hasClass("marked")) { var $div = $('
'); @@ -426,6 +426,17 @@ AJAX.registerOnload('sql.js', function () { } }); + /** + * Checks whether at least one row is selected for deletion or export + */ + $("#resultsForm.ajax .mult_submit[value=delete]," + + "#resultsForm.ajax .mult_submit[value=export]").live('click', function (event) { + /*Check whether at least one row is selected*/ + if (!$("#table_results tbody tr, #table_results tbody tr td").hasClass("marked")) { + event.preventDefault(); + PMA_ajaxShowMessage(PMA_messages.strNoRowSelected); + } + }); /** * Click action for "Go" button in ajax dialog insertForm -> insertRowTable */ diff --git a/js/tbl_zoom_plot_jqplot.js b/js/tbl_zoom_plot_jqplot.js index 17aba65970..fe7dcf35f3 100644 --- a/js/tbl_zoom_plot_jqplot.js +++ b/js/tbl_zoom_plot_jqplot.js @@ -362,7 +362,7 @@ AJAX.registerOnload('tbl_zoom_plot_jqplot.js', function () { // other } else { // type explicitly identified - if (sqlTypes[key] !== null) { + if (sqlTypes[key] != null) { if (sqlTypes[key] == 'bit') { sql_query += "b'" + value + "', "; } @@ -376,6 +376,7 @@ AJAX.registerOnload('tbl_zoom_plot_jqplot.js', function () { } } } + // remove two extraneous characters ', ' sql_query = sql_query.substring(0, sql_query.length - 2); sql_query += ' WHERE ' + PMA_urldecode(searchedData[searchedDataKey].where_clause); diff --git a/libraries/Advisor.class.php b/libraries/Advisor.class.php index 438340f1ec..f7d537197c 100644 --- a/libraries/Advisor.class.php +++ b/libraries/Advisor.class.php @@ -304,11 +304,14 @@ class Advisor */ private function _ruleExprEvaluateVariable($matches) { - return isset($this->variables[$matches[1]]) - ? (is_numeric($this->variables[$matches[1]]) - ? $this->variables[$matches[1]] - : '"'.$this->variables[$matches[1]].'"') - : $matches[1]; + if (! isset($this->variables[$matches[1]])) { + return $matches[1]; + } + if (is_numeric($this->variables[$matches[1]])) { + return $this->variables[$matches[1]]; + } else { + return '\'' . addslashes($this->variables[$matches[1]]) . '\''; + } } /** diff --git a/libraries/advisory_rules.txt b/libraries/advisory_rules.txt index 3ffa1d9faf..354791c12b 100644 --- a/libraries/advisory_rules.txt +++ b/libraries/advisory_rules.txt @@ -200,8 +200,8 @@ rule 'Query cache max size' [!fired('Query cache disabled')] Current query cache size: %s | implode(' ',ADVISOR_formatByteDown(value, 2, 2)) rule 'Query cache min result size' [!fired('Query cache disabled')] - value == 1024*1024 query_cache_limit + value == 1024*1024 The max size of the result set in the query cache is the default of 1 MiB. Changing {query_cache_limit} (usually by increasing) may increase efficiency. This variable determines the maximum size a query result may have to be inserted into the query cache. If there are many query results above 1 MiB that are well cacheable (many reads, little writes) then increasing {query_cache_limit} will increase efficiency. Whereas in the case of many query results being above 1 MiB that are not very well cacheable (often invalidated due to table updates) increasing {query_cache_limit} might reduce efficiency. query_cache_limit is set to 1 MiB diff --git a/libraries/core.lib.php b/libraries/core.lib.php index e5766e51e4..fe26d3f2f3 100644 --- a/libraries/core.lib.php +++ b/libraries/core.lib.php @@ -55,7 +55,7 @@ function PMA_ifSetOr(&$var, $default = null, $type = 'similar') * $type can be: * - false : no type checking * - 'scalar' : whether type of $var is integer, float, string or boolean - * - 'numeric' : whether type of $var is any number repesentation + * - 'numeric' : whether type of $var is any number representation * - 'length' : whether type of $var is scalar with a string length > 0 * - 'similar' : whether type of $var is similar to type of $compare * - 'equal' : whether type of $var is identical to type of $compare diff --git a/libraries/operations.lib.php b/libraries/operations.lib.php index 9e25525437..7d85b369b3 100644 --- a/libraries/operations.lib.php +++ b/libraries/operations.lib.php @@ -380,7 +380,7 @@ function PMA_getSqlQueryAndCreateDbBeforeCopy() // Set the SQL mode to NO_AUTO_VALUE_ON_ZERO to prevent MySQL from creating // export statements it cannot import $sql_set_mode = "SET SQL_MODE='NO_AUTO_VALUE_ON_ZERO'"; - PMA_DBI_query($sql_set_mode); + $GLOBALS['dbi']->query($sql_set_mode); // rebuild the database list because PMA_Table::moveCopy // checks in this list if the target db exists @@ -428,7 +428,7 @@ function PMA_getSqlConstraintsQueryForFullDb( * * @param array $tables_full array of all tables in given db or dbs * @param object $export_sql_plugin export plugin instance - * @param strin $db database name + * @param string $db database name * * @return array $views */ diff --git a/libraries/sql.lib.php b/libraries/sql.lib.php index e2ea325f7b..bbb7f90a8f 100644 --- a/libraries/sql.lib.php +++ b/libraries/sql.lib.php @@ -15,7 +15,7 @@ if (!defined('PHPMYADMIN')) { * @param string $sql SQL query * @param array $databases array with all databases * - * @return strin $db new database name + * @return string $db new database name */ function PMA_getNewDatabase($sql, $databases) { @@ -1028,6 +1028,9 @@ function PMA_addBookmark($pmaAbsoluteUri, $goto) exit; } else { // go back to sql.php to redisplay query; do not use & in this case: + /** + * @todo In which scenario does this happen? + */ PMA_sendHeaderLocation( $pmaAbsoluteUri . $goto . '&label=' . $_POST['bkm_fields']['bkm_label'] @@ -2013,6 +2016,7 @@ function PMA_sendQueryResponseForResultsReturned($result, $justBrowsing, // value of a transformed field, show it here if (isset($_REQUEST['grid_edit']) && $_REQUEST['grid_edit'] == true) { PMA_sendResponseForGridEdit($result); + // script has exited at this point } // Gets the list of fields properties @@ -2249,7 +2253,7 @@ function PMA_executeQueryAndSendQueryResponse($analyzed_sql_results, $query_type, $sql_query, $selected, $complete_query ) { // Include PMA_Index class for use in PMA_DisplayResults class - include './libraries/Index.class.php'; + include_once './libraries/Index.class.php'; include 'libraries/DisplayResults.class.php'; diff --git a/libraries/sqlparser.lib.php b/libraries/sqlparser.lib.php index b99ba814be..c7fe15b7ce 100644 --- a/libraries/sqlparser.lib.php +++ b/libraries/sqlparser.lib.php @@ -3041,5 +3041,18 @@ function PMA_SQP_getParserDataMap() 'PMA_SQPdata_column_type' => $PMA_SQPdata_column_type, ); } +/** + * Get Parser analyze Map from parse_analyze_inc.php + * + * @param array $sql_query The SQL string + * @param array $db Current DB + * + * @return Array analyze Map from parse_analyze_inc.php + */ +function PMA_SQP_getParserAnalyzeMap($sql_query, $db) +{ + include 'libraries/parse_analyze.inc.php'; + return $analyzed_sql_results; +} ?> diff --git a/libraries/sysinfo.lib.php b/libraries/sysinfo.lib.php index d2b2e982b3..ef33910626 100644 --- a/libraries/sysinfo.lib.php +++ b/libraries/sysinfo.lib.php @@ -176,14 +176,10 @@ class PMA_SysInfoWinnt extends PMA_SysInfo } $arrInstance = array(); foreach ($arrProp as $propItem) { - if ( empty($strValue)) { - eval("\$value = \$objItem->" . $propItem->Name . ";"); - $arrInstance[$propItem->Name] = trim($value); - } else { - if (in_array($propItem->Name, $strValue)) { - eval("\$value = \$objItem->" . $propItem->Name . ";"); - $arrInstance[$propItem->Name] = trim($value); - } + $name = $propItem->Name; + if ( empty($strValue) || in_array($name, $strValue)) { + $value = $objItem->$name; + $arrInstance[$name] = trim($value); } } $arrData[] = $arrInstance; diff --git a/po/vls.po b/po/vls.po index f4fe1c24b0..43f1a201e2 100644 --- a/po/vls.po +++ b/po/vls.po @@ -8,14 +8,16 @@ msgstr "" "Project-Id-Version: phpMyAdmin 4.1-dev\n" "Report-Msgid-Bugs-To: phpmyadmin-devel@lists.sourceforge.net\n" "POT-Creation-Date: 2013-07-12 16:06+0200\n" -"PO-Revision-Date: 2013-07-12 16:06+0200\n" -"Last-Translator: Automatically generated\n" -"Language-Team: none\n" +"PO-Revision-Date: 2013-07-25 14:40+0200\n" +"Last-Translator: saurabh chikate \n" +"Language-Team: West Flemish " +"\n" "Language: vls\n" "MIME-Version: 1.0\n" "Content-Type: text/plain; charset=UTF-8\n" "Content-Transfer-Encoding: 8bit\n" -"Plural-Forms: nplurals=INTEGER; plural=EXPRESSION;\n" +"Plural-Forms: nplurals=2; plural=n != 1;\n" +"X-Generator: Weblate 1.6-dev\n" #: browse_foreigners.php:51 browse_foreigners.php:75 js/messages.php:339 #: libraries/DisplayResults.class.php:813 @@ -2099,13 +2101,13 @@ msgstr "" #. l10n: Month-year order for calendar, use either "calendar-month-year" or "calendar-year-month". #: js/messages.php:509 msgid "calendar-month-year" -msgstr "" +msgstr "calendar-month-year" #. l10n: Year suffix for calendar, "none" is empty. #: js/messages.php:511 msgctxt "Year suffix" msgid "none" -msgstr "" +msgstr "none" #: js/messages.php:520 msgid "Hour" @@ -2122,12 +2124,12 @@ msgstr "" #: libraries/Advisor.class.php:78 #, php-format msgid "PHP threw following error: %s" -msgstr "" +msgstr "पी एच पी ने ये त्रुटी दिखाई है:%s" #: libraries/Advisor.class.php:107 #, php-format msgid "Failed evaluating precondition for rule '%s'." -msgstr "" +msgstr "पूर्व शर्त कि वजाह से नियम सुलाझाने मे विफलता'%s'." #: libraries/Advisor.class.php:124 #, php-format diff --git a/sql.php b/sql.php index d64570a65e..2aeadebbb6 100644 --- a/sql.php +++ b/sql.php @@ -24,8 +24,6 @@ $header = $response->getHeader(); $scripts = $header->getScripts(); $scripts->addFile('jquery/jquery-ui-timepicker-addon.js'); $scripts->addFile('tbl_change.js'); -// the next one needed because sql.php may do a "goto" to tbl_structure.php -$scripts->addFile('tbl_structure.js'); $scripts->addFile('indexes.js'); $scripts->addFile('gis_data_editor.js'); @@ -84,17 +82,20 @@ if (isset($_REQUEST['get_relational_values']) && $_REQUEST['get_relational_values'] == true ) { PMA_getRelationalValues($db, $table, $display_field); + // script has exited at this point } // Just like above, find possible values for enum fields during grid edit. if (isset($_REQUEST['get_enum_values']) && $_REQUEST['get_enum_values'] == true) { PMA_getEnumOrSetValues($db, $table, "enum"); + // script has exited at this point } // Find possible values for set fields during grid edit. if (isset($_REQUEST['get_set_values']) && $_REQUEST['get_set_values'] == true) { PMA_getEnumOrSetValues($db, $table, "set"); + // script has exited at this point } /** @@ -102,6 +103,7 @@ if (isset($_REQUEST['get_set_values']) && $_REQUEST['get_set_values'] == true) { */ if (isset($_REQUEST['set_col_prefs']) && $_REQUEST['set_col_prefs'] == true) { PMA_setColumnOrderOrVisibility($table, $db); + // script has exited at this point } // Default to browse if no query set and we have table @@ -153,6 +155,7 @@ if (isset($find_real_end) && $find_real_end) { */ if (isset($_POST['store_bkm'])) { PMA_addBookmark($cfg['PmaAbsoluteUri'], $goto); + // script has exited at this point } // end if diff --git a/tbl_row_action.php b/tbl_row_action.php index b9ccaa4a3c..7ecae32694 100644 --- a/tbl_row_action.php +++ b/tbl_row_action.php @@ -1,7 +1,7 @@ show again the query and tell that user. - */ -if (! PMA_isValid($_REQUEST['rows_to_delete'], 'array') - && ! isset($_REQUEST['mult_btn']) -) { - $disp_message = __('No rows selected'); - $disp_query = ''; - include 'sql.php'; - exit; -} +require_once 'libraries/sql.lib.php'; if (isset($_REQUEST['submit_mult'])) { $submit_mult = $_REQUEST['submit_mult']; @@ -131,13 +120,17 @@ if (!empty($submit_mult)) { $url_query = $original_url_query; } - // this is because sql.php could call tbl_structure - // which would think it needs to call mult_submits.inc.php: - unset($submit_mult, $_REQUEST['mult_btn']); - $active_page = 'sql.php'; - include 'sql.php'; - break; + /** + * Parse and analyze the query + */ + require_once 'libraries/parse_analyze.inc.php'; + + PMA_executeQueryAndSendQueryResponse( + $analyzed_sql_results, false, $db, $table, null, null, null, false, null, + null, null, null, $goto, $pmaThemeImage, null, null, null, $sql_query, + null, null + ); } } ?> diff --git a/tbl_select.php b/tbl_select.php index e0fd01f113..f91b0d1c6c 100644 --- a/tbl_select.php +++ b/tbl_select.php @@ -27,16 +27,6 @@ $scripts->addFile('tbl_change.js'); $scripts->addFile('jquery/jquery-ui-timepicker-addon.js'); $scripts->addFile('gis_data_editor.js'); -$post_params = array( - 'ajax_request', - 'session_max_rows' -); -foreach ($post_params as $one_post_param) { - if (isset($_POST[$one_post_param])) { - $GLOBALS[$one_post_param] = $_POST[$one_post_param]; - } -} - $table_search = new PMA_TableSearch($db, $table, "normal"); /** diff --git a/tbl_structure.php b/tbl_structure.php index c2f8bb1c9a..1a210cf22d 100644 --- a/tbl_structure.php +++ b/tbl_structure.php @@ -1,8 +1,8 @@ getHeader(); @@ -91,7 +93,7 @@ if (! empty($submit_mult)) { if (isset($_REQUEST['selected_fld'])) { $err_url = 'tbl_structure.php?' . PMA_generate_common_url($db, $table); if ($submit_mult == 'browse') { - // browsing the table displaying only selected fields/columns + // browsing the table displaying only selected columns $GLOBALS['active_page'] = 'sql.php'; $sql_query = ''; foreach ($_REQUEST['selected_fld'] as $idx => $sval) { @@ -103,11 +105,18 @@ if (! empty($submit_mult)) { } $sql_query .= ' FROM ' . PMA_Util::backquote($db) . '.' . PMA_Util::backquote($table); - include 'sql.php'; - exit; + + // Parse and analyze the query + require_once 'libraries/parse_analyze.inc.php'; + + PMA_executeQueryAndSendQueryResponse( + $analyzed_sql_results, false, $db, $table, null, null, null, false, null, + null, null, null, $goto, $pmaThemeImage, null, null, null, $sql_query, + null, null + ); } else { // handle multiple field commands - // handle confirmation of deleting multiple fields/columns + // handle confirmation of deleting multiple columns $action = 'tbl_structure.php'; include 'libraries/mult_submits.inc.php'; /** diff --git a/test/libraries/PMA_SQL_parse_analyze_test.php b/test/libraries/PMA_SQL_parse_analyze_test.php new file mode 100644 index 0000000000..61a6723c38 --- /dev/null +++ b/test/libraries/PMA_SQL_parse_analyze_test.php @@ -0,0 +1,67 @@ +assertEquals( + array( + 'type' => 'alpha_reservedWord', + 'data' => 'select', + 'pos' => 6, + 'forbidden' => true, + ), + $data['parsed_sql'][0] + ); + $this->assertEquals( + 'select * from PMA.PMAParse', + $data['analyzed_sql'][0]['unsorted_query'] + ); + + $this->assertTrue($data['is_select']); + $this->assertFalse($data['is_group']); + $this->assertFalse($data['is_show']); + + //update statement + $sql_query = "UPDATE `11`.`pma_bookmark` SET `id` = '2' WHERE `pma_bookmark`.`id` = 1;"; + $db = "PMA"; + $data = PMA_SQP_getParserAnalyzeMap($sql_query, $db); + + $this->assertEquals( + array( + 'type' => 'alpha_reservedWord', + 'data' => 'UPDATE', + 'pos' => 6, + 'forbidden' => true, + ), + $data['parsed_sql'][0] + ); + $this->assertEquals( + $sql_query, + $data['analyzed_sql'][0]['unsorted_query'] + ); + $this->assertFalse($data['is_group']); + $this->assertFalse($data['is_show']); + $this->assertTrue($data['is_affected']); + $this->assertFalse($data['is_select']); + } +} + +?> diff --git a/test/libraries/PMA_display_export_test.php b/test/libraries/PMA_display_export_test.php new file mode 100644 index 0000000000..8475c27890 --- /dev/null +++ b/test/libraries/PMA_display_export_test.php @@ -0,0 +1,239 @@ +getMockBuilder('PMA_Config') + ->disableOriginalConstructor() + ->getMock(); + + $pmaconfig->expects($this->any()) + ->method('getUserValue') + ->will($this->returnValue('user value for test')); + + $GLOBALS['PMA_Config'] = $pmaconfig; + } + + /** + * Test for PMA_getHtmlForHiddenInput + * + * @return void + */ + public function testPMAGetHtmlForHiddenInput() + { + $export_type = "server"; + $db = "PMA"; + $table = "PMA_test"; + $single_table_str = "PMA_single_str"; + $sql_query_str = "sql_query_str"; + + //Call the test function + $html = PMA_getHtmlForHiddenInput( + $export_type, + $db, + $table, + $single_table_str, + $sql_query_str + ); + + //validate 1: PMA_generate_common_hidden_inputs + //$single_table + $this->assertContains( + 'assertContains( + 'assertContains( + ' $export_type, + 'single_table' => isset($single_table) + ) + ); + + //Call the test function + $html = PMA_getHtmlForExportOptions( + $export_type, + $db, + $table, + $multi_values_str, + $num_tables_str, + $export_list, + $unlim_num_rows_str + ); + + //validate 1: PMA_getHtmlForExportOptionHeader + $this->assertContains( + '