Edit File by line
/home/barbar84/public_h.../wp-conte.../plugins/worker/src/MWP/Action/Incremen...
File: AbstractTablesAction.php
<?php
[0] Fix | Delete
/*
[1] Fix | Delete
* This file is part of the ManageWP Worker plugin.
[2] Fix | Delete
*
[3] Fix | Delete
* (c) ManageWP LLC <contact@managewp.com>
[4] Fix | Delete
*
[5] Fix | Delete
* For the full copyright and license information, please view the LICENSE
[6] Fix | Delete
* file that was distributed with this source code.
[7] Fix | Delete
*/
[8] Fix | Delete
[9] Fix | Delete
abstract class MWP_Action_IncrementalBackup_AbstractTablesAction extends MWP_Action_IncrementalBackup_Abstract
[10] Fix | Delete
{
[11] Fix | Delete
const METHOD_MYSQLDUMP = 'mysqldump';
[12] Fix | Delete
const METHOD_PHPDUMPER = 'phpdumper';
[13] Fix | Delete
[14] Fix | Delete
/**
[15] Fix | Delete
* @param MWP_IncrementalBackup_Database_DumperInterface $dumper
[16] Fix | Delete
* @param array $params
[17] Fix | Delete
* @param array $tables
[18] Fix | Delete
*
[19] Fix | Delete
* @return mixed
[20] Fix | Delete
*/
[21] Fix | Delete
abstract protected function executeAction(MWP_IncrementalBackup_Database_DumperInterface $dumper, array $tables = array(), array $params = array());
[22] Fix | Delete
[23] Fix | Delete
public function execute(array $params = array())
[24] Fix | Delete
{
[25] Fix | Delete
$method = $params['method'];
[26] Fix | Delete
$tables = $params['tables'];
[27] Fix | Delete
[28] Fix | Delete
if (isset($params['options']) && is_array($params['options'])) {
[29] Fix | Delete
$options = $params['options'];
[30] Fix | Delete
} else {
[31] Fix | Delete
$options = array();
[32] Fix | Delete
}
[33] Fix | Delete
[34] Fix | Delete
$dumper = $this->createDumper($method, $options);
[35] Fix | Delete
[36] Fix | Delete
return $this->executeAction($dumper, $tables, $params);
[37] Fix | Delete
}
[38] Fix | Delete
[39] Fix | Delete
/**
[40] Fix | Delete
* @param array $tables
[41] Fix | Delete
*
[42] Fix | Delete
* @throws MWP_Worker_Exception
[43] Fix | Delete
*/
[44] Fix | Delete
protected function assertTablesExist(array $tables)
[45] Fix | Delete
{
[46] Fix | Delete
$rows = mwp_context()->getDb()->get_results("SHOW TABLES", ARRAY_N);
[47] Fix | Delete
foreach ($rows as $row) {
[48] Fix | Delete
// $row is always an array with only a single member
[49] Fix | Delete
$table = $row[0];
[50] Fix | Delete
[51] Fix | Delete
$index = array_search($table, $tables);
[52] Fix | Delete
if ($index !== false) {
[53] Fix | Delete
// Remove from $tables - don't worry, $tables has not been passed by reference :)
[54] Fix | Delete
array_splice($tables, $index, 1);
[55] Fix | Delete
}
[56] Fix | Delete
}
[57] Fix | Delete
[58] Fix | Delete
// Tables which have not been found are located in $tables
[59] Fix | Delete
if (count($tables)) {
[60] Fix | Delete
throw new MWP_Worker_Exception(MWP_Worker_Exception::BACKUP_DATABASE_MISSING_TABLES, "Some tables are missing", array(
[61] Fix | Delete
// Return an array of missing tables
[62] Fix | Delete
'tables' => $tables,
[63] Fix | Delete
));
[64] Fix | Delete
}
[65] Fix | Delete
}
[66] Fix | Delete
[67] Fix | Delete
/**
[68] Fix | Delete
* @param string $method
[69] Fix | Delete
*
[70] Fix | Delete
* @param array $options
[71] Fix | Delete
*
[72] Fix | Delete
* @throws MWP_Worker_Exception
[73] Fix | Delete
* @return MWP_IncrementalBackup_Database_DumperInterface
[74] Fix | Delete
*/
[75] Fix | Delete
protected function createDumper($method, array $options = array())
[76] Fix | Delete
{
[77] Fix | Delete
$dumperOptions = MWP_IncrementalBackup_Database_DumpOptions::createFromArray($options);
[78] Fix | Delete
[79] Fix | Delete
switch ($method) {
[80] Fix | Delete
case self::METHOD_MYSQLDUMP:
[81] Fix | Delete
$configuration = MWP_IncrementalBackup_Database_Configuration::createFromWordPressContext(mwp_context());
[82] Fix | Delete
$dumper = new MWP_IncrementalBackup_Database_MysqlDumpDumper($configuration, $dumperOptions);
[83] Fix | Delete
[84] Fix | Delete
return $dumper;
[85] Fix | Delete
case self::METHOD_PHPDUMPER:
[86] Fix | Delete
$configuration = MWP_IncrementalBackup_Database_Configuration::createFromWordPressContext(mwp_context());
[87] Fix | Delete
$dumper = new MWP_IncrementalBackup_Database_PhpDumper($configuration, mwp_container()->getSystemEnvironment(), $dumperOptions);
[88] Fix | Delete
[89] Fix | Delete
return $dumper;
[90] Fix | Delete
default:
[91] Fix | Delete
throw new MWP_Worker_Exception(MWP_Worker_Exception::BACKUP_DATABASE_METHOD_NOT_AVAILABLE);
[92] Fix | Delete
break;
[93] Fix | Delete
}
[94] Fix | Delete
}
[95] Fix | Delete
}
[96] Fix | Delete
[97] Fix | Delete
It is recommended that you Edit text format, this type of Fix handles quite a lot in one request
Function