From 1ce390b3460d21e6cd5852fb9da7025c570779c2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Michal=20=C4=8Ciha=C5=99?= Date: Fri, 11 May 2012 14:39:34 +0200 Subject: [PATCH 01/10] Better name for a variable --- libraries/Config.class.php | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/libraries/Config.class.php b/libraries/Config.class.php index dba6f082d8..c3be57a896 100644 --- a/libraries/Config.class.php +++ b/libraries/Config.class.php @@ -1620,9 +1620,9 @@ class PMA_Config // set cookie with new value /* Calculate cookie validity */ if ($validity == 0) { - $v = 0; + $validity = 0; } else { - $v = time() + $validity; + $validity = time() + $validity; } if (defined('TESTSUITE')) { $_COOKIE[$cookie] = $value; @@ -1631,7 +1631,7 @@ class PMA_Config return setcookie( $cookie, $value, - $v, + $validity, $this->getCookiePath(), '', $this->isHttps(), From fdb2b41f25e66273c8bf153525db82cb84cbf563 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Michal=20=C4=8Ciha=C5=99?= Date: Fri, 11 May 2012 14:40:39 +0200 Subject: [PATCH 02/10] Handle validity at single place --- libraries/Config.class.php | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/libraries/Config.class.php b/libraries/Config.class.php index c3be57a896..43c61dc30c 100644 --- a/libraries/Config.class.php +++ b/libraries/Config.class.php @@ -1599,9 +1599,6 @@ class PMA_Config function setCookie($cookie, $value, $default = null, $validity = null, $httponly = true ) { - if ($validity == null) { - $validity = 2592000; - } if (strlen($value) && null !== $default && $value === $default) { // default value is used if (isset($_COOKIE[$cookie])) { @@ -1619,7 +1616,9 @@ class PMA_Config if (! isset($_COOKIE[$cookie]) || $_COOKIE[$cookie] !== $value) { // set cookie with new value /* Calculate cookie validity */ - if ($validity == 0) { + if ($validity == null) { + $validity = time() + 2592000; + } elseif ($validity == 0) { $validity = 0; } else { $validity = time() + $validity; From 08ceb6e44d2f9c098ed3ec8475bd8340cfd8a585 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Michal=20=C4=8Ciha=C5=99?= Date: Fri, 11 May 2012 14:46:02 +0200 Subject: [PATCH 03/10] Pass parameter as parameter instead of defining constant --- libraries/auth/cookie.auth.lib.php | 8 ++------ libraries/core.lib.php | 7 ++++--- test/libraries/core/PMA_headerLocation_test_disabled.php | 4 ---- 3 files changed, 6 insertions(+), 13 deletions(-) diff --git a/libraries/auth/cookie.auth.lib.php b/libraries/auth/cookie.auth.lib.php index 41a8c2d582..0d1c48533a 100644 --- a/libraries/auth/cookie.auth.lib.php +++ b/libraries/auth/cookie.auth.lib.php @@ -576,18 +576,14 @@ function PMA_auth_set_user() $url_params['target'] = $GLOBALS['target']; } - /** - * whether we come from a fresh cookie login - */ - define('PMA_COMING_FROM_COOKIE_LOGIN', true); - /** * Clear user cache. */ PMA_clearUserCache(); PMA_sendHeaderLocation( - $redirect_url . PMA_generate_common_url($url_params, '&') + $redirect_url . PMA_generate_common_url($url_params, '&'), + true ); exit(); } // end if diff --git a/libraries/core.lib.php b/libraries/core.lib.php index 4af2e11e03..f553010f06 100644 --- a/libraries/core.lib.php +++ b/libraries/core.lib.php @@ -506,11 +506,12 @@ function PMA_getenv($var_name) /** * Send HTTP header, taking IIS limits into account (600 seems ok) * - * @param string $uri the header to send + * @param string $uri the header to send + * @param bool $use_refresh whether to use Refresh: header when running on IIS * * @return boolean always true */ -function PMA_sendHeaderLocation($uri) +function PMA_sendHeaderLocation($uri, $use_refresh = false) { if (PMA_IS_IIS && strlen($uri) > 600) { include_once './libraries/js_escape.lib.php'; @@ -557,7 +558,7 @@ function PMA_sendHeaderLocation($uri) // bug #1523784: IE6 does not like 'Refresh: 0', it // results in a blank page // but we need it when coming from the cookie login panel) - if (PMA_IS_IIS && defined('PMA_COMING_FROM_COOKIE_LOGIN')) { + if (PMA_IS_IIS && $use_refresh) { header('Refresh: 0; ' . $uri); } else { header('Location: ' . $uri); diff --git a/test/libraries/core/PMA_headerLocation_test_disabled.php b/test/libraries/core/PMA_headerLocation_test_disabled.php index 2f749d6488..240352ff69 100644 --- a/test/libraries/core/PMA_headerLocation_test_disabled.php +++ b/test/libraries/core/PMA_headerLocation_test_disabled.php @@ -196,7 +196,6 @@ class PMA_headerLocation_test extends PHPUnit_Framework_TestCase if ($this->runkitExt && $this->apdExt) { runkit_constant_redefine('PMA_IS_IIS', true); - runkit_constant_add('PMA_COMING_FROM_COOKIE_LOGIN', true); $testUri = 'http://testurl.com/test.php'; $separator = PMA_get_arg_separator(); @@ -205,9 +204,6 @@ class PMA_headerLocation_test extends PHPUnit_Framework_TestCase PMA_sendHeaderLocation($testUri); // sets $GLOBALS['header'] - // cleaning constant - runkit_constant_remove('PMA_COMING_FROM_COOKIE_LOGIN'); - $this->assertEquals($header, $GLOBALS['header']); } else { From 18165459e8274d04abf0a1fb9af7649533df38f2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Michal=20=C4=8Ciha=C5=99?= Date: Fri, 11 May 2012 14:49:36 +0200 Subject: [PATCH 04/10] Some comment and whitespace fixes --- test/classes/PMA_Config_test.php | 26 ++++++++++++++++++++++++-- 1 file changed, 24 insertions(+), 2 deletions(-) diff --git a/test/classes/PMA_Config_test.php b/test/classes/PMA_Config_test.php index 20972d7449..86194e14ca 100644 --- a/test/classes/PMA_Config_test.php +++ b/test/classes/PMA_Config_test.php @@ -3,7 +3,6 @@ /** * Test for PMA_Config class * - * * @package PhpMyAdmin-test * @group current */ @@ -272,8 +271,10 @@ class PMA_ConfigTest extends PHPUnit_Framework_TestCase } /** + * * @covers PMA_Config::get * @covers PMA_Config::set + * * @return void */ public function testGetAndSet() @@ -308,6 +309,7 @@ class PMA_ConfigTest extends PHPUnit_Framework_TestCase } /** + * * @depends testCheckPmaAbsoluteUriEmpty */ public function testCheckPmaAbsoluteUriNormal() @@ -323,6 +325,7 @@ class PMA_ConfigTest extends PHPUnit_Framework_TestCase } /** + * * @depends testCheckPmaAbsoluteUriNormal */ public function testCheckPmaAbsoluteUriScheme() @@ -339,6 +342,7 @@ class PMA_ConfigTest extends PHPUnit_Framework_TestCase } /** + * * @depends testCheckPmaAbsoluteUriScheme */ public function testCheckPmaAbsoluteUriUser() @@ -398,6 +402,7 @@ class PMA_ConfigTest extends PHPUnit_Framework_TestCase } /** + * * @depends testDetectHttps */ public function testCheckCookiePath() @@ -408,6 +413,7 @@ class PMA_ConfigTest extends PHPUnit_Framework_TestCase } /** + * * @depends testCheckSystem * @depends testCheckWebServer * @depends testLoadDefaults @@ -438,6 +444,7 @@ class PMA_ConfigTest extends PHPUnit_Framework_TestCase } /** + * * @todo Implement testSave(). */ public function testSave() @@ -449,6 +456,7 @@ class PMA_ConfigTest extends PHPUnit_Framework_TestCase } /** + * * @todo Implement testGetFontsizeForm(). */ public function testGetFontsizeForm() @@ -460,6 +468,7 @@ class PMA_ConfigTest extends PHPUnit_Framework_TestCase } /** + * * @todo Implement testRemoveCookie(). */ public function testRemoveCookie() @@ -469,7 +478,8 @@ class PMA_ConfigTest extends PHPUnit_Framework_TestCase 'This test has not been implemented yet.' ); } - /** + /** + * * @todo Implement testCheckFontsize(). */ public function testCheckFontsize() @@ -481,6 +491,7 @@ class PMA_ConfigTest extends PHPUnit_Framework_TestCase } /** + * * @todo Implement testCheckUpload(). */ public function testCheckUpload() @@ -492,6 +503,7 @@ class PMA_ConfigTest extends PHPUnit_Framework_TestCase } /** + * * @todo Implement testCheckUploadSize(). */ public function testCheckUploadSize() @@ -503,6 +515,7 @@ class PMA_ConfigTest extends PHPUnit_Framework_TestCase } /** + * * @todo Implement testCheckIsHttps(). */ public function testCheckIsHttps() @@ -514,6 +527,7 @@ class PMA_ConfigTest extends PHPUnit_Framework_TestCase } /** + * * @todo Implement testGetCookiePath(). */ public function testGetCookiePath() @@ -525,6 +539,7 @@ class PMA_ConfigTest extends PHPUnit_Framework_TestCase } /** + * * @todo finish implementing test + dependencies */ public function testLoad() @@ -535,6 +550,7 @@ class PMA_ConfigTest extends PHPUnit_Framework_TestCase } /** + * * @todo Implement testLoadUserPreferences(). */ public function testLoadUserPreferences() @@ -545,6 +561,7 @@ class PMA_ConfigTest extends PHPUnit_Framework_TestCase } /** + * * @todo Implement testSetUserValue(). */ public function testSetUserValue() @@ -555,6 +572,7 @@ class PMA_ConfigTest extends PHPUnit_Framework_TestCase } /** + * * @todo Implement testGetUserValue(). */ public function testGetUserValue() @@ -563,6 +581,7 @@ class PMA_ConfigTest extends PHPUnit_Framework_TestCase } /** + * * @todo Implement testGetThemeUniqueValue(). */ public function testGetThemeUniqueValue() @@ -574,6 +593,7 @@ class PMA_ConfigTest extends PHPUnit_Framework_TestCase } /** + * * @todo Implement testCheckPermissions(). */ public function testCheckPermissions() @@ -586,6 +606,7 @@ class PMA_ConfigTest extends PHPUnit_Framework_TestCase /** + * * @todo Implement testSetCookie(). */ public function testSetCookie() @@ -602,6 +623,7 @@ class PMA_ConfigTest extends PHPUnit_Framework_TestCase } /** + * * @dataProvider sslUris */ public function testSSLUri($original, $expected) From fd7cc6ea14f66875c48a881ee86e0bfcd25cfb00 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Michal=20=C4=8Ciha=C5=99?= Date: Fri, 11 May 2012 14:50:35 +0200 Subject: [PATCH 05/10] Some comment and whitespace fixes --- test/classes/PMA_Theme_test.php | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/test/classes/PMA_Theme_test.php b/test/classes/PMA_Theme_test.php index c35480432f..a9305fb564 100644 --- a/test/classes/PMA_Theme_test.php +++ b/test/classes/PMA_Theme_test.php @@ -5,7 +5,6 @@ require_once 'libraries/Theme.class.php'; /** * Test class for PMA_Theme. - * Generated by PHPUnit on 2011-07-18 at 03:19:13. */ class PMA_ThemeTest extends PHPUnit_Framework_TestCase { @@ -76,6 +75,7 @@ class PMA_ThemeTest extends PHPUnit_Framework_TestCase } /** + * * @expectedException PHPUnit_Framework_Error */ public function testCheckImgPathBad() @@ -101,6 +101,7 @@ class PMA_ThemeTest extends PHPUnit_Framework_TestCase } /** + * * @expectedException PHPUnit_Framework_Error */ public function testCheckImgPathGlobalsWrongPath() @@ -115,6 +116,7 @@ class PMA_ThemeTest extends PHPUnit_Framework_TestCase } /** + * * @covers PMA_Theme::setPath * @covers PMA_Theme::getPath */ @@ -132,6 +134,7 @@ class PMA_ThemeTest extends PHPUnit_Framework_TestCase } /** + * * @depends testLoadInfo */ public function testGetSetCheckVersion() @@ -146,6 +149,7 @@ class PMA_ThemeTest extends PHPUnit_Framework_TestCase } /** + * * @covers PMA_Theme::getName * @covers PMA_Theme::setName */ @@ -158,6 +162,7 @@ class PMA_ThemeTest extends PHPUnit_Framework_TestCase } /** + * * @covers PMA_Theme::getId * @covers PMA_Theme::setId */ @@ -170,6 +175,7 @@ class PMA_ThemeTest extends PHPUnit_Framework_TestCase } /** + * * @covers PMA_Theme::getImgPath * @covers PMA_Theme::setImgPath */ @@ -194,6 +200,7 @@ class PMA_ThemeTest extends PHPUnit_Framework_TestCase } /** + * * @todo Implement testPrintPreview(). */ public function testPrintPreview() From ec6c781d22af098a701b24895b4ae74c9832329b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Michal=20=C4=8Ciha=C5=99?= Date: Fri, 11 May 2012 14:53:24 +0200 Subject: [PATCH 06/10] Add some missing docs --- libraries/File.class.php | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/libraries/File.class.php b/libraries/File.class.php index fed2829828..55c833c43d 100644 --- a/libraries/File.class.php +++ b/libraries/File.class.php @@ -239,7 +239,7 @@ class PMA_File } /** - * + * Loads uploaded file from table change request. * * @param string $key the md5 hash of the column name * @param string $rownumber @@ -351,6 +351,8 @@ class PMA_File } /** + * Returns possible error message. + * * @access public * @return string error message */ @@ -360,6 +362,8 @@ class PMA_File } /** + * Checks whether there was any error. + * * @access public * @return boolean whether an error occured or not */ @@ -395,6 +399,7 @@ class PMA_File } /** + * Sets named file to be read from UploadDir. * * @param string $name * @@ -418,6 +423,8 @@ class PMA_File } /** + * Checks whether file can be read. + * * @access public * @return boolean whether the file is readable or not */ @@ -559,6 +566,8 @@ class PMA_File } /** + * Attempts to open the file. + * * @return bool */ function open() @@ -625,6 +634,8 @@ class PMA_File } /** + * Returns compression used by file. + * * @return string MIME type of compression, none for none * @access public */ From 9ed17c91cecd57723d62b4a25c33e6da2f7a7a28 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Michal=20=C4=8Ciha=C5=99?= Date: Fri, 11 May 2012 14:55:43 +0200 Subject: [PATCH 07/10] Wrap some long lines --- libraries/File.class.php | 24 +++++++++++++++++++----- 1 file changed, 19 insertions(+), 5 deletions(-) diff --git a/libraries/File.class.php b/libraries/File.class.php index 55c833c43d..bcdcb1e56e 100644 --- a/libraries/File.class.php +++ b/libraries/File.class.php @@ -252,7 +252,11 @@ class PMA_File if (! isset($_FILES['fields_upload']) || empty($_FILES['fields_upload']['name']['multi_edit'][$rownumber][$key])) { return false; } - $file = PMA_File::fetchUploadedFromTblChangeRequestMultiple($_FILES['fields_upload'], $rownumber, $key); + $file = PMA_File::fetchUploadedFromTblChangeRequestMultiple( + $_FILES['fields_upload'], + $rownumber, + $key + ); // check for file upload errors switch ($file['error']) { @@ -344,7 +348,9 @@ class PMA_File && is_string($_REQUEST['fields_uploadlocal']['multi_edit'][$rownumber][$key]) ) { // ... whether with multiple rows ... - return $this->setLocalSelectedFile($_REQUEST['fields_uploadlocal']['multi_edit'][$rownumber][$key]); + return $this->setLocalSelectedFile( + $_REQUEST['fields_uploadlocal']['multi_edit'][$rownumber][$key] + ); } else { return false; } @@ -412,7 +418,9 @@ class PMA_File return false; } - $this->setName(PMA_userDir($GLOBALS['cfg']['UploadDir']) . PMA_securePath($name)); + $this->setName( + PMA_userDir($GLOBALS['cfg']['UploadDir']) . PMA_securePath($name) + ); if (! $this->isReadable()) { $this->_error_message = __('File could not be read'); $this->setName(null); @@ -459,12 +467,18 @@ class PMA_File return false; } - $new_file_to_upload = tempnam(realpath($GLOBALS['cfg']['TempDir']), basename($this->getName())); + $new_file_to_upload = tempnam( + realpath($GLOBALS['cfg']['TempDir']), + basename($this->getName()) + ); // suppress warnings from being displayed, but not from being logged // any file access outside of open_basedir will issue a warning ob_start(); - $move_uploaded_file_result = move_uploaded_file($this->getName(), $new_file_to_upload); + $move_uploaded_file_result = move_uploaded_file( + $this->getName(), + $new_file_to_upload + ); ob_end_clean(); if (! $move_uploaded_file_result) { $this->_error_message = __('Error while moving uploaded file.'); From d10763d73d2a126bb2e26df4f768d33982737162 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Michal=20=C4=8Ciha=C5=99?= Date: Fri, 11 May 2012 14:57:43 +0200 Subject: [PATCH 08/10] Wrap some long lines --- test/classes/PMA_Theme_test.php | 24 +++++++++++++++++++----- 1 file changed, 19 insertions(+), 5 deletions(-) diff --git a/test/classes/PMA_Theme_test.php b/test/classes/PMA_Theme_test.php index a9305fb564..4608515b85 100644 --- a/test/classes/PMA_Theme_test.php +++ b/test/classes/PMA_Theme_test.php @@ -39,7 +39,10 @@ class PMA_ThemeTest extends PHPUnit_Framework_TestCase public function testCheckImgPathIncorrect() { $this->object->setPath('./test/classes/_data/incorrect_theme'); - $this->assertFalse($this->object->loadInfo(), 'Theme name is not properly set'); + $this->assertFalse( + $this->object->loadInfo(), + 'Theme name is not properly set' + ); } public function testCheckImgPathFull() @@ -53,12 +56,16 @@ class PMA_ThemeTest extends PHPUnit_Framework_TestCase public function testLoadInfo() { $this->object->setPath('./themes/original'); + $infofile = $this->object->getPath().'/info.inc.php'; $this->assertTrue($this->object->loadInfo()); - $this->assertEquals(filemtime($this->object->getPath().'/info.inc.php'), $this->object->mtime_info); + $this->assertEquals( + filemtime($infofile), + $this->object->mtime_info + ); $this->object->setPath('./themes/original'); - $this->object->mtime_info = filemtime($this->object->getPath().'/info.inc.php'); + $this->object->mtime_info = filemtime($infofile); $this->assertTrue($this->object->loadInfo()); $this->assertEquals('Original', $this->object->getName()); } @@ -139,7 +146,11 @@ class PMA_ThemeTest extends PHPUnit_Framework_TestCase */ public function testGetSetCheckVersion() { - $this->assertEquals('0.0.0.0', $this->object->getVersion(), 'Version 0.0.0.0 by default'); + $this->assertEquals( + '0.0.0.0', + $this->object->getVersion(), + 'Version 0.0.0.0 by default' + ); $this->object->setVersion("1.2.3.4"); $this->assertEquals('1.2.3.4', $this->object->getVersion()); @@ -181,7 +192,10 @@ class PMA_ThemeTest extends PHPUnit_Framework_TestCase */ public function testGetSetImgPath() { - $this->assertEmpty($this->object->getImgPath(), 'ImgPath is empty by default'); + $this->assertEmpty( + $this->object->getImgPath(), + 'ImgPath is empty by default' + ); $this->object->setImgPath('/new/path'); $this->assertEquals('/new/path', $this->object->getImgPath()); From 328d1d617c4658fd4faf08b8a6062af049a09c1e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Michal=20=C4=8Ciha=C5=99?= Date: Fri, 11 May 2012 15:04:12 +0200 Subject: [PATCH 09/10] Various coding style improvements --- libraries/common.lib.php | 91 ++++++++++++++++++++++------------------ 1 file changed, 50 insertions(+), 41 deletions(-) diff --git a/libraries/common.lib.php b/libraries/common.lib.php index 9a22ac2499..18e5091acb 100644 --- a/libraries/common.lib.php +++ b/libraries/common.lib.php @@ -531,7 +531,7 @@ function PMA_showPHPDocu($target) * returns HTML for a footnote marker and add the messsage to the footnotes * * @param string $message the error message - * @param bool $bbcode + * @param bool $bbcode whether to interpret BB code * @param string $type message types * * @return string html code for a footnote marker @@ -600,7 +600,7 @@ function PMA_mysqlDie( */ include_once './libraries/header.inc.php'; - $error_msg_output = ''; + $error_msg = ''; if (! $error_message) { $error_message = PMA_DBI_getError(); @@ -625,8 +625,8 @@ function PMA_mysqlDie( } } // --- - $error_msg_output .= "\n" . '' . "\n"; - $error_msg_output .= '

' . __('Error') + $error_msg .= "\n" . '' . "\n"; + $error_msg .= '

' . __('Error') . '

' . "\n"; // if the config password is wrong, or the MySQL server does not // respond, do not show the query that would reveal the @@ -634,15 +634,15 @@ function PMA_mysqlDie( if (! empty($the_query) && ! strstr($the_query, 'connect')) { // --- Added to solve bug #641765 if (function_exists('PMA_SQP_isError') && PMA_SQP_isError()) { - $error_msg_output .= PMA_SQP_getErrorString() . "\n"; - $error_msg_output .= '
' . "\n"; + $error_msg .= PMA_SQP_getErrorString() . "\n"; + $error_msg .= '
' . "\n"; } // --- // modified to show the help on sql errors - $error_msg_output .= '

' . __('SQL query') . ':' . "\n"; + $error_msg .= '

' . __('SQL query') . ':' . "\n"; if (strstr(strtolower($formatted_sql), 'select')) { // please show me help to the error on select - $error_msg_output .= PMA_showMySQLDocu('SQL-Syntax', 'SELECT'); + $error_msg .= PMA_showMySQLDocu('SQL-Syntax', 'SELECT'); } if ($is_modify_link) { $_url_params = array( @@ -663,14 +663,14 @@ function PMA_mysqlDie( . PMA_generate_common_url($_url_params) . '">'; } - $error_msg_output .= $doedit_goto + $error_msg .= $doedit_goto . PMA_getIcon('b_edit.png', __('Edit')) . ''; } // end if - $error_msg_output .= '

' . "\n" - .'

' . "\n" - .' ' . $formatted_sql . "\n" - .'

' . "\n"; + $error_msg .= '

' . "\n" + .'

' . "\n" + . $formatted_sql . "\n" + . '

' . "\n"; } // end if if (! empty($error_message)) { @@ -682,7 +682,7 @@ function PMA_mysqlDie( } // modified to show the help on error-returns // (now error-messages-server) - $error_msg_output .= '

' . "\n" + $error_msg .= '

' . "\n" . ' ' . __('MySQL said: ') . '' . PMA_showMySQLDocu('Error-messages-server', 'Error-messages-server') . "\n" @@ -699,12 +699,12 @@ function PMA_mysqlDie( // Replace linebreaks $error_message = nl2br($error_message); - $error_msg_output .= '' . "\n" + $error_msg .= '' . "\n" . $error_message . "\n" . '
' . "\n"; - $error_msg_output .= '

'; + $error_msg .= '

'; - $_SESSION['Import_message']['message'] = $error_msg_output; + $_SESSION['Import_message']['message'] = $error_msg; if ($exit) { /** @@ -713,7 +713,7 @@ function PMA_mysqlDie( * - use PMA_ajaxResponse() to transmit the message and exit */ if ($GLOBALS['is_ajax_request'] == true) { - PMA_ajaxResponse($error_msg_output, false); + PMA_ajaxResponse($error_msg, false); } if (! empty($back_url)) { if (strstr($back_url, '?')) { @@ -724,18 +724,18 @@ function PMA_mysqlDie( $_SESSION['Import_message']['go_back_url'] = $back_url; - $error_msg_output .= '
'; - $error_msg_output .= '[ ' . __('Back') . ' ]'; - $error_msg_output .= '
' . "\n\n"; + $error_msg .= '
'; + $error_msg .= '[ ' . __('Back') . ' ]'; + $error_msg .= '
' . "\n\n"; } - echo $error_msg_output; + echo $error_msg; /** * display footer and exit */ include './libraries/footer.inc.php'; } else { - echo $error_msg_output; + echo $error_msg; } } // end of the 'PMA_mysqlDie()' function @@ -791,7 +791,12 @@ function PMA_getTableList($db, $tables = null, $limit_offset = 0, $tbl_is_view = $table['TABLE_TYPE'] == 'VIEW'; if ($tbl_is_view || PMA_is_system_schema($db)) { - $table['Rows'] = PMA_Table::countRecords($db, $table['Name'], false, true); + $table['Rows'] = PMA_Table::countRecords( + $db, + $table['Name'], + false, + true + ); } } @@ -933,7 +938,7 @@ function PMA_whichCrlf() * * @access public */ -function PMA_reloadNavigation($jsonly=false) +function PMA_reloadNavigation($jsonly = false) { // Reloads the navigation frame via JavaScript if required if (isset($GLOBALS['reload']) && $GLOBALS['reload']) { @@ -943,19 +948,21 @@ function PMA_reloadNavigation($jsonly=false) // and the offset becomes greater than the total number of tables unset($_SESSION['tmp_user_values']['table_limit_offset']); echo "\n"; - $reload_url = './navigation.php?' . PMA_generate_common_url($GLOBALS['db'], '', '&'); + $reload_url = './navigation.php?' . PMA_generate_common_url( + $GLOBALS['db'], + '', + '&' + ); if (!$jsonly) { echo '' . PHP_EOL; } @@ -1013,8 +1020,10 @@ function PMA_showMessage( $retval .= "\n"; $retval .= '' . "\n"; } // end if ... elseif @@ -1507,7 +1516,7 @@ function PMA_formatNumber( $value, $digits_left = 3, $digits_right = 0, $only_down = false, $noTrailingZero = true ) { - if ($value==0) { + if ($value == 0) { return '0'; } @@ -1565,11 +1574,11 @@ function PMA_formatNumber( */ $cur_digits = floor(log10($value / PMA_pow(1000, $d, 'pow'))+1); if ($digits_left > $cur_digits) { - $d-= floor(($digits_left - $cur_digits)/3); + $d -= floor(($digits_left - $cur_digits)/3); } - if ($d<0 && $only_down) { - $d=0; + if ($d < 0 && $only_down) { + $d = 0; } $value = round($value / (PMA_pow(1000, $d, 'pow') / $dh)) /$dh; @@ -1585,7 +1594,7 @@ function PMA_formatNumber( $value = PMA_localizeNumber(number_format($value, $digits_right)); } - if ($originalValue!=0 && floatval($value) == 0) { + if ($originalValue != 0 && floatval($value) == 0) { return ' <' . (1 / PMA_pow(10, $digits_right)) . ' ' . $unit; } From 13f6033b5fa63cce7879cbb8ecaae1e172a22955 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Michal=20=C4=8Ciha=C5=99?= Date: Fri, 11 May 2012 15:16:49 +0200 Subject: [PATCH 10/10] Remove workaround for ancient MySQL bug --- libraries/common.lib.php | 13 ------------- 1 file changed, 13 deletions(-) diff --git a/libraries/common.lib.php b/libraries/common.lib.php index 18e5091acb..5cbe2b201d 100644 --- a/libraries/common.lib.php +++ b/libraries/common.lib.php @@ -1028,19 +1028,6 @@ function PMA_showMessage( $retval .= '' . "\n"; } // end if ... elseif - // Checks if the table needs to be repaired after a TRUNCATE query. - // @todo what about $GLOBALS['display_query']??? - // @todo this is REALLY the wrong place to do this - very unexpected here - if (strlen($GLOBALS['table']) - && $GLOBALS['sql_query'] == 'TRUNCATE TABLE ' . PMA_backquote($GLOBALS['table']) - ) { - if (PMA_Table::sGetStatusInfo($GLOBALS['db'], $GLOBALS['table'], 'Index_length') > 1024 - && ! PMA_DRIZZLE - ) { - PMA_DBI_try_query('REPAIR TABLE ' . PMA_backquote($GLOBALS['table'])); - } - } - // In an Ajax request, $GLOBALS['cell_align_left'] may not be defined. Hence, // check for it's presence before using it $retval .= '