@@ -18,145 +18,145 @@ |
||
| 18 | 18 | class JavascriptAsset extends BrowserAsset |
| 19 | 19 | { |
| 20 | 20 | |
| 21 | - /** |
|
| 22 | - * @var boolean $load_in_footer |
|
| 23 | - */ |
|
| 24 | - private $load_in_footer = false; |
|
| 25 | - |
|
| 26 | - /** |
|
| 27 | - * @var boolean $requires_translation |
|
| 28 | - */ |
|
| 29 | - private $requires_translation = false; |
|
| 30 | - |
|
| 31 | - /** |
|
| 32 | - * @var boolean $has_inline_data |
|
| 33 | - */ |
|
| 34 | - private $has_inline_data = false; |
|
| 35 | - |
|
| 36 | - /** |
|
| 37 | - * @var Closure $inline_data_callback |
|
| 38 | - */ |
|
| 39 | - private $inline_data_callback; |
|
| 40 | - |
|
| 41 | - |
|
| 42 | - /** |
|
| 43 | - * Asset constructor. |
|
| 44 | - * |
|
| 45 | - * @param string $handle |
|
| 46 | - * @param string $source |
|
| 47 | - * @param array $dependencies |
|
| 48 | - * @param bool $load_in_footer |
|
| 49 | - * @param DomainInterface $domain |
|
| 50 | - * @param string $version |
|
| 51 | - * @throws InvalidDataTypeException |
|
| 52 | - * @throws DomainException |
|
| 53 | - */ |
|
| 54 | - public function __construct( |
|
| 55 | - $handle, |
|
| 56 | - $source, |
|
| 57 | - array $dependencies, |
|
| 58 | - $load_in_footer, |
|
| 59 | - DomainInterface $domain, |
|
| 60 | - $version = '' |
|
| 61 | - ) { |
|
| 62 | - parent::__construct(Asset::TYPE_JS, $handle, $source, $dependencies, $domain, $version); |
|
| 63 | - $this->setLoadInFooter($load_in_footer); |
|
| 64 | - } |
|
| 65 | - |
|
| 66 | - |
|
| 67 | - /** |
|
| 68 | - * @return bool |
|
| 69 | - */ |
|
| 70 | - public function loadInFooter() |
|
| 71 | - { |
|
| 72 | - return $this->load_in_footer; |
|
| 73 | - } |
|
| 74 | - |
|
| 75 | - |
|
| 76 | - /** |
|
| 77 | - * @param bool $load_in_footer |
|
| 78 | - */ |
|
| 79 | - private function setLoadInFooter($load_in_footer = true) |
|
| 80 | - { |
|
| 81 | - $this->load_in_footer = filter_var($load_in_footer, FILTER_VALIDATE_BOOLEAN); |
|
| 82 | - } |
|
| 83 | - |
|
| 84 | - |
|
| 85 | - /** |
|
| 86 | - * @return bool |
|
| 87 | - */ |
|
| 88 | - public function requiresTranslation() |
|
| 89 | - { |
|
| 90 | - return $this->requires_translation; |
|
| 91 | - } |
|
| 92 | - |
|
| 93 | - |
|
| 94 | - /** |
|
| 95 | - * @param bool $requires_translation |
|
| 96 | - * @return JavascriptAsset |
|
| 97 | - */ |
|
| 98 | - public function setRequiresTranslation($requires_translation = true) |
|
| 99 | - { |
|
| 100 | - $this->requires_translation = filter_var($requires_translation, FILTER_VALIDATE_BOOLEAN); |
|
| 101 | - return $this; |
|
| 102 | - } |
|
| 103 | - |
|
| 104 | - |
|
| 105 | - /** |
|
| 106 | - * @return bool |
|
| 107 | - */ |
|
| 108 | - public function hasInlineData() |
|
| 109 | - { |
|
| 110 | - return $this->has_inline_data; |
|
| 111 | - } |
|
| 112 | - |
|
| 113 | - |
|
| 114 | - /** |
|
| 115 | - * @param bool $has_inline_data |
|
| 116 | - * @return JavascriptAsset |
|
| 117 | - */ |
|
| 118 | - public function setHasInlineData($has_inline_data = true) |
|
| 119 | - { |
|
| 120 | - $this->has_inline_data = filter_var($has_inline_data, FILTER_VALIDATE_BOOLEAN); |
|
| 121 | - return $this; |
|
| 122 | - } |
|
| 123 | - |
|
| 124 | - |
|
| 125 | - /** |
|
| 126 | - * @return Closure |
|
| 127 | - */ |
|
| 128 | - public function inlineDataCallback() |
|
| 129 | - { |
|
| 130 | - return $this->inline_data_callback; |
|
| 131 | - } |
|
| 132 | - |
|
| 133 | - |
|
| 134 | - /** |
|
| 135 | - * @return bool |
|
| 136 | - */ |
|
| 137 | - public function hasInlineDataCallback() |
|
| 138 | - { |
|
| 139 | - return $this->inline_data_callback instanceof Closure; |
|
| 140 | - } |
|
| 141 | - |
|
| 142 | - |
|
| 143 | - /** |
|
| 144 | - * @param Closure $inline_data_callback |
|
| 145 | - * @return JavascriptAsset |
|
| 146 | - */ |
|
| 147 | - public function setInlineDataCallback(Closure $inline_data_callback) |
|
| 148 | - { |
|
| 149 | - $this->inline_data_callback = $inline_data_callback; |
|
| 150 | - $this->setHasInlineData(); |
|
| 151 | - return $this; |
|
| 152 | - } |
|
| 153 | - |
|
| 154 | - |
|
| 155 | - /** |
|
| 156 | - * @since 4.9.62.p |
|
| 157 | - */ |
|
| 158 | - public function enqueueAsset() |
|
| 159 | - { |
|
| 160 | - wp_enqueue_script($this->handle()); |
|
| 161 | - } |
|
| 21 | + /** |
|
| 22 | + * @var boolean $load_in_footer |
|
| 23 | + */ |
|
| 24 | + private $load_in_footer = false; |
|
| 25 | + |
|
| 26 | + /** |
|
| 27 | + * @var boolean $requires_translation |
|
| 28 | + */ |
|
| 29 | + private $requires_translation = false; |
|
| 30 | + |
|
| 31 | + /** |
|
| 32 | + * @var boolean $has_inline_data |
|
| 33 | + */ |
|
| 34 | + private $has_inline_data = false; |
|
| 35 | + |
|
| 36 | + /** |
|
| 37 | + * @var Closure $inline_data_callback |
|
| 38 | + */ |
|
| 39 | + private $inline_data_callback; |
|
| 40 | + |
|
| 41 | + |
|
| 42 | + /** |
|
| 43 | + * Asset constructor. |
|
| 44 | + * |
|
| 45 | + * @param string $handle |
|
| 46 | + * @param string $source |
|
| 47 | + * @param array $dependencies |
|
| 48 | + * @param bool $load_in_footer |
|
| 49 | + * @param DomainInterface $domain |
|
| 50 | + * @param string $version |
|
| 51 | + * @throws InvalidDataTypeException |
|
| 52 | + * @throws DomainException |
|
| 53 | + */ |
|
| 54 | + public function __construct( |
|
| 55 | + $handle, |
|
| 56 | + $source, |
|
| 57 | + array $dependencies, |
|
| 58 | + $load_in_footer, |
|
| 59 | + DomainInterface $domain, |
|
| 60 | + $version = '' |
|
| 61 | + ) { |
|
| 62 | + parent::__construct(Asset::TYPE_JS, $handle, $source, $dependencies, $domain, $version); |
|
| 63 | + $this->setLoadInFooter($load_in_footer); |
|
| 64 | + } |
|
| 65 | + |
|
| 66 | + |
|
| 67 | + /** |
|
| 68 | + * @return bool |
|
| 69 | + */ |
|
| 70 | + public function loadInFooter() |
|
| 71 | + { |
|
| 72 | + return $this->load_in_footer; |
|
| 73 | + } |
|
| 74 | + |
|
| 75 | + |
|
| 76 | + /** |
|
| 77 | + * @param bool $load_in_footer |
|
| 78 | + */ |
|
| 79 | + private function setLoadInFooter($load_in_footer = true) |
|
| 80 | + { |
|
| 81 | + $this->load_in_footer = filter_var($load_in_footer, FILTER_VALIDATE_BOOLEAN); |
|
| 82 | + } |
|
| 83 | + |
|
| 84 | + |
|
| 85 | + /** |
|
| 86 | + * @return bool |
|
| 87 | + */ |
|
| 88 | + public function requiresTranslation() |
|
| 89 | + { |
|
| 90 | + return $this->requires_translation; |
|
| 91 | + } |
|
| 92 | + |
|
| 93 | + |
|
| 94 | + /** |
|
| 95 | + * @param bool $requires_translation |
|
| 96 | + * @return JavascriptAsset |
|
| 97 | + */ |
|
| 98 | + public function setRequiresTranslation($requires_translation = true) |
|
| 99 | + { |
|
| 100 | + $this->requires_translation = filter_var($requires_translation, FILTER_VALIDATE_BOOLEAN); |
|
| 101 | + return $this; |
|
| 102 | + } |
|
| 103 | + |
|
| 104 | + |
|
| 105 | + /** |
|
| 106 | + * @return bool |
|
| 107 | + */ |
|
| 108 | + public function hasInlineData() |
|
| 109 | + { |
|
| 110 | + return $this->has_inline_data; |
|
| 111 | + } |
|
| 112 | + |
|
| 113 | + |
|
| 114 | + /** |
|
| 115 | + * @param bool $has_inline_data |
|
| 116 | + * @return JavascriptAsset |
|
| 117 | + */ |
|
| 118 | + public function setHasInlineData($has_inline_data = true) |
|
| 119 | + { |
|
| 120 | + $this->has_inline_data = filter_var($has_inline_data, FILTER_VALIDATE_BOOLEAN); |
|
| 121 | + return $this; |
|
| 122 | + } |
|
| 123 | + |
|
| 124 | + |
|
| 125 | + /** |
|
| 126 | + * @return Closure |
|
| 127 | + */ |
|
| 128 | + public function inlineDataCallback() |
|
| 129 | + { |
|
| 130 | + return $this->inline_data_callback; |
|
| 131 | + } |
|
| 132 | + |
|
| 133 | + |
|
| 134 | + /** |
|
| 135 | + * @return bool |
|
| 136 | + */ |
|
| 137 | + public function hasInlineDataCallback() |
|
| 138 | + { |
|
| 139 | + return $this->inline_data_callback instanceof Closure; |
|
| 140 | + } |
|
| 141 | + |
|
| 142 | + |
|
| 143 | + /** |
|
| 144 | + * @param Closure $inline_data_callback |
|
| 145 | + * @return JavascriptAsset |
|
| 146 | + */ |
|
| 147 | + public function setInlineDataCallback(Closure $inline_data_callback) |
|
| 148 | + { |
|
| 149 | + $this->inline_data_callback = $inline_data_callback; |
|
| 150 | + $this->setHasInlineData(); |
|
| 151 | + return $this; |
|
| 152 | + } |
|
| 153 | + |
|
| 154 | + |
|
| 155 | + /** |
|
| 156 | + * @since 4.9.62.p |
|
| 157 | + */ |
|
| 158 | + public function enqueueAsset() |
|
| 159 | + { |
|
| 160 | + wp_enqueue_script($this->handle()); |
|
| 161 | + } |
|
| 162 | 162 | } |
@@ -12,12 +12,12 @@ discard block |
||
| 12 | 12 | // unfortunately, this needs to be done upon INCLUSION of this file, |
| 13 | 13 | // instead of construction, because it only gets constructed on first page load |
| 14 | 14 | // (all other times it gets resurrected from a wordpress option) |
| 15 | -$stages = glob(EE_CORE . 'data_migration_scripts/4_10_0_stages/*'); |
|
| 15 | +$stages = glob(EE_CORE.'data_migration_scripts/4_10_0_stages/*'); |
|
| 16 | 16 | $class_to_filepath = []; |
| 17 | 17 | foreach ($stages as $filepath) { |
| 18 | 18 | $matches = []; |
| 19 | 19 | preg_match('~4_10_0_stages/(.*).dmsstage.php~', $filepath, $matches); |
| 20 | - $class_to_filepath[ $matches[1] ] = $filepath; |
|
| 20 | + $class_to_filepath[$matches[1]] = $filepath; |
|
| 21 | 21 | } |
| 22 | 22 | // give addons a chance to autoload their stages too |
| 23 | 23 | $class_to_filepath = apply_filters('FHEE__EE_DMS_4_10_0__autoloaded_stages', $class_to_filepath); |
@@ -67,10 +67,10 @@ discard block |
||
| 67 | 67 | $version_string = $version_array['Core']; |
| 68 | 68 | if (version_compare($version_string, '4.10.0.decaf', '<') && version_compare($version_string, '4.9.0.decaf', '>=')) { |
| 69 | 69 | return true; |
| 70 | - } elseif (! $version_string) { |
|
| 70 | + } elseif ( ! $version_string) { |
|
| 71 | 71 | // echo "no version string provided: $version_string"; |
| 72 | 72 | // no version string provided... this must be pre 4.3 |
| 73 | - return false;// changed mind. dont want people thinking they should migrate yet because they cant |
|
| 73 | + return false; // changed mind. dont want people thinking they should migrate yet because they cant |
|
| 74 | 74 | } |
| 75 | 75 | return false; |
| 76 | 76 | } |
@@ -82,7 +82,7 @@ discard block |
||
| 82 | 82 | */ |
| 83 | 83 | public function schema_changes_before_migration() |
| 84 | 84 | { |
| 85 | - require_once(EE_HELPERS . 'EEH_Activation.helper.php'); |
|
| 85 | + require_once(EE_HELPERS.'EEH_Activation.helper.php'); |
|
| 86 | 86 | $now_in_mysql = current_time('mysql', true); |
| 87 | 87 | $table_name = 'esp_answer'; |
| 88 | 88 | $sql = " ANS_ID int(10) unsigned NOT NULL AUTO_INCREMENT, |
@@ -633,7 +633,7 @@ discard block |
||
| 633 | 633 | { |
| 634 | 634 | global $wpdb; |
| 635 | 635 | $wpdb->update( |
| 636 | - $wpdb->prefix . 'esp_payment_method', |
|
| 636 | + $wpdb->prefix.'esp_payment_method', |
|
| 637 | 637 | [ |
| 638 | 638 | 'PMD_type' => 'Admin_Only', |
| 639 | 639 | 'PMD_scope' => serialize(array()) |
@@ -15,9 +15,9 @@ discard block |
||
| 15 | 15 | $stages = glob(EE_CORE . 'data_migration_scripts/4_10_0_stages/*'); |
| 16 | 16 | $class_to_filepath = []; |
| 17 | 17 | foreach ($stages as $filepath) { |
| 18 | - $matches = []; |
|
| 19 | - preg_match('~4_10_0_stages/(.*).dmsstage.php~', $filepath, $matches); |
|
| 20 | - $class_to_filepath[ $matches[1] ] = $filepath; |
|
| 18 | + $matches = []; |
|
| 19 | + preg_match('~4_10_0_stages/(.*).dmsstage.php~', $filepath, $matches); |
|
| 20 | + $class_to_filepath[ $matches[1] ] = $filepath; |
|
| 21 | 21 | } |
| 22 | 22 | // give addons a chance to autoload their stages too |
| 23 | 23 | $class_to_filepath = apply_filters('FHEE__EE_DMS_4_10_0__autoloaded_stages', $class_to_filepath); |
@@ -35,66 +35,66 @@ discard block |
||
| 35 | 35 | */ |
| 36 | 36 | class EE_DMS_Core_4_10_0 extends EE_Data_Migration_Script_Base |
| 37 | 37 | { |
| 38 | - /** |
|
| 39 | - * |
|
| 40 | - * @param TableManager $table_manager |
|
| 41 | - * @param TableAnalysis $table_analysis |
|
| 42 | - */ |
|
| 43 | - public function __construct( |
|
| 44 | - TableManager $table_manager = null, |
|
| 45 | - TableAnalysis $table_analysis = null, |
|
| 46 | - EE_DMS_Core_4_9_0 $dms_4_9 |
|
| 47 | - ) { |
|
| 48 | - $this->previous_dms = $dms_4_9; |
|
| 49 | - $this->_pretty_name = esc_html__("Data Update to Event Espresso 4.10.0", "event_espresso"); |
|
| 50 | - $this->_priority = 10; |
|
| 51 | - $this->_migration_stages = array( |
|
| 52 | - new EE_DMS_4_10_0_Event_Question_Group(), |
|
| 53 | - ); |
|
| 54 | - parent::__construct($table_manager, $table_analysis); |
|
| 55 | - } |
|
| 38 | + /** |
|
| 39 | + * |
|
| 40 | + * @param TableManager $table_manager |
|
| 41 | + * @param TableAnalysis $table_analysis |
|
| 42 | + */ |
|
| 43 | + public function __construct( |
|
| 44 | + TableManager $table_manager = null, |
|
| 45 | + TableAnalysis $table_analysis = null, |
|
| 46 | + EE_DMS_Core_4_9_0 $dms_4_9 |
|
| 47 | + ) { |
|
| 48 | + $this->previous_dms = $dms_4_9; |
|
| 49 | + $this->_pretty_name = esc_html__("Data Update to Event Espresso 4.10.0", "event_espresso"); |
|
| 50 | + $this->_priority = 10; |
|
| 51 | + $this->_migration_stages = array( |
|
| 52 | + new EE_DMS_4_10_0_Event_Question_Group(), |
|
| 53 | + ); |
|
| 54 | + parent::__construct($table_manager, $table_analysis); |
|
| 55 | + } |
|
| 56 | 56 | |
| 57 | 57 | |
| 58 | 58 | |
| 59 | - /** |
|
| 60 | - * Whether to migrate or not. |
|
| 61 | - * |
|
| 62 | - * @param array $version_array |
|
| 63 | - * @return bool |
|
| 64 | - */ |
|
| 65 | - public function can_migrate_from_version($version_array) |
|
| 66 | - { |
|
| 67 | - $version_string = $version_array['Core']; |
|
| 68 | - if (version_compare($version_string, '4.10.0.decaf', '<') && version_compare($version_string, '4.9.0.decaf', '>=')) { |
|
| 69 | - return true; |
|
| 70 | - } elseif (! $version_string) { |
|
| 71 | - // echo "no version string provided: $version_string"; |
|
| 72 | - // no version string provided... this must be pre 4.3 |
|
| 73 | - return false;// changed mind. dont want people thinking they should migrate yet because they cant |
|
| 74 | - } |
|
| 75 | - return false; |
|
| 76 | - } |
|
| 59 | + /** |
|
| 60 | + * Whether to migrate or not. |
|
| 61 | + * |
|
| 62 | + * @param array $version_array |
|
| 63 | + * @return bool |
|
| 64 | + */ |
|
| 65 | + public function can_migrate_from_version($version_array) |
|
| 66 | + { |
|
| 67 | + $version_string = $version_array['Core']; |
|
| 68 | + if (version_compare($version_string, '4.10.0.decaf', '<') && version_compare($version_string, '4.9.0.decaf', '>=')) { |
|
| 69 | + return true; |
|
| 70 | + } elseif (! $version_string) { |
|
| 71 | + // echo "no version string provided: $version_string"; |
|
| 72 | + // no version string provided... this must be pre 4.3 |
|
| 73 | + return false;// changed mind. dont want people thinking they should migrate yet because they cant |
|
| 74 | + } |
|
| 75 | + return false; |
|
| 76 | + } |
|
| 77 | 77 | |
| 78 | 78 | |
| 79 | 79 | |
| 80 | - /** |
|
| 81 | - * @return bool |
|
| 82 | - */ |
|
| 83 | - public function schema_changes_before_migration() |
|
| 84 | - { |
|
| 85 | - require_once(EE_HELPERS . 'EEH_Activation.helper.php'); |
|
| 86 | - $now_in_mysql = current_time('mysql', true); |
|
| 87 | - $table_name = 'esp_answer'; |
|
| 88 | - $sql = " ANS_ID int(10) unsigned NOT NULL AUTO_INCREMENT, |
|
| 80 | + /** |
|
| 81 | + * @return bool |
|
| 82 | + */ |
|
| 83 | + public function schema_changes_before_migration() |
|
| 84 | + { |
|
| 85 | + require_once(EE_HELPERS . 'EEH_Activation.helper.php'); |
|
| 86 | + $now_in_mysql = current_time('mysql', true); |
|
| 87 | + $table_name = 'esp_answer'; |
|
| 88 | + $sql = " ANS_ID int(10) unsigned NOT NULL AUTO_INCREMENT, |
|
| 89 | 89 | REG_ID int(10) unsigned NOT NULL, |
| 90 | 90 | QST_ID int(10) unsigned NOT NULL, |
| 91 | 91 | ANS_value text NOT NULL, |
| 92 | 92 | PRIMARY KEY (ANS_ID), |
| 93 | 93 | KEY REG_ID (REG_ID), |
| 94 | 94 | KEY QST_ID (QST_ID)"; |
| 95 | - $this->_table_has_not_changed_since_previous($table_name, $sql, 'ENGINE=InnoDB'); |
|
| 96 | - $table_name = 'esp_attendee_meta'; |
|
| 97 | - $sql = "ATTM_ID int(10) unsigned NOT NULL AUTO_INCREMENT, |
|
| 95 | + $this->_table_has_not_changed_since_previous($table_name, $sql, 'ENGINE=InnoDB'); |
|
| 96 | + $table_name = 'esp_attendee_meta'; |
|
| 97 | + $sql = "ATTM_ID int(10) unsigned NOT NULL AUTO_INCREMENT, |
|
| 98 | 98 | ATT_ID bigint(20) unsigned NOT NULL, |
| 99 | 99 | ATT_fname varchar(45) NOT NULL, |
| 100 | 100 | ATT_lname varchar(45) NOT NULL, |
@@ -111,9 +111,9 @@ discard block |
||
| 111 | 111 | KEY ATT_email (ATT_email(191)), |
| 112 | 112 | KEY ATT_lname (ATT_lname), |
| 113 | 113 | KEY ATT_fname (ATT_fname)"; |
| 114 | - $this->_table_has_not_changed_since_previous($table_name, $sql, 'ENGINE=InnoDB '); |
|
| 115 | - $table_name = 'esp_checkin'; |
|
| 116 | - $sql = "CHK_ID int(10) unsigned NOT NULL AUTO_INCREMENT, |
|
| 114 | + $this->_table_has_not_changed_since_previous($table_name, $sql, 'ENGINE=InnoDB '); |
|
| 115 | + $table_name = 'esp_checkin'; |
|
| 116 | + $sql = "CHK_ID int(10) unsigned NOT NULL AUTO_INCREMENT, |
|
| 117 | 117 | REG_ID int(10) unsigned NOT NULL, |
| 118 | 118 | DTT_ID int(10) unsigned NOT NULL, |
| 119 | 119 | CHK_in tinyint(1) unsigned NOT NULL DEFAULT 1, |
@@ -121,9 +121,9 @@ discard block |
||
| 121 | 121 | PRIMARY KEY (CHK_ID), |
| 122 | 122 | KEY REG_ID (REG_ID), |
| 123 | 123 | KEY DTT_ID (DTT_ID)"; |
| 124 | - $this->_table_has_not_changed_since_previous($table_name, $sql, 'ENGINE=InnoDB'); |
|
| 125 | - $table_name = 'esp_country'; |
|
| 126 | - $sql = "CNT_ISO varchar(2) NOT NULL, |
|
| 124 | + $this->_table_has_not_changed_since_previous($table_name, $sql, 'ENGINE=InnoDB'); |
|
| 125 | + $table_name = 'esp_country'; |
|
| 126 | + $sql = "CNT_ISO varchar(2) NOT NULL, |
|
| 127 | 127 | CNT_ISO3 varchar(3) NOT NULL, |
| 128 | 128 | RGN_ID tinyint(3) unsigned DEFAULT NULL, |
| 129 | 129 | CNT_name varchar(45) NOT NULL, |
@@ -139,29 +139,29 @@ discard block |
||
| 139 | 139 | CNT_is_EU tinyint(1) DEFAULT '0', |
| 140 | 140 | CNT_active tinyint(1) DEFAULT '0', |
| 141 | 141 | PRIMARY KEY (CNT_ISO)"; |
| 142 | - $this->_table_has_not_changed_since_previous($table_name, $sql, 'ENGINE=InnoDB'); |
|
| 143 | - $table_name = 'esp_currency'; |
|
| 144 | - $sql = "CUR_code varchar(6) NOT NULL, |
|
| 142 | + $this->_table_has_not_changed_since_previous($table_name, $sql, 'ENGINE=InnoDB'); |
|
| 143 | + $table_name = 'esp_currency'; |
|
| 144 | + $sql = "CUR_code varchar(6) NOT NULL, |
|
| 145 | 145 | CUR_single varchar(45) DEFAULT 'dollar', |
| 146 | 146 | CUR_plural varchar(45) DEFAULT 'dollars', |
| 147 | 147 | CUR_sign varchar(45) DEFAULT '$', |
| 148 | 148 | CUR_dec_plc varchar(1) NOT NULL DEFAULT '2', |
| 149 | 149 | CUR_active tinyint(1) DEFAULT '0', |
| 150 | 150 | PRIMARY KEY (CUR_code)"; |
| 151 | - $this->_table_has_not_changed_since_previous($table_name, $sql, 'ENGINE=InnoDB'); |
|
| 152 | - // note: although this table is no longer in use, |
|
| 153 | - // it hasn't been removed because then queries to the model will have errors. |
|
| 154 | - // but you should expect this table and its corresponding model to be removed in |
|
| 155 | - // the next few months |
|
| 156 | - $table_name = 'esp_currency_payment_method'; |
|
| 157 | - $sql = "CPM_ID int(11) NOT NULL AUTO_INCREMENT, |
|
| 151 | + $this->_table_has_not_changed_since_previous($table_name, $sql, 'ENGINE=InnoDB'); |
|
| 152 | + // note: although this table is no longer in use, |
|
| 153 | + // it hasn't been removed because then queries to the model will have errors. |
|
| 154 | + // but you should expect this table and its corresponding model to be removed in |
|
| 155 | + // the next few months |
|
| 156 | + $table_name = 'esp_currency_payment_method'; |
|
| 157 | + $sql = "CPM_ID int(11) NOT NULL AUTO_INCREMENT, |
|
| 158 | 158 | CUR_code varchar(6) NOT NULL, |
| 159 | 159 | PMD_ID int(11) NOT NULL, |
| 160 | 160 | PRIMARY KEY (CPM_ID), |
| 161 | 161 | KEY PMD_ID (PMD_ID)"; |
| 162 | - $this->_table_has_not_changed_since_previous($table_name, $sql, 'ENGINE=InnoDB '); |
|
| 163 | - $table_name = 'esp_datetime'; |
|
| 164 | - $sql = "DTT_ID int(10) unsigned NOT NULL AUTO_INCREMENT, |
|
| 162 | + $this->_table_has_not_changed_since_previous($table_name, $sql, 'ENGINE=InnoDB '); |
|
| 163 | + $table_name = 'esp_datetime'; |
|
| 164 | + $sql = "DTT_ID int(10) unsigned NOT NULL AUTO_INCREMENT, |
|
| 165 | 165 | EVT_ID bigint(20) unsigned NOT NULL, |
| 166 | 166 | DTT_name varchar(255) NOT NULL DEFAULT '', |
| 167 | 167 | DTT_description text NOT NULL, |
@@ -178,25 +178,25 @@ discard block |
||
| 178 | 178 | KEY DTT_EVT_start (DTT_EVT_start), |
| 179 | 179 | KEY EVT_ID (EVT_ID), |
| 180 | 180 | KEY DTT_is_primary (DTT_is_primary)"; |
| 181 | - $this->_table_has_not_changed_since_previous($table_name, $sql, 'ENGINE=InnoDB'); |
|
| 182 | - $table_name = "esp_datetime_ticket"; |
|
| 183 | - $sql = "DTK_ID int(10) unsigned NOT NULL AUTO_INCREMENT, |
|
| 181 | + $this->_table_has_not_changed_since_previous($table_name, $sql, 'ENGINE=InnoDB'); |
|
| 182 | + $table_name = "esp_datetime_ticket"; |
|
| 183 | + $sql = "DTK_ID int(10) unsigned NOT NULL AUTO_INCREMENT, |
|
| 184 | 184 | DTT_ID int(10) unsigned NOT NULL, |
| 185 | 185 | TKT_ID int(10) unsigned NOT NULL, |
| 186 | 186 | PRIMARY KEY (DTK_ID), |
| 187 | 187 | KEY DTT_ID (DTT_ID), |
| 188 | 188 | KEY TKT_ID (TKT_ID)"; |
| 189 | - $this->_table_has_not_changed_since_previous($table_name, $sql, 'ENGINE=InnoDB'); |
|
| 190 | - $table_name = 'esp_event_message_template'; |
|
| 191 | - $sql = "EMT_ID bigint(20) unsigned NOT NULL AUTO_INCREMENT, |
|
| 189 | + $this->_table_has_not_changed_since_previous($table_name, $sql, 'ENGINE=InnoDB'); |
|
| 190 | + $table_name = 'esp_event_message_template'; |
|
| 191 | + $sql = "EMT_ID bigint(20) unsigned NOT NULL AUTO_INCREMENT, |
|
| 192 | 192 | EVT_ID bigint(20) unsigned NOT NULL DEFAULT 0, |
| 193 | 193 | GRP_ID int(10) unsigned NOT NULL DEFAULT 0, |
| 194 | 194 | PRIMARY KEY (EMT_ID), |
| 195 | 195 | KEY EVT_ID (EVT_ID), |
| 196 | 196 | KEY GRP_ID (GRP_ID)"; |
| 197 | - $this->_table_has_not_changed_since_previous($table_name, $sql, 'ENGINE=InnoDB'); |
|
| 198 | - $table_name = 'esp_event_meta'; |
|
| 199 | - $sql = "EVTM_ID int(10) NOT NULL AUTO_INCREMENT, |
|
| 197 | + $this->_table_has_not_changed_since_previous($table_name, $sql, 'ENGINE=InnoDB'); |
|
| 198 | + $table_name = 'esp_event_meta'; |
|
| 199 | + $sql = "EVTM_ID int(10) NOT NULL AUTO_INCREMENT, |
|
| 200 | 200 | EVT_ID bigint(20) unsigned NOT NULL, |
| 201 | 201 | EVT_display_desc tinyint(1) unsigned NOT NULL DEFAULT 1, |
| 202 | 202 | EVT_display_ticket_selector tinyint(1) unsigned NOT NULL DEFAULT 1, |
@@ -211,9 +211,9 @@ discard block |
||
| 211 | 211 | EVT_donations tinyint(1) NULL, |
| 212 | 212 | PRIMARY KEY (EVTM_ID), |
| 213 | 213 | KEY EVT_ID (EVT_ID)"; |
| 214 | - $this->_table_has_not_changed_since_previous($table_name, $sql, 'ENGINE=InnoDB'); |
|
| 215 | - $table_name = 'esp_event_question_group'; |
|
| 216 | - $sql = "EQG_ID int(10) unsigned NOT NULL AUTO_INCREMENT, |
|
| 214 | + $this->_table_has_not_changed_since_previous($table_name, $sql, 'ENGINE=InnoDB'); |
|
| 215 | + $table_name = 'esp_event_question_group'; |
|
| 216 | + $sql = "EQG_ID int(10) unsigned NOT NULL AUTO_INCREMENT, |
|
| 217 | 217 | EVT_ID bigint(20) unsigned NOT NULL, |
| 218 | 218 | QSG_ID int(10) unsigned NOT NULL, |
| 219 | 219 | EQG_primary tinyint(1) unsigned NOT NULL DEFAULT 0, |
@@ -221,25 +221,25 @@ discard block |
||
| 221 | 221 | PRIMARY KEY (EQG_ID), |
| 222 | 222 | KEY EVT_ID (EVT_ID), |
| 223 | 223 | KEY QSG_ID (QSG_ID)"; |
| 224 | - $this->_table_is_changed_in_this_version($table_name, $sql, 'ENGINE=InnoDB'); |
|
| 225 | - $table_name = 'esp_event_venue'; |
|
| 226 | - $sql = "EVV_ID int(11) NOT NULL AUTO_INCREMENT, |
|
| 224 | + $this->_table_is_changed_in_this_version($table_name, $sql, 'ENGINE=InnoDB'); |
|
| 225 | + $table_name = 'esp_event_venue'; |
|
| 226 | + $sql = "EVV_ID int(11) NOT NULL AUTO_INCREMENT, |
|
| 227 | 227 | EVT_ID bigint(20) unsigned NOT NULL, |
| 228 | 228 | VNU_ID bigint(20) unsigned NOT NULL, |
| 229 | 229 | EVV_primary tinyint(1) unsigned NOT NULL DEFAULT 0, |
| 230 | 230 | PRIMARY KEY (EVV_ID)"; |
| 231 | - $this->_table_has_not_changed_since_previous($table_name, $sql, 'ENGINE=InnoDB'); |
|
| 232 | - $table_name = 'esp_extra_meta'; |
|
| 233 | - $sql = "EXM_ID int(11) NOT NULL AUTO_INCREMENT, |
|
| 231 | + $this->_table_has_not_changed_since_previous($table_name, $sql, 'ENGINE=InnoDB'); |
|
| 232 | + $table_name = 'esp_extra_meta'; |
|
| 233 | + $sql = "EXM_ID int(11) NOT NULL AUTO_INCREMENT, |
|
| 234 | 234 | OBJ_ID int(11) DEFAULT NULL, |
| 235 | 235 | EXM_type varchar(45) DEFAULT NULL, |
| 236 | 236 | EXM_key varchar(45) DEFAULT NULL, |
| 237 | 237 | EXM_value text, |
| 238 | 238 | PRIMARY KEY (EXM_ID), |
| 239 | 239 | KEY EXM_type (EXM_type,OBJ_ID,EXM_key)"; |
| 240 | - $this->_table_has_not_changed_since_previous($table_name, $sql, 'ENGINE=InnoDB'); |
|
| 241 | - $table_name = 'esp_extra_join'; |
|
| 242 | - $sql = "EXJ_ID int(11) NOT NULL AUTO_INCREMENT, |
|
| 240 | + $this->_table_has_not_changed_since_previous($table_name, $sql, 'ENGINE=InnoDB'); |
|
| 241 | + $table_name = 'esp_extra_join'; |
|
| 242 | + $sql = "EXJ_ID int(11) NOT NULL AUTO_INCREMENT, |
|
| 243 | 243 | EXJ_first_model_id varchar(6) NOT NULL, |
| 244 | 244 | EXJ_first_model_name varchar(20) NOT NULL, |
| 245 | 245 | EXJ_second_model_id varchar(6) NOT NULL, |
@@ -247,9 +247,9 @@ discard block |
||
| 247 | 247 | PRIMARY KEY (EXJ_ID), |
| 248 | 248 | KEY first_model (EXJ_first_model_name,EXJ_first_model_id), |
| 249 | 249 | KEY second_model (EXJ_second_model_name,EXJ_second_model_id)"; |
| 250 | - $this->_table_has_not_changed_since_previous($table_name, $sql, 'ENGINE=InnoDB '); |
|
| 251 | - $table_name = 'esp_line_item'; |
|
| 252 | - $sql = "LIN_ID int(11) NOT NULL AUTO_INCREMENT, |
|
| 250 | + $this->_table_has_not_changed_since_previous($table_name, $sql, 'ENGINE=InnoDB '); |
|
| 251 | + $table_name = 'esp_line_item'; |
|
| 252 | + $sql = "LIN_ID int(11) NOT NULL AUTO_INCREMENT, |
|
| 253 | 253 | LIN_code varchar(245) NOT NULL DEFAULT '', |
| 254 | 254 | TXN_ID int(11) DEFAULT NULL, |
| 255 | 255 | LIN_name varchar(245) NOT NULL DEFAULT '', |
@@ -270,9 +270,9 @@ discard block |
||
| 270 | 270 | KEY txn_type_timestamp (TXN_ID,LIN_type,LIN_timestamp), |
| 271 | 271 | KEY txn_obj_id_obj_type (TXN_ID,OBJ_ID,OBJ_type), |
| 272 | 272 | KEY obj_id_obj_type (OBJ_ID,OBJ_type)"; |
| 273 | - $this->_table_has_not_changed_since_previous($table_name, $sql, 'ENGINE=InnoDB'); |
|
| 274 | - $table_name = 'esp_log'; |
|
| 275 | - $sql = "LOG_ID int(11) NOT NULL AUTO_INCREMENT, |
|
| 273 | + $this->_table_has_not_changed_since_previous($table_name, $sql, 'ENGINE=InnoDB'); |
|
| 274 | + $table_name = 'esp_log'; |
|
| 275 | + $sql = "LOG_ID int(11) NOT NULL AUTO_INCREMENT, |
|
| 276 | 276 | LOG_time datetime DEFAULT NULL, |
| 277 | 277 | OBJ_ID varchar(45) DEFAULT NULL, |
| 278 | 278 | OBJ_type varchar(45) DEFAULT NULL, |
@@ -283,9 +283,9 @@ discard block |
||
| 283 | 283 | KEY LOG_time (LOG_time), |
| 284 | 284 | KEY OBJ (OBJ_type,OBJ_ID), |
| 285 | 285 | KEY LOG_type (LOG_type)"; |
| 286 | - $this->_table_has_not_changed_since_previous($table_name, $sql, 'ENGINE=InnoDB'); |
|
| 287 | - $table_name = 'esp_message'; |
|
| 288 | - $sql = "MSG_ID bigint(20) unsigned NOT NULL AUTO_INCREMENT, |
|
| 286 | + $this->_table_has_not_changed_since_previous($table_name, $sql, 'ENGINE=InnoDB'); |
|
| 287 | + $table_name = 'esp_message'; |
|
| 288 | + $sql = "MSG_ID bigint(20) unsigned NOT NULL AUTO_INCREMENT, |
|
| 289 | 289 | GRP_ID int(10) unsigned NULL, |
| 290 | 290 | MSG_token varchar(255) NULL, |
| 291 | 291 | TXN_ID int(10) unsigned NULL, |
@@ -317,18 +317,18 @@ discard block |
||
| 317 | 317 | KEY STS_ID (STS_ID), |
| 318 | 318 | KEY MSG_created (MSG_created), |
| 319 | 319 | KEY MSG_modified (MSG_modified)"; |
| 320 | - $this->_table_is_new_in_this_version($table_name, $sql, 'ENGINE=InnoDB'); |
|
| 321 | - $table_name = 'esp_message_template'; |
|
| 322 | - $sql = "MTP_ID int(10) unsigned NOT NULL AUTO_INCREMENT, |
|
| 320 | + $this->_table_is_new_in_this_version($table_name, $sql, 'ENGINE=InnoDB'); |
|
| 321 | + $table_name = 'esp_message_template'; |
|
| 322 | + $sql = "MTP_ID int(10) unsigned NOT NULL AUTO_INCREMENT, |
|
| 323 | 323 | GRP_ID int(10) unsigned NOT NULL, |
| 324 | 324 | MTP_context varchar(50) NOT NULL, |
| 325 | 325 | MTP_template_field varchar(30) NOT NULL, |
| 326 | 326 | MTP_content text NOT NULL, |
| 327 | 327 | PRIMARY KEY (MTP_ID), |
| 328 | 328 | KEY GRP_ID (GRP_ID)"; |
| 329 | - $this->_table_has_not_changed_since_previous($table_name, $sql, 'ENGINE=InnoDB'); |
|
| 330 | - $table_name = 'esp_message_template_group'; |
|
| 331 | - $sql = "GRP_ID int(10) unsigned NOT NULL AUTO_INCREMENT, |
|
| 329 | + $this->_table_has_not_changed_since_previous($table_name, $sql, 'ENGINE=InnoDB'); |
|
| 330 | + $table_name = 'esp_message_template_group'; |
|
| 331 | + $sql = "GRP_ID int(10) unsigned NOT NULL AUTO_INCREMENT, |
|
| 332 | 332 | MTP_user_id int(10) NOT NULL DEFAULT '1', |
| 333 | 333 | MTP_name varchar(245) NOT NULL DEFAULT '', |
| 334 | 334 | MTP_description varchar(245) NOT NULL DEFAULT '', |
@@ -340,9 +340,9 @@ discard block |
||
| 340 | 340 | MTP_is_active tinyint(1) NOT NULL DEFAULT '1', |
| 341 | 341 | PRIMARY KEY (GRP_ID), |
| 342 | 342 | KEY MTP_user_id (MTP_user_id)"; |
| 343 | - $this->_table_has_not_changed_since_previous($table_name, $sql, 'ENGINE=InnoDB'); |
|
| 344 | - $table_name = 'esp_payment'; |
|
| 345 | - $sql = "PAY_ID int(10) unsigned NOT NULL AUTO_INCREMENT, |
|
| 343 | + $this->_table_has_not_changed_since_previous($table_name, $sql, 'ENGINE=InnoDB'); |
|
| 344 | + $table_name = 'esp_payment'; |
|
| 345 | + $sql = "PAY_ID int(10) unsigned NOT NULL AUTO_INCREMENT, |
|
| 346 | 346 | TXN_ID int(10) unsigned DEFAULT NULL, |
| 347 | 347 | STS_ID varchar(3) DEFAULT NULL, |
| 348 | 348 | PAY_timestamp datetime NOT NULL DEFAULT '0000-00-00 00:00:00', |
@@ -359,9 +359,9 @@ discard block |
||
| 359 | 359 | PRIMARY KEY (PAY_ID), |
| 360 | 360 | KEY PAY_timestamp (PAY_timestamp), |
| 361 | 361 | KEY TXN_ID (TXN_ID)"; |
| 362 | - $this->_table_has_not_changed_since_previous($table_name, $sql, 'ENGINE=InnoDB '); |
|
| 363 | - $table_name = 'esp_payment_method'; |
|
| 364 | - $sql = "PMD_ID int(11) NOT NULL AUTO_INCREMENT, |
|
| 362 | + $this->_table_has_not_changed_since_previous($table_name, $sql, 'ENGINE=InnoDB '); |
|
| 363 | + $table_name = 'esp_payment_method'; |
|
| 364 | + $sql = "PMD_ID int(11) NOT NULL AUTO_INCREMENT, |
|
| 365 | 365 | PMD_type varchar(124) DEFAULT NULL, |
| 366 | 366 | PMD_name varchar(255) DEFAULT NULL, |
| 367 | 367 | PMD_desc text, |
@@ -377,24 +377,24 @@ discard block |
||
| 377 | 377 | PRIMARY KEY (PMD_ID), |
| 378 | 378 | UNIQUE KEY PMD_slug_UNIQUE (PMD_slug), |
| 379 | 379 | KEY PMD_type (PMD_type)"; |
| 380 | - $this->_table_has_not_changed_since_previous($table_name, $sql, 'ENGINE=InnoDB '); |
|
| 381 | - $table_name = "esp_ticket_price"; |
|
| 382 | - $sql = "TKP_ID int(10) unsigned NOT NULL AUTO_INCREMENT, |
|
| 380 | + $this->_table_has_not_changed_since_previous($table_name, $sql, 'ENGINE=InnoDB '); |
|
| 381 | + $table_name = "esp_ticket_price"; |
|
| 382 | + $sql = "TKP_ID int(10) unsigned NOT NULL AUTO_INCREMENT, |
|
| 383 | 383 | TKT_ID int(10) unsigned NOT NULL, |
| 384 | 384 | PRC_ID int(10) unsigned NOT NULL, |
| 385 | 385 | PRIMARY KEY (TKP_ID), |
| 386 | 386 | KEY TKT_ID (TKT_ID), |
| 387 | 387 | KEY PRC_ID (PRC_ID)"; |
| 388 | - $this->_table_has_not_changed_since_previous($table_name, $sql, 'ENGINE=InnoDB'); |
|
| 389 | - $table_name = "esp_ticket_template"; |
|
| 390 | - $sql = "TTM_ID int(10) unsigned NOT NULL AUTO_INCREMENT, |
|
| 388 | + $this->_table_has_not_changed_since_previous($table_name, $sql, 'ENGINE=InnoDB'); |
|
| 389 | + $table_name = "esp_ticket_template"; |
|
| 390 | + $sql = "TTM_ID int(10) unsigned NOT NULL AUTO_INCREMENT, |
|
| 391 | 391 | TTM_name varchar(45) NOT NULL, |
| 392 | 392 | TTM_description text, |
| 393 | 393 | TTM_file varchar(45), |
| 394 | 394 | PRIMARY KEY (TTM_ID)"; |
| 395 | - $this->_table_has_not_changed_since_previous($table_name, $sql, 'ENGINE=InnoDB'); |
|
| 396 | - $table_name = 'esp_question'; |
|
| 397 | - $sql = 'QST_ID int(10) unsigned NOT NULL AUTO_INCREMENT, |
|
| 395 | + $this->_table_has_not_changed_since_previous($table_name, $sql, 'ENGINE=InnoDB'); |
|
| 396 | + $table_name = 'esp_question'; |
|
| 397 | + $sql = 'QST_ID int(10) unsigned NOT NULL AUTO_INCREMENT, |
|
| 398 | 398 | QST_display_text text NOT NULL, |
| 399 | 399 | QST_admin_label varchar(255) NOT NULL, |
| 400 | 400 | QST_system varchar(25) DEFAULT NULL, |
@@ -408,18 +408,18 @@ discard block |
||
| 408 | 408 | QST_deleted tinyint(2) unsigned NOT NULL DEFAULT 0, |
| 409 | 409 | PRIMARY KEY (QST_ID), |
| 410 | 410 | KEY QST_order (QST_order)'; |
| 411 | - $this->_table_has_not_changed_since_previous($table_name, $sql, 'ENGINE=InnoDB'); |
|
| 412 | - $table_name = 'esp_question_group_question'; |
|
| 413 | - $sql = "QGQ_ID int(10) unsigned NOT NULL AUTO_INCREMENT, |
|
| 411 | + $this->_table_has_not_changed_since_previous($table_name, $sql, 'ENGINE=InnoDB'); |
|
| 412 | + $table_name = 'esp_question_group_question'; |
|
| 413 | + $sql = "QGQ_ID int(10) unsigned NOT NULL AUTO_INCREMENT, |
|
| 414 | 414 | QSG_ID int(10) unsigned NOT NULL, |
| 415 | 415 | QST_ID int(10) unsigned NOT NULL, |
| 416 | 416 | QGQ_order int(10) unsigned NOT NULL DEFAULT 0, |
| 417 | 417 | PRIMARY KEY (QGQ_ID), |
| 418 | 418 | KEY QST_ID (QST_ID), |
| 419 | 419 | KEY QSG_ID_order (QSG_ID,QGQ_order)"; |
| 420 | - $this->_table_has_not_changed_since_previous($table_name, $sql, 'ENGINE=InnoDB'); |
|
| 421 | - $table_name = 'esp_question_option'; |
|
| 422 | - $sql = "QSO_ID int(10) unsigned NOT NULL AUTO_INCREMENT, |
|
| 420 | + $this->_table_has_not_changed_since_previous($table_name, $sql, 'ENGINE=InnoDB'); |
|
| 421 | + $table_name = 'esp_question_option'; |
|
| 422 | + $sql = "QSO_ID int(10) unsigned NOT NULL AUTO_INCREMENT, |
|
| 423 | 423 | QSO_value varchar(255) NOT NULL, |
| 424 | 424 | QSO_desc text NOT NULL, |
| 425 | 425 | QST_ID int(10) unsigned NOT NULL, |
@@ -429,9 +429,9 @@ discard block |
||
| 429 | 429 | PRIMARY KEY (QSO_ID), |
| 430 | 430 | KEY QST_ID (QST_ID), |
| 431 | 431 | KEY QSO_order (QSO_order)"; |
| 432 | - $this->_table_has_not_changed_since_previous($table_name, $sql, 'ENGINE=InnoDB'); |
|
| 433 | - $table_name = 'esp_registration'; |
|
| 434 | - $sql = "REG_ID int(10) unsigned NOT NULL AUTO_INCREMENT, |
|
| 432 | + $this->_table_has_not_changed_since_previous($table_name, $sql, 'ENGINE=InnoDB'); |
|
| 433 | + $table_name = 'esp_registration'; |
|
| 434 | + $sql = "REG_ID int(10) unsigned NOT NULL AUTO_INCREMENT, |
|
| 435 | 435 | EVT_ID bigint(20) unsigned NOT NULL, |
| 436 | 436 | ATT_ID bigint(20) unsigned NOT NULL, |
| 437 | 437 | TXN_ID int(10) unsigned NOT NULL, |
@@ -455,18 +455,18 @@ discard block |
||
| 455 | 455 | KEY TKT_ID (TKT_ID), |
| 456 | 456 | KEY EVT_ID (EVT_ID), |
| 457 | 457 | KEY STS_ID (STS_ID)"; |
| 458 | - $this->_table_has_not_changed_since_previous($table_name, $sql, 'ENGINE=InnoDB '); |
|
| 459 | - $table_name = 'esp_registration_payment'; |
|
| 460 | - $sql = "RPY_ID int(10) unsigned NOT NULL AUTO_INCREMENT, |
|
| 458 | + $this->_table_has_not_changed_since_previous($table_name, $sql, 'ENGINE=InnoDB '); |
|
| 459 | + $table_name = 'esp_registration_payment'; |
|
| 460 | + $sql = "RPY_ID int(10) unsigned NOT NULL AUTO_INCREMENT, |
|
| 461 | 461 | REG_ID int(10) unsigned NOT NULL, |
| 462 | 462 | PAY_ID int(10) unsigned NULL, |
| 463 | 463 | RPY_amount decimal(12,3) NOT NULL DEFAULT '0.00', |
| 464 | 464 | PRIMARY KEY (RPY_ID), |
| 465 | 465 | KEY REG_ID (REG_ID), |
| 466 | 466 | KEY PAY_ID (PAY_ID)"; |
| 467 | - $this->_table_has_not_changed_since_previous($table_name, $sql, 'ENGINE=InnoDB '); |
|
| 468 | - $table_name = 'esp_state'; |
|
| 469 | - $sql = "STA_ID smallint(5) unsigned NOT NULL AUTO_INCREMENT, |
|
| 467 | + $this->_table_has_not_changed_since_previous($table_name, $sql, 'ENGINE=InnoDB '); |
|
| 468 | + $table_name = 'esp_state'; |
|
| 469 | + $sql = "STA_ID smallint(5) unsigned NOT NULL AUTO_INCREMENT, |
|
| 470 | 470 | CNT_ISO varchar(2) NOT NULL, |
| 471 | 471 | STA_abbrev varchar(24) NOT NULL, |
| 472 | 472 | STA_name varchar(100) NOT NULL, |
@@ -474,9 +474,9 @@ discard block |
||
| 474 | 474 | PRIMARY KEY (STA_ID), |
| 475 | 475 | KEY STA_abbrev (STA_abbrev), |
| 476 | 476 | KEY CNT_ISO (CNT_ISO)"; |
| 477 | - $this->_table_has_not_changed_since_previous($table_name, $sql, 'ENGINE=InnoDB'); |
|
| 478 | - $table_name = 'esp_status'; |
|
| 479 | - $sql = "STS_ID varchar(3) NOT NULL, |
|
| 477 | + $this->_table_has_not_changed_since_previous($table_name, $sql, 'ENGINE=InnoDB'); |
|
| 478 | + $table_name = 'esp_status'; |
|
| 479 | + $sql = "STS_ID varchar(3) NOT NULL, |
|
| 480 | 480 | STS_code varchar(45) NOT NULL, |
| 481 | 481 | STS_type varchar(45) NOT NULL, |
| 482 | 482 | STS_can_edit tinyint(1) NOT NULL DEFAULT 0, |
@@ -484,9 +484,9 @@ discard block |
||
| 484 | 484 | STS_open tinyint(1) NOT NULL DEFAULT 1, |
| 485 | 485 | UNIQUE KEY STS_ID_UNIQUE (STS_ID), |
| 486 | 486 | KEY STS_type (STS_type)"; |
| 487 | - $this->_table_has_not_changed_since_previous($table_name, $sql, 'ENGINE=InnoDB'); |
|
| 488 | - $table_name = 'esp_transaction'; |
|
| 489 | - $sql = "TXN_ID int(10) unsigned NOT NULL AUTO_INCREMENT, |
|
| 487 | + $this->_table_has_not_changed_since_previous($table_name, $sql, 'ENGINE=InnoDB'); |
|
| 488 | + $table_name = 'esp_transaction'; |
|
| 489 | + $sql = "TXN_ID int(10) unsigned NOT NULL AUTO_INCREMENT, |
|
| 490 | 490 | TXN_timestamp datetime NOT NULL DEFAULT '0000-00-00 00:00:00', |
| 491 | 491 | TXN_total decimal(12,3) DEFAULT '0.00', |
| 492 | 492 | TXN_paid decimal(12,3) NOT NULL DEFAULT '0.00', |
@@ -498,9 +498,9 @@ discard block |
||
| 498 | 498 | PRIMARY KEY (TXN_ID), |
| 499 | 499 | KEY TXN_timestamp (TXN_timestamp), |
| 500 | 500 | KEY STS_ID (STS_ID)"; |
| 501 | - $this->_table_has_not_changed_since_previous($table_name, $sql, 'ENGINE=InnoDB'); |
|
| 502 | - $table_name = 'esp_venue_meta'; |
|
| 503 | - $sql = "VNUM_ID int(11) NOT NULL AUTO_INCREMENT, |
|
| 501 | + $this->_table_has_not_changed_since_previous($table_name, $sql, 'ENGINE=InnoDB'); |
|
| 502 | + $table_name = 'esp_venue_meta'; |
|
| 503 | + $sql = "VNUM_ID int(11) NOT NULL AUTO_INCREMENT, |
|
| 504 | 504 | VNU_ID bigint(20) unsigned NOT NULL DEFAULT 0, |
| 505 | 505 | VNU_address varchar(255) DEFAULT NULL, |
| 506 | 506 | VNU_address2 varchar(255) DEFAULT NULL, |
@@ -519,10 +519,10 @@ discard block |
||
| 519 | 519 | KEY VNU_ID (VNU_ID), |
| 520 | 520 | KEY STA_ID (STA_ID), |
| 521 | 521 | KEY CNT_ISO (CNT_ISO)"; |
| 522 | - $this->_table_has_not_changed_since_previous($table_name, $sql, 'ENGINE=InnoDB'); |
|
| 523 | - // modified tables |
|
| 524 | - $table_name = "esp_price"; |
|
| 525 | - $sql = "PRC_ID int(10) unsigned NOT NULL AUTO_INCREMENT, |
|
| 522 | + $this->_table_has_not_changed_since_previous($table_name, $sql, 'ENGINE=InnoDB'); |
|
| 523 | + // modified tables |
|
| 524 | + $table_name = "esp_price"; |
|
| 525 | + $sql = "PRC_ID int(10) unsigned NOT NULL AUTO_INCREMENT, |
|
| 526 | 526 | PRT_ID tinyint(3) unsigned NOT NULL, |
| 527 | 527 | PRC_amount decimal(12,3) NOT NULL DEFAULT '0.00', |
| 528 | 528 | PRC_name varchar(245) NOT NULL, |
@@ -535,9 +535,9 @@ discard block |
||
| 535 | 535 | PRC_parent int(10) unsigned DEFAULT 0, |
| 536 | 536 | PRIMARY KEY (PRC_ID), |
| 537 | 537 | KEY PRT_ID (PRT_ID)"; |
| 538 | - $this->_table_has_not_changed_since_previous($table_name, $sql, 'ENGINE=InnoDB'); |
|
| 539 | - $table_name = "esp_price_type"; |
|
| 540 | - $sql = "PRT_ID tinyint(3) unsigned NOT NULL AUTO_INCREMENT, |
|
| 538 | + $this->_table_has_not_changed_since_previous($table_name, $sql, 'ENGINE=InnoDB'); |
|
| 539 | + $table_name = "esp_price_type"; |
|
| 540 | + $sql = "PRT_ID tinyint(3) unsigned NOT NULL AUTO_INCREMENT, |
|
| 541 | 541 | PRT_name varchar(45) NOT NULL, |
| 542 | 542 | PBT_ID tinyint(3) unsigned NOT NULL DEFAULT '1', |
| 543 | 543 | PRT_is_percent tinyint(1) NOT NULL DEFAULT '0', |
@@ -546,9 +546,9 @@ discard block |
||
| 546 | 546 | PRT_deleted tinyint(1) NOT NULL DEFAULT '0', |
| 547 | 547 | UNIQUE KEY PRT_name_UNIQUE (PRT_name), |
| 548 | 548 | PRIMARY KEY (PRT_ID)"; |
| 549 | - $this->_table_has_not_changed_since_previous($table_name, $sql, 'ENGINE=InnoDB '); |
|
| 550 | - $table_name = "esp_ticket"; |
|
| 551 | - $sql = "TKT_ID int(10) unsigned NOT NULL AUTO_INCREMENT, |
|
| 549 | + $this->_table_has_not_changed_since_previous($table_name, $sql, 'ENGINE=InnoDB '); |
|
| 550 | + $table_name = "esp_ticket"; |
|
| 551 | + $sql = "TKT_ID int(10) unsigned NOT NULL AUTO_INCREMENT, |
|
| 552 | 552 | TTM_ID int(10) unsigned NOT NULL, |
| 553 | 553 | TKT_name varchar(245) NOT NULL DEFAULT '', |
| 554 | 554 | TKT_description text NOT NULL, |
@@ -571,9 +571,9 @@ discard block |
||
| 571 | 571 | TKT_deleted tinyint(1) NOT NULL DEFAULT '0', |
| 572 | 572 | PRIMARY KEY (TKT_ID), |
| 573 | 573 | KEY TKT_start_date (TKT_start_date)"; |
| 574 | - $this->_table_has_not_changed_since_previous($table_name, $sql, 'ENGINE=InnoDB'); |
|
| 575 | - $table_name = 'esp_question_group'; |
|
| 576 | - $sql = 'QSG_ID int(10) unsigned NOT NULL AUTO_INCREMENT, |
|
| 574 | + $this->_table_has_not_changed_since_previous($table_name, $sql, 'ENGINE=InnoDB'); |
|
| 575 | + $table_name = 'esp_question_group'; |
|
| 576 | + $sql = 'QSG_ID int(10) unsigned NOT NULL AUTO_INCREMENT, |
|
| 577 | 577 | QSG_name varchar(255) NOT NULL, |
| 578 | 578 | QSG_identifier varchar(100) NOT NULL, |
| 579 | 579 | QSG_desc text NULL, |
@@ -586,70 +586,70 @@ discard block |
||
| 586 | 586 | PRIMARY KEY (QSG_ID), |
| 587 | 587 | UNIQUE KEY QSG_identifier_UNIQUE (QSG_identifier), |
| 588 | 588 | KEY QSG_order (QSG_order)'; |
| 589 | - $this->_table_has_not_changed_since_previous($table_name, $sql, 'ENGINE=InnoDB'); |
|
| 590 | - $this->insert_default_data(); |
|
| 591 | - return true; |
|
| 592 | - } |
|
| 589 | + $this->_table_has_not_changed_since_previous($table_name, $sql, 'ENGINE=InnoDB'); |
|
| 590 | + $this->insert_default_data(); |
|
| 591 | + return true; |
|
| 592 | + } |
|
| 593 | 593 | |
| 594 | - /** |
|
| 595 | - * Inserts default data on new installs |
|
| 596 | - * @since 4.10.0.p |
|
| 597 | - * @throws EE_Error |
|
| 598 | - * @throws InvalidArgumentException |
|
| 599 | - * @throws ReflectionException |
|
| 600 | - * @throws InvalidDataTypeException |
|
| 601 | - * @throws InvalidInterfaceException |
|
| 602 | - */ |
|
| 603 | - public function insert_default_data() |
|
| 604 | - { |
|
| 605 | - $this->previous_dms->insert_default_data(); |
|
| 606 | - $this->removeMijirehPM(); |
|
| 607 | - } |
|
| 594 | + /** |
|
| 595 | + * Inserts default data on new installs |
|
| 596 | + * @since 4.10.0.p |
|
| 597 | + * @throws EE_Error |
|
| 598 | + * @throws InvalidArgumentException |
|
| 599 | + * @throws ReflectionException |
|
| 600 | + * @throws InvalidDataTypeException |
|
| 601 | + * @throws InvalidInterfaceException |
|
| 602 | + */ |
|
| 603 | + public function insert_default_data() |
|
| 604 | + { |
|
| 605 | + $this->previous_dms->insert_default_data(); |
|
| 606 | + $this->removeMijirehPM(); |
|
| 607 | + } |
|
| 608 | 608 | |
| 609 | 609 | |
| 610 | 610 | |
| 611 | - /** |
|
| 612 | - * @return boolean |
|
| 613 | - */ |
|
| 614 | - public function schema_changes_after_migration() |
|
| 615 | - { |
|
| 616 | - return true; |
|
| 617 | - } |
|
| 611 | + /** |
|
| 612 | + * @return boolean |
|
| 613 | + */ |
|
| 614 | + public function schema_changes_after_migration() |
|
| 615 | + { |
|
| 616 | + return true; |
|
| 617 | + } |
|
| 618 | 618 | |
| 619 | 619 | |
| 620 | 620 | |
| 621 | - public function migration_page_hooks() |
|
| 622 | - { |
|
| 623 | - } |
|
| 621 | + public function migration_page_hooks() |
|
| 622 | + { |
|
| 623 | + } |
|
| 624 | 624 | |
| 625 | - /** |
|
| 626 | - * Mijireh was removed in 4.10.3.p, but let's avoid having an error message because its files were removed, and don't |
|
| 627 | - * show old payments made with it as being by "Unknown". The fix is to make it an "Admin_Only" payment method |
|
| 628 | - * (like Invoice or Check) but don't allow it to be used in the admin either... so it's usable nowhere from now on, |
|
| 629 | - * but it still exists so there's no problems. |
|
| 630 | - * @since 4.10.3.p |
|
| 631 | - */ |
|
| 632 | - protected function removeMijirehPM() |
|
| 633 | - { |
|
| 634 | - global $wpdb; |
|
| 635 | - $wpdb->update( |
|
| 636 | - $wpdb->prefix . 'esp_payment_method', |
|
| 637 | - [ |
|
| 638 | - 'PMD_type' => 'Admin_Only', |
|
| 639 | - 'PMD_scope' => serialize(array()) |
|
| 640 | - ], |
|
| 641 | - [ |
|
| 642 | - 'PMD_type' => 'Mijireh' |
|
| 643 | - ], |
|
| 644 | - [ |
|
| 645 | - // update formats |
|
| 646 | - '%s', // PMD_type |
|
| 647 | - '%s', // PMD_scope |
|
| 648 | - ], |
|
| 649 | - [ |
|
| 650 | - // where formats |
|
| 651 | - '%s' |
|
| 652 | - ] |
|
| 653 | - ); |
|
| 654 | - } |
|
| 625 | + /** |
|
| 626 | + * Mijireh was removed in 4.10.3.p, but let's avoid having an error message because its files were removed, and don't |
|
| 627 | + * show old payments made with it as being by "Unknown". The fix is to make it an "Admin_Only" payment method |
|
| 628 | + * (like Invoice or Check) but don't allow it to be used in the admin either... so it's usable nowhere from now on, |
|
| 629 | + * but it still exists so there's no problems. |
|
| 630 | + * @since 4.10.3.p |
|
| 631 | + */ |
|
| 632 | + protected function removeMijirehPM() |
|
| 633 | + { |
|
| 634 | + global $wpdb; |
|
| 635 | + $wpdb->update( |
|
| 636 | + $wpdb->prefix . 'esp_payment_method', |
|
| 637 | + [ |
|
| 638 | + 'PMD_type' => 'Admin_Only', |
|
| 639 | + 'PMD_scope' => serialize(array()) |
|
| 640 | + ], |
|
| 641 | + [ |
|
| 642 | + 'PMD_type' => 'Mijireh' |
|
| 643 | + ], |
|
| 644 | + [ |
|
| 645 | + // update formats |
|
| 646 | + '%s', // PMD_type |
|
| 647 | + '%s', // PMD_scope |
|
| 648 | + ], |
|
| 649 | + [ |
|
| 650 | + // where formats |
|
| 651 | + '%s' |
|
| 652 | + ] |
|
| 653 | + ); |
|
| 654 | + } |
|
| 655 | 655 | } |
@@ -37,7 +37,7 @@ |
||
| 37 | 37 | if (get_option(RewriteRules::OPTION_KEY_FLUSH_REWRITE_RULES, true)) { |
| 38 | 38 | add_action( |
| 39 | 39 | 'shutdown', |
| 40 | - static function () { |
|
| 40 | + static function() { |
|
| 41 | 41 | flush_rewrite_rules(); |
| 42 | 42 | update_option(RewriteRules::OPTION_KEY_FLUSH_REWRITE_RULES, false); |
| 43 | 43 | } |
@@ -12,35 +12,35 @@ |
||
| 12 | 12 | */ |
| 13 | 13 | class RewriteRules |
| 14 | 14 | { |
| 15 | - const OPTION_KEY_FLUSH_REWRITE_RULES = 'ee_flush_rewrite_rules'; |
|
| 15 | + const OPTION_KEY_FLUSH_REWRITE_RULES = 'ee_flush_rewrite_rules'; |
|
| 16 | 16 | |
| 17 | 17 | |
| 18 | - /** |
|
| 19 | - * This will flush rewrite rules on demand. This actually gets called around wp init priority level 100. |
|
| 20 | - * |
|
| 21 | - * @return void |
|
| 22 | - */ |
|
| 23 | - public function flush() |
|
| 24 | - { |
|
| 25 | - update_option(RewriteRules::OPTION_KEY_FLUSH_REWRITE_RULES, true); |
|
| 26 | - } |
|
| 18 | + /** |
|
| 19 | + * This will flush rewrite rules on demand. This actually gets called around wp init priority level 100. |
|
| 20 | + * |
|
| 21 | + * @return void |
|
| 22 | + */ |
|
| 23 | + public function flush() |
|
| 24 | + { |
|
| 25 | + update_option(RewriteRules::OPTION_KEY_FLUSH_REWRITE_RULES, true); |
|
| 26 | + } |
|
| 27 | 27 | |
| 28 | 28 | |
| 29 | - /** |
|
| 30 | - * This will flush rewrite rules on demand. This actually gets called around wp init priority level 100. |
|
| 31 | - * |
|
| 32 | - * @return void |
|
| 33 | - */ |
|
| 34 | - public function flushRewriteRules() |
|
| 35 | - { |
|
| 36 | - if (get_option(RewriteRules::OPTION_KEY_FLUSH_REWRITE_RULES, true)) { |
|
| 37 | - add_action( |
|
| 38 | - 'shutdown', |
|
| 39 | - static function () { |
|
| 40 | - flush_rewrite_rules(); |
|
| 41 | - update_option(RewriteRules::OPTION_KEY_FLUSH_REWRITE_RULES, false); |
|
| 42 | - } |
|
| 43 | - ); |
|
| 44 | - } |
|
| 45 | - } |
|
| 29 | + /** |
|
| 30 | + * This will flush rewrite rules on demand. This actually gets called around wp init priority level 100. |
|
| 31 | + * |
|
| 32 | + * @return void |
|
| 33 | + */ |
|
| 34 | + public function flushRewriteRules() |
|
| 35 | + { |
|
| 36 | + if (get_option(RewriteRules::OPTION_KEY_FLUSH_REWRITE_RULES, true)) { |
|
| 37 | + add_action( |
|
| 38 | + 'shutdown', |
|
| 39 | + static function () { |
|
| 40 | + flush_rewrite_rules(); |
|
| 41 | + update_option(RewriteRules::OPTION_KEY_FLUSH_REWRITE_RULES, false); |
|
| 42 | + } |
|
| 43 | + ); |
|
| 44 | + } |
|
| 45 | + } |
|
| 46 | 46 | } |
@@ -68,7 +68,7 @@ |
||
| 68 | 68 | */ |
| 69 | 69 | public function visit($model_objects_to_identify) |
| 70 | 70 | { |
| 71 | - if (! $this->isDiscovered()) { |
|
| 71 | + if ( ! $this->isDiscovered()) { |
|
| 72 | 72 | $this->discover(); |
| 73 | 73 | } |
| 74 | 74 | if ($this->isComplete()) { |
@@ -31,105 +31,105 @@ |
||
| 31 | 31 | */ |
| 32 | 32 | abstract class BaseNode |
| 33 | 33 | { |
| 34 | - /** |
|
| 35 | - * @var boolean |
|
| 36 | - */ |
|
| 37 | - protected $complete; |
|
| 34 | + /** |
|
| 35 | + * @var boolean |
|
| 36 | + */ |
|
| 37 | + protected $complete; |
|
| 38 | 38 | |
| 39 | 39 | |
| 40 | - /** |
|
| 41 | - * @var array of model names we don't want to traverse |
|
| 42 | - */ |
|
| 43 | - protected $dont_traverse_models; |
|
| 40 | + /** |
|
| 41 | + * @var array of model names we don't want to traverse |
|
| 42 | + */ |
|
| 43 | + protected $dont_traverse_models; |
|
| 44 | 44 | |
| 45 | - /** |
|
| 46 | - * Whether this item has already been initialized |
|
| 47 | - */ |
|
| 48 | - abstract protected function isDiscovered(); |
|
| 45 | + /** |
|
| 46 | + * Whether this item has already been initialized |
|
| 47 | + */ |
|
| 48 | + abstract protected function isDiscovered(); |
|
| 49 | 49 | |
| 50 | - /** |
|
| 51 | - * Determines if the work is done yet or not. Requires you to have first discovered what work exists by calling |
|
| 52 | - * discover(). |
|
| 53 | - * @since 4.10.12.p |
|
| 54 | - * @return boolean |
|
| 55 | - */ |
|
| 56 | - abstract public function isComplete(); |
|
| 50 | + /** |
|
| 51 | + * Determines if the work is done yet or not. Requires you to have first discovered what work exists by calling |
|
| 52 | + * discover(). |
|
| 53 | + * @since 4.10.12.p |
|
| 54 | + * @return boolean |
|
| 55 | + */ |
|
| 56 | + abstract public function isComplete(); |
|
| 57 | 57 | |
| 58 | - /** |
|
| 59 | - * Discovers what work needs to be done to complete traversing this node and its children. |
|
| 60 | - * Note that this is separate from the constructor, so we can create child nodes without |
|
| 61 | - * discovering them immediately. |
|
| 62 | - * @since 4.10.12.p |
|
| 63 | - * @return mixed |
|
| 64 | - */ |
|
| 65 | - abstract protected function discover(); |
|
| 58 | + /** |
|
| 59 | + * Discovers what work needs to be done to complete traversing this node and its children. |
|
| 60 | + * Note that this is separate from the constructor, so we can create child nodes without |
|
| 61 | + * discovering them immediately. |
|
| 62 | + * @since 4.10.12.p |
|
| 63 | + * @return mixed |
|
| 64 | + */ |
|
| 65 | + abstract protected function discover(); |
|
| 66 | 66 | |
| 67 | - /** |
|
| 68 | - * Identifies model objects, up to the limit $model_objects_to_identify. |
|
| 69 | - * @since 4.10.12.p |
|
| 70 | - * @param int $model_objects_to_identify |
|
| 71 | - * @return int units of work done |
|
| 72 | - */ |
|
| 73 | - abstract protected function work($model_objects_to_identify); |
|
| 67 | + /** |
|
| 68 | + * Identifies model objects, up to the limit $model_objects_to_identify. |
|
| 69 | + * @since 4.10.12.p |
|
| 70 | + * @param int $model_objects_to_identify |
|
| 71 | + * @return int units of work done |
|
| 72 | + */ |
|
| 73 | + abstract protected function work($model_objects_to_identify); |
|
| 74 | 74 | |
| 75 | - /** |
|
| 76 | - * Shows the entity/relation node as an array. |
|
| 77 | - * @since 4.10.12.p |
|
| 78 | - * @return array |
|
| 79 | - */ |
|
| 80 | - abstract public function toArray(); |
|
| 75 | + /** |
|
| 76 | + * Shows the entity/relation node as an array. |
|
| 77 | + * @since 4.10.12.p |
|
| 78 | + * @return array |
|
| 79 | + */ |
|
| 80 | + abstract public function toArray(); |
|
| 81 | 81 | |
| 82 | - /** |
|
| 83 | - * Discovers how much work there is to do, double-checks the work isn't already finished, and then does the work. |
|
| 84 | - * Note: do not call when site is in maintenance mode level 2. |
|
| 85 | - * |
|
| 86 | - * @since 4.10.12.p |
|
| 87 | - * @param $model_objects_to_identify |
|
| 88 | - * @return int number of model objects we want to identify during this call. On subsequent calls we'll continue |
|
| 89 | - * where we left off. |
|
| 90 | - */ |
|
| 91 | - public function visit($model_objects_to_identify) |
|
| 92 | - { |
|
| 93 | - if (! $this->isDiscovered()) { |
|
| 94 | - $this->discover(); |
|
| 95 | - } |
|
| 96 | - if ($this->isComplete()) { |
|
| 97 | - return 0; |
|
| 98 | - } |
|
| 99 | - return $this->work($model_objects_to_identify); |
|
| 100 | - } |
|
| 82 | + /** |
|
| 83 | + * Discovers how much work there is to do, double-checks the work isn't already finished, and then does the work. |
|
| 84 | + * Note: do not call when site is in maintenance mode level 2. |
|
| 85 | + * |
|
| 86 | + * @since 4.10.12.p |
|
| 87 | + * @param $model_objects_to_identify |
|
| 88 | + * @return int number of model objects we want to identify during this call. On subsequent calls we'll continue |
|
| 89 | + * where we left off. |
|
| 90 | + */ |
|
| 91 | + public function visit($model_objects_to_identify) |
|
| 92 | + { |
|
| 93 | + if (! $this->isDiscovered()) { |
|
| 94 | + $this->discover(); |
|
| 95 | + } |
|
| 96 | + if ($this->isComplete()) { |
|
| 97 | + return 0; |
|
| 98 | + } |
|
| 99 | + return $this->work($model_objects_to_identify); |
|
| 100 | + } |
|
| 101 | 101 | |
| 102 | - /** |
|
| 103 | - * Gets the IDs of completely identified model objects that can be deleted. |
|
| 104 | - * @since 4.10.12.p |
|
| 105 | - * @return mixed |
|
| 106 | - */ |
|
| 107 | - abstract public function getIds(); |
|
| 102 | + /** |
|
| 103 | + * Gets the IDs of completely identified model objects that can be deleted. |
|
| 104 | + * @since 4.10.12.p |
|
| 105 | + * @return mixed |
|
| 106 | + */ |
|
| 107 | + abstract public function getIds(); |
|
| 108 | 108 | |
| 109 | - /** |
|
| 110 | - * Make sure we encode whether its complete or not, but don't use such a long name. |
|
| 111 | - * @since 4.10.12.p |
|
| 112 | - * @return array |
|
| 113 | - */ |
|
| 114 | - public function __sleep() |
|
| 115 | - { |
|
| 116 | - $this->c = $this->complete; |
|
| 117 | - $this->dtm = $this->dont_traverse_models; |
|
| 118 | - return [ |
|
| 119 | - 'c', |
|
| 120 | - 'dtm' |
|
| 121 | - ]; |
|
| 122 | - } |
|
| 109 | + /** |
|
| 110 | + * Make sure we encode whether its complete or not, but don't use such a long name. |
|
| 111 | + * @since 4.10.12.p |
|
| 112 | + * @return array |
|
| 113 | + */ |
|
| 114 | + public function __sleep() |
|
| 115 | + { |
|
| 116 | + $this->c = $this->complete; |
|
| 117 | + $this->dtm = $this->dont_traverse_models; |
|
| 118 | + return [ |
|
| 119 | + 'c', |
|
| 120 | + 'dtm' |
|
| 121 | + ]; |
|
| 122 | + } |
|
| 123 | 123 | |
| 124 | - /** |
|
| 125 | - * Use the dynamic property to set the "complete" property. |
|
| 126 | - * @since 4.10.12.p |
|
| 127 | - */ |
|
| 128 | - public function __wakeup() |
|
| 129 | - { |
|
| 130 | - $this->complete = $this->c; |
|
| 131 | - $this->dont_traverse_models = $this->dtm; |
|
| 132 | - } |
|
| 124 | + /** |
|
| 125 | + * Use the dynamic property to set the "complete" property. |
|
| 126 | + * @since 4.10.12.p |
|
| 127 | + */ |
|
| 128 | + public function __wakeup() |
|
| 129 | + { |
|
| 130 | + $this->complete = $this->c; |
|
| 131 | + $this->dont_traverse_models = $this->dtm; |
|
| 132 | + } |
|
| 133 | 133 | } |
| 134 | 134 | // End of file BaseNode.php |
| 135 | 135 | // Location: EventEspresso\core\services\orm\tree_traversal/BaseNode.php |
@@ -49,12 +49,12 @@ discard block |
||
| 49 | 49 | */ |
| 50 | 50 | public function getModelObjNodesInGroup($code) |
| 51 | 51 | { |
| 52 | - if (! $code) { |
|
| 52 | + if ( ! $code) { |
|
| 53 | 53 | throw new Exception(esc_html__('We aren’t sure which job you are performing. Please press back in your browser and try again.', 'event_espresso')); |
| 54 | 54 | } |
| 55 | - $deletion_data = get_option($this->getOptionPrefix() . $code, []); |
|
| 55 | + $deletion_data = get_option($this->getOptionPrefix().$code, []); |
|
| 56 | 56 | foreach ($deletion_data as $root) { |
| 57 | - if (! $root instanceof ModelObjNode) { |
|
| 57 | + if ( ! $root instanceof ModelObjNode) { |
|
| 58 | 58 | throw new UnexpectedEntityException($root, 'ModelObjNode'); |
| 59 | 59 | } |
| 60 | 60 | } |
@@ -111,7 +111,7 @@ discard block |
||
| 111 | 111 | public function persistModelObjNodesGroup($model_obj_nodes, $code) |
| 112 | 112 | { |
| 113 | 113 | return add_option( |
| 114 | - $this->getOptionPrefix() . $code, |
|
| 114 | + $this->getOptionPrefix().$code, |
|
| 115 | 115 | $model_obj_nodes, |
| 116 | 116 | null, |
| 117 | 117 | 'no' |
@@ -126,7 +126,7 @@ discard block |
||
| 126 | 126 | */ |
| 127 | 127 | public function deleteModelObjNodesInGroup($code) |
| 128 | 128 | { |
| 129 | - return delete_option($this->getOptionPrefix() . $code); |
|
| 129 | + return delete_option($this->getOptionPrefix().$code); |
|
| 130 | 130 | } |
| 131 | 131 | } |
| 132 | 132 | // End of file NodeGroupDao.php |
@@ -22,112 +22,112 @@ |
||
| 22 | 22 | */ |
| 23 | 23 | class NodeGroupDao |
| 24 | 24 | { |
| 25 | - /** |
|
| 26 | - * @since 4.10.12.p |
|
| 27 | - * @return mixed|void |
|
| 28 | - */ |
|
| 29 | - public function generateGroupCode() |
|
| 30 | - { |
|
| 31 | - return wp_generate_password(6, false); |
|
| 32 | - } |
|
| 25 | + /** |
|
| 26 | + * @since 4.10.12.p |
|
| 27 | + * @return mixed|void |
|
| 28 | + */ |
|
| 29 | + public function generateGroupCode() |
|
| 30 | + { |
|
| 31 | + return wp_generate_password(6, false); |
|
| 32 | + } |
|
| 33 | 33 | |
| 34 | - /** |
|
| 35 | - * Gets the string we put in front of the WP Option name used to store the jobs. |
|
| 36 | - * @since 4.10.12.p |
|
| 37 | - * @return string |
|
| 38 | - */ |
|
| 39 | - private function getOptionPrefix() |
|
| 40 | - { |
|
| 41 | - return 'ee_deletion_'; |
|
| 42 | - } |
|
| 34 | + /** |
|
| 35 | + * Gets the string we put in front of the WP Option name used to store the jobs. |
|
| 36 | + * @since 4.10.12.p |
|
| 37 | + * @return string |
|
| 38 | + */ |
|
| 39 | + private function getOptionPrefix() |
|
| 40 | + { |
|
| 41 | + return 'ee_deletion_'; |
|
| 42 | + } |
|
| 43 | 43 | |
| 44 | - /** |
|
| 45 | - * @since 4.10.12.p |
|
| 46 | - * @param $code |
|
| 47 | - * @return ModelObjNode[] |
|
| 48 | - * @throws UnexpectedEntityException |
|
| 49 | - */ |
|
| 50 | - public function getModelObjNodesInGroup($code) |
|
| 51 | - { |
|
| 52 | - if (! $code) { |
|
| 53 | - throw new Exception(esc_html__('We aren’t sure which job you are performing. Please press back in your browser and try again.', 'event_espresso')); |
|
| 54 | - } |
|
| 55 | - $deletion_data = get_option($this->getOptionPrefix() . $code, []); |
|
| 56 | - foreach ($deletion_data as $root) { |
|
| 57 | - if (! $root instanceof ModelObjNode) { |
|
| 58 | - throw new UnexpectedEntityException($root, 'ModelObjNode'); |
|
| 59 | - } |
|
| 60 | - } |
|
| 61 | - return $deletion_data; |
|
| 62 | - } |
|
| 44 | + /** |
|
| 45 | + * @since 4.10.12.p |
|
| 46 | + * @param $code |
|
| 47 | + * @return ModelObjNode[] |
|
| 48 | + * @throws UnexpectedEntityException |
|
| 49 | + */ |
|
| 50 | + public function getModelObjNodesInGroup($code) |
|
| 51 | + { |
|
| 52 | + if (! $code) { |
|
| 53 | + throw new Exception(esc_html__('We aren’t sure which job you are performing. Please press back in your browser and try again.', 'event_espresso')); |
|
| 54 | + } |
|
| 55 | + $deletion_data = get_option($this->getOptionPrefix() . $code, []); |
|
| 56 | + foreach ($deletion_data as $root) { |
|
| 57 | + if (! $root instanceof ModelObjNode) { |
|
| 58 | + throw new UnexpectedEntityException($root, 'ModelObjNode'); |
|
| 59 | + } |
|
| 60 | + } |
|
| 61 | + return $deletion_data; |
|
| 62 | + } |
|
| 63 | 63 | |
| 64 | - /** |
|
| 65 | - * Gets an array indicating what database rows are contained in the job. |
|
| 66 | - * Each top-level key is a model name, and its value is an array of IDs. |
|
| 67 | - * @since 4.10.12.p |
|
| 68 | - * @param ModelObjNode[] $model_obj_nodes |
|
| 69 | - * @return array |
|
| 70 | - * @throws EE_Error |
|
| 71 | - * @throws InvalidDataTypeException |
|
| 72 | - * @throws InvalidInterfaceException |
|
| 73 | - * @throws InvalidArgumentException |
|
| 74 | - * @throws ReflectionException |
|
| 75 | - */ |
|
| 76 | - public function getModelsAndIdsContainedIn($model_obj_nodes) |
|
| 77 | - { |
|
| 78 | - $models_and_ids_to_delete = []; |
|
| 79 | - foreach ($model_obj_nodes as $root) { |
|
| 80 | - $models_and_ids_to_delete = array_replace_recursive($models_and_ids_to_delete, $root->getIds()); |
|
| 81 | - } |
|
| 82 | - return $models_and_ids_to_delete; |
|
| 83 | - } |
|
| 64 | + /** |
|
| 65 | + * Gets an array indicating what database rows are contained in the job. |
|
| 66 | + * Each top-level key is a model name, and its value is an array of IDs. |
|
| 67 | + * @since 4.10.12.p |
|
| 68 | + * @param ModelObjNode[] $model_obj_nodes |
|
| 69 | + * @return array |
|
| 70 | + * @throws EE_Error |
|
| 71 | + * @throws InvalidDataTypeException |
|
| 72 | + * @throws InvalidInterfaceException |
|
| 73 | + * @throws InvalidArgumentException |
|
| 74 | + * @throws ReflectionException |
|
| 75 | + */ |
|
| 76 | + public function getModelsAndIdsContainedIn($model_obj_nodes) |
|
| 77 | + { |
|
| 78 | + $models_and_ids_to_delete = []; |
|
| 79 | + foreach ($model_obj_nodes as $root) { |
|
| 80 | + $models_and_ids_to_delete = array_replace_recursive($models_and_ids_to_delete, $root->getIds()); |
|
| 81 | + } |
|
| 82 | + return $models_and_ids_to_delete; |
|
| 83 | + } |
|
| 84 | 84 | |
| 85 | - /** |
|
| 86 | - * Gets an array indicating what database rows are contained in the job. |
|
| 87 | - * Each top-level key is a model name, and its value is an array of IDs. |
|
| 88 | - * @since 4.10.12.p |
|
| 89 | - * @param string $code |
|
| 90 | - * @return array |
|
| 91 | - * @throws EE_Error |
|
| 92 | - * @throws InvalidArgumentException |
|
| 93 | - * @throws InvalidDataTypeException |
|
| 94 | - * @throws InvalidInterfaceException |
|
| 95 | - * @throws ReflectionException |
|
| 96 | - * @throws UnexpectedEntityException |
|
| 97 | - */ |
|
| 98 | - public function getModelsAndIdsFromGroup($code) |
|
| 99 | - { |
|
| 100 | - $model_obj_nodes = $this->getModelObjNodesInGroup($code); |
|
| 101 | - return $this->getModelsAndIdsContainedIn($model_obj_nodes); |
|
| 102 | - } |
|
| 85 | + /** |
|
| 86 | + * Gets an array indicating what database rows are contained in the job. |
|
| 87 | + * Each top-level key is a model name, and its value is an array of IDs. |
|
| 88 | + * @since 4.10.12.p |
|
| 89 | + * @param string $code |
|
| 90 | + * @return array |
|
| 91 | + * @throws EE_Error |
|
| 92 | + * @throws InvalidArgumentException |
|
| 93 | + * @throws InvalidDataTypeException |
|
| 94 | + * @throws InvalidInterfaceException |
|
| 95 | + * @throws ReflectionException |
|
| 96 | + * @throws UnexpectedEntityException |
|
| 97 | + */ |
|
| 98 | + public function getModelsAndIdsFromGroup($code) |
|
| 99 | + { |
|
| 100 | + $model_obj_nodes = $this->getModelObjNodesInGroup($code); |
|
| 101 | + return $this->getModelsAndIdsContainedIn($model_obj_nodes); |
|
| 102 | + } |
|
| 103 | 103 | |
| 104 | - /** |
|
| 105 | - * Persists the ModelObjNodes for future requests, using the code for reference. |
|
| 106 | - * @since 4.10.12.p |
|
| 107 | - * @param ModelObjNode[] $model_obj_nodes |
|
| 108 | - * @param string $code |
|
| 109 | - * @return bool |
|
| 110 | - */ |
|
| 111 | - public function persistModelObjNodesGroup($model_obj_nodes, $code) |
|
| 112 | - { |
|
| 113 | - return add_option( |
|
| 114 | - $this->getOptionPrefix() . $code, |
|
| 115 | - $model_obj_nodes, |
|
| 116 | - null, |
|
| 117 | - 'no' |
|
| 118 | - ); |
|
| 119 | - } |
|
| 104 | + /** |
|
| 105 | + * Persists the ModelObjNodes for future requests, using the code for reference. |
|
| 106 | + * @since 4.10.12.p |
|
| 107 | + * @param ModelObjNode[] $model_obj_nodes |
|
| 108 | + * @param string $code |
|
| 109 | + * @return bool |
|
| 110 | + */ |
|
| 111 | + public function persistModelObjNodesGroup($model_obj_nodes, $code) |
|
| 112 | + { |
|
| 113 | + return add_option( |
|
| 114 | + $this->getOptionPrefix() . $code, |
|
| 115 | + $model_obj_nodes, |
|
| 116 | + null, |
|
| 117 | + 'no' |
|
| 118 | + ); |
|
| 119 | + } |
|
| 120 | 120 | |
| 121 | - /** |
|
| 122 | - * Forgets about the group of ModelObjNodes. Doesn't delete the rows in the database they reference though. |
|
| 123 | - * @since 4.10.12.p |
|
| 124 | - * @param $code |
|
| 125 | - * @return bool |
|
| 126 | - */ |
|
| 127 | - public function deleteModelObjNodesInGroup($code) |
|
| 128 | - { |
|
| 129 | - return delete_option($this->getOptionPrefix() . $code); |
|
| 130 | - } |
|
| 121 | + /** |
|
| 122 | + * Forgets about the group of ModelObjNodes. Doesn't delete the rows in the database they reference though. |
|
| 123 | + * @since 4.10.12.p |
|
| 124 | + * @param $code |
|
| 125 | + * @return bool |
|
| 126 | + */ |
|
| 127 | + public function deleteModelObjNodesInGroup($code) |
|
| 128 | + { |
|
| 129 | + return delete_option($this->getOptionPrefix() . $code); |
|
| 130 | + } |
|
| 131 | 131 | } |
| 132 | 132 | // End of file NodeGroupDao.php |
| 133 | 133 | // Location: EventEspresso\core\services\orm\tree_traversal/NodeGroupDao.php |
@@ -32,158 +32,158 @@ |
||
| 32 | 32 | */ |
| 33 | 33 | class ExecuteBatchDeletion extends JobHandler |
| 34 | 34 | { |
| 35 | - /** |
|
| 36 | - * @var NodeGroupDao |
|
| 37 | - */ |
|
| 38 | - protected $model_obj_node_group_persister; |
|
| 39 | - public function __construct(NodeGroupDao $model_obj_node_group_persister) |
|
| 40 | - { |
|
| 41 | - $this->model_obj_node_group_persister = $model_obj_node_group_persister; |
|
| 42 | - } |
|
| 35 | + /** |
|
| 36 | + * @var NodeGroupDao |
|
| 37 | + */ |
|
| 38 | + protected $model_obj_node_group_persister; |
|
| 39 | + public function __construct(NodeGroupDao $model_obj_node_group_persister) |
|
| 40 | + { |
|
| 41 | + $this->model_obj_node_group_persister = $model_obj_node_group_persister; |
|
| 42 | + } |
|
| 43 | 43 | |
| 44 | 44 | |
| 45 | - // phpcs:disable PSR1.Methods.CamelCapsMethodName.NotCamelCaps |
|
| 46 | - /** |
|
| 47 | - * |
|
| 48 | - * @param JobParameters $job_parameters |
|
| 49 | - * @throws BatchRequestException |
|
| 50 | - * @return JobStepResponse |
|
| 51 | - */ |
|
| 52 | - public function create_job(JobParameters $job_parameters) |
|
| 53 | - { |
|
| 54 | - $deletion_job_code = $job_parameters->request_datum('deletion_job_code', null); |
|
| 55 | - $roots = $this->model_obj_node_group_persister->getModelObjNodesInGroup($deletion_job_code); |
|
| 56 | - if ($roots === null) { |
|
| 57 | - throw new UnexpectedEntityException($roots, 'array', esc_html__('The job seems to be stale. Please press the back button in your browser twice.', 'event_espresso')); |
|
| 58 | - } |
|
| 59 | - $models_and_ids_to_delete = []; |
|
| 60 | - foreach ($roots as $root) { |
|
| 61 | - if (! $root instanceof ModelObjNode) { |
|
| 62 | - throw new UnexpectedEntityException($root, 'ModelObjNode'); |
|
| 63 | - } |
|
| 64 | - $models_and_ids_to_delete = array_replace_recursive($models_and_ids_to_delete, $root->getIds()); |
|
| 65 | - } |
|
| 66 | - $job_parameters->set_extra_data( |
|
| 67 | - [ |
|
| 68 | - 'models_and_ids_to_delete' => $models_and_ids_to_delete |
|
| 69 | - ] |
|
| 70 | - ); |
|
| 71 | - // Find the job's actual size. |
|
| 72 | - $job_size = 0; |
|
| 73 | - foreach ($models_and_ids_to_delete as $model_name => $ids) { |
|
| 74 | - $job_size += count($ids); |
|
| 75 | - } |
|
| 76 | - $job_parameters->set_job_size($job_size); |
|
| 77 | - return new JobStepResponse( |
|
| 78 | - $job_parameters, |
|
| 79 | - esc_html__('Beginning to delete items...', 'event_espresso') |
|
| 80 | - ); |
|
| 81 | - } |
|
| 45 | + // phpcs:disable PSR1.Methods.CamelCapsMethodName.NotCamelCaps |
|
| 46 | + /** |
|
| 47 | + * |
|
| 48 | + * @param JobParameters $job_parameters |
|
| 49 | + * @throws BatchRequestException |
|
| 50 | + * @return JobStepResponse |
|
| 51 | + */ |
|
| 52 | + public function create_job(JobParameters $job_parameters) |
|
| 53 | + { |
|
| 54 | + $deletion_job_code = $job_parameters->request_datum('deletion_job_code', null); |
|
| 55 | + $roots = $this->model_obj_node_group_persister->getModelObjNodesInGroup($deletion_job_code); |
|
| 56 | + if ($roots === null) { |
|
| 57 | + throw new UnexpectedEntityException($roots, 'array', esc_html__('The job seems to be stale. Please press the back button in your browser twice.', 'event_espresso')); |
|
| 58 | + } |
|
| 59 | + $models_and_ids_to_delete = []; |
|
| 60 | + foreach ($roots as $root) { |
|
| 61 | + if (! $root instanceof ModelObjNode) { |
|
| 62 | + throw new UnexpectedEntityException($root, 'ModelObjNode'); |
|
| 63 | + } |
|
| 64 | + $models_and_ids_to_delete = array_replace_recursive($models_and_ids_to_delete, $root->getIds()); |
|
| 65 | + } |
|
| 66 | + $job_parameters->set_extra_data( |
|
| 67 | + [ |
|
| 68 | + 'models_and_ids_to_delete' => $models_and_ids_to_delete |
|
| 69 | + ] |
|
| 70 | + ); |
|
| 71 | + // Find the job's actual size. |
|
| 72 | + $job_size = 0; |
|
| 73 | + foreach ($models_and_ids_to_delete as $model_name => $ids) { |
|
| 74 | + $job_size += count($ids); |
|
| 75 | + } |
|
| 76 | + $job_parameters->set_job_size($job_size); |
|
| 77 | + return new JobStepResponse( |
|
| 78 | + $job_parameters, |
|
| 79 | + esc_html__('Beginning to delete items...', 'event_espresso') |
|
| 80 | + ); |
|
| 81 | + } |
|
| 82 | 82 | |
| 83 | - /** |
|
| 84 | - * Performs another step of the job |
|
| 85 | - * @param JobParameters $job_parameters |
|
| 86 | - * @param int $batch_size |
|
| 87 | - * @return JobStepResponse |
|
| 88 | - * @throws BatchRequestException |
|
| 89 | - */ |
|
| 90 | - public function continue_job(JobParameters $job_parameters, $batch_size = 50) |
|
| 91 | - { |
|
| 92 | - // We already have the items IDs. So deleting is really fast. Let's speed it up. |
|
| 93 | - $batch_size *= 10; |
|
| 94 | - $units_processed = 0; |
|
| 95 | - $models_and_ids_to_delete = $job_parameters->extra_datum('models_and_ids_to_delete', []); |
|
| 96 | - // Build a new list of everything leftover after this request's of deletions. |
|
| 97 | - $models_and_ids_remaining = []; |
|
| 98 | - foreach ($models_and_ids_to_delete as $model_name => $ids_to_delete) { |
|
| 99 | - if ($units_processed < $batch_size) { |
|
| 100 | - $model = EE_Registry::instance()->load_model($model_name); |
|
| 101 | - $ids_to_delete_this_query = array_slice($ids_to_delete, 0, $batch_size - $units_processed, true); |
|
| 102 | - if ($model->has_primary_key_field()) { |
|
| 103 | - $where_conditions = [ |
|
| 104 | - $model->primary_key_name() => [ |
|
| 105 | - 'IN', |
|
| 106 | - $ids_to_delete_this_query |
|
| 107 | - ] |
|
| 108 | - ]; |
|
| 109 | - } else { |
|
| 110 | - $where_conditions = [ |
|
| 111 | - 'OR' => [] |
|
| 112 | - ]; |
|
| 113 | - foreach ($ids_to_delete_this_query as $index_primary_key_string) { |
|
| 114 | - $keys_n_values = $model->parse_index_primary_key_string($index_primary_key_string); |
|
| 115 | - $where_conditions['OR'][ 'AND*' . $index_primary_key_string ] = $keys_n_values; |
|
| 116 | - } |
|
| 117 | - } |
|
| 118 | - // Deleting time! |
|
| 119 | - // The model's deletion method reports every ROW deleted, and in the case of CPT models that will be |
|
| 120 | - // two rows deleted for event CPT item. So don't rely on it for the count of items deleted. |
|
| 121 | - $model->delete_permanently( |
|
| 122 | - [ |
|
| 123 | - $where_conditions |
|
| 124 | - ], |
|
| 125 | - false |
|
| 126 | - ); |
|
| 127 | - $units_processed += count($ids_to_delete_this_query); |
|
| 128 | - $remaining_ids = array_diff_key($ids_to_delete, $ids_to_delete_this_query); |
|
| 129 | - // If there's any more from this model, we'll do them next time. |
|
| 130 | - if (count($remaining_ids) > 0) { |
|
| 131 | - $models_and_ids_remaining[ $model_name ] = $remaining_ids; |
|
| 132 | - } |
|
| 133 | - } else { |
|
| 134 | - $models_and_ids_remaining[ $model_name ] = $models_and_ids_to_delete[ $model_name ]; |
|
| 135 | - } |
|
| 136 | - } |
|
| 137 | - $job_parameters->mark_processed($units_processed); |
|
| 138 | - // All done deleting for this request. Is there anything to do next time? |
|
| 139 | - if (empty($models_and_ids_remaining)) { |
|
| 140 | - $job_parameters->set_status(JobParameters::status_complete); |
|
| 141 | - return new JobStepResponse( |
|
| 142 | - $job_parameters, |
|
| 143 | - esc_html__('Deletion complete.', 'event_espresso') |
|
| 144 | - ); |
|
| 145 | - } |
|
| 146 | - $job_parameters->add_extra_data('models_and_ids_to_delete', $models_and_ids_remaining); |
|
| 147 | - return new JobStepResponse( |
|
| 148 | - $job_parameters, |
|
| 149 | - sprintf( |
|
| 150 | - esc_html__('Deleted %d items.', 'event_espresso'), |
|
| 151 | - $units_processed |
|
| 152 | - ) |
|
| 153 | - ); |
|
| 154 | - } |
|
| 83 | + /** |
|
| 84 | + * Performs another step of the job |
|
| 85 | + * @param JobParameters $job_parameters |
|
| 86 | + * @param int $batch_size |
|
| 87 | + * @return JobStepResponse |
|
| 88 | + * @throws BatchRequestException |
|
| 89 | + */ |
|
| 90 | + public function continue_job(JobParameters $job_parameters, $batch_size = 50) |
|
| 91 | + { |
|
| 92 | + // We already have the items IDs. So deleting is really fast. Let's speed it up. |
|
| 93 | + $batch_size *= 10; |
|
| 94 | + $units_processed = 0; |
|
| 95 | + $models_and_ids_to_delete = $job_parameters->extra_datum('models_and_ids_to_delete', []); |
|
| 96 | + // Build a new list of everything leftover after this request's of deletions. |
|
| 97 | + $models_and_ids_remaining = []; |
|
| 98 | + foreach ($models_and_ids_to_delete as $model_name => $ids_to_delete) { |
|
| 99 | + if ($units_processed < $batch_size) { |
|
| 100 | + $model = EE_Registry::instance()->load_model($model_name); |
|
| 101 | + $ids_to_delete_this_query = array_slice($ids_to_delete, 0, $batch_size - $units_processed, true); |
|
| 102 | + if ($model->has_primary_key_field()) { |
|
| 103 | + $where_conditions = [ |
|
| 104 | + $model->primary_key_name() => [ |
|
| 105 | + 'IN', |
|
| 106 | + $ids_to_delete_this_query |
|
| 107 | + ] |
|
| 108 | + ]; |
|
| 109 | + } else { |
|
| 110 | + $where_conditions = [ |
|
| 111 | + 'OR' => [] |
|
| 112 | + ]; |
|
| 113 | + foreach ($ids_to_delete_this_query as $index_primary_key_string) { |
|
| 114 | + $keys_n_values = $model->parse_index_primary_key_string($index_primary_key_string); |
|
| 115 | + $where_conditions['OR'][ 'AND*' . $index_primary_key_string ] = $keys_n_values; |
|
| 116 | + } |
|
| 117 | + } |
|
| 118 | + // Deleting time! |
|
| 119 | + // The model's deletion method reports every ROW deleted, and in the case of CPT models that will be |
|
| 120 | + // two rows deleted for event CPT item. So don't rely on it for the count of items deleted. |
|
| 121 | + $model->delete_permanently( |
|
| 122 | + [ |
|
| 123 | + $where_conditions |
|
| 124 | + ], |
|
| 125 | + false |
|
| 126 | + ); |
|
| 127 | + $units_processed += count($ids_to_delete_this_query); |
|
| 128 | + $remaining_ids = array_diff_key($ids_to_delete, $ids_to_delete_this_query); |
|
| 129 | + // If there's any more from this model, we'll do them next time. |
|
| 130 | + if (count($remaining_ids) > 0) { |
|
| 131 | + $models_and_ids_remaining[ $model_name ] = $remaining_ids; |
|
| 132 | + } |
|
| 133 | + } else { |
|
| 134 | + $models_and_ids_remaining[ $model_name ] = $models_and_ids_to_delete[ $model_name ]; |
|
| 135 | + } |
|
| 136 | + } |
|
| 137 | + $job_parameters->mark_processed($units_processed); |
|
| 138 | + // All done deleting for this request. Is there anything to do next time? |
|
| 139 | + if (empty($models_and_ids_remaining)) { |
|
| 140 | + $job_parameters->set_status(JobParameters::status_complete); |
|
| 141 | + return new JobStepResponse( |
|
| 142 | + $job_parameters, |
|
| 143 | + esc_html__('Deletion complete.', 'event_espresso') |
|
| 144 | + ); |
|
| 145 | + } |
|
| 146 | + $job_parameters->add_extra_data('models_and_ids_to_delete', $models_and_ids_remaining); |
|
| 147 | + return new JobStepResponse( |
|
| 148 | + $job_parameters, |
|
| 149 | + sprintf( |
|
| 150 | + esc_html__('Deleted %d items.', 'event_espresso'), |
|
| 151 | + $units_processed |
|
| 152 | + ) |
|
| 153 | + ); |
|
| 154 | + } |
|
| 155 | 155 | |
| 156 | - /** |
|
| 157 | - * Performs any clean-up logic when we know the job is completed |
|
| 158 | - * @param JobParameters $job_parameters |
|
| 159 | - * @return JobStepResponse |
|
| 160 | - */ |
|
| 161 | - public function cleanup_job(JobParameters $job_parameters) |
|
| 162 | - { |
|
| 163 | - $this->model_obj_node_group_persister->deleteModelObjNodesInGroup( |
|
| 164 | - $job_parameters->request_datum('deletion_job_code') |
|
| 165 | - ); |
|
| 166 | - // For backwards compatibility with how we used to delete events, make sure we still trigger the old action. |
|
| 167 | - $models_and_ids_to_delete = $job_parameters->extra_datum('models_and_ids_to_delete', []); |
|
| 168 | - foreach ($models_and_ids_to_delete['Event'] as $event_id) { |
|
| 169 | - // Create a log entry so we know who and when this event was permanently deleted. |
|
| 170 | - (EE_Change_Log::new_instance( |
|
| 171 | - [ |
|
| 172 | - 'OBJ_ID' => $event_id, |
|
| 173 | - 'OBJ_type' => 'Event', |
|
| 174 | - 'LOG_message' => sprintf( |
|
| 175 | - esc_html__('Event %1$d permanently deleted using ExecuteBatchDeletion.', 'event_espresso'), |
|
| 176 | - $event_id |
|
| 177 | - ) |
|
| 178 | - ] |
|
| 179 | - ))->save(); |
|
| 180 | - do_action('AHEE__Events_Admin_Page___permanently_delete_event__after_event_deleted', $event_id); |
|
| 181 | - } |
|
| 182 | - return new JobStepResponse( |
|
| 183 | - $job_parameters, |
|
| 184 | - esc_html__('All done', 'event_espresso') |
|
| 185 | - ); |
|
| 186 | - } |
|
| 156 | + /** |
|
| 157 | + * Performs any clean-up logic when we know the job is completed |
|
| 158 | + * @param JobParameters $job_parameters |
|
| 159 | + * @return JobStepResponse |
|
| 160 | + */ |
|
| 161 | + public function cleanup_job(JobParameters $job_parameters) |
|
| 162 | + { |
|
| 163 | + $this->model_obj_node_group_persister->deleteModelObjNodesInGroup( |
|
| 164 | + $job_parameters->request_datum('deletion_job_code') |
|
| 165 | + ); |
|
| 166 | + // For backwards compatibility with how we used to delete events, make sure we still trigger the old action. |
|
| 167 | + $models_and_ids_to_delete = $job_parameters->extra_datum('models_and_ids_to_delete', []); |
|
| 168 | + foreach ($models_and_ids_to_delete['Event'] as $event_id) { |
|
| 169 | + // Create a log entry so we know who and when this event was permanently deleted. |
|
| 170 | + (EE_Change_Log::new_instance( |
|
| 171 | + [ |
|
| 172 | + 'OBJ_ID' => $event_id, |
|
| 173 | + 'OBJ_type' => 'Event', |
|
| 174 | + 'LOG_message' => sprintf( |
|
| 175 | + esc_html__('Event %1$d permanently deleted using ExecuteBatchDeletion.', 'event_espresso'), |
|
| 176 | + $event_id |
|
| 177 | + ) |
|
| 178 | + ] |
|
| 179 | + ))->save(); |
|
| 180 | + do_action('AHEE__Events_Admin_Page___permanently_delete_event__after_event_deleted', $event_id); |
|
| 181 | + } |
|
| 182 | + return new JobStepResponse( |
|
| 183 | + $job_parameters, |
|
| 184 | + esc_html__('All done', 'event_espresso') |
|
| 185 | + ); |
|
| 186 | + } |
|
| 187 | 187 | } |
| 188 | 188 | // End of file EventDeletion.php |
| 189 | 189 | // Location: EventEspressoBatchRequest\JobHandlers/EventDeletion.php |
@@ -58,7 +58,7 @@ discard block |
||
| 58 | 58 | } |
| 59 | 59 | $models_and_ids_to_delete = []; |
| 60 | 60 | foreach ($roots as $root) { |
| 61 | - if (! $root instanceof ModelObjNode) { |
|
| 61 | + if ( ! $root instanceof ModelObjNode) { |
|
| 62 | 62 | throw new UnexpectedEntityException($root, 'ModelObjNode'); |
| 63 | 63 | } |
| 64 | 64 | $models_and_ids_to_delete = array_replace_recursive($models_and_ids_to_delete, $root->getIds()); |
@@ -112,7 +112,7 @@ discard block |
||
| 112 | 112 | ]; |
| 113 | 113 | foreach ($ids_to_delete_this_query as $index_primary_key_string) { |
| 114 | 114 | $keys_n_values = $model->parse_index_primary_key_string($index_primary_key_string); |
| 115 | - $where_conditions['OR'][ 'AND*' . $index_primary_key_string ] = $keys_n_values; |
|
| 115 | + $where_conditions['OR']['AND*'.$index_primary_key_string] = $keys_n_values; |
|
| 116 | 116 | } |
| 117 | 117 | } |
| 118 | 118 | // Deleting time! |
@@ -128,10 +128,10 @@ discard block |
||
| 128 | 128 | $remaining_ids = array_diff_key($ids_to_delete, $ids_to_delete_this_query); |
| 129 | 129 | // If there's any more from this model, we'll do them next time. |
| 130 | 130 | if (count($remaining_ids) > 0) { |
| 131 | - $models_and_ids_remaining[ $model_name ] = $remaining_ids; |
|
| 131 | + $models_and_ids_remaining[$model_name] = $remaining_ids; |
|
| 132 | 132 | } |
| 133 | 133 | } else { |
| 134 | - $models_and_ids_remaining[ $model_name ] = $models_and_ids_to_delete[ $model_name ]; |
|
| 134 | + $models_and_ids_remaining[$model_name] = $models_and_ids_to_delete[$model_name]; |
|
| 135 | 135 | } |
| 136 | 136 | } |
| 137 | 137 | $job_parameters->mark_processed($units_processed); |
@@ -89,17 +89,17 @@ discard block |
||
| 89 | 89 | $deletion_job_code = isset($request_data['deletion_job_code']) ? sanitize_key($request_data['deletion_job_code']) : ''; |
| 90 | 90 | $models_and_ids_to_delete = $this->dao->getModelsAndIdsFromGroup($deletion_job_code); |
| 91 | 91 | $event_ids = isset($models_and_ids_to_delete['Event']) ? $models_and_ids_to_delete['Event'] : array(); |
| 92 | - if (empty($event_ids) || !is_array($event_ids)) { |
|
| 92 | + if (empty($event_ids) || ! is_array($event_ids)) { |
|
| 93 | 93 | throw new EE_Error( |
| 94 | 94 | esc_html__('No Events were found to delete.', 'event_espresso') |
| 95 | 95 | ); |
| 96 | 96 | } |
| 97 | 97 | $datetime_ids = isset($models_and_ids_to_delete['Datetime']) ? $models_and_ids_to_delete['Datetime'] : array(); |
| 98 | - if (!is_array($datetime_ids)) { |
|
| 98 | + if ( ! is_array($datetime_ids)) { |
|
| 99 | 99 | throw new UnexpectedEntityException($datetime_ids, 'array'); |
| 100 | 100 | } |
| 101 | 101 | $registration_ids = isset($models_and_ids_to_delete['Registration']) ? $models_and_ids_to_delete['Registration'] : array(); |
| 102 | - if (!is_array($registration_ids)) { |
|
| 102 | + if ( ! is_array($registration_ids)) { |
|
| 103 | 103 | throw new UnexpectedEntityException($registration_ids, 'array'); |
| 104 | 104 | } |
| 105 | 105 | $num_registrations_to_show = 10; |
@@ -135,7 +135,7 @@ discard block |
||
| 135 | 135 | ]; |
| 136 | 136 | return [ |
| 137 | 137 | 'admin_page_content' => EEH_Template::display_template( |
| 138 | - EVENTS_TEMPLATE_PATH . 'event_preview_deletion.template.php', |
|
| 138 | + EVENTS_TEMPLATE_PATH.'event_preview_deletion.template.php', |
|
| 139 | 139 | [ |
| 140 | 140 | 'form_url' => EE_Admin_Page::add_query_args_and_nonce( |
| 141 | 141 | $confirm_deletion_args, |
@@ -31,127 +31,127 @@ |
||
| 31 | 31 | */ |
| 32 | 32 | class PreviewDeletion |
| 33 | 33 | { |
| 34 | - /** |
|
| 35 | - * @var NodeGroupDao |
|
| 36 | - */ |
|
| 37 | - protected $dao; |
|
| 34 | + /** |
|
| 35 | + * @var NodeGroupDao |
|
| 36 | + */ |
|
| 37 | + protected $dao; |
|
| 38 | 38 | |
| 39 | - /** |
|
| 40 | - * @var EEM_Event |
|
| 41 | - */ |
|
| 42 | - protected $event_model; |
|
| 39 | + /** |
|
| 40 | + * @var EEM_Event |
|
| 41 | + */ |
|
| 42 | + protected $event_model; |
|
| 43 | 43 | |
| 44 | - /** |
|
| 45 | - * @var EEM_Datetime |
|
| 46 | - */ |
|
| 47 | - protected $datetime_model; |
|
| 44 | + /** |
|
| 45 | + * @var EEM_Datetime |
|
| 46 | + */ |
|
| 47 | + protected $datetime_model; |
|
| 48 | 48 | |
| 49 | - /** |
|
| 50 | - * @var EEM_Registration |
|
| 51 | - */ |
|
| 52 | - protected $registration_model; |
|
| 49 | + /** |
|
| 50 | + * @var EEM_Registration |
|
| 51 | + */ |
|
| 52 | + protected $registration_model; |
|
| 53 | 53 | |
| 54 | - /** |
|
| 55 | - * PreviewDeletion constructor. |
|
| 56 | - * @param NodeGroupDao $dao |
|
| 57 | - * @param EEM_Event $event_model |
|
| 58 | - * @param EEM_Datetime $datetime_model |
|
| 59 | - * @param EEM_Registration $registration_model |
|
| 60 | - */ |
|
| 61 | - public function __construct( |
|
| 62 | - NodeGroupDao $dao, |
|
| 63 | - EEM_Event $event_model, |
|
| 64 | - EEM_Datetime $datetime_model, |
|
| 65 | - EEM_Registration $registration_model |
|
| 66 | - ) { |
|
| 67 | - $this->dao = $dao; |
|
| 68 | - $this->event_model = $event_model; |
|
| 69 | - $this->datetime_model = $datetime_model; |
|
| 70 | - $this->registration_model = $registration_model; |
|
| 71 | - } |
|
| 54 | + /** |
|
| 55 | + * PreviewDeletion constructor. |
|
| 56 | + * @param NodeGroupDao $dao |
|
| 57 | + * @param EEM_Event $event_model |
|
| 58 | + * @param EEM_Datetime $datetime_model |
|
| 59 | + * @param EEM_Registration $registration_model |
|
| 60 | + */ |
|
| 61 | + public function __construct( |
|
| 62 | + NodeGroupDao $dao, |
|
| 63 | + EEM_Event $event_model, |
|
| 64 | + EEM_Datetime $datetime_model, |
|
| 65 | + EEM_Registration $registration_model |
|
| 66 | + ) { |
|
| 67 | + $this->dao = $dao; |
|
| 68 | + $this->event_model = $event_model; |
|
| 69 | + $this->datetime_model = $datetime_model; |
|
| 70 | + $this->registration_model = $registration_model; |
|
| 71 | + } |
|
| 72 | 72 | |
| 73 | - /** |
|
| 74 | - * Renders the preview deletion page. |
|
| 75 | - * @since 4.10.12.p |
|
| 76 | - * @param $request_data |
|
| 77 | - * @param $admin_base_url |
|
| 78 | - * @return array |
|
| 79 | - * @throws UnexpectedEntityException |
|
| 80 | - * @throws DomainException |
|
| 81 | - * @throws EE_Error |
|
| 82 | - * @throws InvalidDataTypeException |
|
| 83 | - * @throws InvalidInterfaceException |
|
| 84 | - * @throws InvalidArgumentException |
|
| 85 | - * @throws ReflectionException |
|
| 86 | - */ |
|
| 87 | - public function handle($request_data, $admin_base_url) |
|
| 88 | - { |
|
| 89 | - $deletion_job_code = isset($request_data['deletion_job_code']) ? sanitize_key($request_data['deletion_job_code']) : ''; |
|
| 90 | - $models_and_ids_to_delete = $this->dao->getModelsAndIdsFromGroup($deletion_job_code); |
|
| 91 | - $event_ids = isset($models_and_ids_to_delete['Event']) ? $models_and_ids_to_delete['Event'] : array(); |
|
| 92 | - if (empty($event_ids) || !is_array($event_ids)) { |
|
| 93 | - throw new EE_Error( |
|
| 94 | - esc_html__('No Events were found to delete.', 'event_espresso') |
|
| 95 | - ); |
|
| 96 | - } |
|
| 97 | - $datetime_ids = isset($models_and_ids_to_delete['Datetime']) ? $models_and_ids_to_delete['Datetime'] : array(); |
|
| 98 | - if (!is_array($datetime_ids)) { |
|
| 99 | - throw new UnexpectedEntityException($datetime_ids, 'array'); |
|
| 100 | - } |
|
| 101 | - $registration_ids = isset($models_and_ids_to_delete['Registration']) ? $models_and_ids_to_delete['Registration'] : array(); |
|
| 102 | - if (!is_array($registration_ids)) { |
|
| 103 | - throw new UnexpectedEntityException($registration_ids, 'array'); |
|
| 104 | - } |
|
| 105 | - $num_registrations_to_show = 10; |
|
| 106 | - $reg_count = count($registration_ids); |
|
| 107 | - if ($reg_count > $num_registrations_to_show) { |
|
| 108 | - $registration_ids = array_slice($registration_ids, 0, $num_registrations_to_show); |
|
| 109 | - } |
|
| 110 | - $form = new ConfirmEventDeletionForm($event_ids); |
|
| 111 | - $events = $this->event_model->get_all_deleted_and_undeleted( |
|
| 112 | - [ |
|
| 113 | - [ |
|
| 114 | - 'EVT_ID' => ['IN', $event_ids] |
|
| 115 | - ] |
|
| 116 | - ] |
|
| 117 | - ); |
|
| 118 | - $datetimes = $this->datetime_model->get_all_deleted_and_undeleted( |
|
| 119 | - [ |
|
| 120 | - [ |
|
| 121 | - 'DTT_ID' => ['IN', $datetime_ids] |
|
| 122 | - ] |
|
| 123 | - ] |
|
| 124 | - ); |
|
| 125 | - $registrations = $this->registration_model->get_all_deleted_and_undeleted( |
|
| 126 | - [ |
|
| 127 | - [ |
|
| 128 | - 'REG_ID' => ['IN', $registration_ids] |
|
| 129 | - ] |
|
| 130 | - ] |
|
| 131 | - ); |
|
| 132 | - $confirm_deletion_args = [ |
|
| 133 | - 'action' => 'confirm_deletion', |
|
| 134 | - 'deletion_job_code' => $deletion_job_code |
|
| 135 | - ]; |
|
| 136 | - return [ |
|
| 137 | - 'admin_page_content' => EEH_Template::display_template( |
|
| 138 | - EVENTS_TEMPLATE_PATH . 'event_preview_deletion.template.php', |
|
| 139 | - [ |
|
| 140 | - 'form_url' => EE_Admin_Page::add_query_args_and_nonce( |
|
| 141 | - $confirm_deletion_args, |
|
| 142 | - $admin_base_url |
|
| 143 | - ), |
|
| 144 | - 'form' => $form, |
|
| 145 | - 'events' => $events, |
|
| 146 | - 'datetimes' => $datetimes, |
|
| 147 | - 'registrations' => $registrations, |
|
| 148 | - 'reg_count' => $reg_count, |
|
| 149 | - 'num_registrations_to_show' => $num_registrations_to_show |
|
| 150 | - ], |
|
| 151 | - true |
|
| 152 | - ) |
|
| 153 | - ]; |
|
| 154 | - } |
|
| 73 | + /** |
|
| 74 | + * Renders the preview deletion page. |
|
| 75 | + * @since 4.10.12.p |
|
| 76 | + * @param $request_data |
|
| 77 | + * @param $admin_base_url |
|
| 78 | + * @return array |
|
| 79 | + * @throws UnexpectedEntityException |
|
| 80 | + * @throws DomainException |
|
| 81 | + * @throws EE_Error |
|
| 82 | + * @throws InvalidDataTypeException |
|
| 83 | + * @throws InvalidInterfaceException |
|
| 84 | + * @throws InvalidArgumentException |
|
| 85 | + * @throws ReflectionException |
|
| 86 | + */ |
|
| 87 | + public function handle($request_data, $admin_base_url) |
|
| 88 | + { |
|
| 89 | + $deletion_job_code = isset($request_data['deletion_job_code']) ? sanitize_key($request_data['deletion_job_code']) : ''; |
|
| 90 | + $models_and_ids_to_delete = $this->dao->getModelsAndIdsFromGroup($deletion_job_code); |
|
| 91 | + $event_ids = isset($models_and_ids_to_delete['Event']) ? $models_and_ids_to_delete['Event'] : array(); |
|
| 92 | + if (empty($event_ids) || !is_array($event_ids)) { |
|
| 93 | + throw new EE_Error( |
|
| 94 | + esc_html__('No Events were found to delete.', 'event_espresso') |
|
| 95 | + ); |
|
| 96 | + } |
|
| 97 | + $datetime_ids = isset($models_and_ids_to_delete['Datetime']) ? $models_and_ids_to_delete['Datetime'] : array(); |
|
| 98 | + if (!is_array($datetime_ids)) { |
|
| 99 | + throw new UnexpectedEntityException($datetime_ids, 'array'); |
|
| 100 | + } |
|
| 101 | + $registration_ids = isset($models_and_ids_to_delete['Registration']) ? $models_and_ids_to_delete['Registration'] : array(); |
|
| 102 | + if (!is_array($registration_ids)) { |
|
| 103 | + throw new UnexpectedEntityException($registration_ids, 'array'); |
|
| 104 | + } |
|
| 105 | + $num_registrations_to_show = 10; |
|
| 106 | + $reg_count = count($registration_ids); |
|
| 107 | + if ($reg_count > $num_registrations_to_show) { |
|
| 108 | + $registration_ids = array_slice($registration_ids, 0, $num_registrations_to_show); |
|
| 109 | + } |
|
| 110 | + $form = new ConfirmEventDeletionForm($event_ids); |
|
| 111 | + $events = $this->event_model->get_all_deleted_and_undeleted( |
|
| 112 | + [ |
|
| 113 | + [ |
|
| 114 | + 'EVT_ID' => ['IN', $event_ids] |
|
| 115 | + ] |
|
| 116 | + ] |
|
| 117 | + ); |
|
| 118 | + $datetimes = $this->datetime_model->get_all_deleted_and_undeleted( |
|
| 119 | + [ |
|
| 120 | + [ |
|
| 121 | + 'DTT_ID' => ['IN', $datetime_ids] |
|
| 122 | + ] |
|
| 123 | + ] |
|
| 124 | + ); |
|
| 125 | + $registrations = $this->registration_model->get_all_deleted_and_undeleted( |
|
| 126 | + [ |
|
| 127 | + [ |
|
| 128 | + 'REG_ID' => ['IN', $registration_ids] |
|
| 129 | + ] |
|
| 130 | + ] |
|
| 131 | + ); |
|
| 132 | + $confirm_deletion_args = [ |
|
| 133 | + 'action' => 'confirm_deletion', |
|
| 134 | + 'deletion_job_code' => $deletion_job_code |
|
| 135 | + ]; |
|
| 136 | + return [ |
|
| 137 | + 'admin_page_content' => EEH_Template::display_template( |
|
| 138 | + EVENTS_TEMPLATE_PATH . 'event_preview_deletion.template.php', |
|
| 139 | + [ |
|
| 140 | + 'form_url' => EE_Admin_Page::add_query_args_and_nonce( |
|
| 141 | + $confirm_deletion_args, |
|
| 142 | + $admin_base_url |
|
| 143 | + ), |
|
| 144 | + 'form' => $form, |
|
| 145 | + 'events' => $events, |
|
| 146 | + 'datetimes' => $datetimes, |
|
| 147 | + 'registrations' => $registrations, |
|
| 148 | + 'reg_count' => $reg_count, |
|
| 149 | + 'num_registrations_to_show' => $num_registrations_to_show |
|
| 150 | + ], |
|
| 151 | + true |
|
| 152 | + ) |
|
| 153 | + ]; |
|
| 154 | + } |
|
| 155 | 155 | } |
| 156 | 156 | // End of file PreviewDeletion.php |
| 157 | 157 | // Location: EventEspresso\core\domain\services\admin\events\data/PreviewDeletion.php |
@@ -93,8 +93,8 @@ discard block |
||
| 93 | 93 | // Add entity nodes for each of the model objects we fetched. |
| 94 | 94 | foreach ($related_model_objs as $related_model_obj) { |
| 95 | 95 | $entity_node = new ModelObjNode($related_model_obj->ID(), $related_model_obj->get_model(), $this->dont_traverse_models); |
| 96 | - $this->nodes[ $related_model_obj->ID() ] = $entity_node; |
|
| 97 | - $new_item_nodes[ $related_model_obj->ID() ] = $entity_node; |
|
| 96 | + $this->nodes[$related_model_obj->ID()] = $entity_node; |
|
| 97 | + $new_item_nodes[$related_model_obj->ID()] = $entity_node; |
|
| 98 | 98 | } |
| 99 | 99 | $num_identified += count($new_item_nodes); |
| 100 | 100 | if ($num_identified < $model_objects_to_identify) { |
@@ -120,7 +120,7 @@ discard block |
||
| 120 | 120 | protected function allChildrenComplete() |
| 121 | 121 | { |
| 122 | 122 | foreach ($this->nodes as $model_obj_node) { |
| 123 | - if (! $model_obj_node->isComplete()) { |
|
| 123 | + if ( ! $model_obj_node->isComplete()) { |
|
| 124 | 124 | return false; |
| 125 | 125 | } |
| 126 | 126 | } |
@@ -137,7 +137,7 @@ discard block |
||
| 137 | 137 | protected function visitAlreadyDiscoveredNodes($model_obj_nodes, $work_budget) |
| 138 | 138 | { |
| 139 | 139 | $work_done = 0; |
| 140 | - if (! $model_obj_nodes) { |
|
| 140 | + if ( ! $model_obj_nodes) { |
|
| 141 | 141 | return 0; |
| 142 | 142 | } |
| 143 | 143 | foreach ($model_obj_nodes as $model_obj_node) { |
@@ -199,7 +199,7 @@ discard block |
||
| 199 | 199 | */ |
| 200 | 200 | protected function whereQueryParams() |
| 201 | 201 | { |
| 202 | - $where_params = [ |
|
| 202 | + $where_params = [ |
|
| 203 | 203 | $this->related_model->get_foreign_key_to( |
| 204 | 204 | $this->main_model->get_this_model_name() |
| 205 | 205 | )->get_name() => $this->id |
@@ -212,7 +212,7 @@ discard block |
||
| 212 | 212 | $relation_settings = null; |
| 213 | 213 | } |
| 214 | 214 | if ($relation_settings instanceof EE_Has_Many_Any_Relation) { |
| 215 | - $where_params[ $this->related_model->get_field_containing_related_model_name()->get_name() ] = $this->main_model->get_this_model_name(); |
|
| 215 | + $where_params[$this->related_model->get_field_containing_related_model_name()->get_name()] = $this->main_model->get_this_model_name(); |
|
| 216 | 216 | } |
| 217 | 217 | return $where_params; |
| 218 | 218 | } |
@@ -228,7 +228,7 @@ discard block |
||
| 228 | 228 | 'objs' => [] |
| 229 | 229 | ]; |
| 230 | 230 | foreach ($this->nodes as $id => $model_obj_node) { |
| 231 | - $tree['objs'][ $id ] = $model_obj_node->toArray(); |
|
| 231 | + $tree['objs'][$id] = $model_obj_node->toArray(); |
|
| 232 | 232 | } |
| 233 | 233 | return $tree; |
| 234 | 234 | } |
@@ -27,289 +27,289 @@ |
||
| 27 | 27 | */ |
| 28 | 28 | class RelationNode extends BaseNode |
| 29 | 29 | { |
| 30 | - /** |
|
| 31 | - * @var string|int |
|
| 32 | - */ |
|
| 33 | - protected $id; |
|
| 30 | + /** |
|
| 31 | + * @var string|int |
|
| 32 | + */ |
|
| 33 | + protected $id; |
|
| 34 | 34 | |
| 35 | - /** |
|
| 36 | - * @var EEM_Base |
|
| 37 | - */ |
|
| 38 | - protected $main_model; |
|
| 35 | + /** |
|
| 36 | + * @var EEM_Base |
|
| 37 | + */ |
|
| 38 | + protected $main_model; |
|
| 39 | 39 | |
| 40 | - /** |
|
| 41 | - * @var int |
|
| 42 | - */ |
|
| 43 | - protected $count; |
|
| 40 | + /** |
|
| 41 | + * @var int |
|
| 42 | + */ |
|
| 43 | + protected $count; |
|
| 44 | 44 | |
| 45 | - /** |
|
| 46 | - * @var EEM_Base |
|
| 47 | - */ |
|
| 48 | - protected $related_model; |
|
| 45 | + /** |
|
| 46 | + * @var EEM_Base |
|
| 47 | + */ |
|
| 48 | + protected $related_model; |
|
| 49 | 49 | |
| 50 | - /** |
|
| 51 | - * @var ModelObjNode[] |
|
| 52 | - */ |
|
| 53 | - protected $nodes; |
|
| 50 | + /** |
|
| 51 | + * @var ModelObjNode[] |
|
| 52 | + */ |
|
| 53 | + protected $nodes; |
|
| 54 | 54 | |
| 55 | - /** |
|
| 56 | - * RelationNode constructor. |
|
| 57 | - * @param $main_model_obj_id |
|
| 58 | - * @param EEM_Base $main_model |
|
| 59 | - * @param EEM_Base $related_model |
|
| 60 | - * @param array $dont_traverse_models array of model names we DON'T want to traverse |
|
| 61 | - */ |
|
| 62 | - public function __construct( |
|
| 63 | - $main_model_obj_id, |
|
| 64 | - EEM_Base $main_model, |
|
| 65 | - EEM_Base $related_model, |
|
| 66 | - array $dont_traverse_models = [] |
|
| 67 | - ) { |
|
| 68 | - $this->id = $main_model_obj_id; |
|
| 69 | - $this->main_model = $main_model; |
|
| 70 | - $this->related_model = $related_model; |
|
| 71 | - $this->nodes = []; |
|
| 72 | - $this->dont_traverse_models = $dont_traverse_models; |
|
| 73 | - } |
|
| 55 | + /** |
|
| 56 | + * RelationNode constructor. |
|
| 57 | + * @param $main_model_obj_id |
|
| 58 | + * @param EEM_Base $main_model |
|
| 59 | + * @param EEM_Base $related_model |
|
| 60 | + * @param array $dont_traverse_models array of model names we DON'T want to traverse |
|
| 61 | + */ |
|
| 62 | + public function __construct( |
|
| 63 | + $main_model_obj_id, |
|
| 64 | + EEM_Base $main_model, |
|
| 65 | + EEM_Base $related_model, |
|
| 66 | + array $dont_traverse_models = [] |
|
| 67 | + ) { |
|
| 68 | + $this->id = $main_model_obj_id; |
|
| 69 | + $this->main_model = $main_model; |
|
| 70 | + $this->related_model = $related_model; |
|
| 71 | + $this->nodes = []; |
|
| 72 | + $this->dont_traverse_models = $dont_traverse_models; |
|
| 73 | + } |
|
| 74 | 74 | |
| 75 | 75 | |
| 76 | - /** |
|
| 77 | - * Here is where most of the work happens. We've counted how many related model objects exist, here we identify |
|
| 78 | - * them (ie, learn their IDs). But its recursive, so we'll also find their related dependent model objects etc. |
|
| 79 | - * @since 4.10.12.p |
|
| 80 | - * @param int $model_objects_to_identify |
|
| 81 | - * @return int |
|
| 82 | - * @throws EE_Error |
|
| 83 | - * @throws InvalidArgumentException |
|
| 84 | - * @throws InvalidDataTypeException |
|
| 85 | - * @throws InvalidInterfaceException |
|
| 86 | - * @throws ReflectionException |
|
| 87 | - */ |
|
| 88 | - protected function work($model_objects_to_identify) |
|
| 89 | - { |
|
| 90 | - $num_identified = $this->visitAlreadyDiscoveredNodes($this->nodes, $model_objects_to_identify); |
|
| 91 | - if ($num_identified < $model_objects_to_identify) { |
|
| 92 | - $related_model_objs = $this->related_model->get_all( |
|
| 93 | - [ |
|
| 94 | - $this->whereQueryParams(), |
|
| 95 | - 'limit' => [ |
|
| 96 | - count($this->nodes), |
|
| 97 | - $model_objects_to_identify - $num_identified |
|
| 98 | - ] |
|
| 99 | - ] |
|
| 100 | - ); |
|
| 101 | - $new_item_nodes = []; |
|
| 76 | + /** |
|
| 77 | + * Here is where most of the work happens. We've counted how many related model objects exist, here we identify |
|
| 78 | + * them (ie, learn their IDs). But its recursive, so we'll also find their related dependent model objects etc. |
|
| 79 | + * @since 4.10.12.p |
|
| 80 | + * @param int $model_objects_to_identify |
|
| 81 | + * @return int |
|
| 82 | + * @throws EE_Error |
|
| 83 | + * @throws InvalidArgumentException |
|
| 84 | + * @throws InvalidDataTypeException |
|
| 85 | + * @throws InvalidInterfaceException |
|
| 86 | + * @throws ReflectionException |
|
| 87 | + */ |
|
| 88 | + protected function work($model_objects_to_identify) |
|
| 89 | + { |
|
| 90 | + $num_identified = $this->visitAlreadyDiscoveredNodes($this->nodes, $model_objects_to_identify); |
|
| 91 | + if ($num_identified < $model_objects_to_identify) { |
|
| 92 | + $related_model_objs = $this->related_model->get_all( |
|
| 93 | + [ |
|
| 94 | + $this->whereQueryParams(), |
|
| 95 | + 'limit' => [ |
|
| 96 | + count($this->nodes), |
|
| 97 | + $model_objects_to_identify - $num_identified |
|
| 98 | + ] |
|
| 99 | + ] |
|
| 100 | + ); |
|
| 101 | + $new_item_nodes = []; |
|
| 102 | 102 | |
| 103 | - // Add entity nodes for each of the model objects we fetched. |
|
| 104 | - foreach ($related_model_objs as $related_model_obj) { |
|
| 105 | - $entity_node = new ModelObjNode($related_model_obj->ID(), $related_model_obj->get_model(), $this->dont_traverse_models); |
|
| 106 | - $this->nodes[ $related_model_obj->ID() ] = $entity_node; |
|
| 107 | - $new_item_nodes[ $related_model_obj->ID() ] = $entity_node; |
|
| 108 | - } |
|
| 109 | - $num_identified += count($new_item_nodes); |
|
| 110 | - if ($num_identified < $model_objects_to_identify) { |
|
| 111 | - // And lastly do the work. |
|
| 112 | - $num_identified += $this->visitAlreadyDiscoveredNodes( |
|
| 113 | - $new_item_nodes, |
|
| 114 | - $model_objects_to_identify - $num_identified |
|
| 115 | - ); |
|
| 116 | - } |
|
| 117 | - } |
|
| 103 | + // Add entity nodes for each of the model objects we fetched. |
|
| 104 | + foreach ($related_model_objs as $related_model_obj) { |
|
| 105 | + $entity_node = new ModelObjNode($related_model_obj->ID(), $related_model_obj->get_model(), $this->dont_traverse_models); |
|
| 106 | + $this->nodes[ $related_model_obj->ID() ] = $entity_node; |
|
| 107 | + $new_item_nodes[ $related_model_obj->ID() ] = $entity_node; |
|
| 108 | + } |
|
| 109 | + $num_identified += count($new_item_nodes); |
|
| 110 | + if ($num_identified < $model_objects_to_identify) { |
|
| 111 | + // And lastly do the work. |
|
| 112 | + $num_identified += $this->visitAlreadyDiscoveredNodes( |
|
| 113 | + $new_item_nodes, |
|
| 114 | + $model_objects_to_identify - $num_identified |
|
| 115 | + ); |
|
| 116 | + } |
|
| 117 | + } |
|
| 118 | 118 | |
| 119 | - if (count($this->nodes) >= $this->count && $this->allChildrenComplete()) { |
|
| 120 | - $this->complete = true; |
|
| 121 | - } |
|
| 122 | - return $num_identified; |
|
| 123 | - } |
|
| 119 | + if (count($this->nodes) >= $this->count && $this->allChildrenComplete()) { |
|
| 120 | + $this->complete = true; |
|
| 121 | + } |
|
| 122 | + return $num_identified; |
|
| 123 | + } |
|
| 124 | 124 | |
| 125 | - /** |
|
| 126 | - * Checks if all the identified child nodes are complete or not. |
|
| 127 | - * @since 4.10.12.p |
|
| 128 | - * @return bool |
|
| 129 | - */ |
|
| 130 | - protected function allChildrenComplete() |
|
| 131 | - { |
|
| 132 | - foreach ($this->nodes as $model_obj_node) { |
|
| 133 | - if (! $model_obj_node->isComplete()) { |
|
| 134 | - return false; |
|
| 135 | - } |
|
| 136 | - } |
|
| 137 | - return true; |
|
| 138 | - } |
|
| 125 | + /** |
|
| 126 | + * Checks if all the identified child nodes are complete or not. |
|
| 127 | + * @since 4.10.12.p |
|
| 128 | + * @return bool |
|
| 129 | + */ |
|
| 130 | + protected function allChildrenComplete() |
|
| 131 | + { |
|
| 132 | + foreach ($this->nodes as $model_obj_node) { |
|
| 133 | + if (! $model_obj_node->isComplete()) { |
|
| 134 | + return false; |
|
| 135 | + } |
|
| 136 | + } |
|
| 137 | + return true; |
|
| 138 | + } |
|
| 139 | 139 | |
| 140 | - /** |
|
| 141 | - * Visits the provided nodes and keeps track of how much work was done, making sure to not go over budget. |
|
| 142 | - * @since 4.10.12.p |
|
| 143 | - * @param ModelObjNode[] $model_obj_nodes |
|
| 144 | - * @param $work_budget |
|
| 145 | - * @return int |
|
| 146 | - */ |
|
| 147 | - protected function visitAlreadyDiscoveredNodes($model_obj_nodes, $work_budget) |
|
| 148 | - { |
|
| 149 | - $work_done = 0; |
|
| 150 | - if (! $model_obj_nodes) { |
|
| 151 | - return 0; |
|
| 152 | - } |
|
| 153 | - foreach ($model_obj_nodes as $model_obj_node) { |
|
| 154 | - if ($work_done >= $work_budget) { |
|
| 155 | - break; |
|
| 156 | - } |
|
| 157 | - $work_done += $model_obj_node->visit($work_budget - $work_done); |
|
| 158 | - } |
|
| 159 | - return $work_done; |
|
| 160 | - } |
|
| 140 | + /** |
|
| 141 | + * Visits the provided nodes and keeps track of how much work was done, making sure to not go over budget. |
|
| 142 | + * @since 4.10.12.p |
|
| 143 | + * @param ModelObjNode[] $model_obj_nodes |
|
| 144 | + * @param $work_budget |
|
| 145 | + * @return int |
|
| 146 | + */ |
|
| 147 | + protected function visitAlreadyDiscoveredNodes($model_obj_nodes, $work_budget) |
|
| 148 | + { |
|
| 149 | + $work_done = 0; |
|
| 150 | + if (! $model_obj_nodes) { |
|
| 151 | + return 0; |
|
| 152 | + } |
|
| 153 | + foreach ($model_obj_nodes as $model_obj_node) { |
|
| 154 | + if ($work_done >= $work_budget) { |
|
| 155 | + break; |
|
| 156 | + } |
|
| 157 | + $work_done += $model_obj_node->visit($work_budget - $work_done); |
|
| 158 | + } |
|
| 159 | + return $work_done; |
|
| 160 | + } |
|
| 161 | 161 | |
| 162 | - /** |
|
| 163 | - * Whether this item has already been initialized |
|
| 164 | - */ |
|
| 165 | - protected function isDiscovered() |
|
| 166 | - { |
|
| 167 | - return $this->count !== null; |
|
| 168 | - } |
|
| 162 | + /** |
|
| 163 | + * Whether this item has already been initialized |
|
| 164 | + */ |
|
| 165 | + protected function isDiscovered() |
|
| 166 | + { |
|
| 167 | + return $this->count !== null; |
|
| 168 | + } |
|
| 169 | 169 | |
| 170 | - /** |
|
| 171 | - * @since 4.10.12.p |
|
| 172 | - * @return boolean |
|
| 173 | - */ |
|
| 174 | - public function isComplete() |
|
| 175 | - { |
|
| 176 | - if ($this->complete === null) { |
|
| 177 | - if (count($this->nodes) === $this->count) { |
|
| 178 | - $this->complete = true; |
|
| 179 | - } else { |
|
| 180 | - $this->complete = false; |
|
| 181 | - } |
|
| 182 | - } |
|
| 183 | - return $this->complete; |
|
| 184 | - } |
|
| 170 | + /** |
|
| 171 | + * @since 4.10.12.p |
|
| 172 | + * @return boolean |
|
| 173 | + */ |
|
| 174 | + public function isComplete() |
|
| 175 | + { |
|
| 176 | + if ($this->complete === null) { |
|
| 177 | + if (count($this->nodes) === $this->count) { |
|
| 178 | + $this->complete = true; |
|
| 179 | + } else { |
|
| 180 | + $this->complete = false; |
|
| 181 | + } |
|
| 182 | + } |
|
| 183 | + return $this->complete; |
|
| 184 | + } |
|
| 185 | 185 | |
| 186 | - /** |
|
| 187 | - * Discovers how many related model objects exist. |
|
| 188 | - * @since 4.10.12.p |
|
| 189 | - * @return mixed|void |
|
| 190 | - * @throws EE_Error |
|
| 191 | - * @throws InvalidArgumentException |
|
| 192 | - * @throws InvalidDataTypeException |
|
| 193 | - * @throws InvalidInterfaceException |
|
| 194 | - * @throws ReflectionException |
|
| 195 | - */ |
|
| 196 | - protected function discover() |
|
| 197 | - { |
|
| 198 | - $this->count = $this->related_model->count([$this->whereQueryParams()]); |
|
| 199 | - } |
|
| 186 | + /** |
|
| 187 | + * Discovers how many related model objects exist. |
|
| 188 | + * @since 4.10.12.p |
|
| 189 | + * @return mixed|void |
|
| 190 | + * @throws EE_Error |
|
| 191 | + * @throws InvalidArgumentException |
|
| 192 | + * @throws InvalidDataTypeException |
|
| 193 | + * @throws InvalidInterfaceException |
|
| 194 | + * @throws ReflectionException |
|
| 195 | + */ |
|
| 196 | + protected function discover() |
|
| 197 | + { |
|
| 198 | + $this->count = $this->related_model->count([$this->whereQueryParams()]); |
|
| 199 | + } |
|
| 200 | 200 | |
| 201 | - /** |
|
| 202 | - * @since 4.10.12.p |
|
| 203 | - * @return array |
|
| 204 | - * @throws EE_Error |
|
| 205 | - * @throws InvalidDataTypeException |
|
| 206 | - * @throws InvalidInterfaceException |
|
| 207 | - * @throws InvalidArgumentException |
|
| 208 | - * @throws ReflectionException |
|
| 209 | - */ |
|
| 210 | - protected function whereQueryParams() |
|
| 211 | - { |
|
| 212 | - $where_params = [ |
|
| 213 | - $this->related_model->get_foreign_key_to( |
|
| 214 | - $this->main_model->get_this_model_name() |
|
| 215 | - )->get_name() => $this->id |
|
| 216 | - ]; |
|
| 217 | - try { |
|
| 218 | - $relation_settings = $this->main_model->related_settings_for($this->related_model->get_this_model_name()); |
|
| 219 | - } catch (EE_Error $e) { |
|
| 220 | - // This will happen for has-and-belongs-to-many relations, when this node's related model is that join table |
|
| 221 | - // which hasn't been explicitly declared in the main model object's model's relations. |
|
| 222 | - $relation_settings = null; |
|
| 223 | - } |
|
| 224 | - if ($relation_settings instanceof EE_Has_Many_Any_Relation) { |
|
| 225 | - $where_params[ $this->related_model->get_field_containing_related_model_name()->get_name() ] = $this->main_model->get_this_model_name(); |
|
| 226 | - } |
|
| 227 | - return $where_params; |
|
| 228 | - } |
|
| 229 | - /** |
|
| 230 | - * @since 4.10.12.p |
|
| 231 | - * @return array |
|
| 232 | - */ |
|
| 233 | - public function toArray() |
|
| 234 | - { |
|
| 235 | - $tree = [ |
|
| 236 | - 'count' => $this->count, |
|
| 237 | - 'complete' => $this->isComplete(), |
|
| 238 | - 'objs' => [] |
|
| 239 | - ]; |
|
| 240 | - foreach ($this->nodes as $id => $model_obj_node) { |
|
| 241 | - $tree['objs'][ $id ] = $model_obj_node->toArray(); |
|
| 242 | - } |
|
| 243 | - return $tree; |
|
| 244 | - } |
|
| 201 | + /** |
|
| 202 | + * @since 4.10.12.p |
|
| 203 | + * @return array |
|
| 204 | + * @throws EE_Error |
|
| 205 | + * @throws InvalidDataTypeException |
|
| 206 | + * @throws InvalidInterfaceException |
|
| 207 | + * @throws InvalidArgumentException |
|
| 208 | + * @throws ReflectionException |
|
| 209 | + */ |
|
| 210 | + protected function whereQueryParams() |
|
| 211 | + { |
|
| 212 | + $where_params = [ |
|
| 213 | + $this->related_model->get_foreign_key_to( |
|
| 214 | + $this->main_model->get_this_model_name() |
|
| 215 | + )->get_name() => $this->id |
|
| 216 | + ]; |
|
| 217 | + try { |
|
| 218 | + $relation_settings = $this->main_model->related_settings_for($this->related_model->get_this_model_name()); |
|
| 219 | + } catch (EE_Error $e) { |
|
| 220 | + // This will happen for has-and-belongs-to-many relations, when this node's related model is that join table |
|
| 221 | + // which hasn't been explicitly declared in the main model object's model's relations. |
|
| 222 | + $relation_settings = null; |
|
| 223 | + } |
|
| 224 | + if ($relation_settings instanceof EE_Has_Many_Any_Relation) { |
|
| 225 | + $where_params[ $this->related_model->get_field_containing_related_model_name()->get_name() ] = $this->main_model->get_this_model_name(); |
|
| 226 | + } |
|
| 227 | + return $where_params; |
|
| 228 | + } |
|
| 229 | + /** |
|
| 230 | + * @since 4.10.12.p |
|
| 231 | + * @return array |
|
| 232 | + */ |
|
| 233 | + public function toArray() |
|
| 234 | + { |
|
| 235 | + $tree = [ |
|
| 236 | + 'count' => $this->count, |
|
| 237 | + 'complete' => $this->isComplete(), |
|
| 238 | + 'objs' => [] |
|
| 239 | + ]; |
|
| 240 | + foreach ($this->nodes as $id => $model_obj_node) { |
|
| 241 | + $tree['objs'][ $id ] = $model_obj_node->toArray(); |
|
| 242 | + } |
|
| 243 | + return $tree; |
|
| 244 | + } |
|
| 245 | 245 | |
| 246 | - /** |
|
| 247 | - * Gets the IDs of all the model objects to delete; indexed first by model object name. |
|
| 248 | - * @since 4.10.12.p |
|
| 249 | - * @return array |
|
| 250 | - */ |
|
| 251 | - public function getIds() |
|
| 252 | - { |
|
| 253 | - if (empty($this->nodes)) { |
|
| 254 | - return []; |
|
| 255 | - } |
|
| 256 | - $ids = [ |
|
| 257 | - $this->related_model->get_this_model_name() => array_combine( |
|
| 258 | - array_keys($this->nodes), |
|
| 259 | - array_keys($this->nodes) |
|
| 260 | - ) |
|
| 261 | - ]; |
|
| 262 | - foreach ($this->nodes as $model_obj_node) { |
|
| 263 | - $ids = array_replace_recursive($ids, $model_obj_node->getIds()); |
|
| 264 | - } |
|
| 265 | - return $ids; |
|
| 266 | - } |
|
| 246 | + /** |
|
| 247 | + * Gets the IDs of all the model objects to delete; indexed first by model object name. |
|
| 248 | + * @since 4.10.12.p |
|
| 249 | + * @return array |
|
| 250 | + */ |
|
| 251 | + public function getIds() |
|
| 252 | + { |
|
| 253 | + if (empty($this->nodes)) { |
|
| 254 | + return []; |
|
| 255 | + } |
|
| 256 | + $ids = [ |
|
| 257 | + $this->related_model->get_this_model_name() => array_combine( |
|
| 258 | + array_keys($this->nodes), |
|
| 259 | + array_keys($this->nodes) |
|
| 260 | + ) |
|
| 261 | + ]; |
|
| 262 | + foreach ($this->nodes as $model_obj_node) { |
|
| 263 | + $ids = array_replace_recursive($ids, $model_obj_node->getIds()); |
|
| 264 | + } |
|
| 265 | + return $ids; |
|
| 266 | + } |
|
| 267 | 267 | |
| 268 | - /** |
|
| 269 | - * Returns the number of sub-nodes found (ie, related model objects across this relation.) |
|
| 270 | - * @since 4.10.12.p |
|
| 271 | - * @return int |
|
| 272 | - */ |
|
| 273 | - public function countSubNodes() |
|
| 274 | - { |
|
| 275 | - return count($this->nodes); |
|
| 276 | - } |
|
| 268 | + /** |
|
| 269 | + * Returns the number of sub-nodes found (ie, related model objects across this relation.) |
|
| 270 | + * @since 4.10.12.p |
|
| 271 | + * @return int |
|
| 272 | + */ |
|
| 273 | + public function countSubNodes() |
|
| 274 | + { |
|
| 275 | + return count($this->nodes); |
|
| 276 | + } |
|
| 277 | 277 | |
| 278 | - /** |
|
| 279 | - * Don't serialize the models. Just record their names on some dynamic properties. |
|
| 280 | - * @since 4.10.12.p |
|
| 281 | - */ |
|
| 282 | - public function __sleep() |
|
| 283 | - { |
|
| 284 | - $this->m = $this->main_model->get_this_model_name(); |
|
| 285 | - $this->rm = $this->related_model->get_this_model_name(); |
|
| 286 | - return array_merge( |
|
| 287 | - [ |
|
| 288 | - 'm', |
|
| 289 | - 'rm', |
|
| 290 | - 'id', |
|
| 291 | - 'count', |
|
| 292 | - 'nodes', |
|
| 293 | - ], |
|
| 294 | - parent::__sleep() |
|
| 295 | - ); |
|
| 296 | - } |
|
| 278 | + /** |
|
| 279 | + * Don't serialize the models. Just record their names on some dynamic properties. |
|
| 280 | + * @since 4.10.12.p |
|
| 281 | + */ |
|
| 282 | + public function __sleep() |
|
| 283 | + { |
|
| 284 | + $this->m = $this->main_model->get_this_model_name(); |
|
| 285 | + $this->rm = $this->related_model->get_this_model_name(); |
|
| 286 | + return array_merge( |
|
| 287 | + [ |
|
| 288 | + 'm', |
|
| 289 | + 'rm', |
|
| 290 | + 'id', |
|
| 291 | + 'count', |
|
| 292 | + 'nodes', |
|
| 293 | + ], |
|
| 294 | + parent::__sleep() |
|
| 295 | + ); |
|
| 296 | + } |
|
| 297 | 297 | |
| 298 | - /** |
|
| 299 | - * Use the dynamic properties to instantiate the models we use. |
|
| 300 | - * @since 4.10.12.p |
|
| 301 | - * @throws EE_Error |
|
| 302 | - * @throws InvalidArgumentException |
|
| 303 | - * @throws InvalidDataTypeException |
|
| 304 | - * @throws InvalidInterfaceException |
|
| 305 | - * @throws ReflectionException |
|
| 306 | - */ |
|
| 307 | - public function __wakeup() |
|
| 308 | - { |
|
| 309 | - $this->main_model = EE_Registry::instance()->load_model($this->m); |
|
| 310 | - $this->related_model = EE_Registry::instance()->load_model($this->rm); |
|
| 311 | - parent::__wakeup(); |
|
| 312 | - } |
|
| 298 | + /** |
|
| 299 | + * Use the dynamic properties to instantiate the models we use. |
|
| 300 | + * @since 4.10.12.p |
|
| 301 | + * @throws EE_Error |
|
| 302 | + * @throws InvalidArgumentException |
|
| 303 | + * @throws InvalidDataTypeException |
|
| 304 | + * @throws InvalidInterfaceException |
|
| 305 | + * @throws ReflectionException |
|
| 306 | + */ |
|
| 307 | + public function __wakeup() |
|
| 308 | + { |
|
| 309 | + $this->main_model = EE_Registry::instance()->load_model($this->m); |
|
| 310 | + $this->related_model = EE_Registry::instance()->load_model($this->rm); |
|
| 311 | + parent::__wakeup(); |
|
| 312 | + } |
|
| 313 | 313 | } |
| 314 | 314 | // End of file RelationNode.php |
| 315 | 315 | // Location: EventEspresso\core\services\orm\tree_traversal/RelationNode.php |
@@ -22,55 +22,55 @@ |
||
| 22 | 22 | */ |
| 23 | 23 | class ConfirmEventDeletionForm extends \EE_Form_Section_Proper |
| 24 | 24 | { |
| 25 | - /** |
|
| 26 | - * @var EE_Event[] |
|
| 27 | - */ |
|
| 28 | - protected $events; |
|
| 29 | - public function __construct($event_ids, $options_array = array()) |
|
| 30 | - { |
|
| 31 | - if (! isset($options_array['subsections'])) { |
|
| 32 | - $options_array['subsections'] = []; |
|
| 33 | - } |
|
| 34 | - if (! isset($options_array['subsections']['events'])) { |
|
| 35 | - $events_subsection = new \EE_Form_Section_Proper(); |
|
| 36 | - $options_array['subsections']['events'] = $events_subsection; |
|
| 37 | - } |
|
| 38 | - $events = EEM_Event::instance()->get_all_deleted_and_undeleted( |
|
| 39 | - [ |
|
| 40 | - [ |
|
| 41 | - 'EVT_ID' => ['IN',$event_ids] |
|
| 42 | - ] |
|
| 43 | - ] |
|
| 44 | - ); |
|
| 45 | - if (! is_array($events)) { |
|
| 46 | - throw new UnexpectedEntityException($event_ids, 'array'); |
|
| 47 | - } |
|
| 48 | - $this->events = $events; |
|
| 49 | - $events_inputs = [ |
|
| 50 | - ]; |
|
| 51 | - foreach ($events as $event) { |
|
| 52 | - $events_inputs[ $event->ID() ] = new EE_Checkbox_Multi_Input( |
|
| 53 | - [ |
|
| 54 | - 'yes' => $event->name(), |
|
| 55 | - ], |
|
| 56 | - [ |
|
| 57 | - 'html_label_text' => esc_html__('Please confirm you wish to delete:', 'event_espresso'), |
|
| 58 | - 'required' => true |
|
| 59 | - ] |
|
| 60 | - ); |
|
| 61 | - } |
|
| 62 | - $events_subsection->add_subsections($events_inputs); |
|
| 63 | - $options_array['subsections']['backup'] = new EE_Checkbox_Multi_Input( |
|
| 64 | - [ |
|
| 65 | - 'yes' => esc_html__('I have backed up my database.', 'event_espresso') |
|
| 66 | - ], |
|
| 67 | - [ |
|
| 68 | - 'html_label_text' => esc_html__('Deleting this data cannot be undone. Please confirm you have a usable database backup.', 'event_espresso'), |
|
| 69 | - 'required' => true |
|
| 70 | - ] |
|
| 71 | - ); |
|
| 72 | - parent::__construct($options_array); |
|
| 73 | - } |
|
| 25 | + /** |
|
| 26 | + * @var EE_Event[] |
|
| 27 | + */ |
|
| 28 | + protected $events; |
|
| 29 | + public function __construct($event_ids, $options_array = array()) |
|
| 30 | + { |
|
| 31 | + if (! isset($options_array['subsections'])) { |
|
| 32 | + $options_array['subsections'] = []; |
|
| 33 | + } |
|
| 34 | + if (! isset($options_array['subsections']['events'])) { |
|
| 35 | + $events_subsection = new \EE_Form_Section_Proper(); |
|
| 36 | + $options_array['subsections']['events'] = $events_subsection; |
|
| 37 | + } |
|
| 38 | + $events = EEM_Event::instance()->get_all_deleted_and_undeleted( |
|
| 39 | + [ |
|
| 40 | + [ |
|
| 41 | + 'EVT_ID' => ['IN',$event_ids] |
|
| 42 | + ] |
|
| 43 | + ] |
|
| 44 | + ); |
|
| 45 | + if (! is_array($events)) { |
|
| 46 | + throw new UnexpectedEntityException($event_ids, 'array'); |
|
| 47 | + } |
|
| 48 | + $this->events = $events; |
|
| 49 | + $events_inputs = [ |
|
| 50 | + ]; |
|
| 51 | + foreach ($events as $event) { |
|
| 52 | + $events_inputs[ $event->ID() ] = new EE_Checkbox_Multi_Input( |
|
| 53 | + [ |
|
| 54 | + 'yes' => $event->name(), |
|
| 55 | + ], |
|
| 56 | + [ |
|
| 57 | + 'html_label_text' => esc_html__('Please confirm you wish to delete:', 'event_espresso'), |
|
| 58 | + 'required' => true |
|
| 59 | + ] |
|
| 60 | + ); |
|
| 61 | + } |
|
| 62 | + $events_subsection->add_subsections($events_inputs); |
|
| 63 | + $options_array['subsections']['backup'] = new EE_Checkbox_Multi_Input( |
|
| 64 | + [ |
|
| 65 | + 'yes' => esc_html__('I have backed up my database.', 'event_espresso') |
|
| 66 | + ], |
|
| 67 | + [ |
|
| 68 | + 'html_label_text' => esc_html__('Deleting this data cannot be undone. Please confirm you have a usable database backup.', 'event_espresso'), |
|
| 69 | + 'required' => true |
|
| 70 | + ] |
|
| 71 | + ); |
|
| 72 | + parent::__construct($options_array); |
|
| 73 | + } |
|
| 74 | 74 | } |
| 75 | 75 | // End of file ConfirmEventDeletionForm.php |
| 76 | 76 | // Location: EventEspresso\admin_pages\events\form_sections/ConfirmEventDeletionForm.php |
@@ -28,28 +28,28 @@ |
||
| 28 | 28 | protected $events; |
| 29 | 29 | public function __construct($event_ids, $options_array = array()) |
| 30 | 30 | { |
| 31 | - if (! isset($options_array['subsections'])) { |
|
| 31 | + if ( ! isset($options_array['subsections'])) { |
|
| 32 | 32 | $options_array['subsections'] = []; |
| 33 | 33 | } |
| 34 | - if (! isset($options_array['subsections']['events'])) { |
|
| 34 | + if ( ! isset($options_array['subsections']['events'])) { |
|
| 35 | 35 | $events_subsection = new \EE_Form_Section_Proper(); |
| 36 | 36 | $options_array['subsections']['events'] = $events_subsection; |
| 37 | 37 | } |
| 38 | 38 | $events = EEM_Event::instance()->get_all_deleted_and_undeleted( |
| 39 | 39 | [ |
| 40 | 40 | [ |
| 41 | - 'EVT_ID' => ['IN',$event_ids] |
|
| 41 | + 'EVT_ID' => ['IN', $event_ids] |
|
| 42 | 42 | ] |
| 43 | 43 | ] |
| 44 | 44 | ); |
| 45 | - if (! is_array($events)) { |
|
| 45 | + if ( ! is_array($events)) { |
|
| 46 | 46 | throw new UnexpectedEntityException($event_ids, 'array'); |
| 47 | 47 | } |
| 48 | 48 | $this->events = $events; |
| 49 | 49 | $events_inputs = [ |
| 50 | 50 | ]; |
| 51 | 51 | foreach ($events as $event) { |
| 52 | - $events_inputs[ $event->ID() ] = new EE_Checkbox_Multi_Input( |
|
| 52 | + $events_inputs[$event->ID()] = new EE_Checkbox_Multi_Input( |
|
| 53 | 53 | [ |
| 54 | 54 | 'yes' => $event->name(), |
| 55 | 55 | ], |