Refactor relation_cleanup functions to static methods
Signed-off-by: Maurício Meneghini Fauth <mauriciofauth@gmail.com>
This commit is contained in:
parent
df6ef79e93
commit
15d8ee270f
@ -18,6 +18,7 @@ use PhpMyAdmin\Operations;
|
||||
use PhpMyAdmin\Plugins;
|
||||
use PhpMyAdmin\Plugins\Export\ExportSql;
|
||||
use PhpMyAdmin\Relation;
|
||||
use PhpMyAdmin\RelationCleanup;
|
||||
use PhpMyAdmin\Response;
|
||||
use PhpMyAdmin\Util;
|
||||
|
||||
@ -133,8 +134,7 @@ if (strlen($GLOBALS['db']) > 0
|
||||
/**
|
||||
* cleanup pmadb stuff for this db
|
||||
*/
|
||||
include_once 'libraries/relation_cleanup.lib.php';
|
||||
PMA_relationsCleanupDatabase($GLOBALS['db']);
|
||||
RelationCleanup::database($GLOBALS['db']);
|
||||
|
||||
// if someday the RENAME DATABASE reappears, do not DROP
|
||||
$local_query = 'DROP DATABASE '
|
||||
|
||||
@ -10,6 +10,7 @@
|
||||
namespace PhpMyAdmin;
|
||||
|
||||
use PhpMyAdmin\Operations;
|
||||
use PhpMyAdmin\RelationCleanup;
|
||||
use PhpMyAdmin\Sql;
|
||||
use PhpMyAdmin\Table;
|
||||
use PhpMyAdmin\Transformations;
|
||||
@ -124,7 +125,7 @@ class MultSubmits
|
||||
break;
|
||||
|
||||
case 'drop_db':
|
||||
PMA_relationsCleanupDatabase($selected[$i]);
|
||||
RelationCleanup::database($selected[$i]);
|
||||
$a_query = 'DROP DATABASE '
|
||||
. Util::backquote($selected[$i]);
|
||||
$reload = 1;
|
||||
@ -133,7 +134,7 @@ class MultSubmits
|
||||
break;
|
||||
|
||||
case 'drop_tbl':
|
||||
PMA_relationsCleanupTable($db, $selected[$i]);
|
||||
RelationCleanup::table($db, $selected[$i]);
|
||||
$current = $selected[$i];
|
||||
if (!empty($views) && in_array($current, $views)) {
|
||||
$sql_query_views .= (empty($sql_query_views) ? 'DROP VIEW ' : ', ')
|
||||
@ -183,7 +184,7 @@ class MultSubmits
|
||||
break;
|
||||
|
||||
case 'drop_fld':
|
||||
PMA_relationsCleanupColumn($db, $table, $selected[$i]);
|
||||
RelationCleanup::column($db, $table, $selected[$i]);
|
||||
$sql_query .= (empty($sql_query)
|
||||
? 'ALTER TABLE ' . Util::backquote($table)
|
||||
: ',')
|
||||
|
||||
367
libraries/classes/RelationCleanup.php
Normal file
367
libraries/classes/RelationCleanup.php
Normal file
@ -0,0 +1,367 @@
|
||||
<?php
|
||||
/* vim: set expandtab sw=4 ts=4 sts=4: */
|
||||
/**
|
||||
* Set of functions used for cleaning up phpMyAdmin tables
|
||||
*
|
||||
* @package PhpMyAdmin
|
||||
*/
|
||||
namespace PhpMyAdmin;
|
||||
|
||||
use PhpMyAdmin\Relation;
|
||||
use PhpMyAdmin\Util;
|
||||
|
||||
/**
|
||||
* PhpMyAdmin\RelationCleanup class
|
||||
*
|
||||
* @package PhpMyAdmin
|
||||
*/
|
||||
class RelationCleanup
|
||||
{
|
||||
/**
|
||||
* Cleanup column related relation stuff
|
||||
*
|
||||
* @param string $db database name
|
||||
* @param string $table table name
|
||||
* @param string $column column name
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public static function column($db, $table, $column)
|
||||
{
|
||||
$cfgRelation = Relation::getRelationsParam();
|
||||
|
||||
if ($cfgRelation['commwork']) {
|
||||
$remove_query = 'DELETE FROM '
|
||||
. Util::backquote($cfgRelation['db'])
|
||||
. '.' . Util::backquote($cfgRelation['column_info'])
|
||||
. ' WHERE db_name = \'' . $GLOBALS['dbi']->escapeString($db) . '\''
|
||||
. ' AND table_name = \'' . $GLOBALS['dbi']->escapeString($table)
|
||||
. '\''
|
||||
. ' AND column_name = \'' . $GLOBALS['dbi']->escapeString($column)
|
||||
. '\'';
|
||||
Relation::queryAsControlUser($remove_query);
|
||||
}
|
||||
|
||||
if ($cfgRelation['displaywork']) {
|
||||
$remove_query = 'DELETE FROM '
|
||||
. Util::backquote($cfgRelation['db'])
|
||||
. '.' . Util::backquote($cfgRelation['table_info'])
|
||||
. ' WHERE db_name = \'' . $GLOBALS['dbi']->escapeString($db) . '\''
|
||||
. ' AND table_name = \'' . $GLOBALS['dbi']->escapeString($table)
|
||||
. '\''
|
||||
. ' AND display_field = \'' . $GLOBALS['dbi']->escapeString($column)
|
||||
. '\'';
|
||||
Relation::queryAsControlUser($remove_query);
|
||||
}
|
||||
|
||||
if ($cfgRelation['relwork']) {
|
||||
$remove_query = 'DELETE FROM '
|
||||
. Util::backquote($cfgRelation['db'])
|
||||
. '.' . Util::backquote($cfgRelation['relation'])
|
||||
. ' WHERE master_db = \'' . $GLOBALS['dbi']->escapeString($db)
|
||||
. '\''
|
||||
. ' AND master_table = \'' . $GLOBALS['dbi']->escapeString($table)
|
||||
. '\''
|
||||
. ' AND master_field = \'' . $GLOBALS['dbi']->escapeString($column)
|
||||
. '\'';
|
||||
Relation::queryAsControlUser($remove_query);
|
||||
|
||||
$remove_query = 'DELETE FROM '
|
||||
. Util::backquote($cfgRelation['db'])
|
||||
. '.' . Util::backquote($cfgRelation['relation'])
|
||||
. ' WHERE foreign_db = \'' . $GLOBALS['dbi']->escapeString($db)
|
||||
. '\''
|
||||
. ' AND foreign_table = \'' . $GLOBALS['dbi']->escapeString($table)
|
||||
. '\''
|
||||
. ' AND foreign_field = \'' . $GLOBALS['dbi']->escapeString($column)
|
||||
. '\'';
|
||||
Relation::queryAsControlUser($remove_query);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Cleanup table related relation stuff
|
||||
*
|
||||
* @param string $db database name
|
||||
* @param string $table table name
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public static function table($db, $table)
|
||||
{
|
||||
$cfgRelation = Relation::getRelationsParam();
|
||||
|
||||
if ($cfgRelation['commwork']) {
|
||||
$remove_query = 'DELETE FROM '
|
||||
. Util::backquote($cfgRelation['db'])
|
||||
. '.' . Util::backquote($cfgRelation['column_info'])
|
||||
. ' WHERE db_name = \'' . $GLOBALS['dbi']->escapeString($db) . '\''
|
||||
. ' AND table_name = \'' . $GLOBALS['dbi']->escapeString($table)
|
||||
. '\'';
|
||||
Relation::queryAsControlUser($remove_query);
|
||||
}
|
||||
|
||||
if ($cfgRelation['displaywork']) {
|
||||
$remove_query = 'DELETE FROM '
|
||||
. Util::backquote($cfgRelation['db'])
|
||||
. '.' . Util::backquote($cfgRelation['table_info'])
|
||||
. ' WHERE db_name = \'' . $GLOBALS['dbi']->escapeString($db) . '\''
|
||||
. ' AND table_name = \'' . $GLOBALS['dbi']->escapeString($table)
|
||||
. '\'';
|
||||
Relation::queryAsControlUser($remove_query);
|
||||
}
|
||||
|
||||
if ($cfgRelation['pdfwork']) {
|
||||
$remove_query = 'DELETE FROM '
|
||||
. Util::backquote($cfgRelation['db'])
|
||||
. '.' . Util::backquote($cfgRelation['table_coords'])
|
||||
. ' WHERE db_name = \'' . $GLOBALS['dbi']->escapeString($db) . '\''
|
||||
. ' AND table_name = \'' . $GLOBALS['dbi']->escapeString($table)
|
||||
. '\'';
|
||||
Relation::queryAsControlUser($remove_query);
|
||||
}
|
||||
|
||||
if ($cfgRelation['relwork']) {
|
||||
$remove_query = 'DELETE FROM '
|
||||
. Util::backquote($cfgRelation['db'])
|
||||
. '.' . Util::backquote($cfgRelation['relation'])
|
||||
. ' WHERE master_db = \'' . $GLOBALS['dbi']->escapeString($db)
|
||||
. '\''
|
||||
. ' AND master_table = \'' . $GLOBALS['dbi']->escapeString($table)
|
||||
. '\'';
|
||||
Relation::queryAsControlUser($remove_query);
|
||||
|
||||
$remove_query = 'DELETE FROM '
|
||||
. Util::backquote($cfgRelation['db'])
|
||||
. '.' . Util::backquote($cfgRelation['relation'])
|
||||
. ' WHERE foreign_db = \'' . $GLOBALS['dbi']->escapeString($db)
|
||||
. '\''
|
||||
. ' AND foreign_table = \'' . $GLOBALS['dbi']->escapeString($table)
|
||||
. '\'';
|
||||
Relation::queryAsControlUser($remove_query);
|
||||
}
|
||||
|
||||
if ($cfgRelation['uiprefswork']) {
|
||||
$remove_query = 'DELETE FROM '
|
||||
. Util::backquote($cfgRelation['db'])
|
||||
. '.' . Util::backquote($cfgRelation['table_uiprefs'])
|
||||
. ' WHERE db_name = \'' . $GLOBALS['dbi']->escapeString($db) . '\''
|
||||
. ' AND table_name = \'' . $GLOBALS['dbi']->escapeString($table)
|
||||
. '\'';
|
||||
Relation::queryAsControlUser($remove_query);
|
||||
}
|
||||
|
||||
if ($cfgRelation['navwork']) {
|
||||
$remove_query = 'DELETE FROM '
|
||||
. Util::backquote($cfgRelation['db'])
|
||||
. '.' . Util::backquote($cfgRelation['navigationhiding'])
|
||||
. ' WHERE db_name = \'' . $GLOBALS['dbi']->escapeString($db) . '\''
|
||||
. ' AND (table_name = \'' . $GLOBALS['dbi']->escapeString($table)
|
||||
. '\''
|
||||
. ' OR (item_name = \'' . $GLOBALS['dbi']->escapeString($table)
|
||||
. '\''
|
||||
. ' AND item_type = \'table\'))';
|
||||
Relation::queryAsControlUser($remove_query);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Cleanup database related relation stuff
|
||||
*
|
||||
* @param string $db database name
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public static function database($db)
|
||||
{
|
||||
$cfgRelation = Relation::getRelationsParam();
|
||||
|
||||
if ($cfgRelation['commwork']) {
|
||||
$remove_query = 'DELETE FROM '
|
||||
. Util::backquote($cfgRelation['db'])
|
||||
. '.' . Util::backquote($cfgRelation['column_info'])
|
||||
. ' WHERE db_name = \'' . $GLOBALS['dbi']->escapeString($db) . '\'';
|
||||
Relation::queryAsControlUser($remove_query);
|
||||
}
|
||||
|
||||
if ($cfgRelation['bookmarkwork']) {
|
||||
$remove_query = 'DELETE FROM '
|
||||
. Util::backquote($cfgRelation['db'])
|
||||
. '.' . Util::backquote($cfgRelation['bookmark'])
|
||||
. ' WHERE dbase = \'' . $GLOBALS['dbi']->escapeString($db) . '\'';
|
||||
Relation::queryAsControlUser($remove_query);
|
||||
}
|
||||
|
||||
if ($cfgRelation['displaywork']) {
|
||||
$remove_query = 'DELETE FROM '
|
||||
. Util::backquote($cfgRelation['db'])
|
||||
. '.' . Util::backquote($cfgRelation['table_info'])
|
||||
. ' WHERE db_name = \'' . $GLOBALS['dbi']->escapeString($db) . '\'';
|
||||
Relation::queryAsControlUser($remove_query);
|
||||
}
|
||||
|
||||
if ($cfgRelation['pdfwork']) {
|
||||
$remove_query = 'DELETE FROM '
|
||||
. Util::backquote($cfgRelation['db'])
|
||||
. '.' . Util::backquote($cfgRelation['pdf_pages'])
|
||||
. ' WHERE db_name = \'' . $GLOBALS['dbi']->escapeString($db) . '\'';
|
||||
Relation::queryAsControlUser($remove_query);
|
||||
|
||||
$remove_query = 'DELETE FROM '
|
||||
. Util::backquote($cfgRelation['db'])
|
||||
. '.' . Util::backquote($cfgRelation['table_coords'])
|
||||
. ' WHERE db_name = \'' . $GLOBALS['dbi']->escapeString($db) . '\'';
|
||||
Relation::queryAsControlUser($remove_query);
|
||||
}
|
||||
|
||||
if ($cfgRelation['relwork']) {
|
||||
$remove_query = 'DELETE FROM '
|
||||
. Util::backquote($cfgRelation['db'])
|
||||
. '.' . Util::backquote($cfgRelation['relation'])
|
||||
. ' WHERE master_db = \''
|
||||
. $GLOBALS['dbi']->escapeString($db) . '\'';
|
||||
Relation::queryAsControlUser($remove_query);
|
||||
|
||||
$remove_query = 'DELETE FROM '
|
||||
. Util::backquote($cfgRelation['db'])
|
||||
. '.' . Util::backquote($cfgRelation['relation'])
|
||||
. ' WHERE foreign_db = \'' . $GLOBALS['dbi']->escapeString($db)
|
||||
. '\'';
|
||||
Relation::queryAsControlUser($remove_query);
|
||||
}
|
||||
|
||||
if ($cfgRelation['uiprefswork']) {
|
||||
$remove_query = 'DELETE FROM '
|
||||
. Util::backquote($cfgRelation['db'])
|
||||
. '.' . Util::backquote($cfgRelation['table_uiprefs'])
|
||||
. ' WHERE db_name = \'' . $GLOBALS['dbi']->escapeString($db) . '\'';
|
||||
Relation::queryAsControlUser($remove_query);
|
||||
}
|
||||
|
||||
if ($cfgRelation['navwork']) {
|
||||
$remove_query = 'DELETE FROM '
|
||||
. Util::backquote($cfgRelation['db'])
|
||||
. '.' . Util::backquote($cfgRelation['navigationhiding'])
|
||||
. ' WHERE db_name = \'' . $GLOBALS['dbi']->escapeString($db) . '\'';
|
||||
Relation::queryAsControlUser($remove_query);
|
||||
}
|
||||
|
||||
if ($cfgRelation['savedsearcheswork']) {
|
||||
$remove_query = 'DELETE FROM '
|
||||
. Util::backquote($cfgRelation['db'])
|
||||
. '.' . Util::backquote($cfgRelation['savedsearches'])
|
||||
. ' WHERE db_name = \'' . $GLOBALS['dbi']->escapeString($db) . '\'';
|
||||
Relation::queryAsControlUser($remove_query);
|
||||
}
|
||||
|
||||
if ($cfgRelation['centralcolumnswork']) {
|
||||
$remove_query = 'DELETE FROM '
|
||||
. Util::backquote($cfgRelation['db'])
|
||||
. '.' . Util::backquote($cfgRelation['central_columns'])
|
||||
. ' WHERE db_name = \'' . $GLOBALS['dbi']->escapeString($db) . '\'';
|
||||
Relation::queryAsControlUser($remove_query);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Cleanup user related relation stuff
|
||||
*
|
||||
* @param string $username username
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public static function user($username)
|
||||
{
|
||||
$cfgRelation = Relation::getRelationsParam();
|
||||
|
||||
if ($cfgRelation['bookmarkwork']) {
|
||||
$remove_query = "DELETE FROM "
|
||||
. Util::backquote($cfgRelation['db'])
|
||||
. "." . Util::backquote($cfgRelation['bookmark'])
|
||||
. " WHERE `user` = '" . $GLOBALS['dbi']->escapeString($username)
|
||||
. "'";
|
||||
Relation::queryAsControlUser($remove_query);
|
||||
}
|
||||
|
||||
if ($cfgRelation['historywork']) {
|
||||
$remove_query = "DELETE FROM "
|
||||
. Util::backquote($cfgRelation['db'])
|
||||
. "." . Util::backquote($cfgRelation['history'])
|
||||
. " WHERE `username` = '" . $GLOBALS['dbi']->escapeString($username)
|
||||
. "'";
|
||||
Relation::queryAsControlUser($remove_query);
|
||||
}
|
||||
|
||||
if ($cfgRelation['recentwork']) {
|
||||
$remove_query = "DELETE FROM "
|
||||
. Util::backquote($cfgRelation['db'])
|
||||
. "." . Util::backquote($cfgRelation['recent'])
|
||||
. " WHERE `username` = '" . $GLOBALS['dbi']->escapeString($username)
|
||||
. "'";
|
||||
Relation::queryAsControlUser($remove_query);
|
||||
}
|
||||
|
||||
if ($cfgRelation['favoritework']) {
|
||||
$remove_query = "DELETE FROM "
|
||||
. Util::backquote($cfgRelation['db'])
|
||||
. "." . Util::backquote($cfgRelation['favorite'])
|
||||
. " WHERE `username` = '" . $GLOBALS['dbi']->escapeString($username)
|
||||
. "'";
|
||||
Relation::queryAsControlUser($remove_query);
|
||||
}
|
||||
|
||||
if ($cfgRelation['uiprefswork']) {
|
||||
$remove_query = "DELETE FROM "
|
||||
. Util::backquote($cfgRelation['db'])
|
||||
. "." . Util::backquote($cfgRelation['table_uiprefs'])
|
||||
. " WHERE `username` = '" . $GLOBALS['dbi']->escapeString($username)
|
||||
. "'";
|
||||
Relation::queryAsControlUser($remove_query);
|
||||
}
|
||||
|
||||
if ($cfgRelation['userconfigwork']) {
|
||||
$remove_query = "DELETE FROM "
|
||||
. Util::backquote($cfgRelation['db'])
|
||||
. "." . Util::backquote($cfgRelation['userconfig'])
|
||||
. " WHERE `username` = '" . $GLOBALS['dbi']->escapeString($username)
|
||||
. "'";
|
||||
Relation::queryAsControlUser($remove_query);
|
||||
}
|
||||
|
||||
if ($cfgRelation['menuswork']) {
|
||||
$remove_query = "DELETE FROM "
|
||||
. Util::backquote($cfgRelation['db'])
|
||||
. "." . Util::backquote($cfgRelation['users'])
|
||||
. " WHERE `username` = '" . $GLOBALS['dbi']->escapeString($username)
|
||||
. "'";
|
||||
Relation::queryAsControlUser($remove_query);
|
||||
}
|
||||
|
||||
if ($cfgRelation['navwork']) {
|
||||
$remove_query = "DELETE FROM "
|
||||
. Util::backquote($cfgRelation['db'])
|
||||
. "." . Util::backquote($cfgRelation['navigationhiding'])
|
||||
. " WHERE `username` = '" . $GLOBALS['dbi']->escapeString($username)
|
||||
. "'";
|
||||
Relation::queryAsControlUser($remove_query);
|
||||
}
|
||||
|
||||
if ($cfgRelation['savedsearcheswork']) {
|
||||
$remove_query = "DELETE FROM "
|
||||
. Util::backquote($cfgRelation['db'])
|
||||
. "." . Util::backquote($cfgRelation['savedsearches'])
|
||||
. " WHERE `username` = '" . $GLOBALS['dbi']->escapeString($username)
|
||||
. "'";
|
||||
Relation::queryAsControlUser($remove_query);
|
||||
}
|
||||
|
||||
if ($cfgRelation['designersettingswork']) {
|
||||
$remove_query = "DELETE FROM "
|
||||
. Util::backquote($cfgRelation['db'])
|
||||
. "." . Util::backquote($cfgRelation['designer_settings'])
|
||||
. " WHERE `username` = '" . $GLOBALS['dbi']->escapeString($username)
|
||||
. "'";
|
||||
Relation::queryAsControlUser($remove_query);
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -12,6 +12,7 @@ use PhpMyAdmin\DatabaseInterface;
|
||||
use PhpMyAdmin\Display\ChangePassword;
|
||||
use PhpMyAdmin\Message;
|
||||
use PhpMyAdmin\Relation;
|
||||
use PhpMyAdmin\RelationCleanup;
|
||||
use PhpMyAdmin\Response;
|
||||
use PhpMyAdmin\Template;
|
||||
use PhpMyAdmin\Url;
|
||||
@ -4042,7 +4043,7 @@ class Privileges
|
||||
$queries[] = 'DROP USER \''
|
||||
. $GLOBALS['dbi']->escapeString($this_user)
|
||||
. '\'@\'' . $GLOBALS['dbi']->escapeString($this_host) . '\';';
|
||||
PMA_relationsCleanupUser($this_user);
|
||||
RelationCleanup::user($this_user);
|
||||
|
||||
if (isset($_REQUEST['drop_users_db'])) {
|
||||
$queries[] = 'DROP DATABASE IF EXISTS '
|
||||
|
||||
@ -16,6 +16,7 @@ use PhpMyAdmin\Message;
|
||||
use PhpMyAdmin\Operations;
|
||||
use PhpMyAdmin\ParseAnalyze;
|
||||
use PhpMyAdmin\Relation;
|
||||
use PhpMyAdmin\RelationCleanup;
|
||||
use PhpMyAdmin\Response;
|
||||
use PhpMyAdmin\SqlParser\Statements\AlterStatement;
|
||||
use PhpMyAdmin\SqlParser\Statements\DropStatement;
|
||||
@ -1092,17 +1093,15 @@ EOT;
|
||||
*/
|
||||
public static function cleanupRelations($db, $table, $column, $purge)
|
||||
{
|
||||
include_once 'libraries/relation_cleanup.lib.php';
|
||||
|
||||
if (! empty($purge) && strlen($db) > 0) {
|
||||
if (strlen($table) > 0) {
|
||||
if (isset($column) && strlen($column) > 0) {
|
||||
PMA_relationsCleanupColumn($db, $table, $column);
|
||||
RelationCleanup::column($db, $table, $column);
|
||||
} else {
|
||||
PMA_relationsCleanupTable($db, $table);
|
||||
RelationCleanup::table($db, $table);
|
||||
}
|
||||
} else {
|
||||
PMA_relationsCleanupDatabase($db);
|
||||
RelationCleanup::database($db);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -210,13 +210,6 @@ if (!empty($submit_mult) && !empty($what)) {
|
||||
/**
|
||||
* Executes the query - dropping rows, columns/fields, tables or dbs
|
||||
*/
|
||||
if ($query_type == 'drop_db'
|
||||
|| $query_type == 'drop_tbl'
|
||||
|| $query_type == 'drop_fld'
|
||||
) {
|
||||
include_once './libraries/relation_cleanup.lib.php';
|
||||
}
|
||||
|
||||
if ($query_type == 'primary_fld') {
|
||||
// Gets table primary key
|
||||
$GLOBALS['dbi']->selectDb($db);
|
||||
|
||||
@ -1,357 +0,0 @@
|
||||
<?php
|
||||
/* vim: set expandtab sw=4 ts=4 sts=4: */
|
||||
/**
|
||||
* Set of functions used for cleaning up phpMyAdmin tables
|
||||
*
|
||||
* @package PhpMyAdmin
|
||||
*/
|
||||
|
||||
use PhpMyAdmin\Relation;
|
||||
|
||||
/**
|
||||
* Cleanup column related relation stuff
|
||||
*
|
||||
* @param string $db database name
|
||||
* @param string $table table name
|
||||
* @param string $column column name
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
function PMA_relationsCleanupColumn($db, $table, $column)
|
||||
{
|
||||
$cfgRelation = Relation::getRelationsParam();
|
||||
|
||||
if ($cfgRelation['commwork']) {
|
||||
$remove_query = 'DELETE FROM '
|
||||
. PhpMyAdmin\Util::backquote($cfgRelation['db'])
|
||||
. '.' . PhpMyAdmin\Util::backquote($cfgRelation['column_info'])
|
||||
. ' WHERE db_name = \'' . $GLOBALS['dbi']->escapeString($db) . '\''
|
||||
. ' AND table_name = \'' . $GLOBALS['dbi']->escapeString($table)
|
||||
. '\''
|
||||
. ' AND column_name = \'' . $GLOBALS['dbi']->escapeString($column)
|
||||
. '\'';
|
||||
Relation::queryAsControlUser($remove_query);
|
||||
}
|
||||
|
||||
if ($cfgRelation['displaywork']) {
|
||||
$remove_query = 'DELETE FROM '
|
||||
. PhpMyAdmin\Util::backquote($cfgRelation['db'])
|
||||
. '.' . PhpMyAdmin\Util::backquote($cfgRelation['table_info'])
|
||||
. ' WHERE db_name = \'' . $GLOBALS['dbi']->escapeString($db) . '\''
|
||||
. ' AND table_name = \'' . $GLOBALS['dbi']->escapeString($table)
|
||||
. '\''
|
||||
. ' AND display_field = \'' . $GLOBALS['dbi']->escapeString($column)
|
||||
. '\'';
|
||||
Relation::queryAsControlUser($remove_query);
|
||||
}
|
||||
|
||||
if ($cfgRelation['relwork']) {
|
||||
$remove_query = 'DELETE FROM '
|
||||
. PhpMyAdmin\Util::backquote($cfgRelation['db'])
|
||||
. '.' . PhpMyAdmin\Util::backquote($cfgRelation['relation'])
|
||||
. ' WHERE master_db = \'' . $GLOBALS['dbi']->escapeString($db)
|
||||
. '\''
|
||||
. ' AND master_table = \'' . $GLOBALS['dbi']->escapeString($table)
|
||||
. '\''
|
||||
. ' AND master_field = \'' . $GLOBALS['dbi']->escapeString($column)
|
||||
. '\'';
|
||||
Relation::queryAsControlUser($remove_query);
|
||||
|
||||
$remove_query = 'DELETE FROM '
|
||||
. PhpMyAdmin\Util::backquote($cfgRelation['db'])
|
||||
. '.' . PhpMyAdmin\Util::backquote($cfgRelation['relation'])
|
||||
. ' WHERE foreign_db = \'' . $GLOBALS['dbi']->escapeString($db)
|
||||
. '\''
|
||||
. ' AND foreign_table = \'' . $GLOBALS['dbi']->escapeString($table)
|
||||
. '\''
|
||||
. ' AND foreign_field = \'' . $GLOBALS['dbi']->escapeString($column)
|
||||
. '\'';
|
||||
Relation::queryAsControlUser($remove_query);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Cleanup table related relation stuff
|
||||
*
|
||||
* @param string $db database name
|
||||
* @param string $table table name
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
function PMA_relationsCleanupTable($db, $table)
|
||||
{
|
||||
$cfgRelation = Relation::getRelationsParam();
|
||||
|
||||
if ($cfgRelation['commwork']) {
|
||||
$remove_query = 'DELETE FROM '
|
||||
. PhpMyAdmin\Util::backquote($cfgRelation['db'])
|
||||
. '.' . PhpMyAdmin\Util::backquote($cfgRelation['column_info'])
|
||||
. ' WHERE db_name = \'' . $GLOBALS['dbi']->escapeString($db) . '\''
|
||||
. ' AND table_name = \'' . $GLOBALS['dbi']->escapeString($table)
|
||||
. '\'';
|
||||
Relation::queryAsControlUser($remove_query);
|
||||
}
|
||||
|
||||
if ($cfgRelation['displaywork']) {
|
||||
$remove_query = 'DELETE FROM '
|
||||
. PhpMyAdmin\Util::backquote($cfgRelation['db'])
|
||||
. '.' . PhpMyAdmin\Util::backquote($cfgRelation['table_info'])
|
||||
. ' WHERE db_name = \'' . $GLOBALS['dbi']->escapeString($db) . '\''
|
||||
. ' AND table_name = \'' . $GLOBALS['dbi']->escapeString($table)
|
||||
. '\'';
|
||||
Relation::queryAsControlUser($remove_query);
|
||||
}
|
||||
|
||||
if ($cfgRelation['pdfwork']) {
|
||||
$remove_query = 'DELETE FROM '
|
||||
. PhpMyAdmin\Util::backquote($cfgRelation['db'])
|
||||
. '.' . PhpMyAdmin\Util::backquote($cfgRelation['table_coords'])
|
||||
. ' WHERE db_name = \'' . $GLOBALS['dbi']->escapeString($db) . '\''
|
||||
. ' AND table_name = \'' . $GLOBALS['dbi']->escapeString($table)
|
||||
. '\'';
|
||||
Relation::queryAsControlUser($remove_query);
|
||||
}
|
||||
|
||||
if ($cfgRelation['relwork']) {
|
||||
$remove_query = 'DELETE FROM '
|
||||
. PhpMyAdmin\Util::backquote($cfgRelation['db'])
|
||||
. '.' . PhpMyAdmin\Util::backquote($cfgRelation['relation'])
|
||||
. ' WHERE master_db = \'' . $GLOBALS['dbi']->escapeString($db)
|
||||
. '\''
|
||||
. ' AND master_table = \'' . $GLOBALS['dbi']->escapeString($table)
|
||||
. '\'';
|
||||
Relation::queryAsControlUser($remove_query);
|
||||
|
||||
$remove_query = 'DELETE FROM '
|
||||
. PhpMyAdmin\Util::backquote($cfgRelation['db'])
|
||||
. '.' . PhpMyAdmin\Util::backquote($cfgRelation['relation'])
|
||||
. ' WHERE foreign_db = \'' . $GLOBALS['dbi']->escapeString($db)
|
||||
. '\''
|
||||
. ' AND foreign_table = \'' . $GLOBALS['dbi']->escapeString($table)
|
||||
. '\'';
|
||||
Relation::queryAsControlUser($remove_query);
|
||||
}
|
||||
|
||||
if ($cfgRelation['uiprefswork']) {
|
||||
$remove_query = 'DELETE FROM '
|
||||
. PhpMyAdmin\Util::backquote($cfgRelation['db'])
|
||||
. '.' . PhpMyAdmin\Util::backquote($cfgRelation['table_uiprefs'])
|
||||
. ' WHERE db_name = \'' . $GLOBALS['dbi']->escapeString($db) . '\''
|
||||
. ' AND table_name = \'' . $GLOBALS['dbi']->escapeString($table)
|
||||
. '\'';
|
||||
Relation::queryAsControlUser($remove_query);
|
||||
}
|
||||
|
||||
if ($cfgRelation['navwork']) {
|
||||
$remove_query = 'DELETE FROM '
|
||||
. PhpMyAdmin\Util::backquote($cfgRelation['db'])
|
||||
. '.' . PhpMyAdmin\Util::backquote($cfgRelation['navigationhiding'])
|
||||
. ' WHERE db_name = \'' . $GLOBALS['dbi']->escapeString($db) . '\''
|
||||
. ' AND (table_name = \'' . $GLOBALS['dbi']->escapeString($table)
|
||||
. '\''
|
||||
. ' OR (item_name = \'' . $GLOBALS['dbi']->escapeString($table)
|
||||
. '\''
|
||||
. ' AND item_type = \'table\'))';
|
||||
Relation::queryAsControlUser($remove_query);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Cleanup database related relation stuff
|
||||
*
|
||||
* @param string $db database name
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
function PMA_relationsCleanupDatabase($db)
|
||||
{
|
||||
$cfgRelation = Relation::getRelationsParam();
|
||||
|
||||
if ($cfgRelation['commwork']) {
|
||||
$remove_query = 'DELETE FROM '
|
||||
. PhpMyAdmin\Util::backquote($cfgRelation['db'])
|
||||
. '.' . PhpMyAdmin\Util::backquote($cfgRelation['column_info'])
|
||||
. ' WHERE db_name = \'' . $GLOBALS['dbi']->escapeString($db) . '\'';
|
||||
Relation::queryAsControlUser($remove_query);
|
||||
}
|
||||
|
||||
if ($cfgRelation['bookmarkwork']) {
|
||||
$remove_query = 'DELETE FROM '
|
||||
. PhpMyAdmin\Util::backquote($cfgRelation['db'])
|
||||
. '.' . PhpMyAdmin\Util::backquote($cfgRelation['bookmark'])
|
||||
. ' WHERE dbase = \'' . $GLOBALS['dbi']->escapeString($db) . '\'';
|
||||
Relation::queryAsControlUser($remove_query);
|
||||
}
|
||||
|
||||
if ($cfgRelation['displaywork']) {
|
||||
$remove_query = 'DELETE FROM '
|
||||
. PhpMyAdmin\Util::backquote($cfgRelation['db'])
|
||||
. '.' . PhpMyAdmin\Util::backquote($cfgRelation['table_info'])
|
||||
. ' WHERE db_name = \'' . $GLOBALS['dbi']->escapeString($db) . '\'';
|
||||
Relation::queryAsControlUser($remove_query);
|
||||
}
|
||||
|
||||
if ($cfgRelation['pdfwork']) {
|
||||
$remove_query = 'DELETE FROM '
|
||||
. PhpMyAdmin\Util::backquote($cfgRelation['db'])
|
||||
. '.' . PhpMyAdmin\Util::backquote($cfgRelation['pdf_pages'])
|
||||
. ' WHERE db_name = \'' . $GLOBALS['dbi']->escapeString($db) . '\'';
|
||||
Relation::queryAsControlUser($remove_query);
|
||||
|
||||
$remove_query = 'DELETE FROM '
|
||||
. PhpMyAdmin\Util::backquote($cfgRelation['db'])
|
||||
. '.' . PhpMyAdmin\Util::backquote($cfgRelation['table_coords'])
|
||||
. ' WHERE db_name = \'' . $GLOBALS['dbi']->escapeString($db) . '\'';
|
||||
Relation::queryAsControlUser($remove_query);
|
||||
}
|
||||
|
||||
if ($cfgRelation['relwork']) {
|
||||
$remove_query = 'DELETE FROM '
|
||||
. PhpMyAdmin\Util::backquote($cfgRelation['db'])
|
||||
. '.' . PhpMyAdmin\Util::backquote($cfgRelation['relation'])
|
||||
. ' WHERE master_db = \''
|
||||
. $GLOBALS['dbi']->escapeString($db) . '\'';
|
||||
Relation::queryAsControlUser($remove_query);
|
||||
|
||||
$remove_query = 'DELETE FROM '
|
||||
. PhpMyAdmin\Util::backquote($cfgRelation['db'])
|
||||
. '.' . PhpMyAdmin\Util::backquote($cfgRelation['relation'])
|
||||
. ' WHERE foreign_db = \'' . $GLOBALS['dbi']->escapeString($db)
|
||||
. '\'';
|
||||
Relation::queryAsControlUser($remove_query);
|
||||
}
|
||||
|
||||
if ($cfgRelation['uiprefswork']) {
|
||||
$remove_query = 'DELETE FROM '
|
||||
. PhpMyAdmin\Util::backquote($cfgRelation['db'])
|
||||
. '.' . PhpMyAdmin\Util::backquote($cfgRelation['table_uiprefs'])
|
||||
. ' WHERE db_name = \'' . $GLOBALS['dbi']->escapeString($db) . '\'';
|
||||
Relation::queryAsControlUser($remove_query);
|
||||
}
|
||||
|
||||
if ($cfgRelation['navwork']) {
|
||||
$remove_query = 'DELETE FROM '
|
||||
. PhpMyAdmin\Util::backquote($cfgRelation['db'])
|
||||
. '.' . PhpMyAdmin\Util::backquote($cfgRelation['navigationhiding'])
|
||||
. ' WHERE db_name = \'' . $GLOBALS['dbi']->escapeString($db) . '\'';
|
||||
Relation::queryAsControlUser($remove_query);
|
||||
}
|
||||
|
||||
if ($cfgRelation['savedsearcheswork']) {
|
||||
$remove_query = 'DELETE FROM '
|
||||
. PhpMyAdmin\Util::backquote($cfgRelation['db'])
|
||||
. '.' . PhpMyAdmin\Util::backquote($cfgRelation['savedsearches'])
|
||||
. ' WHERE db_name = \'' . $GLOBALS['dbi']->escapeString($db) . '\'';
|
||||
Relation::queryAsControlUser($remove_query);
|
||||
}
|
||||
|
||||
if ($cfgRelation['centralcolumnswork']) {
|
||||
$remove_query = 'DELETE FROM '
|
||||
. PhpMyAdmin\Util::backquote($cfgRelation['db'])
|
||||
. '.' . PhpMyAdmin\Util::backquote($cfgRelation['central_columns'])
|
||||
. ' WHERE db_name = \'' . $GLOBALS['dbi']->escapeString($db) . '\'';
|
||||
Relation::queryAsControlUser($remove_query);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Cleanup user related relation stuff
|
||||
*
|
||||
* @param string $username username
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
function PMA_relationsCleanupUser($username)
|
||||
{
|
||||
$cfgRelation = Relation::getRelationsParam();
|
||||
|
||||
if ($cfgRelation['bookmarkwork']) {
|
||||
$remove_query = "DELETE FROM "
|
||||
. PhpMyAdmin\Util::backquote($cfgRelation['db'])
|
||||
. "." . PhpMyAdmin\Util::backquote($cfgRelation['bookmark'])
|
||||
. " WHERE `user` = '" . $GLOBALS['dbi']->escapeString($username)
|
||||
. "'";
|
||||
Relation::queryAsControlUser($remove_query);
|
||||
}
|
||||
|
||||
if ($cfgRelation['historywork']) {
|
||||
$remove_query = "DELETE FROM "
|
||||
. PhpMyAdmin\Util::backquote($cfgRelation['db'])
|
||||
. "." . PhpMyAdmin\Util::backquote($cfgRelation['history'])
|
||||
. " WHERE `username` = '" . $GLOBALS['dbi']->escapeString($username)
|
||||
. "'";
|
||||
Relation::queryAsControlUser($remove_query);
|
||||
}
|
||||
|
||||
if ($cfgRelation['recentwork']) {
|
||||
$remove_query = "DELETE FROM "
|
||||
. PhpMyAdmin\Util::backquote($cfgRelation['db'])
|
||||
. "." . PhpMyAdmin\Util::backquote($cfgRelation['recent'])
|
||||
. " WHERE `username` = '" . $GLOBALS['dbi']->escapeString($username)
|
||||
. "'";
|
||||
Relation::queryAsControlUser($remove_query);
|
||||
}
|
||||
|
||||
if ($cfgRelation['favoritework']) {
|
||||
$remove_query = "DELETE FROM "
|
||||
. PhpMyAdmin\Util::backquote($cfgRelation['db'])
|
||||
. "." . PhpMyAdmin\Util::backquote($cfgRelation['favorite'])
|
||||
. " WHERE `username` = '" . $GLOBALS['dbi']->escapeString($username)
|
||||
. "'";
|
||||
Relation::queryAsControlUser($remove_query);
|
||||
}
|
||||
|
||||
if ($cfgRelation['uiprefswork']) {
|
||||
$remove_query = "DELETE FROM "
|
||||
. PhpMyAdmin\Util::backquote($cfgRelation['db'])
|
||||
. "." . PhpMyAdmin\Util::backquote($cfgRelation['table_uiprefs'])
|
||||
. " WHERE `username` = '" . $GLOBALS['dbi']->escapeString($username)
|
||||
. "'";
|
||||
Relation::queryAsControlUser($remove_query);
|
||||
}
|
||||
|
||||
if ($cfgRelation['userconfigwork']) {
|
||||
$remove_query = "DELETE FROM "
|
||||
. PhpMyAdmin\Util::backquote($cfgRelation['db'])
|
||||
. "." . PhpMyAdmin\Util::backquote($cfgRelation['userconfig'])
|
||||
. " WHERE `username` = '" . $GLOBALS['dbi']->escapeString($username)
|
||||
. "'";
|
||||
Relation::queryAsControlUser($remove_query);
|
||||
}
|
||||
|
||||
if ($cfgRelation['menuswork']) {
|
||||
$remove_query = "DELETE FROM "
|
||||
. PhpMyAdmin\Util::backquote($cfgRelation['db'])
|
||||
. "." . PhpMyAdmin\Util::backquote($cfgRelation['users'])
|
||||
. " WHERE `username` = '" . $GLOBALS['dbi']->escapeString($username)
|
||||
. "'";
|
||||
Relation::queryAsControlUser($remove_query);
|
||||
}
|
||||
|
||||
if ($cfgRelation['navwork']) {
|
||||
$remove_query = "DELETE FROM "
|
||||
. PhpMyAdmin\Util::backquote($cfgRelation['db'])
|
||||
. "." . PhpMyAdmin\Util::backquote($cfgRelation['navigationhiding'])
|
||||
. " WHERE `username` = '" . $GLOBALS['dbi']->escapeString($username)
|
||||
. "'";
|
||||
Relation::queryAsControlUser($remove_query);
|
||||
}
|
||||
|
||||
if ($cfgRelation['savedsearcheswork']) {
|
||||
$remove_query = "DELETE FROM "
|
||||
. PhpMyAdmin\Util::backquote($cfgRelation['db'])
|
||||
. "." . PhpMyAdmin\Util::backquote($cfgRelation['savedsearches'])
|
||||
. " WHERE `username` = '" . $GLOBALS['dbi']->escapeString($username)
|
||||
. "'";
|
||||
Relation::queryAsControlUser($remove_query);
|
||||
}
|
||||
|
||||
if ($cfgRelation['designersettingswork']) {
|
||||
$remove_query = "DELETE FROM "
|
||||
. PhpMyAdmin\Util::backquote($cfgRelation['db'])
|
||||
. "." . PhpMyAdmin\Util::backquote($cfgRelation['designer_settings'])
|
||||
. " WHERE `username` = '" . $GLOBALS['dbi']->escapeString($username)
|
||||
. "'";
|
||||
Relation::queryAsControlUser($remove_query);
|
||||
}
|
||||
}
|
||||
@ -278,7 +278,6 @@ if (isset($_REQUEST['change_pw'])) {
|
||||
if (isset($_REQUEST['delete'])
|
||||
|| (isset($_REQUEST['change_copy']) && $_REQUEST['mode'] < 4)
|
||||
) {
|
||||
include_once 'libraries/relation_cleanup.lib.php';
|
||||
$queries = Privileges::getDataForDeleteUsers($queries);
|
||||
if (empty($_REQUEST['change_copy'])) {
|
||||
list($sql_query, $message) = Privileges::deleteUser($queries);
|
||||
|
||||
@ -426,7 +426,7 @@ if (! (isset($db_is_system_schema) && $db_is_system_schema)) {
|
||||
htmlspecialchars($table)
|
||||
),
|
||||
// table name is needed to avoid running
|
||||
// PMA_relationsCleanupDatabase() on the whole db later
|
||||
// PhpMyAdmin\RelationCleanup::database() on the whole db later
|
||||
'table' => $GLOBALS['table'],
|
||||
)
|
||||
);
|
||||
|
||||
@ -11,8 +11,6 @@ use PhpMyAdmin\MultSubmits;
|
||||
use PhpMyAdmin\Theme;
|
||||
use PhpMyAdmin\Url;
|
||||
|
||||
require_once 'libraries/relation_cleanup.lib.php';
|
||||
|
||||
/**
|
||||
* PhpMyAdmin\Tests\MultSubmitsTest class
|
||||
*
|
||||
|
||||
@ -1,27 +1,25 @@
|
||||
<?php
|
||||
/* vim: set expandtab sw=4 ts=4 sts=4: */
|
||||
/**
|
||||
* tests for relation_cleanup.lib.php
|
||||
* tests for PhpMyAdmin\RelationCleanup
|
||||
*
|
||||
* @package PhpMyAdmin-test
|
||||
*/
|
||||
namespace PhpMyAdmin\Tests;
|
||||
|
||||
use PhpMyAdmin\DatabaseInterface;
|
||||
use PhpMyAdmin\Relation;
|
||||
|
||||
/*
|
||||
* Include to test.
|
||||
*/
|
||||
require_once 'libraries/relation_cleanup.lib.php';
|
||||
use PhpMyAdmin\RelationCleanup;
|
||||
use PHPUnit_Framework_TestCase as TestCase;
|
||||
|
||||
/**
|
||||
* PMA_Relation_Cleanup_Test class
|
||||
* PhpMyAdmin\Tests\RelationCleanupTest class
|
||||
*
|
||||
* this class is for testing relation_cleanup.lib.php functions
|
||||
* this class is for testing PhpMyAdmin\RelationCleanup methods
|
||||
*
|
||||
* @package PhpMyAdmin-test
|
||||
*/
|
||||
class PMA_Relation_Cleanup_Test extends PHPUnit_Framework_TestCase
|
||||
class RelationCleanupTest extends TestCase
|
||||
{
|
||||
/**
|
||||
* Prepares environment for the test.
|
||||
@ -70,7 +68,7 @@ class PMA_Relation_Cleanup_Test extends PHPUnit_Framework_TestCase
|
||||
}
|
||||
|
||||
/**
|
||||
* Test for PMA_relationsCleanupColumn
|
||||
* Test for RelationCleanup::column
|
||||
*
|
||||
* @return void
|
||||
* @group medium
|
||||
@ -123,7 +121,7 @@ class PMA_Relation_Cleanup_Test extends PHPUnit_Framework_TestCase
|
||||
);
|
||||
|
||||
//cleanup
|
||||
PMA_relationsCleanupColumn($db, $table, $column);
|
||||
RelationCleanup::column($db, $table, $column);
|
||||
|
||||
//the $cfgRelation value after cleanup column
|
||||
$cfgRelation = Relation::checkRelationsParam();
|
||||
@ -151,7 +149,7 @@ class PMA_Relation_Cleanup_Test extends PHPUnit_Framework_TestCase
|
||||
}
|
||||
|
||||
/**
|
||||
* Test for PMA_relationsCleanupTable
|
||||
* Test for RelationCleanup::table
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
@ -180,8 +178,8 @@ class PMA_Relation_Cleanup_Test extends PHPUnit_Framework_TestCase
|
||||
$cfgRelation['relation']
|
||||
);
|
||||
|
||||
//PMA_relationsCleanupTable
|
||||
PMA_relationsCleanupTable($db, $table);
|
||||
//RelationCleanup::table
|
||||
RelationCleanup::table($db, $table);
|
||||
|
||||
//the $cfgRelation value after cleanup column
|
||||
$cfgRelation = Relation::checkRelationsParam();
|
||||
@ -216,7 +214,7 @@ class PMA_Relation_Cleanup_Test extends PHPUnit_Framework_TestCase
|
||||
}
|
||||
|
||||
/**
|
||||
* Test for PMA_relationsCleanupDatabase
|
||||
* Test for RelationCleanup::database
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
@ -253,7 +251,7 @@ class PMA_Relation_Cleanup_Test extends PHPUnit_Framework_TestCase
|
||||
);
|
||||
|
||||
//cleanup
|
||||
PMA_relationsCleanupDatabase($db);
|
||||
RelationCleanup::database($db);
|
||||
|
||||
//the value after cleanup column
|
||||
$cfgRelation = Relation::checkRelationsParam();
|
||||
@ -14,8 +14,6 @@ use PhpMyAdmin\Theme;
|
||||
use PhpMyAdmin\Url;
|
||||
use PhpMyAdmin\Util;
|
||||
|
||||
require_once 'libraries/relation_cleanup.lib.php';
|
||||
|
||||
/**
|
||||
* PhpMyAdmin\Tests\Server\PrivilegesTest class
|
||||
*
|
||||
|
||||
Loading…
Reference in New Issue
Block a user