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