diff --git a/libraries/Config.class.php b/libraries/Config.class.php
index dba6f082d8..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,10 +1616,12 @@ class PMA_Config
if (! isset($_COOKIE[$cookie]) || $_COOKIE[$cookie] !== $value) {
// set cookie with new value
/* Calculate cookie validity */
- if ($validity == 0) {
- $v = 0;
+ if ($validity == null) {
+ $validity = time() + 2592000;
+ } elseif ($validity == 0) {
+ $validity = 0;
} else {
- $v = time() + $validity;
+ $validity = time() + $validity;
}
if (defined('TESTSUITE')) {
$_COOKIE[$cookie] = $value;
@@ -1631,7 +1630,7 @@ class PMA_Config
return setcookie(
$cookie,
$value,
- $v,
+ $validity,
$this->getCookiePath(),
'',
$this->isHttps(),
diff --git a/libraries/File.class.php b/libraries/File.class.php
index fed2829828..bcdcb1e56e 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
@@ -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,13 +348,17 @@ 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;
}
}
/**
+ * Returns possible error message.
+ *
* @access public
* @return string error message
*/
@@ -360,6 +368,8 @@ class PMA_File
}
/**
+ * Checks whether there was any error.
+ *
* @access public
* @return boolean whether an error occured or not
*/
@@ -395,6 +405,7 @@ class PMA_File
}
/**
+ * Sets named file to be read from UploadDir.
*
* @param string $name
*
@@ -407,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);
@@ -418,6 +431,8 @@ class PMA_File
}
/**
+ * Checks whether file can be read.
+ *
* @access public
* @return boolean whether the file is readable or not
*/
@@ -452,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.');
@@ -559,6 +580,8 @@ class PMA_File
}
/**
+ * Attempts to open the file.
+ *
* @return bool
*/
function open()
@@ -625,6 +648,8 @@ class PMA_File
}
/**
+ * Returns compression used by file.
+ *
* @return string MIME type of compression, none for none
* @access public
*/
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/common.lib.php b/libraries/common.lib.php
index 9a22ac2499..5cbe2b201d 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 .= '' . "\n\n";
+ $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,25 +1020,14 @@ function PMA_showMessage(
$retval .= "\n";
$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 .= ' $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 +1581,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;
}
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/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)
diff --git a/test/classes/PMA_Theme_test.php b/test/classes/PMA_Theme_test.php
index c35480432f..4608515b85 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
{
@@ -40,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()
@@ -54,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());
}
@@ -76,6 +82,7 @@ class PMA_ThemeTest extends PHPUnit_Framework_TestCase
}
/**
+ *
* @expectedException PHPUnit_Framework_Error
*/
public function testCheckImgPathBad()
@@ -101,6 +108,7 @@ class PMA_ThemeTest extends PHPUnit_Framework_TestCase
}
/**
+ *
* @expectedException PHPUnit_Framework_Error
*/
public function testCheckImgPathGlobalsWrongPath()
@@ -115,6 +123,7 @@ class PMA_ThemeTest extends PHPUnit_Framework_TestCase
}
/**
+ *
* @covers PMA_Theme::setPath
* @covers PMA_Theme::getPath
*/
@@ -132,11 +141,16 @@ class PMA_ThemeTest extends PHPUnit_Framework_TestCase
}
/**
+ *
* @depends testLoadInfo
*/
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());
@@ -146,6 +160,7 @@ class PMA_ThemeTest extends PHPUnit_Framework_TestCase
}
/**
+ *
* @covers PMA_Theme::getName
* @covers PMA_Theme::setName
*/
@@ -158,6 +173,7 @@ class PMA_ThemeTest extends PHPUnit_Framework_TestCase
}
/**
+ *
* @covers PMA_Theme::getId
* @covers PMA_Theme::setId
*/
@@ -170,12 +186,16 @@ class PMA_ThemeTest extends PHPUnit_Framework_TestCase
}
/**
+ *
* @covers PMA_Theme::getImgPath
* @covers PMA_Theme::setImgPath
*/
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());
@@ -194,6 +214,7 @@ class PMA_ThemeTest extends PHPUnit_Framework_TestCase
}
/**
+ *
* @todo Implement testPrintPreview().
*/
public function testPrintPreview()
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 {