Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
Mass modifications to use PMA_String.
Signed-off-by: Hugues Peccatte <hugues.peccatte@gmail.com>
  • Loading branch information
Tithugues committed Sep 6, 2014
1 parent 4960f20 commit 9b77d74
Show file tree
Hide file tree
Showing 164 changed files with 5,126 additions and 1,954 deletions.
2 changes: 1 addition & 1 deletion changelog.php
Expand Up @@ -23,7 +23,7 @@
if (is_readable($filename)) {

// Test if the if is in a compressed format
if (substr($filename, -3) == '.gz') {
if ($GLOBALS['PMA_String']->substr($filename, -3) == '.gz') {
ob_start();
readgzfile($filename);
$changelog = ob_get_contents();
Expand Down
2 changes: 1 addition & 1 deletion db_datadict.php
Expand Up @@ -36,7 +36,7 @@
/**
* Defines the url to return to in case of error in a sql statement
*/
if (strlen($table)) {
if ($GLOBALS['PMA_String']->strlen($table)) {
$err_url = 'tbl_sql.php?' . PMA_URL_getCommon($db, $table);
} else {
$err_url = 'db_sql.php?' . PMA_URL_getCommon($db);
Expand Down
8 changes: 6 additions & 2 deletions db_operations.php
Expand Up @@ -32,7 +32,9 @@
/**
* Rename/move or copy database
*/
if (strlen($GLOBALS['db'])
/** @var PMA_String $pmaString */
$pmaString = $GLOBALS['PMA_String'];
if ($pmaString->strlen($GLOBALS['db'])
&& (! empty($_REQUEST['db_rename']) || ! empty($_REQUEST['db_copy']))
) {
if (! empty($_REQUEST['db_rename'])) {
Expand All @@ -41,7 +43,9 @@
$move = false;
}

if (! isset($_REQUEST['newname']) || ! strlen($_REQUEST['newname'])) {
if (! isset($_REQUEST['newname'])
|| ! $pmaString->strlen($_REQUEST['newname'])
) {
$message = PMA_Message::error(__('The database name is empty!'));
} else {
$sql_query = ''; // in case target db exists
Expand Down
2 changes: 1 addition & 1 deletion db_printview.php
Expand Up @@ -59,7 +59,7 @@
$odd_row = true;
foreach ($tables as $sts_data) {
if (PMA_Table::isMerge($db, $sts_data['TABLE_NAME'])
|| strtoupper($sts_data['ENGINE']) == 'FEDERATED'
|| $GLOBALS['PMA_String']->strtoupper($sts_data['ENGINE']) == 'FEDERATED'
) {
$merged_size = true;
} else {
Expand Down
2 changes: 1 addition & 1 deletion examples/openid.php
Expand Up @@ -79,7 +79,7 @@ function Show_page($contents)

$realm = $base . '/';
$returnTo = $base . dirname($_SERVER['PHP_SELF']);
if ($returnTo[strlen($returnTo) - 1] != '/') {
if ($returnTo[$GLOBALS['PMA_String']->strlen($returnTo) - 1] != '/') {
$returnTo .= '/';
}
$returnTo .= 'openid.php';
Expand Down
10 changes: 8 additions & 2 deletions export.php
Expand Up @@ -238,17 +238,23 @@
}

// Generate error url and check for needed variables
/** @var PMA_String $pmaString */
$pmaString = $GLOBALS['PMA_String'];
if ($export_type == 'server') {
$err_url = 'server_export.php?' . PMA_URL_getCommon();
} elseif ($export_type == 'database' && strlen($db)) {
} elseif ($export_type == 'database'
&& $pmaString->strlen($db)
) {
$err_url = 'db_export.php?' . PMA_URL_getCommon($db);
// Check if we have something to export
if (isset($table_select)) {
$tables = $table_select;
} else {
$tables = array();
}
} elseif ($export_type == 'table' && strlen($db) && strlen($table)) {
} elseif ($export_type == 'table' && $pmaString->strlen($db)
&& $pmaString->strlen($table)
) {
$err_url = 'tbl_export.php?' . PMA_URL_getCommon($db, $table);
} else {
PMA_fatalError(__('Bad parameters!'));
Expand Down
14 changes: 12 additions & 2 deletions file_echo.php
Expand Up @@ -41,16 +41,26 @@
$filename = $_REQUEST['filename'];
}

/** @var PMA_String $pmaString */
$pmaString = $GLOBALS['PMA_String'];

/* Decode data */
if ($extension != 'svg') {
$data = substr($_REQUEST['image'], strpos($_REQUEST['image'], ',') + 1);
$data = $pmaString->substr(
$_REQUEST['image'],
$pmaString->strpos($_REQUEST['image'], ',') + 1
);
$data = base64_decode($data);
} else {
$data = $_REQUEST['image'];
}

/* Send download header */
PMA_downloadHeader($filename, $_REQUEST['type'], strlen($data));
PMA_downloadHeader(
$filename,
$_REQUEST['type'],
$pmaString->strlen($data)
);

/* Send data */
echo $data;
Expand Down
15 changes: 10 additions & 5 deletions gis_data_editor.php
Expand Up @@ -40,16 +40,21 @@ function escape($variable)
'GEOMETRYCOLLECTION'
);

/** @var PMA_String $pmaString */
$pmaString = $GLOBALS['PMA_String'];

// Extract type from the initial call and make sure that it's a valid one.
// Extract from field's values if availbale, if not use the column type passed.
// Extract from field's values if available, if not use the column type passed.
if (! isset($gis_data['gis_type'])) {
if (isset($_REQUEST['type']) && $_REQUEST['type'] != '') {
$gis_data['gis_type'] = strtoupper($_REQUEST['type']);
$gis_data['gis_type'] = $pmaString->strtoupper($_REQUEST['type']);
}
if (isset($_REQUEST['value']) && trim($_REQUEST['value']) != '') {
$start = (substr($_REQUEST['value'], 0, 1) == "'") ? 1 : 0;
$gis_data['gis_type'] = substr(
$_REQUEST['value'], $start, strpos($_REQUEST['value'], "(") - $start
$start = ($pmaString->substr($_REQUEST['value'], 0, 1) == "'") ? 1 : 0;
$gis_data['gis_type'] = $pmaString->substr(
$_REQUEST['value'],
$start,
$pmaString->strpos($_REQUEST['value'], "(") - $start
);
}
if ((! isset($gis_data['gis_type']))
Expand Down
32 changes: 18 additions & 14 deletions import.php
Expand Up @@ -97,7 +97,7 @@
// default values
$GLOBALS['reload'] = false;

// Use to identify curren cycle is executing
// Use to identify current cycle is executing
// a multiquery statement or stored routine
if (!isset($_SESSION['is_multi_query'])) {
$_SESSION['is_multi_query'] = false;
Expand Down Expand Up @@ -222,6 +222,8 @@

// We don't want anything special in format
$format = PMA_securePath($format);
/** @var PMA_String $pmaString */
$pmaString = $GLOBALS['PMA_String'];

// Create error and goto url
if ($import_type == 'table') {
Expand All @@ -238,17 +240,17 @@
$goto = 'server_import.php';
} else {
if (empty($goto) || !preg_match('@^(server|db|tbl)(_[a-z]*)*\.php$@i', $goto)) {
if (strlen($table) && strlen($db)) {
if ($pmaString->strlen($table) && $pmaString->strlen($db)) {
$goto = 'tbl_structure.php';
} elseif (strlen($db)) {
} elseif ($pmaString->strlen($db)) {
$goto = 'db_structure.php';
} else {
$goto = 'server_sql.php';
}
}
if (strlen($table) && strlen($db)) {
if ($pmaString->strlen($table) && $pmaString->strlen($db)) {
$common = PMA_URL_getCommon($db, $table);
} elseif (strlen($db)) {
} elseif ($pmaString->strlen($db)) {
$common = PMA_URL_getCommon($db);
} else {
$common = PMA_URL_getCommon();
Expand All @@ -266,7 +268,7 @@
}


if (strlen($db)) {
if ($pmaString->strlen($db)) {
$GLOBALS['dbi']->selectDb($db);
}

Expand Down Expand Up @@ -390,12 +392,13 @@
}

// Calculate value of the limit
if (strtolower(substr($memory_limit, -1)) == 'm') {
$memory_limit = (int)substr($memory_limit, 0, -1) * 1024 * 1024;
} elseif (strtolower(substr($memory_limit, -1)) == 'k') {
$memory_limit = (int)substr($memory_limit, 0, -1) * 1024;
} elseif (strtolower(substr($memory_limit, -1)) == 'g') {
$memory_limit = (int)substr($memory_limit, 0, -1) * 1024 * 1024 * 1024;
if ($pmaString->strtolower($pmaString->substr($memory_limit, -1)) == 'm') {
$memory_limit = (int)$pmaString->substr($memory_limit, 0, -1) * 1024 * 1024;
} elseif ($pmaString->strtolower($pmaString->substr($memory_limit, -1)) == 'k') {
$memory_limit = (int)$pmaString->substr($memory_limit, 0, -1) * 1024;
} elseif ($pmaString->strtolower($pmaString->substr($memory_limit, -1)) == 'g') {
$memory_limit
= (int)$pmaString->substr($memory_limit, 0, -1) * 1024 * 1024 * 1024;
} else {
$memory_limit = (int)$memory_limit;
}
Expand Down Expand Up @@ -584,7 +587,7 @@
$sql_data = array('valid_sql' => array(), 'valid_queries' => 0);

if (! $error) {
// Check for file existance
// Check for file existence
include_once "libraries/plugin_interface.lib.php";
$import_plugin = PMA_getPlugin(
"import",
Expand Down Expand Up @@ -677,7 +680,8 @@
// in case of a query typed in the query window
// (but if the query is too large, in case of an imported file, the parser
// can choke on it so avoid parsing)
if (strlen($sql_query) <= $GLOBALS['cfg']['MaxCharactersInDisplayedSQL']) {
if ($pmaString->strlen($sql_query) <= $GLOBALS['cfg']['MaxCharactersInDisplayedSQL']
) {
include_once 'libraries/parse_analyze.inc.php';
}

Expand Down
10 changes: 8 additions & 2 deletions import_status.php
Expand Up @@ -32,9 +32,12 @@
define('UPLOAD_PREFIX', ini_get('session.upload_progress.prefix'));
session_start();
/** @var PMA_String $pmaString /
$pmaString = $GLOBALS['PMA_String'];
foreach ($_SESSION as $key => $value) {
// only copy session-prefixed data
if (substr($key, 0, strlen(UPLOAD_PREFIX)) == UPLOAD_PREFIX) {
if ($pmaString->substr($key, 0, $pmaString->strlen(UPLOAD_PREFIX))
== UPLOAD_PREFIX) {
$sessionupload[$key] = $value;
}
}
Expand All @@ -61,9 +64,12 @@
$_SESSION[$key] = $value;
}
/** @var PMA_String $pmaString /
$pmaString = $GLOBALS['PMA_String'];
// remove session upload data that are not set anymore
foreach ($_SESSION as $key => $value) {
if (substr($key, 0, strlen(UPLOAD_PREFIX)) == UPLOAD_PREFIX
if ($pmaString->substr($key, 0, $pmaString->strlen(UPLOAD_PREFIX))
== UPLOAD_PREFIX
&& ! isset($sessionupload[$key])
) {
unset($_SESSION[$key]);
Expand Down
13 changes: 9 additions & 4 deletions index.php
Expand Up @@ -553,20 +553,25 @@
&& !PMA_DRIZZLE
&& $cfg['ServerLibraryDifference_DisableWarning'] == false
) {
/** @var PMA_String $pmaString */
$pmaString = $GLOBALS['PMA_String'];

$_client_info = $GLOBALS['dbi']->getClientInfo();
if ($server > 0
&& strpos($_client_info, 'mysqlnd') === false
&& substr(PMA_MYSQL_CLIENT_API, 0, 3) != substr(PMA_MYSQL_INT_VERSION, 0, 3)
&& $pmaString->strpos($_client_info, 'mysqlnd') === false
&& $pmaString->substr(PMA_MYSQL_CLIENT_API, 0, 3) != $pmaString->substr(
PMA_MYSQL_INT_VERSION, 0, 3
)
) {
trigger_error(
PMA_sanitize(
sprintf(
__('Your PHP MySQL library version %s differs from your MySQL server version %s. This may cause unpredictable behavior.'),
$_client_info,
substr(
$pmaString->substr(
PMA_MYSQL_STR_VERSION,
0,
strpos(PMA_MYSQL_STR_VERSION . '-', '-')
$pmaString->strpos(PMA_MYSQL_STR_VERSION . '-', '-')
)
)
),
Expand Down
9 changes: 7 additions & 2 deletions libraries/Advisor.class.php
Expand Up @@ -382,14 +382,17 @@ public static function parseRulesFile()
$ruleNo = -1;
$ruleLine = -1;

/** @var PMA_String $pmaString */
$pmaString = $GLOBALS['PMA_String'];

for ($i = 0; $i < $numLines; $i++) {
$line = $file[$i];
if ($line == "" || $line[0] == '#') {
continue;
}

// Reading new rule
if (substr($line, 0, 4) == 'rule') {
if ($pmaString->substr($line, 0, 4) == 'rule') {
if ($ruleLine > 0) {
$errors[] = sprintf(
__(
Expand Down Expand Up @@ -443,7 +446,9 @@ public static function parseRulesFile()
);
continue;
}
$rules[$ruleNo][$ruleSyntax[$ruleLine]] = chop(substr($line, 1));
$rules[$ruleNo][$ruleSyntax[$ruleLine]] = chop(
$pmaString->substr($line, 1)
);
$lines[$ruleNo][$ruleSyntax[$ruleLine]] = $i + 1;
$ruleLine += 1;
}
Expand Down

4 comments on commit 9b77d74

@atul516
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hi Hugues,

This commit is causing related bugs 4532/4533/4534.

@lem9
Copy link
Contributor

@lem9 lem9 commented on 9b77d74 Sep 17, 2014

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hi Hugues,
see https://sourceforge.net/p/phpmyadmin/bugs/4536/ (I attached a smaller sample table to import).

@chirayuchiripal
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hi Hugues,

Git bisect says this commit is causing bug 4533 (https://sourceforge.net/p/phpmyadmin/bugs/4533/).

@lem9
Copy link
Contributor

@lem9 lem9 commented on 9b77d74 Jun 29, 2015

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please sign in to comment.