diff --git a/db_export.php b/db_export.php
index b04a8b0193..05df8d9767 100644
--- a/db_export.php
+++ b/db_export.php
@@ -24,6 +24,8 @@ $header = $response->getHeader();
$scripts = $header->getScripts();
$scripts->addFile('export.js');
+$export = new Export();
+
// $sub_part is used in Util::getDbInfo() to see if we are coming from
// db_export.php, in which case we don't obey $cfg['MaxTableList']
$sub_part = '_export';
@@ -95,25 +97,25 @@ foreach (array('table_select', 'table_structure', 'table_data') as $one_key) {
foreach ($tables as $each_table) {
if (isset($_GET['table_select']) && is_array($_GET['table_select'])) {
- $is_checked = Export::getCheckedClause(
+ $is_checked = $export->getCheckedClause(
$each_table['Name'], $_GET['table_select']
);
} elseif (isset($table_select)) {
- $is_checked = Export::getCheckedClause(
+ $is_checked = $export->getCheckedClause(
$each_table['Name'], $table_select
);
} else {
$is_checked = ' checked="checked"';
}
if (isset($_GET['table_structure']) && is_array($_GET['table_structure'])) {
- $structure_checked = Export::getCheckedClause(
+ $structure_checked = $export->getCheckedClause(
$each_table['Name'], $_GET['table_structure']
);
} else {
$structure_checked = $is_checked;
}
if (isset($_GET['table_data']) && is_array($_GET['table_data'])) {
- $data_checked = Export::getCheckedClause(
+ $data_checked = $export->getCheckedClause(
$each_table['Name'], $_GET['table_data']
);
} else {
diff --git a/db_import.php b/db_import.php
index 0ec1d49ef6..e61bae6131 100644
--- a/db_import.php
+++ b/db_import.php
@@ -19,6 +19,8 @@ $header = $response->getHeader();
$scripts = $header->getScripts();
$scripts->addFile('import.js');
+$import = new Import();
+
/**
* Gets tables information and displays top links
*/
@@ -38,7 +40,7 @@ list(
$response = Response::getInstance();
$response->addHTML(
- Import::get(
+ $import->get(
'database', $db, $table, $max_upload_size
)
);
diff --git a/export.php b/export.php
index 376bd020c2..e1255ae631 100644
--- a/export.php
+++ b/export.php
@@ -35,6 +35,8 @@ $header = $response->getHeader();
$scripts = $header->getScripts();
$scripts->addFile('export_output.js');
+$export = new Export();
+
//check if it's the GET request to check export time out
if (isset($_GET['check_time_out'])) {
if (isset($_SESSION['pma_export_error'])) {
@@ -298,7 +300,7 @@ if ((!empty($parser->statements[0]))
$aliases = \PhpMyAdmin\SqlParser\Utils\Misc::getAliases($parser->statements[0], $db);
}
if (!empty($_REQUEST['aliases'])) {
- $aliases = Export::mergeAliases($aliases, $_REQUEST['aliases']);
+ $aliases = $export->mergeAliases($aliases, $_REQUEST['aliases']);
$_SESSION['tmpval']['aliases'] = $_REQUEST['aliases'];
}
@@ -309,7 +311,7 @@ Util::setTimeLimit();
if (! empty($cfg['MemoryLimit'])) {
ini_set('memory_limit', $cfg['MemoryLimit']);
}
-register_shutdown_function('PhpMyAdmin\Export::shutdown');
+register_shutdown_function([$export, 'shutdown']);
// Start with empty buffer
$dump_buffer = '';
$dump_buffer_len = 0;
@@ -339,7 +341,7 @@ $output_charset_conversion = $asfile
$GLOBALS['onfly_compression'] = $GLOBALS['cfg']['CompressOnFly']
&& $compression == 'gzip';
if ($GLOBALS['onfly_compression']) {
- $GLOBALS['memory_limit'] = Export::getMemoryLimit();
+ $GLOBALS['memory_limit'] = $export->getMemoryLimit();
}
// Generate filename and mime type if needed
@@ -347,7 +349,7 @@ if ($asfile) {
if (empty($remember_template)) {
$remember_template = '';
}
- list($filename, $mime_type) = Export::getFilenameAndMimetype(
+ list($filename, $mime_type) = $export->getFilenameAndMimetype(
$export_type, $remember_template, $export_plugin, $compression,
$filename_template
);
@@ -357,13 +359,13 @@ if ($asfile) {
// Open file on server if needed
if ($save_on_server) {
- list($save_filename, $message, $file_handle) = Export::openFile(
+ list($save_filename, $message, $file_handle) = $export->openFile(
$filename, $quick_export
);
// problem opening export file on server?
if (! empty($message)) {
- Export::showPage($db, $table, $export_type);
+ $export->showPage($db, $table, $export_type);
}
} else {
/**
@@ -391,7 +393,7 @@ if ($save_on_server) {
exit();
}
}
- list($html, $back_button, $refreshButton) = Export::getHtmlForDisplayedExportHeader(
+ list($html, $back_button, $refreshButton) = $export->getHtmlForDisplayedExportHeader(
$export_type, $db, $table
);
echo $html;
@@ -434,7 +436,7 @@ do {
if (! isset($db_select)) {
$db_select = '';
}
- Export::exportServer(
+ $export->exportServer(
$db_select, $whatStrucOrData, $export_plugin, $crlf, $err_url,
$export_type, $do_relation, $do_comments, $do_mime, $do_dates,
$aliases, $separate_files
@@ -451,19 +453,19 @@ do {
$table_data = $tables;
}
if (isset($lock_tables)) {
- Export::lockTables($db, $tables, "READ");
+ $export->lockTables($db, $tables, "READ");
try {
- Export::exportDatabase(
+ $export->exportDatabase(
$db, $tables, $whatStrucOrData, $table_structure,
$table_data, $export_plugin, $crlf, $err_url, $export_type,
$do_relation, $do_comments, $do_mime, $do_dates, $aliases,
$separate_files
);
} finally {
- Export::unlockTables();
+ $export->unlockTables();
}
} else {
- Export::exportDatabase(
+ $export->exportDatabase(
$db, $tables, $whatStrucOrData, $table_structure, $table_data,
$export_plugin, $crlf, $err_url, $export_type, $do_relation,
$do_comments, $do_mime, $do_dates, $aliases, $separate_files
@@ -483,18 +485,18 @@ do {
}
if (isset($lock_tables)) {
try {
- Export::lockTables($db, array($table), "READ");
- Export::exportTable(
+ $export->lockTables($db, array($table), "READ");
+ $export->exportTable(
$db, $table, $whatStrucOrData, $export_plugin, $crlf,
$err_url, $export_type, $do_relation, $do_comments,
$do_mime, $do_dates, $allrows, $limit_to, $limit_from,
$sql_query, $aliases
);
} finally {
- Export::unlockTables();
+ $export->unlockTables();
}
} else {
- Export::exportTable(
+ $export->exportTable(
$db, $table, $whatStrucOrData, $export_plugin, $crlf, $err_url,
$export_type, $do_relation, $do_comments, $do_mime, $do_dates,
$allrows, $limit_to, $limit_from, $sql_query, $aliases
@@ -509,14 +511,14 @@ do {
// End of fake loop
if ($save_on_server && ! empty($message)) {
- Export::showPage($db, $table, $export_type);
+ $export->showPage($db, $table, $export_type);
}
/**
* Send the dump as a file...
*/
if (empty($asfile)) {
- echo Export::getHtmlForDisplayedExportFooter($back_button, $refreshButton);
+ echo $export->getHtmlForDisplayedExportFooter($back_button, $refreshButton);
return;
} // end if
@@ -532,21 +534,21 @@ if ($output_charset_conversion) {
// Compression needed?
if ($compression) {
if (! empty($separate_files)) {
- $dump_buffer = Export::compress(
+ $dump_buffer = $export->compress(
$dump_buffer_objects, $compression, $filename
);
} else {
- $dump_buffer = Export::compress($dump_buffer, $compression, $filename);
+ $dump_buffer = $export->compress($dump_buffer, $compression, $filename);
}
}
/* If we saved on server, we have to close file now */
if ($save_on_server) {
- $message = Export::closeFile(
+ $message = $export->closeFile(
$file_handle, $dump_buffer, $save_filename
);
- Export::showPage($db, $table, $export_type);
+ $export->showPage($db, $table, $export_type);
} else {
echo $dump_buffer;
}
diff --git a/import.php b/import.php
index 75ba6d685c..d53de967fb 100644
--- a/import.php
+++ b/import.php
@@ -29,13 +29,15 @@ if (isset($_POST['format']) && $_POST['format'] == 'ldi') {
*/
require_once 'libraries/common.inc.php';
+$import = new Import();
+
if (isset($_REQUEST['show_as_php'])) {
$GLOBALS['show_as_php'] = $_REQUEST['show_as_php'];
}
// If there is a request to 'Simulate DML'.
if (isset($_REQUEST['simulate_dml'])) {
- Import::handleSimulateDmlRequest();
+ $import->handleSimulateDmlRequest();
exit;
}
@@ -154,7 +156,7 @@ if (! empty($sql_query)) {
// If there is a request to ROLLBACK when finished.
if (isset($_REQUEST['rollback_query'])) {
- Import::handleRollbackRequest($import_text);
+ $import->handleRollbackRequest($import_text);
}
// refresh navigation and main panels
@@ -483,12 +485,12 @@ if ($import_file != 'none' && ! $error) {
$import_handle = new File($import_file);
$import_handle->checkUploadedFile();
if ($import_handle->isError()) {
- Import::stop($import_handle->getError());
+ $import->stop($import_handle->getError());
}
$import_handle->setDecompressContent(true);
$import_handle->open();
if ($import_handle->isError()) {
- Import::stop($import_handle->getError());
+ $import->stop($import_handle->getError());
}
} elseif (! $error) {
if (! isset($import_text) || empty($import_text)) {
@@ -499,7 +501,7 @@ if ($import_file != 'none' && ! $error) {
'by your PHP configuration. See [doc@faq1-16]FAQ 1.16[/doc].'
)
);
- Import::stop($message);
+ $import->stop($message);
}
}
@@ -522,7 +524,7 @@ if (Encoding::isSupported() && isset($charset_of_file)) {
if (! $error && isset($_POST['skip'])) {
$original_skip = $skip = intval($_POST['skip']);
while ($skip > 0 && ! $finished) {
- Import::getNextChunk($skip < $read_limit ? $skip : $read_limit);
+ $import->getNextChunk($skip < $read_limit ? $skip : $read_limit);
// Disable read progressivity, otherwise we eat all memory!
$read_multiply = 1;
$skip -= $read_limit;
@@ -546,7 +548,7 @@ if (! $error) {
$message = PhpMyAdmin\Message::error(
__('Could not load import plugins, please check your installation!')
);
- Import::stop($message);
+ $import->stop($message);
} else {
// Do the real import
try {
diff --git a/libraries/classes/Display/Results.php b/libraries/classes/Display/Results.php
index 7b772145bc..20619259ed 100644
--- a/libraries/classes/Display/Results.php
+++ b/libraries/classes/Display/Results.php
@@ -4938,7 +4938,7 @@ class Results
// Export link
// (the url_query has extra parameters that won't be used to export)
- // (the single_table parameter is used in Export::getDisplay()
+ // (the single_table parameter is used in \PhpMyAdmin\Export->getDisplay()
// to hide the SQL and the structure export dialogs)
// If the parser found a PROCEDURE clause
// (most probably PROCEDURE ANALYSE()) it makes no sense to
diff --git a/libraries/classes/Export.php b/libraries/classes/Export.php
index 1f48b5f0c9..71cbfe50e2 100644
--- a/libraries/classes/Export.php
+++ b/libraries/classes/Export.php
@@ -30,7 +30,7 @@ class Export
*
* @return void
*/
- public static function shutdown()
+ public function shutdown()
{
$error = error_get_last();
if ($error != null && mb_strpos($error['message'], "execution time")) {
@@ -44,7 +44,7 @@ class Export
*
* @return bool
*/
- public static function isGzHandlerEnabled()
+ public function isGzHandlerEnabled()
{
return in_array('ob_gzhandler', ob_list_handlers());
}
@@ -55,7 +55,7 @@ class Export
*
* @return bool Whether gzencode is needed
*/
- public static function gzencodeNeeded()
+ public function gzencodeNeeded()
{
/*
* We should gzencode only if the function exists
@@ -69,7 +69,7 @@ class Export
if (function_exists('gzencode')
&& ((! ini_get('zlib.output_compression')
- && ! self::isGzHandlerEnabled())
+ && ! $this->isGzHandlerEnabled())
|| $GLOBALS['save_on_server']
|| $chromeAndGreaterThan43)
) {
@@ -87,7 +87,7 @@ class Export
*
* @return bool Whether output succeeded
*/
- public static function outputHandler($line)
+ public function outputHandler($line)
{
global $time_start, $dump_buffer, $dump_buffer_len, $save_filename;
@@ -117,7 +117,7 @@ class Export
);
}
if ($GLOBALS['compression'] == 'gzip'
- && self::gzencodeNeeded()
+ && $this->gzencodeNeeded()
) {
// as a gzipped file
// without the optional parameter level because it bugs
@@ -184,7 +184,7 @@ class Export
}
}
return true;
- } // end of the 'self::outputHandler()' function
+ }
/**
* Returns HTML containing the footer for a displayed export
@@ -194,7 +194,7 @@ class Export
*
* @return string $html the HTML output
*/
- public static function getHtmlForDisplayedExportFooter($back_button, $refreshButton)
+ public function getHtmlForDisplayedExportFooter($back_button, $refreshButton)
{
/**
* Close the html tags and add the footers for on-screen export
@@ -222,7 +222,7 @@ class Export
*
* @return int $memory_limit the memory limit
*/
- public static function getMemoryLimit()
+ public function getMemoryLimit()
{
$memory_limit = trim(ini_get('memory_limit'));
$memory_limit_num = (int)substr($memory_limit, 0, -1);
@@ -263,7 +263,7 @@ class Export
*
* @return string[] the filename template and mime type
*/
- public static function getFilenameAndMimetype(
+ public function getFilenameAndMimetype(
$export_type, $remember_template, $export_plugin, $compression,
$filename_template
) {
@@ -332,7 +332,7 @@ class Export
*
* @return array the full save filename, possible message and the file handle
*/
- public static function openFile($filename, $quick_export)
+ public function openFile($filename, $quick_export)
{
$file_handle = null;
$message = '';
@@ -381,7 +381,7 @@ class Export
*
* @return Message $message a message object (or empty string)
*/
- public static function closeFile($file_handle, $dump_buffer, $save_filename)
+ public function closeFile($file_handle, $dump_buffer, $save_filename)
{
$write_result = @fwrite($file_handle, $dump_buffer);
fclose($file_handle);
@@ -414,13 +414,13 @@ class Export
*
* @return object $message a message object (or empty string)
*/
- public static function compress($dump_buffer, $compression, $filename)
+ public function compress($dump_buffer, $compression, $filename)
{
if ($compression == 'zip' && function_exists('gzcompress')) {
$zipExtension = new ZipExtension();
$filename = substr($filename, 0, -4); // remove extension (.zip)
$dump_buffer = $zipExtension->createFile($dump_buffer, $filename);
- } elseif ($compression == 'gzip' && self::gzencodeNeeded()) {
+ } elseif ($compression == 'gzip' && $this->gzencodeNeeded()) {
// without the optional parameter level because it bugs
$dump_buffer = gzencode($dump_buffer);
}
@@ -436,7 +436,7 @@ class Export
*
* @return void
*/
- public static function saveObjectInBuffer($object_name, $append = false)
+ public function saveObjectInBuffer($object_name, $append = false)
{
global $dump_buffer_objects, $dump_buffer, $dump_buffer_len;
@@ -464,7 +464,7 @@ class Export
*
* @return string[] the generated HTML and back button
*/
- public static function getHtmlForDisplayedExportHeader($export_type, $db, $table)
+ public function getHtmlForDisplayedExportHeader($export_type, $db, $table)
{
$html = '
';
@@ -555,7 +555,7 @@ class Export
*
* @return void
*/
- public static function exportServer(
+ public function exportServer(
$db_select, $whatStrucOrData, $export_plugin, $crlf, $err_url,
$export_type, $do_relation, $do_comments, $do_mime, $do_dates,
array $aliases, $separate_files
@@ -570,14 +570,14 @@ class Export
&& mb_strpos(' ' . $tmp_select, '|' . $current_db . '|')
) {
$tables = $GLOBALS['dbi']->getTables($current_db);
- self::exportDatabase(
+ $this->exportDatabase(
$current_db, $tables, $whatStrucOrData, $tables, $tables,
$export_plugin, $crlf, $err_url, $export_type, $do_relation,
$do_comments, $do_mime, $do_dates, $aliases,
$separate_files == 'database' ? $separate_files : ''
);
if ($separate_files == 'server') {
- self::saveObjectInBuffer($current_db);
+ $this->saveObjectInBuffer($current_db);
}
}
} // end foreach database
@@ -604,7 +604,7 @@ class Export
*
* @return void
*/
- public static function exportDatabase(
+ public function exportDatabase(
$db, array $tables, $whatStrucOrData, array $table_structure, array $table_data,
$export_plugin, $crlf, $err_url, $export_type, $do_relation,
$do_comments, $do_mime, $do_dates, array $aliases, $separate_files
@@ -619,7 +619,7 @@ class Export
return;
}
if ($separate_files == 'database') {
- self::saveObjectInBuffer('database', true);
+ $this->saveObjectInBuffer('database', true);
}
if (($GLOBALS['sql_structure_or_data'] == 'structure'
@@ -629,7 +629,7 @@ class Export
$export_plugin->exportRoutines($db, $aliases);
if ($separate_files == 'database') {
- self::saveObjectInBuffer('routines');
+ $this->saveObjectInBuffer('routines');
}
}
@@ -712,7 +712,7 @@ class Export
// this buffer was filled, we save it and go to the next one
if ($separate_files == 'database') {
- self::saveObjectInBuffer('table_' . $table);
+ $this->saveObjectInBuffer('table_' . $table);
}
// now export the triggers (needs to be done after the data because
@@ -730,7 +730,7 @@ class Export
}
if ($separate_files == 'database') {
- self::saveObjectInBuffer('table_' . $table, true);
+ $this->saveObjectInBuffer('table_' . $table, true);
}
}
@@ -752,7 +752,7 @@ class Export
}
if ($separate_files == 'database') {
- self::saveObjectInBuffer('view_' . $view);
+ $this->saveObjectInBuffer('view_' . $view);
}
}
}
@@ -767,16 +767,16 @@ class Export
if (isset($GLOBALS['sql_metadata'])) {
// Types of metadata to export.
// In the future these can be allowed to be selected by the user
- $metadataTypes = self::getMetadataTypes();
+ $metadataTypes = $this->getMetadataTypes();
$export_plugin->exportMetadata($db, $tables, $metadataTypes);
if ($separate_files == 'database') {
- self::saveObjectInBuffer('metadata');
+ $this->saveObjectInBuffer('metadata');
}
}
if ($separate_files == 'database') {
- self::saveObjectInBuffer('extra');
+ $this->saveObjectInBuffer('extra');
}
if (($GLOBALS['sql_structure_or_data'] == 'structure'
@@ -786,7 +786,7 @@ class Export
$export_plugin->exportEvents($db);
if ($separate_files == 'database') {
- self::saveObjectInBuffer('events');
+ $this->saveObjectInBuffer('events');
}
}
}
@@ -813,7 +813,7 @@ class Export
*
* @return void
*/
- public static function exportTable(
+ public function exportTable(
$db, $table, $whatStrucOrData, $export_plugin, $crlf, $err_url,
$export_type, $do_relation, $do_comments, $do_mime, $do_dates,
$allrows, $limit_to, $limit_from, $sql_query, array $aliases
@@ -915,7 +915,7 @@ class Export
if (isset($GLOBALS['sql_metadata'])) {
// Types of metadata to export.
// In the future these can be allowed to be selected by the user
- $metadataTypes = self::getMetadataTypes();
+ $metadataTypes = $this->getMetadataTypes();
$export_plugin->exportMetadata($db, $table, $metadataTypes);
}
}
@@ -929,7 +929,7 @@ class Export
*
* @return void
*/
- public static function showPage($db, $table, $export_type)
+ public function showPage($db, $table, $export_type)
{
global $cfg;
if ($export_type == 'server') {
@@ -955,7 +955,7 @@ class Export
*
* @return array resultant merged aliases info
*/
- public static function mergeAliases(array $aliases1, array $aliases2)
+ public function mergeAliases(array $aliases1, array $aliases2)
{
// First do a recursive array merge
// on aliases arrays.
@@ -1008,7 +1008,7 @@ class Export
*
* @return mixed result of the query
*/
- public static function lockTables($db, array $tables, $lockType = "WRITE")
+ public function lockTables($db, array $tables, $lockType = "WRITE")
{
$locks = array();
foreach ($tables as $table) {
@@ -1025,7 +1025,7 @@ class Export
*
* @return mixed result of the query
*/
- public static function unlockTables()
+ public function unlockTables()
{
return $GLOBALS['dbi']->tryQuery("UNLOCK TABLES");
}
@@ -1035,7 +1035,7 @@ class Export
*
* @return string[] metadata types.
*/
- public static function getMetadataTypes()
+ public function getMetadataTypes()
{
return array(
'column_info',
@@ -1059,7 +1059,7 @@ class Export
*
* @return string the checked clause
*/
- public static function getCheckedClause($key, array $array)
+ public function getCheckedClause($key, array $array)
{
if (in_array($key, $array)) {
return ' checked="checked"';
@@ -1076,7 +1076,7 @@ class Export
*
* @return void
*/
- public static function processExportSchema($export_type)
+ public function processExportSchema($export_type)
{
/**
* default is PDF, otherwise validate it's only letters a-z
diff --git a/libraries/classes/Import.php b/libraries/classes/Import.php
index 7456685401..10726da8a8 100644
--- a/libraries/classes/Import.php
+++ b/libraries/classes/Import.php
@@ -59,7 +59,7 @@ class Import
* @return boolean true if timeout is close
* @access public
*/
- public static function checkTimeout()
+ public function checkTimeout()
{
global $timestamp, $maximum_time, $timeout_passed;
if ($maximum_time == 0) {
@@ -86,7 +86,7 @@ class Import
* @return void
* @access public
*/
- public static function executeQuery($sql, $full, array &$sql_data)
+ public function executeQuery($sql, $full, array &$sql_data)
{
global $go_sql,
$sql_query, $my_die, $error, $reload,
@@ -147,7 +147,7 @@ class Import
// If a 'USE ' SQL-clause was found and the query
// succeeded, set our current $db to the new one
if ($result != false) {
- list($db, $reload) = self::lookForUse(
+ list($db, $reload) = $this->lookForUse(
$sql,
$db,
$reload
@@ -174,7 +174,7 @@ class Import
* @return void
* @access public
*/
- public static function runQuery($sql = '', $full = '', array &$sql_data = array())
+ public function runQuery($sql = '', $full = '', array &$sql_data = array())
{
global $import_run_buffer, $go_sql, $complete_query, $display_query,
$sql_query, $error, $reload, $result, $msg,
@@ -183,7 +183,7 @@ class Import
$read_multiply = 1;
if (!isset($import_run_buffer)) {
// Do we have something to push into buffer?
- $import_run_buffer = self::runQueryPost(
+ $import_run_buffer = $this->runQueryPost(
$import_run_buffer, $sql, $full
);
return;
@@ -193,7 +193,7 @@ class Import
if ($skip_queries > 0) {
$skip_queries--;
// Do we have something to push into buffer?
- $import_run_buffer = self::runQueryPost(
+ $import_run_buffer = $this->runQueryPost(
$import_run_buffer, $sql, $full
);
return;
@@ -242,7 +242,7 @@ class Import
$sql_data['valid_queries'] = 0;
unset($sql_data['valid_full']);
for ($i = 0; $i < $count; $i++) {
- self::executeQuery(
+ $this->executeQuery(
$queries[$i],
$fulls[$i],
$sql_data
@@ -250,7 +250,7 @@ class Import
}
}
- self::executeQuery(
+ $this->executeQuery(
$import_run_buffer['sql'],
$import_run_buffer['full'],
$sql_data
@@ -283,7 +283,7 @@ class Import
}
// Do we have something to push into buffer?
- $import_run_buffer = self::runQueryPost($import_run_buffer, $sql, $full);
+ $import_run_buffer = $this->runQueryPost($import_run_buffer, $sql, $full);
// In case of ROLLBACK, notify the user.
if (isset($_REQUEST['rollback_query'])) {
@@ -300,7 +300,7 @@ class Import
*
* @return array Buffer of queries for import
*/
- public static function runQueryPost($import_run_buffer, $sql, $full)
+ public function runQueryPost($import_run_buffer, $sql, $full)
{
if (!empty($sql) || !empty($full)) {
$import_run_buffer = array('sql' => $sql, 'full' => $full);
@@ -321,15 +321,15 @@ class Import
* @return array (current or new db, whether to reload)
* @access public
*/
- public static function lookForUse($buffer, $db, $reload)
+ public function lookForUse($buffer, $db, $reload)
{
if (preg_match('@^[\s]*USE[[:space:]]+([\S]+)@i', $buffer, $match)) {
$db = trim($match[1]);
$db = trim($db, ';'); // for example, USE abc;
// $db must not contain the escape characters generated by backquote()
- // ( used in self::buildSql() as: backquote($db_name), and then called
- // in self::runQuery() which in turn calls self::lookForUse() )
+ // ( used in buildSql() as: backquote($db_name), and then called
+ // in runQuery() which in turn calls lookForUse() )
$db = Util::unQuote($db);
$reload = true;
@@ -347,7 +347,7 @@ class Import
* @return string part of file/buffer
* @access public
*/
- public static function getNextChunk($size = 32768)
+ public function getNextChunk($size = 32768)
{
global $compression, $import_handle, $charset_conversion, $charset_of_file,
$read_multiply;
@@ -365,7 +365,7 @@ class Import
$size = $GLOBALS['read_limit'];
}
- if (self::checkTimeout()) {
+ if ($this->checkTimeout()) {
return false;
}
if ($GLOBALS['finished']) {
@@ -440,7 +440,7 @@ class Import
* @return string The column's "Excel" name
* @access public
*/
- public static function getColumnAlphaName($num)
+ public function getColumnAlphaName($num)
{
$A = 65; // ASCII value for capital "A"
$col_name = "";
@@ -456,7 +456,7 @@ class Import
}
// recursive function call
- $col_name = self::getColumnAlphaName($div);
+ $col_name = $this->getColumnAlphaName($div);
// use modulus as new column number
$num = $remain;
}
@@ -487,7 +487,7 @@ class Import
* @return int The column number
* @access public
*/
- public static function getColumnNumberFromName($name)
+ public function getColumnNumberFromName($name)
{
if (empty($name)) {
return 0;
@@ -522,7 +522,7 @@ class Import
* @return int Precision of the given decimal size notation
* @access public
*/
- public static function getDecimalPrecision($last_cumulative_size)
+ public function getDecimalPrecision($last_cumulative_size)
{
return (int)substr(
$last_cumulative_size,
@@ -540,7 +540,7 @@ class Import
* @return int Scale of the given decimal size notation
* @access public
*/
- public static function getDecimalScale($last_cumulative_size)
+ public function getDecimalScale($last_cumulative_size)
{
return (int)substr(
$last_cumulative_size,
@@ -558,7 +558,7 @@ class Import
* representation of the given decimal cell
* @access public
*/
- public static function getDecimalSize($cell)
+ public function getDecimalSize($cell)
{
$curr_size = mb_strlen((string)$cell);
$decPos = mb_strpos($cell, ".");
@@ -585,7 +585,7 @@ class Import
*
* @todo Handle the error cases more elegantly
*/
- public static function detectSize($last_cumulative_size, $last_cumulative_type,
+ public function detectSize($last_cumulative_size, $last_cumulative_type,
$curr_type, $cell
) {
$curr_size = mb_strlen((string)$cell);
@@ -612,7 +612,7 @@ class Import
/**
* The last cumulative type was DECIMAL
*/
- $oldM = self::getDecimalPrecision($last_cumulative_size);
+ $oldM = $this->getDecimalPrecision($last_cumulative_size);
if ($curr_size >= $oldM) {
return $curr_size;
@@ -652,7 +652,7 @@ class Import
*/
if ($last_cumulative_type == self::VARCHAR) {
/* Convert $last_cumulative_size from varchar to decimal format */
- $size = self::getDecimalSize($cell);
+ $size = $this->getDecimalSize($cell);
if ($size[self::M] >= $last_cumulative_size) {
return $size[self::M];
@@ -663,10 +663,10 @@ class Import
/**
* The last cumulative type was DECIMAL
*/
- $size = self::getDecimalSize($cell);
+ $size = $this->getDecimalSize($cell);
- $oldM = self::getDecimalPrecision($last_cumulative_size);
- $oldD = self::getDecimalScale($last_cumulative_size);
+ $oldM = $this->getDecimalPrecision($last_cumulative_size);
+ $oldD = $this->getDecimalScale($last_cumulative_size);
/* New val if M or D is greater than current largest */
if ($size[self::M] > $oldM || $size[self::D] > $oldD) {
@@ -681,7 +681,7 @@ class Import
* The last cumulative type was BIGINT or INT
*/
/* Convert $last_cumulative_size from int to decimal format */
- $size = self::getDecimalSize($cell);
+ $size = $this->getDecimalSize($cell);
if ($size[self::M] >= $last_cumulative_size) {
return $size[self::FULL];
@@ -693,7 +693,7 @@ class Import
* This is the first row to be analyzed
*/
/* First row of the column */
- $size = self::getDecimalSize($cell);
+ $size = $this->getDecimalSize($cell);
return $size[self::FULL];
}
@@ -723,8 +723,8 @@ class Import
/**
* The last cumulative type was DECIMAL
*/
- $oldM = self::getDecimalPrecision($last_cumulative_size);
- $oldD = self::getDecimalScale($last_cumulative_size);
+ $oldM = $this->getDecimalPrecision($last_cumulative_size);
+ $oldD = $this->getDecimalScale($last_cumulative_size);
$oldInt = $oldM - $oldD;
$newInt = mb_strlen((string)$cell);
@@ -784,7 +784,7 @@ class Import
* (VARCHAR or INT or BIGINT or DECIMAL or NONE)
* @access public
*/
- public static function detectType($last_cumulative_type, $cell)
+ public function detectType($last_cumulative_type, $cell)
{
/**
* If numeric, determine if decimal, int or bigint
@@ -829,7 +829,7 @@ class Import
*
* @todo Handle the error case more elegantly
*/
- public static function analyzeTable(array &$table)
+ public function analyzeTable(array &$table)
{
/* Get number of rows in table */
$numRows = count($table[self::ROWS]);
@@ -867,9 +867,9 @@ class Import
/* Analyze the column in each row */
for ($j = 0; $j < $numRows; ++$j) {
/* Determine type of the current cell */
- $curr_type = self::detectType($types[$i], $table[self::ROWS][$j][$i]);
+ $curr_type = $this->detectType($types[$i], $table[self::ROWS][$j][$i]);
/* Determine size of the current cell */
- $sizes[$i] = self::detectSize(
+ $sizes[$i] = $this->detectSize(
$sizes[$i],
$types[$i],
$curr_type,
@@ -931,7 +931,7 @@ class Import
*
* @link https://wiki.phpmyadmin.net/pma/Import
*/
- public static function buildSql($db_name, array &$tables, &$analyses = null,
+ public function buildSql($db_name, array &$tables, &$analyses = null,
&$additional_sql = null, $options = null, array &$sql_data
) {
/* Needed to quell the beast that is Message */
@@ -975,7 +975,7 @@ class Import
/* Execute the SQL statements create above */
$sql_len = count($sql);
for ($i = 0; $i < $sql_len; ++$i) {
- self::runQuery($sql[$i], $sql[$i], $sql_data);
+ $this->runQuery($sql[$i], $sql[$i], $sql_data);
}
/* No longer needed */
@@ -1010,7 +1010,7 @@ class Import
$additional_sql[$i]
);
/* Execute the resulting statements */
- self::runQuery($additional_sql[$i], $additional_sql[$i], $sql_data);
+ $this->runQuery($additional_sql[$i], $additional_sql[$i], $sql_data);
}
}
@@ -1062,7 +1062,7 @@ class Import
* after it is formed so that we don't have
* to store them in a (possibly large) buffer
*/
- self::runQuery($tempSQLStr, $tempSQLStr, $sql_data);
+ $this->runQuery($tempSQLStr, $tempSQLStr, $sql_data);
}
}
@@ -1153,7 +1153,7 @@ class Import
* after it is formed so that we don't have
* to store them in a (possibly large) buffer
*/
- self::runQuery($tempSQLStr, $tempSQLStr, $sql_data);
+ $this->runQuery($tempSQLStr, $tempSQLStr, $sql_data);
}
/* No longer needed */
@@ -1310,7 +1310,7 @@ class Import
* @access public
*
*/
- public static function stop(Message $error_message)
+ public function stop(Message $error_message)
{
global $import_handle, $file_to_unlink;
@@ -1338,7 +1338,7 @@ class Import
*
* @return void
*/
- public static function handleSimulateDmlRequest()
+ public function handleSimulateDmlRequest()
{
$response = Response::getInstance();
$error = false;
@@ -1381,7 +1381,7 @@ class Import
}
// Get the matched rows for the query.
- $result = self::getMatchedRows($analyzed_sql_results);
+ $result = $this->getMatchedRows($analyzed_sql_results);
if (! $error = $GLOBALS['dbi']->getError()) {
$sql_data[] = $result;
} else {
@@ -1405,19 +1405,19 @@ class Import
*
* @return mixed
*/
- public static function getMatchedRows(array $analyzed_sql_results = array())
+ public function getMatchedRows(array $analyzed_sql_results = array())
{
$statement = $analyzed_sql_results['statement'];
$matched_row_query = '';
if ($statement instanceof DeleteStatement) {
- $matched_row_query = self::getSimulatedDeleteQuery($analyzed_sql_results);
+ $matched_row_query = $this->getSimulatedDeleteQuery($analyzed_sql_results);
} elseif ($statement instanceof UpdateStatement) {
- $matched_row_query = self::getSimulatedUpdateQuery($analyzed_sql_results);
+ $matched_row_query = $this->getSimulatedUpdateQuery($analyzed_sql_results);
}
// Execute the query and get the number of matched rows.
- $matched_rows = self::executeMatchedRowQuery($matched_row_query);
+ $matched_rows = $this->executeMatchedRowQuery($matched_row_query);
// URL to matched rows.
$_url_params = array(
@@ -1440,7 +1440,7 @@ class Import
*
* @return string SQL query
*/
- public static function getSimulatedUpdateQuery(array $analyzed_sql_results)
+ public function getSimulatedUpdateQuery(array $analyzed_sql_results)
{
$table_references = Query::getTables(
$analyzed_sql_results['statement']
@@ -1496,7 +1496,7 @@ class Import
*
* @return string SQL query
*/
- public static function getSimulatedDeleteQuery(array $analyzed_sql_results)
+ public function getSimulatedDeleteQuery(array $analyzed_sql_results)
{
$table_references = Query::getTables(
$analyzed_sql_results['statement']
@@ -1541,7 +1541,7 @@ class Import
*
* @return integer Number of rows returned
*/
- public static function executeMatchedRowQuery($matched_row_query)
+ public function executeMatchedRowQuery($matched_row_query)
{
$GLOBALS['dbi']->selectDb($GLOBALS['db']);
// Execute the query.
@@ -1559,7 +1559,7 @@ class Import
*
* @return void
*/
- public static function handleRollbackRequest($sql_query)
+ public function handleRollbackRequest($sql_query)
{
$sql_delimiter = $_REQUEST['sql_delimiter'];
$queries = explode($sql_delimiter, $sql_query);
@@ -1574,7 +1574,7 @@ class Import
}
// Check each query for ROLLBACK support.
- if (! self::checkIfRollbackPossible($sql_query)) {
+ if (! $this->checkIfRollbackPossible($sql_query)) {
$global_error = $GLOBALS['dbi']->getError();
if ($global_error) {
$error = $global_error;
@@ -1604,7 +1604,7 @@ class Import
*
* @return bool
*/
- public static function checkIfRollbackPossible($sql_query)
+ public function checkIfRollbackPossible($sql_query)
{
$parser = new Parser($sql_query);
@@ -1628,7 +1628,7 @@ class Import
// Check if each table is 'InnoDB'.
foreach ($tables as $table) {
- if (! self::isTableTransactional($table)) {
+ if (! $this->isTableTransactional($table)) {
return false;
}
}
@@ -1643,7 +1643,7 @@ class Import
*
* @return bool
*/
- public static function isTableTransactional($table)
+ public function isTableTransactional($table)
{
$table = explode('.', $table);
if (count($table) == 2) {
diff --git a/libraries/classes/Plugins/Export/ExportCodegen.php b/libraries/classes/Plugins/Export/ExportCodegen.php
index b2a2763fd4..e00f22462b 100644
--- a/libraries/classes/Plugins/Export/ExportCodegen.php
+++ b/libraries/classes/Plugins/Export/ExportCodegen.php
@@ -44,6 +44,7 @@ class ExportCodegen extends ExportPlugin
*/
public function __construct()
{
+ parent::__construct();
// initialize the specific export CodeGen variables
$this->initSpecificVariables();
$this->setProperties();
@@ -196,12 +197,12 @@ class ExportCodegen extends ExportPlugin
if (isset($CG_FORMATS[$format])) {
$method = $CG_HANDLERS[$format];
- return Export::outputHandler(
+ return $this->export->outputHandler(
$this->$method($db, $table, $crlf, $aliases)
);
}
- return Export::outputHandler(sprintf("%s is not supported.", $format));
+ return $this->export->outputHandler(sprintf("%s is not supported.", $format));
}
/**
diff --git a/libraries/classes/Plugins/Export/ExportCsv.php b/libraries/classes/Plugins/Export/ExportCsv.php
index 13f2c87bad..40effaf1ce 100644
--- a/libraries/classes/Plugins/Export/ExportCsv.php
+++ b/libraries/classes/Plugins/Export/ExportCsv.php
@@ -32,6 +32,7 @@ class ExportCsv extends ExportPlugin
*/
public function __construct()
{
+ parent::__construct();
$this->setProperties();
}
@@ -256,7 +257,7 @@ class ExportCsv extends ExportPlugin
$schema_insert .= $csv_separator;
} // end for
$schema_insert = trim(mb_substr($schema_insert, 0, -1));
- if (!Export::outputHandler($schema_insert . $csv_terminated)) {
+ if (!$this->export->outputHandler($schema_insert . $csv_terminated)) {
return false;
}
} // end if
@@ -321,7 +322,7 @@ class ExportCsv extends ExportPlugin
}
} // end for
- if (!Export::outputHandler($schema_insert . $csv_terminated)) {
+ if (!$this->export->outputHandler($schema_insert . $csv_terminated)) {
return false;
}
} // end while
diff --git a/libraries/classes/Plugins/Export/ExportHtmlword.php b/libraries/classes/Plugins/Export/ExportHtmlword.php
index 5aa72935c9..fda8fa1e6a 100644
--- a/libraries/classes/Plugins/Export/ExportHtmlword.php
+++ b/libraries/classes/Plugins/Export/ExportHtmlword.php
@@ -109,7 +109,7 @@ class ExportHtmlword extends ExportPlugin
{
global $charset;
- return Export::outputHandler(
+ return $this->export->outputHandler(
'
@@ -132,7 +132,7 @@ class ExportHtmlword extends ExportPlugin
*/
public function exportFooter()
{
- return Export::outputHandler('