Exporter
1 day ago
QueryBuilder
1 day ago
CustomTable.php
1 day ago
DbInfo.php
1 day ago
ExcludedTables.php
1 day ago
ExternalDatabaseConfiguration.php
1 day ago
OptionPreservationHandler.php
1 day ago
SearchReplace.php
1 day ago
SelectedTables.php
1 day ago
TableDto.php
1 day ago
TableService.php
1 day ago
TablesRenamer.php
1 day ago
WpDbInfo.php
1 day ago
WpOptionsInfo.php
1 day 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 | |
| 10 | |
| 11 | class ExcludedTables |
| 12 | { |
| 13 | |
| 14 | |
| 15 | |
| 16 | const CLONE_DATABASE_TABLES_EXCLUDE_FILTER = 'wpstg_clone_database_tables_exclude'; |
| 17 | |
| 18 | |
| 19 | |
| 20 | |
| 21 | const CLONE_SEARCH_REPLACE_TABLES_EXCLUDE_FILTER = 'wpstg_clone_searchreplace_tables_exclude'; |
| 22 | |
| 23 | |
| 24 | |
| 25 | |
| 26 | const SEARCH_REPLACE_TABLES_EXCLUDE_FILTER = 'wpstg_searchreplace_excl_tables'; |
| 27 | |
| 28 | |
| 29 | |
| 30 | |
| 31 | private $excludedTables; |
| 32 | |
| 33 | |
| 34 | |
| 35 | |
| 36 | private $networkExcludedTables; |
| 37 | |
| 38 | |
| 39 | |
| 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', |
| 56 | '_cerber_sets', |
| 57 | ]; |
| 58 | } |
| 59 | |
| 60 | |
| 61 | |
| 62 | |
| 63 | |
| 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 | |
| 78 | |
| 79 | |
| 80 | |
| 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 | |
| 92 | |
| 93 | |
| 94 | |
| 95 | public function getExcludedTablesForSearchReplacePushOnly() |
| 96 | { |
| 97 | return Hooks::applyFilters(self::SEARCH_REPLACE_TABLES_EXCLUDE_FILTER, $this->excludedTablesSearchReplaceOnly); |
| 98 | } |
| 99 | } |
| 100 |