Exporter
2 weeks ago
QueryBuilder
2 years ago
CustomTable.php
3 months ago
DbInfo.php
7 months ago
ExcludedTables.php
5 months ago
OptionPreservationHandler.php
2 years ago
SearchReplace.php
2 months ago
SelectedTables.php
2 weeks ago
TableDto.php
1 year ago
TableService.php
9 months ago
TablesRenamer.php
3 months ago
WpDbInfo.php
9 months ago
WpOptionsInfo.php
1 year ago
iDbInfo.php
2 years ago
ExcludedTables.php
100 lines
| 1 | <?php |
| 2 | |
| 3 | namespace WPStaging\Framework\Database; |
| 4 | |
| 5 | use WPStaging\Framework\BackgroundProcessing\Queue; |
| 6 | use WPStaging\Framework\Facades\Hooks; |
| 7 | |
| 8 | /** |
| 9 | * Provide list of table excluded from Database Copy and SearchReplace Job |
| 10 | */ |
| 11 | class ExcludedTables |
| 12 | { |
| 13 | /** |
| 14 | * @var string |
| 15 | */ |
| 16 | const CLONE_DATABASE_TABLES_EXCLUDE_FILTER = 'wpstg_clone_database_tables_exclude'; |
| 17 | |
| 18 | /** |
| 19 | * @var string |
| 20 | */ |
| 21 | const CLONE_SEARCH_REPLACE_TABLES_EXCLUDE_FILTER = 'wpstg_clone_searchreplace_tables_exclude'; |
| 22 | |
| 23 | /** |
| 24 | * @var string |
| 25 | */ |
| 26 | const SEARCH_REPLACE_TABLES_EXCLUDE_FILTER = 'wpstg_searchreplace_excl_tables'; |
| 27 | |
| 28 | /** |
| 29 | * @var array |
| 30 | */ |
| 31 | private $excludedTables; |
| 32 | |
| 33 | /** |
| 34 | * @var array |
| 35 | */ |
| 36 | private $networkExcludedTables; |
| 37 | |
| 38 | /** |
| 39 | * @var array |
| 40 | */ |
| 41 | private $excludedTablesSearchReplaceOnly; |
| 42 | |
| 43 | public function __construct() |
| 44 | { |
| 45 | $this->excludedTables = [ |
| 46 | Queue::getTableName(), |
| 47 | ]; |
| 48 | |
| 49 | $this->networkExcludedTables = [ |
| 50 | 'blogs', |
| 51 | 'blog_version', |
| 52 | ]; |
| 53 | |
| 54 | $this->excludedTablesSearchReplaceOnly = [ |
| 55 | '_cerber_files', // Cerber Security Plugin |
| 56 | '_cerber_sets', // Cerber Security Plugin |
| 57 | ]; |
| 58 | } |
| 59 | |
| 60 | /** |
| 61 | * Get List of excluded tables for database copy |
| 62 | * |
| 63 | * @return array |
| 64 | */ |
| 65 | public function getExcludedTables($networkClone = false) |
| 66 | { |
| 67 | $excludedCustomTables = Hooks::applyFilters(self::CLONE_DATABASE_TABLES_EXCLUDE_FILTER, []); |
| 68 | |
| 69 | if ($networkClone) { |
| 70 | return array_merge($this->excludedTables, $excludedCustomTables); |
| 71 | } |
| 72 | |
| 73 | return array_merge($this->excludedTables, $this->networkExcludedTables, $excludedCustomTables); |
| 74 | } |
| 75 | |
| 76 | /** |
| 77 | * Get List of excluded tables for search replace cloning process job |
| 78 | * This also includes list of tables excluded through filters for cloning database copy process |
| 79 | * |
| 80 | * @return array |
| 81 | */ |
| 82 | public function getExcludedTablesForSearchReplace($networkClone = false) |
| 83 | { |
| 84 | $excludedCustomCloneTables = Hooks::applyFilters(self::CLONE_SEARCH_REPLACE_TABLES_EXCLUDE_FILTER, []); |
| 85 | $excludedCustomClonePushTables = Hooks::applyFilters(self::SEARCH_REPLACE_TABLES_EXCLUDE_FILTER, $this->excludedTablesSearchReplaceOnly); |
| 86 | $searchReplaceExcludedTables = array_merge($excludedCustomCloneTables, $excludedCustomClonePushTables); |
| 87 | return array_merge($this->getExcludedTables($networkClone), $searchReplaceExcludedTables); |
| 88 | } |
| 89 | |
| 90 | /** |
| 91 | * Get List of excluded tables for search replace push process job |
| 92 | * |
| 93 | * @return array |
| 94 | */ |
| 95 | public function getExcludedTablesForSearchReplacePushOnly() |
| 96 | { |
| 97 | return Hooks::applyFilters(self::SEARCH_REPLACE_TABLES_EXCLUDE_FILTER, $this->excludedTablesSearchReplaceOnly); |
| 98 | } |
| 99 | } |
| 100 |