The branch, master has been updated via 40388d4fe0748d8873682b4983d7081ae478b345 (commit) via b1109fa7f4800be57dcddb5ebe001c1e4d47c6ef (commit) via 142c0b5f841eb6e73e7d63a0a30f90d1edba50d6 (commit) via ee776a570cc438a24fa364f495a79e7fc511850e (commit) via e788257512a424ca42a1ca55959ec2617bb9cf71 (commit) from d4172032d16e7446fae60a7da5aaf0a931430d32 (commit)
- Log ----------------------------------------------------------------- commit 40388d4fe0748d8873682b4983d7081ae478b345 Author: Michal Čihař mcihar@novell.com Date: Wed May 5 11:36:33 2010 +0200
Simplify MySQL modules warnings by using standard functions.
commit b1109fa7f4800be57dcddb5ebe001c1e4d47c6ef Author: Michal Čihař mcihar@novell.com Date: Wed May 5 11:36:10 2010 +0200
Convert session module warning to generic message function.
commit 142c0b5f841eb6e73e7d63a0a30f90d1edba50d6 Author: Michal Čihař mcihar@novell.com Date: Wed May 5 11:35:49 2010 +0200
Convert pcre warning to generic message.
commit ee776a570cc438a24fa364f495a79e7fc511850e Author: Michal Čihař mcihar@novell.com Date: Wed May 5 11:35:32 2010 +0200
Convert mcrypt warning to generic function.
commit e788257512a424ca42a1ca55959ec2617bb9cf71 Author: Michal Čihař mcihar@novell.com Date: Wed May 5 11:35:14 2010 +0200
Generic function to warn about missing extension.
-----------------------------------------------------------------------
Summary of changes: libraries/auth/cookie.auth.lib.php | 4 +- libraries/common.inc.php | 2 +- libraries/core.lib.php | 20 +++++++++++++ libraries/database_interface.lib.php | 53 ++++++++++++++-------------------- libraries/session.inc.php | 2 +- 5 files changed, 46 insertions(+), 35 deletions(-)
diff --git a/libraries/auth/cookie.auth.lib.php b/libraries/auth/cookie.auth.lib.php index 7ccd7a4..d2e16ec 100644 --- a/libraries/auth/cookie.auth.lib.php +++ b/libraries/auth/cookie.auth.lib.php @@ -36,7 +36,7 @@ if (function_exists('mcrypt_encrypt')) { srand((double) microtime() * 1000000); $td = mcrypt_module_open(MCRYPT_BLOWFISH, '', MCRYPT_MODE_CBC, ''); if ($td === false) { - trigger_error(PMA_sanitize(sprintf(__('Cannot load [a@http://php.net/%1@Documentation%5D%5Bem%5D%1%5B/em%5D%5B/a] extension. Please check your PHP configuration.'), 'mcrypt')), E_USER_WARNING); + PMA_warnMissingExtension('mcrypt'); } $iv = mcrypt_create_iv(mcrypt_enc_get_iv_size($td), MCRYPT_RAND); $GLOBALS['PMA_Config']->setCookie('pma_mcrypt_iv', base64_encode($iv)); @@ -79,7 +79,7 @@ if (function_exists('mcrypt_encrypt')) { } else { require_once './libraries/blowfish.php'; if (!$GLOBALS['cfg']['McryptDisableWarning']) { - trigger_error(PMA_sanitize(sprintf(__('Cannot load [a@http://php.net/%1@Documentation%5D%5Bem%5D%1%5B/em%5D%5B/a] extension. Please check your PHP configuration.'), 'mcrypt')), E_USER_WARNING); + PMA_warnMissingExtension('mcrypt'); } }
diff --git a/libraries/common.inc.php b/libraries/common.inc.php index d0644e7..dbe4627 100644 --- a/libraries/common.inc.php +++ b/libraries/common.inc.php @@ -280,7 +280,7 @@ date_default_timezone_set(@date_default_timezone_get()); * We really need this one! */ if (! function_exists('preg_replace')) { - PMA_fatalError('strCantLoad', 'pcre'); + PMA_warnMissingExtension('pcre', true); }
/** diff --git a/libraries/core.lib.php b/libraries/core.lib.php index b565121..70740b6 100644 --- a/libraries/core.lib.php +++ b/libraries/core.lib.php @@ -275,6 +275,26 @@ function PMA_fatalError($error_message, $message_args = null) }
/** + * Warn or fail on missing extension. + * + * @param string $extension Extension name + * @param bool $fatal Whether the error is fatal. + / @param string $extra Extra string to append to messsage. + */ +function PMA_warnMissingExtension($extension, $fatal = false, $extra = '') +{ + $message = sprintf(__('Cannot load [a@http://php.net/%1$s@Documentation%5D%5Bem%5D%1$s%5B/em%5D%5B/a] extension. Please check your PHP configuration.'), $extension); + if ($extra != '') { + $message .= ' ' . $extra; + } + if ($fatal) { + PMA_fatalError($message); + } else { + trigger_error($message, E_USER_WARNING); + } +} + +/** * returns count of tables in given db * * @uses PMA_DBI_try_query() diff --git a/libraries/database_interface.lib.php b/libraries/database_interface.lib.php index ac13117..de65d12 100644 --- a/libraries/database_interface.lib.php +++ b/libraries/database_interface.lib.php @@ -45,12 +45,7 @@ if (! PMA_DBI_checkMysqlExtension($GLOBALS['cfg']['Server']['extension'])) { * @todo add different messages for alternative extension * and complete fail (no alternative extension too) */ - $error = - sprintf(PMA_sanitize(__('Cannot load [a@http://php.net/%1@Documentation%5D%5Bem%5D%1%5B/em%5D%5B/a] extension. Please check your PHP configuration.')), - $GLOBALS['cfg']['Server']['extension']) - .' - <a href="./Documentation.html#faqmysql" target="documentation">' - .__('Documentation') . '</a>'; - trigger_error($error, E_USER_ERROR); + PMA_warnMissingExtension($GLOBALS['cfg']['Server']['extension'], false, PMA_showDocu('faqmysql'));
if ($GLOBALS['cfg']['Server']['extension'] === 'mysql') { $alternativ_extension = 'mysqli'; @@ -60,11 +55,7 @@ if (! PMA_DBI_checkMysqlExtension($GLOBALS['cfg']['Server']['extension'])) {
if (! PMA_DBI_checkMysqlExtension($alternativ_extension)) { // if alternative fails too ... - PMA_fatalError( - sprintf(__('Cannot load [a@http://php.net/%1@Documentation%5D%5Bem%5D%1%5B/em%5D%5B/a] extension. Please check your PHP configuration.'), - $GLOBALS['cfg']['Server']['extension']) - . ' - [a@./Documentation.html#faqmysql@documentation]' - . __('Documentation') . '[/a]'); + PMA_warnMissingExtension($GLOBALS['cfg']['Server']['extension'], true, PMA_showDocu('faqmysql')); }
$GLOBALS['cfg']['Server']['extension'] = $alternativ_extension; @@ -611,7 +602,7 @@ function PMA_DBI_get_databases_full($database = null, $force_stats = false, $databases[$database_name]['SCHEMA_INDEX_LENGTH'] += $row['Index_length'];
- // for InnoDB, this does not contain the number of + // for InnoDB, this does not contain the number of // overhead bytes but the total free space if ('InnoDB' != $row['Engine']) { $databases[$database_name]['SCHEMA_DATA_FREE'] @@ -824,25 +815,25 @@ function PMA_DBI_get_columns($database, $table, $full = false, $link = null) * * @param string $database name of database * @param string $table name of table to retrieve columns from - * @param string $column name of the column to retrieve data from + * @param string $column name of the column to retrieve data from * @param mixed $link mysql link resource * @return array $field_values */
function PMA_DBI_get_column_values($database, $table, $column, $link = null) -{ +{ $query = 'SELECT '; for($i=0; $i< sizeof($column); $i++) { $query.= PMA_backquote($column[$i]); if($i < (sizeof($column)-1)) { - $query.= ', '; + $query.= ', '; } } $query.= ' FROM ' . PMA_backquote($database) . '.' . PMA_backquote($table); $field_values = PMA_DBI_fetch_result($query, null, null, $link); - + if (! is_array($field_values) || count($field_values) < 1) { return false; } @@ -856,23 +847,23 @@ function PMA_DBI_get_column_values($database, $table, $column, $link = null) * @param mixed $link mysql link resource * @return array $result */ - + function PMA_DBI_get_table_data($database, $table, $link = null) - { - + { + $result = PMA_DBI_fetch_result( 'SELECT * FROM ' . PMA_backquote($database) . '.' . PMA_backquote($table), null,null, $link); - + if (! is_array($result) || count($result) < 1) { return false; - } + } return $result; } - + /** * array PMA_DBI_get_table_indexes($database, $table, $link = null) -* +* * @param string $database name of database * @param string $table name of the table whose indexes are to be retreived * @param mixed $link mysql link resource @@ -881,17 +872,17 @@ function PMA_DBI_get_column_values($database, $table, $column, $link = null)
function PMA_DBI_get_table_indexes($database, $table, $link = null) { - + $indexes = PMA_DBI_fetch_result( 'SHOW INDEXES FROM ' .PMA_backquote($database) . '.' . PMA_backquote($table), - null, null, $link); - + null, null, $link); + if (! is_array($indexes) || count($indexes) < 1) { return false; } return $indexes; } - + /** * returns value of given mysql server variable * @@ -900,8 +891,8 @@ function PMA_DBI_get_table_indexes($database, $table, $link = null) * @param mixed $link mysql link resource|object * @return mixed value for mysql server variable */ - - + + function PMA_DBI_get_variable($var, $type = PMA_DBI_GETVAR_SESSION, $link = null) { if ($link === null) { @@ -1387,7 +1378,7 @@ function PMA_DBI_get_definition($db, $which, $name, $link = null) * @uses PMA_DBI_fetch_result() * @param string $db db name * @param string $table table name - * @param string $delimiter the delimiter to use (may be empty) + * @param string $delimiter the delimiter to use (may be empty) * * @return array information about triggers (may be empty) */ @@ -1442,7 +1433,7 @@ function PMA_DBI_get_triggers($db, $table, $delimiter = '//') function PMA_isView($db, $view_name) { $result = PMA_DBI_fetch_result("SELECT TABLE_NAME FROM information_schema.VIEWS WHERE TABLE_SCHEMA = '".$db."' and TABLE_NAME = '".$view_name."';"); - + if ($result) { return TRUE; } else { diff --git a/libraries/session.inc.php b/libraries/session.inc.php index df2e13c..8b92f37 100644 --- a/libraries/session.inc.php +++ b/libraries/session.inc.php @@ -19,7 +19,7 @@ if (! defined('PHPMYADMIN')) { // verify if PHP supports session, die if it does not
if (!@function_exists('session_name')) { - PMA_fatalError('strCantLoad', 'session'); + PMA_warnMissingExtension('session', true); } elseif (ini_get('session.auto_start') == true && session_name() != 'phpMyAdmin') { // Do not delete the existing session, it might be used by other // applications; instead just close it.
hooks/post-receive