Merge remote-tracking branch 'origin/master'

This commit is contained in:
Pootle server 2011-08-19 18:40:16 +02:00
commit 84a055a5d4
6 changed files with 98 additions and 58 deletions

View File

@ -174,6 +174,22 @@ class Advisor
$this->runResult[$type][] = $rule;
}
private function ruleExprEvaluate_var1($matches)
{
// '/fired\s*\(\s*(\'|")(.*)\1\s*\)/Uie'
return '1'; //isset($this->runResult[\'fired\']
}
private function ruleExprEvaluate_var2($matches)
{
// '/\b(\w+)\b/e'
return isset($this->variables[$matches[1]])
? (is_numeric($this->variables[$matches[1]])
? $this->variables[$matches[1]]
: '"'.$this->variables[$matches[1]].'"')
: $matches[1];
}
// Runs a code expression, replacing variable names with their respective values
// ignoreUntil: if > 0, it doesn't replace any variables until that string position, but still evaluates the whole expr
function ruleExprEvaluate($expr, $ignoreUntil = 0)
@ -182,13 +198,14 @@ class Advisor
$exprIgnore = substr($expr,0,$ignoreUntil);
$expr = substr($expr,$ignoreUntil);
}
$expr = preg_replace('/fired\s*\(\s*(\'|")(.*)\1\s*\)/Uie','1',$expr); //isset($this->runResult[\'fired\']
$expr = preg_replace('/\b(\w+)\b/e','isset($this->variables[\'\1\']) ? (!is_numeric($this->variables[\'\1\']) ? \'"\'.$this->variables[\'\1\'].\'"\' : $this->variables[\'\1\']) : \'\1\'', $expr);
$expr = preg_replace_callback('/fired\s*\(\s*(\'|")(.*)\1\s*\)/Ui', array($this, 'ruleExprEvaluate_var1'), $expr);
$expr = preg_replace_callback('/\b(\w+)\b/', array($this, 'ruleExprEvaluate_var2'), $expr);
if ($ignoreUntil > 0) {
$expr = $exprIgnore . $expr;
}
$value = 0;
$err = 0;
ob_start();
eval('$value = '.$expr.';');
$err = ob_get_contents();

View File

@ -111,7 +111,7 @@ rule 'Distribution'
rule 'MySQL Architecture'
system_memory
value > 3072*1024 && !preg_match('/64/',version_compile_machine)
value > 3072*1024 && !preg_match('/64/',version_compile_machine) && !preg_match('/64/',version_compile_os)
MySQL is not compiled as a 64-bit package.
Your memory capacity is above 3 GiB (assuming the Server is on localhost), so MySQL might not be able to access all of your memory. You might want to consider installing the 64-bit version of MySQL.
Available memory on this host: %s | implode(' ',PMA_formatByteDown(value*1024, 2, 2))

View File

@ -9,13 +9,14 @@
/**
* Generates text with hidden inputs.
*
* @see PMA_generate_common_url()
* @param string optional database name
* (can also be an array of parameters)
* @param string optional table name
* @param int indenting level
* @param string do not generate a hidden field for this parameter
* (can be an array of strings)
* @param string $db optional database name
* (can also be an array of parameters)
* @param string $table optional table name
* @param int $indent indenting level
* @param string $skip do not generate a hidden field for this parameter
* (can be an array of strings)
*
* @see PMA_generate_common_url()
*
* @return string string with input fields
*
@ -27,7 +28,6 @@
* @global boolean whether recoding is allowed or not
*
* @access public
*
*/
function PMA_generate_common_hidden_inputs($db = '', $table = '', $indent = 0, $skip = array())
{
@ -48,15 +48,16 @@ function PMA_generate_common_hidden_inputs($db = '', $table = '', $indent = 0, $
}
if (! empty($GLOBALS['server'])
&& $GLOBALS['server'] != $GLOBALS['cfg']['ServerDefault']) {
&& $GLOBALS['server'] != $GLOBALS['cfg']['ServerDefault']
) {
$params['server'] = $GLOBALS['server'];
}
if (empty($_COOKIE['pma_lang'])
&& ! empty($GLOBALS['lang'])) {
if (empty($_COOKIE['pma_lang']) && ! empty($GLOBALS['lang'])) {
$params['lang'] = $GLOBALS['lang'];
}
if (empty($_COOKIE['pma_collation_connection'])
&& ! empty($GLOBALS['collation_connection'])) {
&& ! empty($GLOBALS['collation_connection'])
) {
$params['collation_connection'] = $GLOBALS['collation_connection'];
}
@ -102,8 +103,9 @@ function PMA_generate_common_hidden_inputs($db = '', $table = '', $indent = 0, $
* <input type="hidden" name="ccc[b]" Value="ccc_b" />
* </code>
*
* @param array $values
* @param string $pre
* @param array $values hidden values
* @param string $pre prefix
*
* @return string form fields of type hidden
*/
function PMA_getHiddenFields($values, $pre = '')
@ -160,19 +162,20 @@ function PMA_getHiddenFields($values, $pre = '')
* // script.php?server=1&amp;lang=en
* </code>
*
* @param mixed assoc. array with url params or optional string with database name
* if first param is an array there is also an ? prefixed to the url
* @param mixed assoc. array with url params or optional string with database name
* if first param is an array there is also an ? prefixed to the url
*
* @param string - if first param is array: 'html' to use htmlspecialchars()
* on the resulting URL (for a normal URL displayed in HTML)
* or something else to avoid using htmlspecialchars() (for
* a URL sent via a header); if not set,'html' is assumed
* - if first param is not array: optional table name
* @param string - if first param is array: 'html' to use htmlspecialchars()
* on the resulting URL (for a normal URL displayed in HTML)
* or something else to avoid using htmlspecialchars() (for
* a URL sent via a header); if not set,'html' is assumed
* - if first param is not array: optional table name
*
* @param string - if first param is array: optional character to
* use instead of '?'
* - if first param is not array: optional character to use
* instead of '&amp;' for dividing URL parameters
*
* @param string - if first param is array: optional character to
* use instead of '?'
* - if first param is not array: optional character to use
* instead of '&amp;' for dividing URL parameters
* @return string string with URL parameters
* @access public
*/
@ -219,17 +222,18 @@ function PMA_generate_common_url()
if (isset($GLOBALS['server'])
&& $GLOBALS['server'] != $GLOBALS['cfg']['ServerDefault']
// avoid overwriting when creating navi panel links to servers
&& ! isset($params['server'])) {
// avoid overwriting when creating navi panel links to servers
&& ! isset($params['server'])
) {
$params['server'] = $GLOBALS['server'];
}
if (empty($_COOKIE['pma_lang'])
&& ! empty($GLOBALS['lang'])) {
if (empty($_COOKIE['pma_lang']) && ! empty($GLOBALS['lang'])) {
$params['lang'] = $GLOBALS['lang'];
}
if (empty($_COOKIE['pma_collation_connection'])
&& ! empty($GLOBALS['collation_connection'])) {
&& ! empty($GLOBALS['collation_connection'])
) {
$params['collation_connection'] = $GLOBALS['collation_connection'];
}
@ -256,7 +260,9 @@ function PMA_generate_common_url()
* extracted from arg_separator.input as set in php.ini
* we do not use arg_separator.output to avoid problems with &amp; and &
*
* @param string whether to encode separator or not, currently 'none' or 'html'
* @param string $encode whether to encode separator or not,
* currently 'none' or 'html'
*
* @return string character used for separating url parts usally ; or &
* @access public
*/
@ -278,13 +284,13 @@ function PMA_get_arg_separator($encode = 'none')
}
switch ($encode) {
case 'html':
return htmlentities($separator);
break;
case 'text' :
case 'none' :
default :
return $separator;
case 'html':
return htmlentities($separator);
break;
case 'text' :
case 'none' :
default :
return $separator;
}
}

View File

@ -27,9 +27,12 @@ $tabs_icons = array(
'Import' => 'ic_b_import',
'Export' => 'ic_b_export');
echo '<ul id="topmenu2">';
echo PMA_generate_html_tab(array(
'link' => 'prefs_manage.php',
'text' => __('Manage your settings'))) . "\n";
echo PMA_generate_html_tab(
array(
'link' => 'prefs_manage.php',
'text' => __('Manage your settings')
)
) . "\n";
echo '<li>&nbsp; &nbsp;</li>' . "\n";
$script_name = basename($GLOBALS['PMA_PHP_SELF']);
foreach (array_keys($forms) as $formset) {

View File

@ -16,9 +16,12 @@ function PMA_userprefs_pageinit()
$cf = ConfigFile::getInstance();
$cf->resetConfigData(); // start with a clean instance
$cf->setAllowedKeys($forms_all_keys);
$cf->setCfgUpdateReadMapping(array(
'Server/hide_db' => 'Servers/1/hide_db',
'Server/only_db' => 'Servers/1/only_db'));
$cf->setCfgUpdateReadMapping(
array(
'Server/hide_db' => 'Servers/1/hide_db',
'Server/only_db' => 'Servers/1/only_db'
)
);
$cf->updateWithGlobalConfig($GLOBALS['cfg']);
}
@ -64,7 +67,8 @@ function PMA_load_userprefs()
/**
* Saves user preferences
*
* @param array $config_data
* @param array $config_array configuration array
*
* @return true|PMA_Message
*/
function PMA_save_userprefs(array $config_array)
@ -80,7 +84,7 @@ function PMA_save_userprefs(array $config_array)
'db' => $config_array,
'ts' => time());
if (isset($_SESSION['cache'][$cache_key]['userprefs'])) {
unset($_SESSION['cache'][$cache_key]['userprefs']);
unset($_SESSION['cache'][$cache_key]['userprefs']);
}
return true;
}
@ -122,6 +126,7 @@ function PMA_save_userprefs(array $config_array)
* (blacklist) and keys from user preferences form (whitelist)
*
* @param array $config_data path => value pairs
*
* @return array
*/
function PMA_apply_userprefs(array $config_data)
@ -155,6 +160,7 @@ function PMA_apply_userprefs(array $config_data)
* Reads user preferences field names
*
* @param array|null $forms
*
* @return array
*/
function PMA_read_userprefs_fieldnames(array $forms = null)
@ -185,8 +191,10 @@ function PMA_read_userprefs_fieldnames(array $forms = null)
*
* No validation is done!
*
* @param string $cfg_name
* @param mixed $value
* @param string $path configuration
* @param mixed $value value
* @param mixed $default_value default value
*
* @return void
*/
function PMA_persist_option($path, $value, $default_value)
@ -222,12 +230,16 @@ function PMA_userprefs_redirect(array $forms, array $old_settings, $file_name, $
? $old_settings['config_data']
: array();
$new_settings = ConfigFile::getInstance()->getConfigArray();
$diff_keys = array_keys(array_diff_assoc($old_settings, $new_settings)
+ array_diff_assoc($new_settings, $old_settings));
$diff_keys = array_keys(
array_diff_assoc($old_settings, $new_settings)
+ array_diff_assoc($new_settings, $old_settings)
);
$check_keys = array('NaturalOrder', 'MainPageIconic', 'DefaultTabDatabase',
'Server/hide_db', 'Server/only_db');
$check_keys = array_merge($check_keys, $forms['Left_frame']['Left_frame'],
$forms['Left_frame']['Left_databases']);
$check_keys = array_merge(
$check_keys, $forms['Left_frame']['Left_frame'],
$forms['Left_frame']['Left_databases']
);
$diff = array_intersect($check_keys, $diff_keys);
$reload_left_frame = !empty($diff);
}
@ -242,8 +254,10 @@ function PMA_userprefs_redirect(array $forms, array $old_settings, $file_name, $
if ($hash) {
$hash = '#' . urlencode($hash);
}
PMA_sendHeaderLocation($GLOBALS['cfg']['PmaAbsoluteUri'] . $file_name
. PMA_generate_common_url($url_params, '&') . $hash);
PMA_sendHeaderLocation(
$GLOBALS['cfg']['PmaAbsoluteUri'] . $file_name
. PMA_generate_common_url($url_params, '&') . $hash
);
}
/**

View File

@ -165,7 +165,7 @@ unset($show_create_table);
* Get the list of the fields of the current table
*/
PMA_DBI_select_db($db);
$table_fields = PMA_DBI_get_columns($db, $table);
$table_fields = array_values(PMA_DBI_get_columns($db, $table));
$rows = array();
if (isset($where_clause)) {
// when in edit mode load all selected rows from table