@@ -31,35 +31,35 @@ discard block |
||
31 | 31 | <tbody> |
32 | 32 | <tr> |
33 | 33 | <td> |
34 | - <h2><?php printf( esc_html__( 'Hello, %s:', 'event_espresso' ), '[PRIMARY_REGISTRANT_FNAME] [PRIMARY_REGISTRANT_LNAME]' ); ?></h2> |
|
35 | - <p class="lead"><?php printf( esc_html__( 'Your payment was %1$sDECLINED%2$s for the following transaction and ticket purchases:', 'event_espresso' ), '<strong>', '</strong>') ?></p> |
|
36 | - <h3><?php esc_html_e( 'Payment Details:', 'event_espresso' ); ?></h3> |
|
34 | + <h2><?php printf(esc_html__('Hello, %s:', 'event_espresso'), '[PRIMARY_REGISTRANT_FNAME] [PRIMARY_REGISTRANT_LNAME]'); ?></h2> |
|
35 | + <p class="lead"><?php printf(esc_html__('Your payment was %1$sDECLINED%2$s for the following transaction and ticket purchases:', 'event_espresso'), '<strong>', '</strong>') ?></p> |
|
36 | + <h3><?php esc_html_e('Payment Details:', 'event_espresso'); ?></h3> |
|
37 | 37 | <ul> |
38 | 38 | <li> |
39 | - <strong><?php esc_html_e( 'Payment Status:', 'event_espresso' ); ?></strong> [PAYMENT_STATUS] |
|
39 | + <strong><?php esc_html_e('Payment Status:', 'event_espresso'); ?></strong> [PAYMENT_STATUS] |
|
40 | 40 | </li> |
41 | 41 | <li> |
42 | - <strong><?php esc_html_e( 'Transaction ID:', 'event_espresso' ); ?></strong> [TXN_ID] |
|
42 | + <strong><?php esc_html_e('Transaction ID:', 'event_espresso'); ?></strong> [TXN_ID] |
|
43 | 43 | </li> |
44 | 44 | <li> |
45 | - <strong><?php esc_html_e( 'Total Cost:', 'event_espresso' ); ?></strong> [TOTAL_COST] |
|
45 | + <strong><?php esc_html_e('Total Cost:', 'event_espresso'); ?></strong> [TOTAL_COST] |
|
46 | 46 | </li> |
47 | 47 | <li> |
48 | - <strong><?php esc_html_e( 'Payment Method:', 'event_espresso' ); ?></strong> [PAYMENT_GATEWAY] |
|
48 | + <strong><?php esc_html_e('Payment Method:', 'event_espresso'); ?></strong> [PAYMENT_GATEWAY] |
|
49 | 49 | </li> |
50 | 50 | <li> |
51 | - <strong><?php esc_html_e( 'Payment Amount:', 'event_espresso' ); ?></strong> [AMOUNT_PAID] |
|
51 | + <strong><?php esc_html_e('Payment Amount:', 'event_espresso'); ?></strong> [AMOUNT_PAID] |
|
52 | 52 | </li> |
53 | 53 | <li> |
54 | - <strong><?php esc_html_e( 'Amount Due:', 'event_espresso' ); ?></strong> [TOTAL_OWING] |
|
54 | + <strong><?php esc_html_e('Amount Due:', 'event_espresso'); ?></strong> [TOTAL_OWING] |
|
55 | 55 | </li> |
56 | 56 | </ul> |
57 | 57 | <p class="callout"> |
58 | - <?php printf( esc_html__( 'Please %sretry your payment%s, or choose an alternate payment method to reserve your space.', 'event_espresso' ), '<a href="[PAYMENT_URL]">', '</a>' ); ?> |
|
58 | + <?php printf(esc_html__('Please %sretry your payment%s, or choose an alternate payment method to reserve your space.', 'event_espresso'), '<a href="[PAYMENT_URL]">', '</a>'); ?> |
|
59 | 59 | </p> |
60 | 60 | [EVENT_LIST] |
61 | 61 | <p class="callout"> |
62 | - <?php printf( esc_html__( 'Please %sretry your payment%s, or choose an alternate payment method to reserve your space.', 'event_espresso' ), '<a href="[PAYMENT_URL]">', '</a>' ); ?> |
|
62 | + <?php printf(esc_html__('Please %sretry your payment%s, or choose an alternate payment method to reserve your space.', 'event_espresso'), '<a href="[PAYMENT_URL]">', '</a>'); ?> |
|
63 | 63 | </p> |
64 | 64 | </td> |
65 | 65 | </tr> |
@@ -84,10 +84,10 @@ discard block |
||
84 | 84 | <tbody> |
85 | 85 | <tr> |
86 | 86 | <td> |
87 | - <h3><?php esc_html_e( 'Connect with Us:', 'event_espresso' ); ?></h3> |
|
88 | - <a class="soc-btn fb" href="[CO_FACEBOOK_URL]"><?php esc_html_e( 'Facebook', 'event_espresso' ); ?></a> |
|
89 | - <a class="soc-btn tw" href="[CO_TWITTER_URL]"><?php esc_html_e( 'Twitter', 'event_espresso' ); ?></a> |
|
90 | - <a class="soc-btn gp" href="[CO_GOOGLE_URL]"><?php esc_html_e( 'Google+', 'event_espresso' ); ?></a> |
|
87 | + <h3><?php esc_html_e('Connect with Us:', 'event_espresso'); ?></h3> |
|
88 | + <a class="soc-btn fb" href="[CO_FACEBOOK_URL]"><?php esc_html_e('Facebook', 'event_espresso'); ?></a> |
|
89 | + <a class="soc-btn tw" href="[CO_TWITTER_URL]"><?php esc_html_e('Twitter', 'event_espresso'); ?></a> |
|
90 | + <a class="soc-btn gp" href="[CO_GOOGLE_URL]"><?php esc_html_e('Google+', 'event_espresso'); ?></a> |
|
91 | 91 | </td> |
92 | 92 | </tr> |
93 | 93 | </tbody> |
@@ -97,9 +97,9 @@ discard block |
||
97 | 97 | <tbody> |
98 | 98 | <tr> |
99 | 99 | <td> |
100 | - <h3><?php esc_html_e( 'Contact Info:', 'event_espresso' ); ?></h3> |
|
101 | - <?php esc_html_e( 'Phone:', 'event_espresso' ); ?> <strong>[CO_PHONE]</strong> |
|
102 | - <?php esc_html_e( 'Email:', 'event_espresso' ); ?> <strong><a href="mailto:[CO_EMAIL]" target="_blank">[CO_EMAIL]</a></strong> |
|
100 | + <h3><?php esc_html_e('Contact Info:', 'event_espresso'); ?></h3> |
|
101 | + <?php esc_html_e('Phone:', 'event_espresso'); ?> <strong>[CO_PHONE]</strong> |
|
102 | + <?php esc_html_e('Email:', 'event_espresso'); ?> <strong><a href="mailto:[CO_EMAIL]" target="_blank">[CO_EMAIL]</a></strong> |
|
103 | 103 | </td> |
104 | 104 | </tr> |
105 | 105 | </tbody> |
@@ -1,6 +1,5 @@ |
||
1 | 1 | <?php |
2 | 2 | use EventEspresso\core\interfaces\ResettableInterface; |
3 | - |
|
4 | 3 | use EventEspresso\core\services\database\TableManager; |
5 | 4 | use EventEspresso\core\services\database\TableAnalysis; |
6 | 5 |
@@ -127,9 +127,9 @@ discard block |
||
127 | 127 | protected $_table_analysis; |
128 | 128 | |
129 | 129 | /** |
130 | - * @var EE_Data_Migration_Manager $_instance |
|
130 | + * @var EE_Data_Migration_Manager $_instance |
|
131 | 131 | * @access private |
132 | - */ |
|
132 | + */ |
|
133 | 133 | private static $_instance = NULL; |
134 | 134 | |
135 | 135 | |
@@ -720,18 +720,18 @@ discard block |
||
720 | 720 | |
721 | 721 | |
722 | 722 | |
723 | - /** |
|
724 | - * Gets all the data migration scripts available in the core folder and folders |
|
725 | - * in addons. Has the side effect of adding them for autoloading |
|
726 | - * |
|
727 | - * @return array keys are expected classnames, values are their filepaths |
|
728 | - * @throws \EE_Error |
|
729 | - */ |
|
723 | + /** |
|
724 | + * Gets all the data migration scripts available in the core folder and folders |
|
725 | + * in addons. Has the side effect of adding them for autoloading |
|
726 | + * |
|
727 | + * @return array keys are expected classnames, values are their filepaths |
|
728 | + * @throws \EE_Error |
|
729 | + */ |
|
730 | 730 | public function get_all_data_migration_scripts_available(){ |
731 | 731 | if( ! $this->_data_migration_class_to_filepath_map){ |
732 | 732 | $this->_data_migration_class_to_filepath_map = array(); |
733 | 733 | foreach($this->get_data_migration_script_folders() as $folder_path){ |
734 | - $folder_path = EEH_File::end_with_directory_separator($folder_path); |
|
734 | + $folder_path = EEH_File::end_with_directory_separator($folder_path); |
|
735 | 735 | $files = glob( $folder_path. '*.dms.php' ); |
736 | 736 | |
737 | 737 | if ( empty( $files ) ) { |
@@ -748,15 +748,15 @@ discard block |
||
748 | 748 | if( $slug !== 'Core' ){ |
749 | 749 | if( ! EE_Registry::instance()->get_addon_by_name( $slug ) ) { |
750 | 750 | EE_Error::doing_it_wrong( |
751 | - __FUNCTION__, |
|
752 | - sprintf( |
|
753 | - __( 'The data migration script "%s" migrates the "%s" data, but there is no EE addon with that name. There is only: %s. ', 'event_espresso' ), |
|
754 | - $classname, |
|
755 | - $slug, |
|
756 | - implode(', ', array_keys( EE_Registry::instance()->get_addons_by_name() ) ) |
|
757 | - ), |
|
758 | - '4.3.0.alpha.019' |
|
759 | - ); |
|
751 | + __FUNCTION__, |
|
752 | + sprintf( |
|
753 | + __( 'The data migration script "%s" migrates the "%s" data, but there is no EE addon with that name. There is only: %s. ', 'event_espresso' ), |
|
754 | + $classname, |
|
755 | + $slug, |
|
756 | + implode(', ', array_keys( EE_Registry::instance()->get_addons_by_name() ) ) |
|
757 | + ), |
|
758 | + '4.3.0.alpha.019' |
|
759 | + ); |
|
760 | 760 | } |
761 | 761 | } |
762 | 762 | $this->_data_migration_class_to_filepath_map[$classname] = $file; |
@@ -939,12 +939,12 @@ discard block |
||
939 | 939 | } |
940 | 940 | |
941 | 941 | /** |
942 | - * Resets the borked data migration scripts so they're no longer borked |
|
943 | - * so we can again attempt to migrate |
|
944 | - * |
|
945 | - * @return bool |
|
946 | - * @throws \EE_Error |
|
947 | - */ |
|
942 | + * Resets the borked data migration scripts so they're no longer borked |
|
943 | + * so we can again attempt to migrate |
|
944 | + * |
|
945 | + * @return bool |
|
946 | + * @throws \EE_Error |
|
947 | + */ |
|
948 | 948 | public function reattempt(){ |
949 | 949 | //find if the last-ran script was borked |
950 | 950 | //set it as being non-borked (we shouldn't ever get DMSs that we don't recognize) |
@@ -208,7 +208,7 @@ discard block |
||
208 | 208 | //it's 4.2-style.eg Core.4.1.0 |
209 | 209 | $plugin_slug = $parts[0];//eg Core |
210 | 210 | $version_string = $parts[1].".".$parts[2].".".$parts[3]; //eg 4.1.0 |
211 | - }else{ |
|
211 | + } else{ |
|
212 | 212 | //it's 4.1-style: eg 4.1.0 |
213 | 213 | $plugin_slug = 'Core'; |
214 | 214 | $version_string = $plugin_slug_and_version_string;//eg 4.1.0 |
@@ -231,12 +231,12 @@ discard block |
||
231 | 231 | if($class instanceof EE_Data_Migration_Script_Base){ |
232 | 232 | $class->instantiate_from_array_of_properties($data_migration_data); |
233 | 233 | return $class; |
234 | - }else{ |
|
234 | + } else{ |
|
235 | 235 | //huh, so its an object but not a data migration script?? that shouldn't happen |
236 | 236 | //just leave it as an array (which will probably just get ignored) |
237 | 237 | throw new EE_Error(sprintf(__("Trying to retrieve DMS class from wp option. No DMS by the name '%s' exists", 'event_espresso'),$data_migration_data['class'])); |
238 | 238 | } |
239 | - }else{ |
|
239 | + } else{ |
|
240 | 240 | //so the data doesn't specify a class. So it must either be a legacy array of info or some array (which we'll probably just ignore), or a class that no longer exists |
241 | 241 | throw new EE_Error(sprintf(__("The wp option with key '%s' does not represent a DMS", 'event_espresso'),$dms_option_name)); |
242 | 242 | } |
@@ -266,7 +266,7 @@ discard block |
||
266 | 266 | //sometimes we also like to know which was the last incomplete script (or if there are any at all) |
267 | 267 | $this->_last_ran_incomplete_script = $class; |
268 | 268 | } |
269 | - }catch(EE_Error $e){ |
|
269 | + } catch(EE_Error $e){ |
|
270 | 270 | //ok so its not a DMS. We'll just keep it, although other code will need to expect non-DMSs |
271 | 271 | $data_migrations_ran[$plugin_slug][$version_string] = maybe_unserialize($data_migration_option['option_value']); |
272 | 272 | } |
@@ -367,7 +367,7 @@ discard block |
||
367 | 367 | //so we want the data migrations to happen. SO, we're going to say the DB is at that state |
368 | 368 | // echo "4.1.0 is greater than $previous_version_installed! update the option"; |
369 | 369 | $db_state = array('Core'=>$previous_version_installed); |
370 | - }else{ |
|
370 | + } else{ |
|
371 | 371 | // echo "4.1.0 is SMALLER than $previous_version_installed"; |
372 | 372 | $db_state = array('Core'=>EVENT_ESPRESSO_VERSION); |
373 | 373 | } |
@@ -435,10 +435,10 @@ discard block |
||
435 | 435 | $migrates_to_version = $script->migrates_to_version(); |
436 | 436 | $next_database_state_to_consider[ $migrates_to_version[ 'slug' ] ] = $migrates_to_version[ 'version' ]; |
437 | 437 | unset($script_class_and_filepaths_available[$classname]); |
438 | - }else{ |
|
438 | + } else{ |
|
439 | 439 | //it must have a status that indicates it has finished, so we don't want to try and run it again |
440 | 440 | } |
441 | - }else{ |
|
441 | + } else{ |
|
442 | 442 | //it exists but it's not a proper data migration script |
443 | 443 | //maybe the script got renamed? or was simply removed from EE? |
444 | 444 | //either way, its certainly not runnable! |
@@ -478,7 +478,7 @@ discard block |
||
478 | 478 | } |
479 | 479 | if($include_completed_scripts){ |
480 | 480 | return $this->_last_ran_script; |
481 | - }else{ |
|
481 | + } else{ |
|
482 | 482 | return $this->_last_ran_incomplete_script; |
483 | 483 | } |
484 | 484 | } |
@@ -539,7 +539,7 @@ discard block |
||
539 | 539 | $this->_data_migrations_ran[$plugin_slug][$version] = $currently_executing_script; |
540 | 540 | } |
541 | 541 | $current_script_name = get_class($currently_executing_script); |
542 | - }catch(Exception $e){ |
|
542 | + } catch(Exception $e){ |
|
543 | 543 | //an exception occurred while trying to get migration scripts |
544 | 544 | |
545 | 545 | $message = sprintf( __("Error Message: %sStack Trace:%s", "event_espresso"), $e->getMessage() . '<br>', $e->getTraceAsString() ); |
@@ -604,14 +604,14 @@ discard block |
||
604 | 604 | ); |
605 | 605 | break; |
606 | 606 | } |
607 | - }catch(Exception $e){ |
|
607 | + } catch(Exception $e){ |
|
608 | 608 | //ok so some exception was thrown which killed the data migration script |
609 | 609 | //double-check we have a real script |
610 | 610 | if($currently_executing_script instanceof EE_Data_Migration_Script_Base){ |
611 | 611 | $script_name = $currently_executing_script->pretty_name(); |
612 | 612 | $currently_executing_script->set_broken(); |
613 | 613 | $currently_executing_script->add_error($e->getMessage()); |
614 | - }else{ |
|
614 | + } else{ |
|
615 | 615 | $script_name = __("Error getting Migration Script", "event_espresso"); |
616 | 616 | } |
617 | 617 | $response_array = array( |
@@ -654,7 +654,7 @@ discard block |
||
654 | 654 | ob_start(); |
655 | 655 | try{ |
656 | 656 | $response = $this->migration_step(); |
657 | - }catch(Exception $e){ |
|
657 | + } catch(Exception $e){ |
|
658 | 658 | $response = array( |
659 | 659 | 'records_to_migrate'=>0, |
660 | 660 | 'records_migrated'=>0, |
@@ -703,7 +703,7 @@ discard block |
||
703 | 703 | $current_database_state = get_option(self::current_database_state); |
704 | 704 | if( ! isset( $current_database_state[ $slug ] ) ) { |
705 | 705 | return true; |
706 | - }else{ |
|
706 | + } else{ |
|
707 | 707 | //just compare the first 3 parts of version string, eg "4.7.1", not "4.7.1.dev.032" because DBs shouldn't change on nano version changes |
708 | 708 | $version_parts_current_db_state = array_slice( explode('.', $current_database_state[ $slug ] ), 0, 3); |
709 | 709 | $version_parts_of_provided_db_state = array_slice( explode( '.', $version ), 0, 3 ); |
@@ -803,7 +803,7 @@ discard block |
||
803 | 803 | //ok then just add this error to its list of errors |
804 | 804 | $last_ran_migration_script_properties['_errors'][] = $error_message; |
805 | 805 | $last_ran_migration_script_properties['_status'] = self::status_fatal_error; |
806 | - }else{ |
|
806 | + } else{ |
|
807 | 807 | //so we don't even know which script was last running |
808 | 808 | //use the data migration error stub, which is designed specifically for this type of thing |
809 | 809 | $general_migration_error = new EE_DMS_Unknown_1_0_0(); |
@@ -839,7 +839,7 @@ discard block |
||
839 | 839 | if( $old_option_value != $script_array_for_saving){ |
840 | 840 | $successful_updates = update_option($option_name,$script_array_for_saving); |
841 | 841 | } |
842 | - }else{//we don't know what this array-thing is. So just save it as-is |
|
842 | + } else{//we don't know what this array-thing is. So just save it as-is |
|
843 | 843 | // $array_of_migrations[$version_string] = $array_or_migration_obj; |
844 | 844 | if($old_option_value != $array_or_migration_obj){ |
845 | 845 | $successful_updates = update_option($option_name,$array_or_migration_obj); |
@@ -906,7 +906,7 @@ discard block |
||
906 | 906 | } |
907 | 907 | //if it wasn't for core, we must keep searching for one that is! |
908 | 908 | continue; |
909 | - }else{ |
|
909 | + } else{ |
|
910 | 910 | $champion_migrates_to= $this->script_migrates_to_version($most_up_to_date_dms_classname); |
911 | 911 | $contender_migrates_to = $this->script_migrates_to_version($classname); |
912 | 912 | if($contender_migrates_to[ 'slug' ] == $plugin_slug && version_compare($champion_migrates_to[ 'version' ], $contender_migrates_to[ 'version' ], '<')){ |
@@ -933,7 +933,7 @@ discard block |
||
933 | 933 | $migrations_ran = $this->get_data_migrations_ran(); |
934 | 934 | if( isset( $migrations_ran[ $plugin_slug ] ) && isset( $migrations_ran[ $plugin_slug ][ $version ] ) ){ |
935 | 935 | return $migrations_ran[ $plugin_slug ][ $version ]; |
936 | - }else{ |
|
936 | + } else{ |
|
937 | 937 | return NULL; |
938 | 938 | } |
939 | 939 | } |
@@ -955,9 +955,9 @@ discard block |
||
955 | 955 | if( $last_ran_script instanceof EE_DMS_Unknown_1_0_0 ){ |
956 | 956 | //if it was an error DMS, just mark it as complete (if another error occurs it will overwrite it) |
957 | 957 | $last_ran_script->set_completed(); |
958 | - }elseif( $last_ran_script instanceof EE_Data_Migration_Script_Base ) { |
|
958 | + } elseif( $last_ran_script instanceof EE_Data_Migration_Script_Base ) { |
|
959 | 959 | $last_ran_script->reattempt(); |
960 | - }else{ |
|
960 | + } else{ |
|
961 | 961 | throw new EE_Error( sprintf( __( 'Unable to reattempt the last ran migration script because it was not a valid migration script. || It was %s', 'event_espresso' ), print_r( $last_ran_script, true ) ) ); |
962 | 962 | } |
963 | 963 | return $this->_save_migrations_ran(); |
@@ -995,7 +995,7 @@ discard block |
||
995 | 995 | if( ! $most_up_to_date_dms ) { |
996 | 996 | //if there is NO DMS for this plugin, obviously there's no schema to verify anyways |
997 | 997 | $verify_db = false; |
998 | - }else{ |
|
998 | + } else{ |
|
999 | 999 | $most_up_to_date_dms_migrates_to = $this->script_migrates_to_version( $most_up_to_date_dms ); |
1000 | 1000 | $verify_db = $this->database_needs_updating_to( $most_up_to_date_dms_migrates_to ); |
1001 | 1001 | } |
@@ -1004,7 +1004,7 @@ discard block |
||
1004 | 1004 | false, |
1005 | 1005 | $verify_db |
1006 | 1006 | ); |
1007 | - }else{ |
|
1007 | + } else{ |
|
1008 | 1008 | //just loop through the addons to make sure their database is setup |
1009 | 1009 | foreach( EE_Registry::instance()->addons as $addon ) { |
1010 | 1010 | if( $addon->name() == $plugin_slug ) { |
@@ -82,7 +82,7 @@ discard block |
||
82 | 82 | * of this EE installation. Keys should be the name of the version the script upgraded to |
83 | 83 | * @var EE_Data_Migration_Script_Base[] |
84 | 84 | */ |
85 | - private $_data_migrations_ran =null; |
|
85 | + private $_data_migrations_ran = null; |
|
86 | 86 | /** |
87 | 87 | * The last ran script. It's nice to store this somewhere accessible, as its easiest |
88 | 88 | * to know which was the last run by which is the newest wp option; but in most of the code |
@@ -142,7 +142,7 @@ discard block |
||
142 | 142 | */ |
143 | 143 | public static function instance() { |
144 | 144 | // check if class object is instantiated |
145 | - if ( ! self::$_instance instanceof EE_Data_Migration_Manager ) { |
|
145 | + if ( ! self::$_instance instanceof EE_Data_Migration_Manager) { |
|
146 | 146 | self::$_instance = new self(); |
147 | 147 | } |
148 | 148 | return self::$_instance; |
@@ -152,7 +152,7 @@ discard block |
||
152 | 152 | * all new usages of the singleton should be made with Classname::instance()) and returns it |
153 | 153 | * @return EE_Data_Migration_Manager |
154 | 154 | */ |
155 | - public static function reset(){ |
|
155 | + public static function reset() { |
|
156 | 156 | self::$_instance = NULL; |
157 | 157 | return self::instance(); |
158 | 158 | } |
@@ -162,7 +162,7 @@ discard block |
||
162 | 162 | /** |
163 | 163 | * constructor |
164 | 164 | */ |
165 | - private function __construct(){ |
|
165 | + private function __construct() { |
|
166 | 166 | $this->stati_that_indicate_to_continue_migrations = array( |
167 | 167 | self::status_continue, |
168 | 168 | self::status_completed |
@@ -181,13 +181,13 @@ discard block |
||
181 | 181 | ); |
182 | 182 | //make sure we've included the base migration script, because we may need the EE_DMS_Unknown_1_0_0 class |
183 | 183 | //to be defined, because right now it doesn't get autoloaded on its own |
184 | - EE_Registry::instance()->load_core( 'Data_Migration_Class_Base', array(), TRUE ); |
|
185 | - EE_Registry::instance()->load_core( 'Data_Migration_Script_Base', array(), TRUE ); |
|
186 | - EE_Registry::instance()->load_core( 'DMS_Unknown_1_0_0', array(), TRUE ); |
|
187 | - EE_Registry::instance()->load_core( 'Data_Migration_Script_Stage', array(), TRUE ); |
|
188 | - EE_Registry::instance()->load_core( 'Data_Migration_Script_Stage_Table', array(), TRUE ); |
|
189 | - $this->_table_manager = EE_Registry::instance()->create( 'TableManager', array(), true ); |
|
190 | - $this->_table_analysis = EE_Registry::instance()->create( 'TableAnalysis', array(), true ); |
|
184 | + EE_Registry::instance()->load_core('Data_Migration_Class_Base', array(), TRUE); |
|
185 | + EE_Registry::instance()->load_core('Data_Migration_Script_Base', array(), TRUE); |
|
186 | + EE_Registry::instance()->load_core('DMS_Unknown_1_0_0', array(), TRUE); |
|
187 | + EE_Registry::instance()->load_core('Data_Migration_Script_Stage', array(), TRUE); |
|
188 | + EE_Registry::instance()->load_core('Data_Migration_Script_Stage_Table', array(), TRUE); |
|
189 | + $this->_table_manager = EE_Registry::instance()->create('TableManager', array(), true); |
|
190 | + $this->_table_analysis = EE_Registry::instance()->create('TableAnalysis', array(), true); |
|
191 | 191 | } |
192 | 192 | |
193 | 193 | |
@@ -200,21 +200,21 @@ discard block |
||
200 | 200 | * @param string $option_name (see EE_Data_Migration_Manage::_save_migrations_ran() where the option name is set) |
201 | 201 | * @return array where the first item is the plugin slug (eg 'Core','Calendar',etc) and the 2nd is the version of that plugin (eg '4.1.0') |
202 | 202 | */ |
203 | - private function _get_plugin_slug_and_version_string_from_dms_option_name($option_name){ |
|
203 | + private function _get_plugin_slug_and_version_string_from_dms_option_name($option_name) { |
|
204 | 204 | $plugin_slug_and_version_string = str_replace(EE_Data_Migration_Manager::data_migration_script_option_prefix, "", $option_name); |
205 | 205 | //check if $plugin_slug_and_version_string is like '4.1.0' (4.1-style) or 'Core.4.1.0' (4.2-style) |
206 | - $parts = explode(".",$plugin_slug_and_version_string); |
|
206 | + $parts = explode(".", $plugin_slug_and_version_string); |
|
207 | 207 | |
208 | - if(count($parts) == 4){ |
|
208 | + if (count($parts) == 4) { |
|
209 | 209 | //it's 4.2-style.eg Core.4.1.0 |
210 | - $plugin_slug = $parts[0];//eg Core |
|
210 | + $plugin_slug = $parts[0]; //eg Core |
|
211 | 211 | $version_string = $parts[1].".".$parts[2].".".$parts[3]; //eg 4.1.0 |
212 | - }else{ |
|
212 | + } else { |
|
213 | 213 | //it's 4.1-style: eg 4.1.0 |
214 | 214 | $plugin_slug = 'Core'; |
215 | - $version_string = $plugin_slug_and_version_string;//eg 4.1.0 |
|
215 | + $version_string = $plugin_slug_and_version_string; //eg 4.1.0 |
|
216 | 216 | } |
217 | - return array($plugin_slug,$version_string); |
|
217 | + return array($plugin_slug, $version_string); |
|
218 | 218 | } |
219 | 219 | |
220 | 220 | /** |
@@ -225,21 +225,21 @@ discard block |
||
225 | 225 | * @return EE_Data_Migration_Script_Base |
226 | 226 | * @throws EE_Error |
227 | 227 | */ |
228 | - private function _get_dms_class_from_wp_option($dms_option_name,$dms_option_value){ |
|
228 | + private function _get_dms_class_from_wp_option($dms_option_name, $dms_option_value) { |
|
229 | 229 | $data_migration_data = maybe_unserialize($dms_option_value); |
230 | - if(isset($data_migration_data['class']) && class_exists($data_migration_data['class'])){ |
|
230 | + if (isset($data_migration_data['class']) && class_exists($data_migration_data['class'])) { |
|
231 | 231 | $class = new $data_migration_data['class']; |
232 | - if($class instanceof EE_Data_Migration_Script_Base){ |
|
232 | + if ($class instanceof EE_Data_Migration_Script_Base) { |
|
233 | 233 | $class->instantiate_from_array_of_properties($data_migration_data); |
234 | 234 | return $class; |
235 | - }else{ |
|
235 | + } else { |
|
236 | 236 | //huh, so its an object but not a data migration script?? that shouldn't happen |
237 | 237 | //just leave it as an array (which will probably just get ignored) |
238 | - throw new EE_Error(sprintf(__("Trying to retrieve DMS class from wp option. No DMS by the name '%s' exists", 'event_espresso'),$data_migration_data['class'])); |
|
238 | + throw new EE_Error(sprintf(__("Trying to retrieve DMS class from wp option. No DMS by the name '%s' exists", 'event_espresso'), $data_migration_data['class'])); |
|
239 | 239 | } |
240 | - }else{ |
|
240 | + } else { |
|
241 | 241 | //so the data doesn't specify a class. So it must either be a legacy array of info or some array (which we'll probably just ignore), or a class that no longer exists |
242 | - throw new EE_Error(sprintf(__("The wp option with key '%s' does not represent a DMS", 'event_espresso'),$dms_option_name)); |
|
242 | + throw new EE_Error(sprintf(__("The wp option with key '%s' does not represent a DMS", 'event_espresso'), $dms_option_name)); |
|
243 | 243 | } |
244 | 244 | } |
245 | 245 | /** |
@@ -247,34 +247,34 @@ discard block |
||
247 | 247 | * the last ran which hasn't finished yet |
248 | 248 | * @return array where each element should be an array of EE_Data_Migration_Script_Base (but also has a few legacy arrays in there - which should probably be ignored) |
249 | 249 | */ |
250 | - public function get_data_migrations_ran(){ |
|
251 | - if( ! $this->_data_migrations_ran ){ |
|
250 | + public function get_data_migrations_ran() { |
|
251 | + if ( ! $this->_data_migrations_ran) { |
|
252 | 252 | //setup autoloaders for each of the scripts in there |
253 | 253 | $this->get_all_data_migration_scripts_available(); |
254 | - $data_migrations_options = $this->get_all_migration_script_options();//get_option(EE_Data_Migration_Manager::data_migrations_option_name,get_option('espresso_data_migrations',array())); |
|
254 | + $data_migrations_options = $this->get_all_migration_script_options(); //get_option(EE_Data_Migration_Manager::data_migrations_option_name,get_option('espresso_data_migrations',array())); |
|
255 | 255 | |
256 | 256 | $data_migrations_ran = array(); |
257 | 257 | //convert into data migration script classes where possible |
258 | - foreach($data_migrations_options as $data_migration_option){ |
|
259 | - list($plugin_slug,$version_string) = $this->_get_plugin_slug_and_version_string_from_dms_option_name($data_migration_option['option_name']); |
|
258 | + foreach ($data_migrations_options as $data_migration_option) { |
|
259 | + list($plugin_slug, $version_string) = $this->_get_plugin_slug_and_version_string_from_dms_option_name($data_migration_option['option_name']); |
|
260 | 260 | |
261 | - try{ |
|
262 | - $class = $this->_get_dms_class_from_wp_option($data_migration_option['option_name'],$data_migration_option['option_value']); |
|
261 | + try { |
|
262 | + $class = $this->_get_dms_class_from_wp_option($data_migration_option['option_name'], $data_migration_option['option_value']); |
|
263 | 263 | $data_migrations_ran[$plugin_slug][$version_string] = $class; |
264 | 264 | //ok so far THIS is the 'last-ran-script'... unless we find another on next iteration |
265 | 265 | $this->_last_ran_script = $class; |
266 | - if( ! $class->is_completed()){ |
|
266 | + if ( ! $class->is_completed()) { |
|
267 | 267 | //sometimes we also like to know which was the last incomplete script (or if there are any at all) |
268 | 268 | $this->_last_ran_incomplete_script = $class; |
269 | 269 | } |
270 | - }catch(EE_Error $e){ |
|
270 | + } catch (EE_Error $e) { |
|
271 | 271 | //ok so its not a DMS. We'll just keep it, although other code will need to expect non-DMSs |
272 | 272 | $data_migrations_ran[$plugin_slug][$version_string] = maybe_unserialize($data_migration_option['option_value']); |
273 | 273 | } |
274 | 274 | } |
275 | 275 | //so here the array of $data_migrations_ran is actually a mix of classes and a few legacy arrays |
276 | 276 | $this->_data_migrations_ran = $data_migrations_ran; |
277 | - if ( ! $this->_data_migrations_ran || ! is_array($this->_data_migrations_ran) ){ |
|
277 | + if ( ! $this->_data_migrations_ran || ! is_array($this->_data_migrations_ran)) { |
|
278 | 278 | $this->_data_migrations_ran = array(); |
279 | 279 | } |
280 | 280 | } |
@@ -291,7 +291,7 @@ discard block |
||
291 | 291 | * @param $new_table |
292 | 292 | * @return mixed string or int |
293 | 293 | */ |
294 | - public function get_mapping_new_pk( $script_name, $old_table, $old_pk, $new_table){ |
|
294 | + public function get_mapping_new_pk($script_name, $old_table, $old_pk, $new_table) { |
|
295 | 295 | $script = EE_Registry::instance()->load_dms($script_name); |
296 | 296 | $mapping = $script->get_mapping_new_pk($old_table, $old_pk, $new_table); |
297 | 297 | return $mapping; |
@@ -302,9 +302,9 @@ discard block |
||
302 | 302 | * option returned in this array is the most-recently ran DMS option |
303 | 303 | * @return array |
304 | 304 | */ |
305 | - public function get_all_migration_script_options(){ |
|
305 | + public function get_all_migration_script_options() { |
|
306 | 306 | global $wpdb; |
307 | - return $wpdb->get_results("SELECT * FROM {$wpdb->options} WHERE option_name like '".EE_Data_Migration_Manager::data_migration_script_option_prefix."%' ORDER BY option_id ASC",ARRAY_A); |
|
307 | + return $wpdb->get_results("SELECT * FROM {$wpdb->options} WHERE option_name like '".EE_Data_Migration_Manager::data_migration_script_option_prefix."%' ORDER BY option_id ASC", ARRAY_A); |
|
308 | 308 | } |
309 | 309 | |
310 | 310 | /** |
@@ -312,8 +312,8 @@ discard block |
||
312 | 312 | * @return array where each value is the full folder path of a folder containing data migration scripts, WITH slashes at the end of the |
313 | 313 | * folder name. |
314 | 314 | */ |
315 | - public function get_data_migration_script_folders(){ |
|
316 | - return apply_filters( 'FHEE__EE_Data_Migration_Manager__get_data_migration_script_folders',array(EE_CORE.'data_migration_scripts') ); |
|
315 | + public function get_data_migration_script_folders() { |
|
316 | + return apply_filters('FHEE__EE_Data_Migration_Manager__get_data_migration_script_folders', array(EE_CORE.'data_migration_scripts')); |
|
317 | 317 | } |
318 | 318 | |
319 | 319 | /** |
@@ -325,11 +325,11 @@ discard block |
||
325 | 325 | * } |
326 | 326 | * @throws EE_Error |
327 | 327 | */ |
328 | - public function script_migrates_to_version($migration_script_name){ |
|
328 | + public function script_migrates_to_version($migration_script_name) { |
|
329 | 329 | $dms_info = $this->parse_dms_classname($migration_script_name); |
330 | 330 | return array( |
331 | - 'slug'=> $dms_info[ 'slug' ], |
|
332 | - 'version'=> $dms_info[ 'major_version' ] . "." . $dms_info[ 'minor_version' ] . "." . $dms_info[ 'micro_version' ] ); |
|
331 | + 'slug'=> $dms_info['slug'], |
|
332 | + 'version'=> $dms_info['major_version'].".".$dms_info['minor_version'].".".$dms_info['micro_version'] ); |
|
333 | 333 | } |
334 | 334 | |
335 | 335 | /** |
@@ -338,13 +338,13 @@ discard block |
||
338 | 338 | * @return array with keys 'slug','major_version','minor_version', and 'micro_version' (the last 3 are ints) |
339 | 339 | * @throws EE_Error |
340 | 340 | */ |
341 | - public function parse_dms_classname($classname){ |
|
341 | + public function parse_dms_classname($classname) { |
|
342 | 342 | $matches = array(); |
343 | - preg_match('~EE_DMS_(.*)_([0-9]*)_([0-9]*)_([0-9]*)~',$classname,$matches); |
|
344 | - if( ! $matches || ! (isset($matches[1]) && isset($matches[2]) && isset($matches[3]))){ |
|
345 | - throw new EE_Error(sprintf(__("%s is not a valid Data Migration Script. The classname should be like EE_DMS_w_x_y_z, where w is either 'Core' or the slug of an addon and x, y and z are numbers, ", "event_espresso"),$classname)); |
|
343 | + preg_match('~EE_DMS_(.*)_([0-9]*)_([0-9]*)_([0-9]*)~', $classname, $matches); |
|
344 | + if ( ! $matches || ! (isset($matches[1]) && isset($matches[2]) && isset($matches[3]))) { |
|
345 | + throw new EE_Error(sprintf(__("%s is not a valid Data Migration Script. The classname should be like EE_DMS_w_x_y_z, where w is either 'Core' or the slug of an addon and x, y and z are numbers, ", "event_espresso"), $classname)); |
|
346 | 346 | } |
347 | - return array('slug'=>$matches[1],'major_version'=>intval($matches[2]),'minor_version'=>intval($matches[3]),'micro_version'=>intval($matches[4])); |
|
347 | + return array('slug'=>$matches[1], 'major_version'=>intval($matches[2]), 'minor_version'=>intval($matches[3]), 'micro_version'=>intval($matches[4])); |
|
348 | 348 | } |
349 | 349 | /** |
350 | 350 | * Ensures that the option indicating the current DB version is set. This should only be |
@@ -353,33 +353,33 @@ discard block |
||
353 | 353 | * to 4.1.x. |
354 | 354 | * @return string of current db state |
355 | 355 | */ |
356 | - public function ensure_current_database_state_is_set(){ |
|
357 | - $espresso_db_core_updates = get_option( 'espresso_db_update', array() ); |
|
356 | + public function ensure_current_database_state_is_set() { |
|
357 | + $espresso_db_core_updates = get_option('espresso_db_update', array()); |
|
358 | 358 | $db_state = get_option(EE_Data_Migration_Manager::current_database_state); |
359 | - if( ! $db_state ){ |
|
359 | + if ( ! $db_state) { |
|
360 | 360 | //mark the DB as being in the state as the last version in there. |
361 | 361 | //this is done to trigger maintenance mode and do data migration scripts |
362 | 362 | //if the admin installed this version of EE over 3.1.x or 4.0.x |
363 | 363 | //otherwise, the normal maintenance mode code is fine |
364 | 364 | $previous_versions_installed = array_keys($espresso_db_core_updates); |
365 | 365 | $previous_version_installed = end($previous_versions_installed); |
366 | - if(version_compare('4.1.0', $previous_version_installed)){ |
|
366 | + if (version_compare('4.1.0', $previous_version_installed)) { |
|
367 | 367 | //last installed version was less than 4.1 |
368 | 368 | //so we want the data migrations to happen. SO, we're going to say the DB is at that state |
369 | 369 | // echo "4.1.0 is greater than $previous_version_installed! update the option"; |
370 | 370 | $db_state = array('Core'=>$previous_version_installed); |
371 | - }else{ |
|
371 | + } else { |
|
372 | 372 | // echo "4.1.0 is SMALLER than $previous_version_installed"; |
373 | 373 | $db_state = array('Core'=>EVENT_ESPRESSO_VERSION); |
374 | 374 | } |
375 | - update_option(EE_Data_Migration_Manager::current_database_state,$db_state); |
|
375 | + update_option(EE_Data_Migration_Manager::current_database_state, $db_state); |
|
376 | 376 | } |
377 | 377 | //in 4.1, $db_state would have only been a simple string like '4.1.0', |
378 | 378 | //but in 4.2+ it should be an array with at least key 'Core' and the value of that plugin's |
379 | 379 | //db, and possibly other keys for other addons like 'Calendar','Permissions',etc |
380 | - if( ! is_array($db_state)){ |
|
380 | + if ( ! is_array($db_state)) { |
|
381 | 381 | $db_state = array('Core'=>$db_state); |
382 | - update_option(EE_Data_Migration_Manager::current_database_state,$db_state); |
|
382 | + update_option(EE_Data_Migration_Manager::current_database_state, $db_state); |
|
383 | 383 | } |
384 | 384 | return $db_state; |
385 | 385 | } |
@@ -390,7 +390,7 @@ discard block |
||
390 | 390 | * or they don't apply), returns an empty array |
391 | 391 | * @return EE_Data_Migration_Script_Base[] |
392 | 392 | */ |
393 | - public function check_for_applicable_data_migration_scripts(){ |
|
393 | + public function check_for_applicable_data_migration_scripts() { |
|
394 | 394 | //get the option describing what options have already run |
395 | 395 | $scripts_ran = $this->get_data_migrations_ran(); |
396 | 396 | //$scripts_ran = array('4.1.0.core'=>array('monkey'=>null)); |
@@ -403,62 +403,62 @@ discard block |
||
403 | 403 | $iteration = 0; |
404 | 404 | $next_database_state_to_consider = $current_database_state; |
405 | 405 | $theoretical_database_state = NULL; |
406 | - do{ |
|
406 | + do { |
|
407 | 407 | //the next state after the currently-considered one will start off looking the same as the current, but we may make additions... |
408 | 408 | $theoretical_database_state = $next_database_state_to_consider; |
409 | 409 | //the next db state to consider is "what would the DB be like had we run all the scripts we found that applied last time?) |
410 | - foreach($script_class_and_filepaths_available as $classname => $filepath){ |
|
410 | + foreach ($script_class_and_filepaths_available as $classname => $filepath) { |
|
411 | 411 | |
412 | 412 | $migrates_to_version = $this->script_migrates_to_version($classname); |
413 | - $script_converts_plugin_slug = $migrates_to_version[ 'slug' ]; |
|
414 | - $script_converts_to_version = $migrates_to_version[ 'version' ]; |
|
413 | + $script_converts_plugin_slug = $migrates_to_version['slug']; |
|
414 | + $script_converts_to_version = $migrates_to_version['version']; |
|
415 | 415 | //check if this version script is DONE or not; or if it's never been ran |
416 | - if( ! $scripts_ran || |
|
416 | + if ( ! $scripts_ran || |
|
417 | 417 | ! isset($scripts_ran[$script_converts_plugin_slug]) || |
418 | - ! isset($scripts_ran[$script_converts_plugin_slug][$script_converts_to_version])){ |
|
418 | + ! isset($scripts_ran[$script_converts_plugin_slug][$script_converts_to_version])) { |
|
419 | 419 | //we haven't ran this conversion script before |
420 | 420 | //now check if it applies... note that we've added an autoloader for it on get_all_data_migration_scripts_available |
421 | - $script = new $classname( $this->_get_table_manager(), $this->_get_table_analysis() ); |
|
421 | + $script = new $classname($this->_get_table_manager(), $this->_get_table_analysis()); |
|
422 | 422 | /* @var $script EE_Data_Migration_Script_Base */ |
423 | 423 | $can_migrate = $script->can_migrate_from_version($theoretical_database_state); |
424 | - if($can_migrate){ |
|
424 | + if ($can_migrate) { |
|
425 | 425 | $script_classes_that_should_run_per_iteration[$iteration][$script->priority()][] = $script; |
426 | 426 | $migrates_to_version = $script->migrates_to_version(); |
427 | - $next_database_state_to_consider[ $migrates_to_version[ 'slug' ] ] = $migrates_to_version[ 'version' ]; |
|
427 | + $next_database_state_to_consider[$migrates_to_version['slug']] = $migrates_to_version['version']; |
|
428 | 428 | unset($script_class_and_filepaths_available[$classname]); |
429 | 429 | } |
430 | - } elseif($scripts_ran[$script_converts_plugin_slug][$script_converts_to_version] instanceof EE_Data_Migration_Script_Base){ |
|
430 | + } elseif ($scripts_ran[$script_converts_plugin_slug][$script_converts_to_version] instanceof EE_Data_Migration_Script_Base) { |
|
431 | 431 | //this script has been ran, or at least started |
432 | 432 | $script = $scripts_ran[$script_converts_plugin_slug][$script_converts_to_version]; |
433 | - if( $script->get_status() != self::status_completed){ |
|
433 | + if ($script->get_status() != self::status_completed) { |
|
434 | 434 | //this script is already underway... keep going with it |
435 | 435 | $script_classes_that_should_run_per_iteration[$iteration][$script->priority()][] = $script; |
436 | 436 | $migrates_to_version = $script->migrates_to_version(); |
437 | - $next_database_state_to_consider[ $migrates_to_version[ 'slug' ] ] = $migrates_to_version[ 'version' ]; |
|
437 | + $next_database_state_to_consider[$migrates_to_version['slug']] = $migrates_to_version['version']; |
|
438 | 438 | unset($script_class_and_filepaths_available[$classname]); |
439 | - }else{ |
|
439 | + } else { |
|
440 | 440 | //it must have a status that indicates it has finished, so we don't want to try and run it again |
441 | 441 | } |
442 | - }else{ |
|
442 | + } else { |
|
443 | 443 | //it exists but it's not a proper data migration script |
444 | 444 | //maybe the script got renamed? or was simply removed from EE? |
445 | 445 | //either way, its certainly not runnable! |
446 | 446 | } |
447 | 447 | } |
448 | 448 | $iteration++; |
449 | - }while( $next_database_state_to_consider != $theoretical_database_state && $iteration<6); |
|
449 | + }while ($next_database_state_to_consider != $theoretical_database_state && $iteration < 6); |
|
450 | 450 | //ok we have all the scripts that should run, now let's make them into flat array |
451 | 451 | $scripts_that_should_run = array(); |
452 | - foreach($script_classes_that_should_run_per_iteration as $scripts_at_priority){ |
|
452 | + foreach ($script_classes_that_should_run_per_iteration as $scripts_at_priority) { |
|
453 | 453 | ksort($scripts_at_priority); |
454 | - foreach($scripts_at_priority as $scripts){ |
|
455 | - foreach($scripts as $script){ |
|
454 | + foreach ($scripts_at_priority as $scripts) { |
|
455 | + foreach ($scripts as $script) { |
|
456 | 456 | $scripts_that_should_run[get_class($script)] = $script; |
457 | 457 | } |
458 | 458 | } |
459 | 459 | } |
460 | 460 | |
461 | - do_action( 'AHEE__EE_Data_Migration_Manager__check_for_applicable_data_migration_scripts__scripts_that_should_run', $scripts_that_should_run ); |
|
461 | + do_action('AHEE__EE_Data_Migration_Manager__check_for_applicable_data_migration_scripts__scripts_that_should_run', $scripts_that_should_run); |
|
462 | 462 | return $scripts_that_should_run; |
463 | 463 | } |
464 | 464 | |
@@ -472,14 +472,14 @@ discard block |
||
472 | 472 | * @param bool $include_completed_scripts |
473 | 473 | * @return EE_Data_Migration_Script_Base |
474 | 474 | */ |
475 | - public function get_last_ran_script($include_completed_scripts = false){ |
|
475 | + public function get_last_ran_script($include_completed_scripts = false) { |
|
476 | 476 | //make sure we've setup the class properties _last_ran_script and _last_ran_incomplete_script |
477 | - if( ! $this->_data_migrations_ran){ |
|
477 | + if ( ! $this->_data_migrations_ran) { |
|
478 | 478 | $this->get_data_migrations_ran(); |
479 | 479 | } |
480 | - if($include_completed_scripts){ |
|
480 | + if ($include_completed_scripts) { |
|
481 | 481 | return $this->_last_ran_script; |
482 | - }else{ |
|
482 | + } else { |
|
483 | 483 | return $this->_last_ran_incomplete_script; |
484 | 484 | } |
485 | 485 | } |
@@ -502,19 +502,19 @@ discard block |
||
502 | 502 | * @type string $message string describing what was done during this step |
503 | 503 | * } |
504 | 504 | */ |
505 | - public function migration_step( $step_size = 0 ){ |
|
505 | + public function migration_step($step_size = 0) { |
|
506 | 506 | |
507 | 507 | //bandaid fix for issue https://events.codebasehq.com/projects/event-espresso/tickets/7535 |
508 | - if ( class_exists( 'EE_CPT_Strategy' ) ) { |
|
509 | - remove_action( 'pre_get_posts', array( EE_CPT_Strategy::instance(), 'pre_get_posts' ), 5 ); |
|
508 | + if (class_exists('EE_CPT_Strategy')) { |
|
509 | + remove_action('pre_get_posts', array(EE_CPT_Strategy::instance(), 'pre_get_posts'), 5); |
|
510 | 510 | } |
511 | 511 | |
512 | - try{ |
|
512 | + try { |
|
513 | 513 | $currently_executing_script = $this->get_last_ran_script(); |
514 | - if( ! $currently_executing_script){ |
|
514 | + if ( ! $currently_executing_script) { |
|
515 | 515 | //Find the next script that needs to execute |
516 | 516 | $scripts = $this->check_for_applicable_data_migration_scripts(); |
517 | - if( ! $scripts ){ |
|
517 | + if ( ! $scripts) { |
|
518 | 518 | //huh, no more scripts to run... apparently we're done! |
519 | 519 | //but dont forget to make sure initial data is there |
520 | 520 | //we should be good to allow them to exit maintenance mode now |
@@ -535,18 +535,18 @@ discard block |
||
535 | 535 | //and add to the array/wp option showing the scripts ran |
536 | 536 | // $this->_data_migrations_ran[$this->script_migrates_to_version(get_class($currently_executing_script))] = $currently_executing_script; |
537 | 537 | $migrates_to = $this->script_migrates_to_version(get_class($currently_executing_script)); |
538 | - $plugin_slug = $migrates_to[ 'slug' ]; |
|
539 | - $version = $migrates_to[ 'version' ]; |
|
538 | + $plugin_slug = $migrates_to['slug']; |
|
539 | + $version = $migrates_to['version']; |
|
540 | 540 | $this->_data_migrations_ran[$plugin_slug][$version] = $currently_executing_script; |
541 | 541 | } |
542 | 542 | $current_script_name = get_class($currently_executing_script); |
543 | - }catch(Exception $e){ |
|
543 | + } catch (Exception $e) { |
|
544 | 544 | //an exception occurred while trying to get migration scripts |
545 | 545 | |
546 | - $message = sprintf( __("Error Message: %sStack Trace:%s", "event_espresso"), $e->getMessage() . '<br>', $e->getTraceAsString() ); |
|
546 | + $message = sprintf(__("Error Message: %sStack Trace:%s", "event_espresso"), $e->getMessage().'<br>', $e->getTraceAsString()); |
|
547 | 547 | //record it on the array of data migration scripts ran. This will be overwritten next time we try and try to run data migrations |
548 | 548 | //but that's ok-- it's just an FYI to support that we couldn't even run any data migrations |
549 | - $this->add_error_to_migrations_ran(sprintf(__("Could not run data migrations because: %s", "event_espresso"),$message)); |
|
549 | + $this->add_error_to_migrations_ran(sprintf(__("Could not run data migrations because: %s", "event_espresso"), $message)); |
|
550 | 550 | return array( |
551 | 551 | 'records_to_migrate'=>1, |
552 | 552 | 'records_migrated'=>0, |
@@ -556,16 +556,16 @@ discard block |
||
556 | 556 | ); |
557 | 557 | } |
558 | 558 | //ok so we definitely have a data migration script |
559 | - try{ |
|
559 | + try { |
|
560 | 560 | //how big of a bite do we want to take? Allow users to easily override via their wp-config |
561 | - if( ! absint( $step_size ) > 0 ){ |
|
562 | - $step_size = defined( 'EE_MIGRATION_STEP_SIZE' ) && absint( EE_MIGRATION_STEP_SIZE ) ? EE_MIGRATION_STEP_SIZE : EE_Data_Migration_Manager::step_size; |
|
561 | + if ( ! absint($step_size) > 0) { |
|
562 | + $step_size = defined('EE_MIGRATION_STEP_SIZE') && absint(EE_MIGRATION_STEP_SIZE) ? EE_MIGRATION_STEP_SIZE : EE_Data_Migration_Manager::step_size; |
|
563 | 563 | } |
564 | 564 | //do what we came to do! |
565 | 565 | $currently_executing_script->migration_step($step_size); |
566 | 566 | //can we wrap it up and verify default data? |
567 | 567 | $init_dbs = false; |
568 | - switch($currently_executing_script->get_status()){ |
|
568 | + switch ($currently_executing_script->get_status()) { |
|
569 | 569 | case EE_Data_Migration_Manager::status_continue: |
570 | 570 | $response_array = array( |
571 | 571 | 'records_to_migrate'=>$currently_executing_script->count_records_to_migrate(), |
@@ -577,16 +577,16 @@ discard block |
||
577 | 577 | case EE_Data_Migration_Manager::status_completed: |
578 | 578 | //ok so THAT script has completed |
579 | 579 | $this->update_current_database_state_to($this->script_migrates_to_version($current_script_name)); |
580 | - $response_array = array( |
|
580 | + $response_array = array( |
|
581 | 581 | 'records_to_migrate'=>$currently_executing_script->count_records_to_migrate(), |
582 | 582 | 'records_migrated'=>$currently_executing_script->count_records_migrated(), |
583 | 583 | 'status'=> EE_Data_Migration_Manager::status_completed, |
584 | 584 | 'message'=>$currently_executing_script->get_feedback_message(), |
585 | - 'script'=> sprintf(__("%s Completed",'event_espresso'),$currently_executing_script->pretty_name()) |
|
585 | + 'script'=> sprintf(__("%s Completed", 'event_espresso'), $currently_executing_script->pretty_name()) |
|
586 | 586 | ); |
587 | 587 | //check if there are any more after this one. |
588 | 588 | $scripts_remaining = $this->check_for_applicable_data_migration_scripts(); |
589 | - if( ! $scripts_remaining ){ |
|
589 | + if ( ! $scripts_remaining) { |
|
590 | 590 | //we should be good to allow them to exit maintenance mode now |
591 | 591 | EE_Maintenance_Mode::instance()->set_maintenance_level(intval(EE_Maintenance_Mode::level_0_not_in_maintenance)); |
592 | 592 | ////huh, no more scripts to run... apparently we're done! |
@@ -600,39 +600,39 @@ discard block |
||
600 | 600 | 'records_to_migrate'=>$currently_executing_script->count_records_to_migrate(), |
601 | 601 | 'records_migrated'=>$currently_executing_script->count_records_migrated(), |
602 | 602 | 'status'=> $currently_executing_script->get_status(), |
603 | - 'message'=> sprintf(__("Minor errors occurred during %s: %s", "event_espresso"), $currently_executing_script->pretty_name(), implode(", ",$currently_executing_script->get_errors())), |
|
603 | + 'message'=> sprintf(__("Minor errors occurred during %s: %s", "event_espresso"), $currently_executing_script->pretty_name(), implode(", ", $currently_executing_script->get_errors())), |
|
604 | 604 | 'script'=>$currently_executing_script->pretty_name() |
605 | 605 | ); |
606 | 606 | break; |
607 | 607 | } |
608 | - }catch(Exception $e){ |
|
608 | + } catch (Exception $e) { |
|
609 | 609 | //ok so some exception was thrown which killed the data migration script |
610 | 610 | //double-check we have a real script |
611 | - if($currently_executing_script instanceof EE_Data_Migration_Script_Base){ |
|
611 | + if ($currently_executing_script instanceof EE_Data_Migration_Script_Base) { |
|
612 | 612 | $script_name = $currently_executing_script->pretty_name(); |
613 | 613 | $currently_executing_script->set_broken(); |
614 | 614 | $currently_executing_script->add_error($e->getMessage()); |
615 | - }else{ |
|
615 | + } else { |
|
616 | 616 | $script_name = __("Error getting Migration Script", "event_espresso"); |
617 | 617 | } |
618 | 618 | $response_array = array( |
619 | 619 | 'records_to_migrate'=>1, |
620 | 620 | 'records_migrated'=>0, |
621 | 621 | 'status'=>self::status_fatal_error, |
622 | - 'message'=> sprintf(__("A fatal error occurred during the migration: %s", "event_espresso"),$e->getMessage()), |
|
622 | + 'message'=> sprintf(__("A fatal error occurred during the migration: %s", "event_espresso"), $e->getMessage()), |
|
623 | 623 | 'script'=>$script_name |
624 | 624 | ); |
625 | 625 | } |
626 | 626 | $successful_save = $this->_save_migrations_ran(); |
627 | - if($successful_save !== TRUE){ |
|
627 | + if ($successful_save !== TRUE) { |
|
628 | 628 | //ok so the current wp option didn't save. that's tricky, because we'd like to update it |
629 | 629 | //and mark it as having a fatal error, but remember- WE CAN'T SAVE THIS WP OPTION! |
630 | 630 | //however, if we throw an exception, and return that, then the next request |
631 | 631 | //won't have as much info in it, and it may be able to save |
632 | - throw new EE_Error(sprintf(__("The error '%s' occurred updating the status of the migration. This is a FATAL ERROR, but the error is preventing the system from remembering that. Please contact event espresso support.", "event_espresso"),$successful_save)); |
|
632 | + throw new EE_Error(sprintf(__("The error '%s' occurred updating the status of the migration. This is a FATAL ERROR, but the error is preventing the system from remembering that. Please contact event espresso support.", "event_espresso"), $successful_save)); |
|
633 | 633 | } |
634 | 634 | //if we're all done, initialize EE plugins' default data etc. |
635 | - if( $init_dbs ) { |
|
635 | + if ($init_dbs) { |
|
636 | 636 | $this->initialize_db_for_enqueued_ee_plugins(); |
637 | 637 | } |
638 | 638 | return $response_array; |
@@ -650,23 +650,23 @@ discard block |
||
650 | 650 | * 'message'=>a string, containing any message you want to show to the user. We may decide to split this up into errors, notifications, and successes |
651 | 651 | * 'script'=>a pretty name of the script currently running |
652 | 652 | */ |
653 | - public function response_to_migration_ajax_request(){ |
|
653 | + public function response_to_migration_ajax_request() { |
|
654 | 654 | // //start output buffer just to make sure we don't mess up the json |
655 | 655 | ob_start(); |
656 | - try{ |
|
656 | + try { |
|
657 | 657 | $response = $this->migration_step(); |
658 | - }catch(Exception $e){ |
|
658 | + } catch (Exception $e) { |
|
659 | 659 | $response = array( |
660 | 660 | 'records_to_migrate'=>0, |
661 | 661 | 'records_migrated'=>0, |
662 | 662 | 'status'=> EE_Data_Migration_Manager::status_fatal_error, |
663 | - 'message'=> sprintf(__("Unknown fatal error occurred: %s", "event_espresso"),$e->getMessage()), |
|
663 | + 'message'=> sprintf(__("Unknown fatal error occurred: %s", "event_espresso"), $e->getMessage()), |
|
664 | 664 | 'script'=>'Unknown'); |
665 | 665 | $this->add_error_to_migrations_ran($e->getMessage()."; Stack trace:".$e->getTraceAsString()); |
666 | 666 | } |
667 | 667 | $warnings_etc = @ob_get_contents(); |
668 | 668 | ob_end_clean(); |
669 | - $response['message'] .=$warnings_etc; |
|
669 | + $response['message'] .= $warnings_etc; |
|
670 | 670 | return $response; |
671 | 671 | } |
672 | 672 | |
@@ -679,14 +679,14 @@ discard block |
||
679 | 679 | * } |
680 | 680 | * @return void |
681 | 681 | */ |
682 | - public function update_current_database_state_to($slug_and_version = null){ |
|
683 | - if( ! $slug_and_version ){ |
|
682 | + public function update_current_database_state_to($slug_and_version = null) { |
|
683 | + if ( ! $slug_and_version) { |
|
684 | 684 | //no version was provided, assume it should be at the current code version |
685 | 685 | $slug_and_version = array('slug' => 'Core', 'version' => espresso_version()); |
686 | 686 | } |
687 | 687 | $current_database_state = get_option(self::current_database_state); |
688 | - $current_database_state[ $slug_and_version[ 'slug' ] ]=$slug_and_version[ 'version' ]; |
|
689 | - update_option(self::current_database_state,$current_database_state); |
|
688 | + $current_database_state[$slug_and_version['slug']] = $slug_and_version['version']; |
|
689 | + update_option(self::current_database_state, $current_database_state); |
|
690 | 690 | } |
691 | 691 | |
692 | 692 | /** |
@@ -697,20 +697,20 @@ discard block |
||
697 | 697 | * } |
698 | 698 | * @return boolean |
699 | 699 | */ |
700 | - public function database_needs_updating_to( $slug_and_version ) { |
|
700 | + public function database_needs_updating_to($slug_and_version) { |
|
701 | 701 | |
702 | - $slug = $slug_and_version[ 'slug' ]; |
|
703 | - $version = $slug_and_version[ 'version' ]; |
|
702 | + $slug = $slug_and_version['slug']; |
|
703 | + $version = $slug_and_version['version']; |
|
704 | 704 | $current_database_state = get_option(self::current_database_state); |
705 | - if( ! isset( $current_database_state[ $slug ] ) ) { |
|
705 | + if ( ! isset($current_database_state[$slug])) { |
|
706 | 706 | return true; |
707 | - }else{ |
|
707 | + } else { |
|
708 | 708 | //just compare the first 3 parts of version string, eg "4.7.1", not "4.7.1.dev.032" because DBs shouldn't change on nano version changes |
709 | - $version_parts_current_db_state = array_slice( explode('.', $current_database_state[ $slug ] ), 0, 3); |
|
710 | - $version_parts_of_provided_db_state = array_slice( explode( '.', $version ), 0, 3 ); |
|
709 | + $version_parts_current_db_state = array_slice(explode('.', $current_database_state[$slug]), 0, 3); |
|
710 | + $version_parts_of_provided_db_state = array_slice(explode('.', $version), 0, 3); |
|
711 | 711 | $needs_updating = false; |
712 | - foreach($version_parts_current_db_state as $offset => $version_part_in_current_db_state ) { |
|
713 | - if( $version_part_in_current_db_state < $version_parts_of_provided_db_state[ $offset ] ) { |
|
712 | + foreach ($version_parts_current_db_state as $offset => $version_part_in_current_db_state) { |
|
713 | + if ($version_part_in_current_db_state < $version_parts_of_provided_db_state[$offset]) { |
|
714 | 714 | $needs_updating = true; |
715 | 715 | break; |
716 | 716 | } |
@@ -728,33 +728,33 @@ discard block |
||
728 | 728 | * @return array keys are expected classnames, values are their filepaths |
729 | 729 | * @throws \EE_Error |
730 | 730 | */ |
731 | - public function get_all_data_migration_scripts_available(){ |
|
732 | - if( ! $this->_data_migration_class_to_filepath_map){ |
|
731 | + public function get_all_data_migration_scripts_available() { |
|
732 | + if ( ! $this->_data_migration_class_to_filepath_map) { |
|
733 | 733 | $this->_data_migration_class_to_filepath_map = array(); |
734 | - foreach($this->get_data_migration_script_folders() as $folder_path){ |
|
734 | + foreach ($this->get_data_migration_script_folders() as $folder_path) { |
|
735 | 735 | $folder_path = EEH_File::end_with_directory_separator($folder_path); |
736 | - $files = glob( $folder_path. '*.dms.php' ); |
|
736 | + $files = glob($folder_path.'*.dms.php'); |
|
737 | 737 | |
738 | - if ( empty( $files ) ) { |
|
738 | + if (empty($files)) { |
|
739 | 739 | continue; |
740 | 740 | } |
741 | 741 | |
742 | - foreach($files as $file){ |
|
743 | - $pos_of_last_slash = strrpos($file,DS); |
|
742 | + foreach ($files as $file) { |
|
743 | + $pos_of_last_slash = strrpos($file, DS); |
|
744 | 744 | $classname = str_replace('.dms.php', '', substr($file, $pos_of_last_slash + 1)); |
745 | - $migrates_to = $this->script_migrates_to_version( $classname ); |
|
746 | - $slug = $migrates_to[ 'slug' ]; |
|
745 | + $migrates_to = $this->script_migrates_to_version($classname); |
|
746 | + $slug = $migrates_to['slug']; |
|
747 | 747 | //check that the slug as contained in the DMS is associated with |
748 | 748 | //the slug of an addon or core |
749 | - if( $slug !== 'Core' ){ |
|
750 | - if( ! EE_Registry::instance()->get_addon_by_name( $slug ) ) { |
|
749 | + if ($slug !== 'Core') { |
|
750 | + if ( ! EE_Registry::instance()->get_addon_by_name($slug)) { |
|
751 | 751 | EE_Error::doing_it_wrong( |
752 | 752 | __FUNCTION__, |
753 | 753 | sprintf( |
754 | - __( 'The data migration script "%s" migrates the "%s" data, but there is no EE addon with that name. There is only: %s. ', 'event_espresso' ), |
|
754 | + __('The data migration script "%s" migrates the "%s" data, but there is no EE addon with that name. There is only: %s. ', 'event_espresso'), |
|
755 | 755 | $classname, |
756 | 756 | $slug, |
757 | - implode(', ', array_keys( EE_Registry::instance()->get_addons_by_name() ) ) |
|
757 | + implode(', ', array_keys(EE_Registry::instance()->get_addons_by_name())) |
|
758 | 758 | ), |
759 | 759 | '4.3.0.alpha.019' |
760 | 760 | ); |
@@ -777,7 +777,7 @@ discard block |
||
777 | 777 | * from each addon, and check if they need updating, |
778 | 778 | * @return boolean |
779 | 779 | */ |
780 | - public function addons_need_updating(){ |
|
780 | + public function addons_need_updating() { |
|
781 | 781 | return false; |
782 | 782 | } |
783 | 783 | /** |
@@ -786,25 +786,25 @@ discard block |
||
786 | 786 | * @param string $error_message |
787 | 787 | * @throws EE_Error |
788 | 788 | */ |
789 | - public function add_error_to_migrations_ran($error_message){ |
|
789 | + public function add_error_to_migrations_ran($error_message) { |
|
790 | 790 | //get last-ran migration script |
791 | 791 | global $wpdb; |
792 | - $last_migration_script_option = $wpdb->get_row("SELECT * FROM $wpdb->options WHERE option_name like '".EE_Data_Migration_Manager::data_migration_script_option_prefix."%' ORDER BY option_id DESC LIMIT 1",ARRAY_A); |
|
792 | + $last_migration_script_option = $wpdb->get_row("SELECT * FROM $wpdb->options WHERE option_name like '".EE_Data_Migration_Manager::data_migration_script_option_prefix."%' ORDER BY option_id DESC LIMIT 1", ARRAY_A); |
|
793 | 793 | |
794 | 794 | $last_ran_migration_script_properties = isset($last_migration_script_option['option_value']) ? maybe_unserialize($last_migration_script_option['option_value']) : null; |
795 | 795 | //now, tread lightly because we're here because a FATAL non-catchable error |
796 | 796 | //was thrown last time when we were trying to run a data migration script |
797 | 797 | //so the fatal error could have happened while getting the migration script |
798 | 798 | //or doing running it... |
799 | - $versions_migrated_to = isset($last_migration_script_option['option_name']) ? str_replace(EE_Data_Migration_Manager::data_migration_script_option_prefix,"",$last_migration_script_option['option_name']) : null; |
|
799 | + $versions_migrated_to = isset($last_migration_script_option['option_name']) ? str_replace(EE_Data_Migration_Manager::data_migration_script_option_prefix, "", $last_migration_script_option['option_name']) : null; |
|
800 | 800 | |
801 | 801 | //check if it THINKS its a data migration script and especially if it's one that HASN'T finished yet |
802 | 802 | //because if it has finished, then it obviously couldn't be the cause of this error, right? (because its all done) |
803 | - if(isset($last_ran_migration_script_properties['class']) && isset($last_ran_migration_script_properties['_status']) && $last_ran_migration_script_properties['_status'] != self::status_completed){ |
|
803 | + if (isset($last_ran_migration_script_properties['class']) && isset($last_ran_migration_script_properties['_status']) && $last_ran_migration_script_properties['_status'] != self::status_completed) { |
|
804 | 804 | //ok then just add this error to its list of errors |
805 | 805 | $last_ran_migration_script_properties['_errors'][] = $error_message; |
806 | 806 | $last_ran_migration_script_properties['_status'] = self::status_fatal_error; |
807 | - }else{ |
|
807 | + } else { |
|
808 | 808 | //so we don't even know which script was last running |
809 | 809 | //use the data migration error stub, which is designed specifically for this type of thing |
810 | 810 | $general_migration_error = new EE_DMS_Unknown_1_0_0(); |
@@ -814,39 +814,39 @@ discard block |
||
814 | 814 | $versions_migrated_to = 'Unknown.1.0.0'; |
815 | 815 | //now just to make sure appears as last (in case the were previously a fatal error like this) |
816 | 816 | //delete the old one |
817 | - delete_option( self::data_migration_script_option_prefix . $versions_migrated_to ); |
|
817 | + delete_option(self::data_migration_script_option_prefix.$versions_migrated_to); |
|
818 | 818 | } |
819 | - update_option(self::data_migration_script_option_prefix.$versions_migrated_to,$last_ran_migration_script_properties); |
|
819 | + update_option(self::data_migration_script_option_prefix.$versions_migrated_to, $last_ran_migration_script_properties); |
|
820 | 820 | |
821 | 821 | } |
822 | 822 | /** |
823 | 823 | * saves what data migrations have ran to the database |
824 | 824 | * @return mixed TRUE if successfully saved migrations ran, string if an error occurred |
825 | 825 | */ |
826 | - protected function _save_migrations_ran(){ |
|
827 | - if($this->_data_migrations_ran == null){ |
|
826 | + protected function _save_migrations_ran() { |
|
827 | + if ($this->_data_migrations_ran == null) { |
|
828 | 828 | $this->get_data_migrations_ran(); |
829 | 829 | } |
830 | 830 | //now, we don't want to save actual classes to the DB because that's messy |
831 | 831 | $successful_updates = true; |
832 | - foreach($this->_data_migrations_ran as $plugin_slug => $migrations_ran_for_plugin){ |
|
833 | - foreach($migrations_ran_for_plugin as $version_string => $array_or_migration_obj){ |
|
832 | + foreach ($this->_data_migrations_ran as $plugin_slug => $migrations_ran_for_plugin) { |
|
833 | + foreach ($migrations_ran_for_plugin as $version_string => $array_or_migration_obj) { |
|
834 | 834 | // echo "saving migration script to $version_string<br>"; |
835 | 835 | $plugin_slug_for_use_in_option_name = $plugin_slug."."; |
836 | 836 | $option_name = self::data_migration_script_option_prefix.$plugin_slug_for_use_in_option_name.$version_string; |
837 | 837 | $old_option_value = get_option($option_name); |
838 | - if($array_or_migration_obj instanceof EE_Data_Migration_Script_Base){ |
|
838 | + if ($array_or_migration_obj instanceof EE_Data_Migration_Script_Base) { |
|
839 | 839 | $script_array_for_saving = $array_or_migration_obj->properties_as_array(); |
840 | - if( $old_option_value != $script_array_for_saving){ |
|
841 | - $successful_updates = update_option($option_name,$script_array_for_saving); |
|
840 | + if ($old_option_value != $script_array_for_saving) { |
|
841 | + $successful_updates = update_option($option_name, $script_array_for_saving); |
|
842 | 842 | } |
843 | - }else{//we don't know what this array-thing is. So just save it as-is |
|
843 | + } else {//we don't know what this array-thing is. So just save it as-is |
|
844 | 844 | // $array_of_migrations[$version_string] = $array_or_migration_obj; |
845 | - if($old_option_value != $array_or_migration_obj){ |
|
846 | - $successful_updates = update_option($option_name,$array_or_migration_obj); |
|
845 | + if ($old_option_value != $array_or_migration_obj) { |
|
846 | + $successful_updates = update_option($option_name, $array_or_migration_obj); |
|
847 | 847 | } |
848 | 848 | } |
849 | - if( ! $successful_updates ){ |
|
849 | + if ( ! $successful_updates) { |
|
850 | 850 | global $wpdb; |
851 | 851 | return $wpdb->last_error; |
852 | 852 | } |
@@ -870,17 +870,17 @@ discard block |
||
870 | 870 | * @return EE_Data_Migration_Script_Base |
871 | 871 | * @throws EE_Error |
872 | 872 | */ |
873 | - function _instantiate_script_from_properties_array($properties_array){ |
|
874 | - if( ! isset($properties_array['class'])){ |
|
875 | - throw new EE_Error(sprintf(__("Properties array has no 'class' properties. Here's what it has: %s", "event_espresso"),implode(",",$properties_array))); |
|
873 | + function _instantiate_script_from_properties_array($properties_array) { |
|
874 | + if ( ! isset($properties_array['class'])) { |
|
875 | + throw new EE_Error(sprintf(__("Properties array has no 'class' properties. Here's what it has: %s", "event_espresso"), implode(",", $properties_array))); |
|
876 | 876 | } |
877 | 877 | $class_name = $properties_array['class']; |
878 | - if( ! class_exists($class_name)){ |
|
879 | - throw new EE_Error(sprintf(__("There is no migration script named %s", "event_espresso"),$class_name)); |
|
878 | + if ( ! class_exists($class_name)) { |
|
879 | + throw new EE_Error(sprintf(__("There is no migration script named %s", "event_espresso"), $class_name)); |
|
880 | 880 | } |
881 | 881 | $class = new $class_name; |
882 | - if( ! $class instanceof EE_Data_Migration_Script_Base){ |
|
883 | - throw new EE_Error(sprintf(__("Class '%s' is supposed to be a migration script. Its not, its a '%s'", "event_espresso"),$class_name,get_class($class))); |
|
882 | + if ( ! $class instanceof EE_Data_Migration_Script_Base) { |
|
883 | + throw new EE_Error(sprintf(__("Class '%s' is supposed to be a migration script. Its not, its a '%s'", "event_espresso"), $class_name, get_class($class))); |
|
884 | 884 | } |
885 | 885 | $class->instantiate_from_array_of_properties($properties_array); |
886 | 886 | return $class; |
@@ -892,25 +892,25 @@ discard block |
||
892 | 892 | * @param string $plugin_slug the slug for the ee plugin we are searching for. Default is 'Core' |
893 | 893 | * @return string |
894 | 894 | */ |
895 | - public function get_most_up_to_date_dms($plugin_slug = 'Core'){ |
|
895 | + public function get_most_up_to_date_dms($plugin_slug = 'Core') { |
|
896 | 896 | $class_to_filepath_map = $this->get_all_data_migration_scripts_available(); |
897 | 897 | $most_up_to_date_dms_classname = NULL; |
898 | - foreach($class_to_filepath_map as $classname => $filepath){ |
|
899 | - if($most_up_to_date_dms_classname === NULL){ |
|
898 | + foreach ($class_to_filepath_map as $classname => $filepath) { |
|
899 | + if ($most_up_to_date_dms_classname === NULL) { |
|
900 | 900 | $migrates_to = $this->script_migrates_to_version($classname); |
901 | - $this_plugin_slug = $migrates_to[ 'slug' ]; |
|
901 | + $this_plugin_slug = $migrates_to['slug']; |
|
902 | 902 | // $version_string = $migrates_to[ 'version' ]; |
903 | 903 | // $details = $this->parse_dms_classname($classname); |
904 | - if($this_plugin_slug == $plugin_slug){ |
|
904 | + if ($this_plugin_slug == $plugin_slug) { |
|
905 | 905 | //if it's for core, it wins |
906 | 906 | $most_up_to_date_dms_classname = $classname; |
907 | 907 | } |
908 | 908 | //if it wasn't for core, we must keep searching for one that is! |
909 | 909 | continue; |
910 | - }else{ |
|
911 | - $champion_migrates_to= $this->script_migrates_to_version($most_up_to_date_dms_classname); |
|
910 | + } else { |
|
911 | + $champion_migrates_to = $this->script_migrates_to_version($most_up_to_date_dms_classname); |
|
912 | 912 | $contender_migrates_to = $this->script_migrates_to_version($classname); |
913 | - if($contender_migrates_to[ 'slug' ] == $plugin_slug && version_compare($champion_migrates_to[ 'version' ], $contender_migrates_to[ 'version' ], '<')){ |
|
913 | + if ($contender_migrates_to['slug'] == $plugin_slug && version_compare($champion_migrates_to['version'], $contender_migrates_to['version'], '<')) { |
|
914 | 914 | //so the contenders version is higher and its for Core |
915 | 915 | $most_up_to_date_dms_classname = $classname; |
916 | 916 | } |
@@ -930,11 +930,11 @@ discard block |
||
930 | 930 | * @param string $plugin_slug like 'Core', 'Mailchimp', 'Calendar', etc |
931 | 931 | * @return EE_Data_Migration_Script_Base |
932 | 932 | */ |
933 | - public function get_migration_ran( $version, $plugin_slug = 'Core' ) { |
|
933 | + public function get_migration_ran($version, $plugin_slug = 'Core') { |
|
934 | 934 | $migrations_ran = $this->get_data_migrations_ran(); |
935 | - if( isset( $migrations_ran[ $plugin_slug ] ) && isset( $migrations_ran[ $plugin_slug ][ $version ] ) ){ |
|
936 | - return $migrations_ran[ $plugin_slug ][ $version ]; |
|
937 | - }else{ |
|
935 | + if (isset($migrations_ran[$plugin_slug]) && isset($migrations_ran[$plugin_slug][$version])) { |
|
936 | + return $migrations_ran[$plugin_slug][$version]; |
|
937 | + } else { |
|
938 | 938 | return NULL; |
939 | 939 | } |
940 | 940 | } |
@@ -946,20 +946,20 @@ discard block |
||
946 | 946 | * @return bool |
947 | 947 | * @throws \EE_Error |
948 | 948 | */ |
949 | - public function reattempt(){ |
|
949 | + public function reattempt() { |
|
950 | 950 | //find if the last-ran script was borked |
951 | 951 | //set it as being non-borked (we shouldn't ever get DMSs that we don't recognize) |
952 | 952 | //add an 'error' saying that we attempted to reset |
953 | 953 | //does it have a stage that was borked too? if so make it no longer borked |
954 | 954 | //add an 'error' saying we attempted to reset |
955 | 955 | $last_ran_script = $this->get_last_ran_script(); |
956 | - if( $last_ran_script instanceof EE_DMS_Unknown_1_0_0 ){ |
|
956 | + if ($last_ran_script instanceof EE_DMS_Unknown_1_0_0) { |
|
957 | 957 | //if it was an error DMS, just mark it as complete (if another error occurs it will overwrite it) |
958 | 958 | $last_ran_script->set_completed(); |
959 | - }elseif( $last_ran_script instanceof EE_Data_Migration_Script_Base ) { |
|
959 | + }elseif ($last_ran_script instanceof EE_Data_Migration_Script_Base) { |
|
960 | 960 | $last_ran_script->reattempt(); |
961 | - }else{ |
|
962 | - throw new EE_Error( sprintf( __( 'Unable to reattempt the last ran migration script because it was not a valid migration script. || It was %s', 'event_espresso' ), print_r( $last_ran_script, true ) ) ); |
|
961 | + } else { |
|
962 | + throw new EE_Error(sprintf(__('Unable to reattempt the last ran migration script because it was not a valid migration script. || It was %s', 'event_espresso'), print_r($last_ran_script, true))); |
|
963 | 963 | } |
964 | 964 | return $this->_save_migrations_ran(); |
965 | 965 | } |
@@ -969,19 +969,19 @@ discard block |
||
969 | 969 | * @param string $plugin_slug like 'Core', 'Mailchimp', 'Calendar', etc |
970 | 970 | * @return boolean |
971 | 971 | */ |
972 | - public function migration_has_ran( $version, $plugin_slug = 'Core' ) { |
|
973 | - return $this->get_migration_ran( $version, $plugin_slug ) !== NULL; |
|
972 | + public function migration_has_ran($version, $plugin_slug = 'Core') { |
|
973 | + return $this->get_migration_ran($version, $plugin_slug) !== NULL; |
|
974 | 974 | } |
975 | 975 | /** |
976 | 976 | * Enqueues this ee plugin to have its data initialized |
977 | 977 | * @param string $plugin_slug either 'Core' or EE_Addon::name()'s return value |
978 | 978 | */ |
979 | - public function enqueue_db_initialization_for( $plugin_slug ) { |
|
979 | + public function enqueue_db_initialization_for($plugin_slug) { |
|
980 | 980 | $queue = $this->get_db_initialization_queue(); |
981 | - if( ! in_array( $plugin_slug, $queue ) ) { |
|
981 | + if ( ! in_array($plugin_slug, $queue)) { |
|
982 | 982 | $queue[] = $plugin_slug; |
983 | 983 | } |
984 | - update_option( self::db_init_queue_option_name, $queue ); |
|
984 | + update_option(self::db_init_queue_option_name, $queue); |
|
985 | 985 | } |
986 | 986 | /** |
987 | 987 | * Calls EE_Addon::initialize_db_if_no_migrations_required() on each addon |
@@ -991,26 +991,26 @@ discard block |
||
991 | 991 | public function initialize_db_for_enqueued_ee_plugins() { |
992 | 992 | // EEH_Debug_Tools::instance()->start_timer( 'initialize_db_for_enqueued_ee_plugins' ); |
993 | 993 | $queue = $this->get_db_initialization_queue(); |
994 | - foreach( $queue as $plugin_slug ) { |
|
995 | - $most_up_to_date_dms = $this->get_most_up_to_date_dms( $plugin_slug ); |
|
996 | - if( ! $most_up_to_date_dms ) { |
|
994 | + foreach ($queue as $plugin_slug) { |
|
995 | + $most_up_to_date_dms = $this->get_most_up_to_date_dms($plugin_slug); |
|
996 | + if ( ! $most_up_to_date_dms) { |
|
997 | 997 | //if there is NO DMS for this plugin, obviously there's no schema to verify anyways |
998 | 998 | $verify_db = false; |
999 | - }else{ |
|
1000 | - $most_up_to_date_dms_migrates_to = $this->script_migrates_to_version( $most_up_to_date_dms ); |
|
1001 | - $verify_db = $this->database_needs_updating_to( $most_up_to_date_dms_migrates_to ); |
|
999 | + } else { |
|
1000 | + $most_up_to_date_dms_migrates_to = $this->script_migrates_to_version($most_up_to_date_dms); |
|
1001 | + $verify_db = $this->database_needs_updating_to($most_up_to_date_dms_migrates_to); |
|
1002 | 1002 | } |
1003 | - if( $plugin_slug == 'Core' ){ |
|
1003 | + if ($plugin_slug == 'Core') { |
|
1004 | 1004 | EE_System::instance()->initialize_db_if_no_migrations_required( |
1005 | 1005 | false, |
1006 | 1006 | $verify_db |
1007 | 1007 | ); |
1008 | - }else{ |
|
1008 | + } else { |
|
1009 | 1009 | //just loop through the addons to make sure their database is setup |
1010 | - foreach( EE_Registry::instance()->addons as $addon ) { |
|
1011 | - if( $addon->name() == $plugin_slug ) { |
|
1010 | + foreach (EE_Registry::instance()->addons as $addon) { |
|
1011 | + if ($addon->name() == $plugin_slug) { |
|
1012 | 1012 | |
1013 | - $addon->initialize_db_if_no_migrations_required( $verify_db ); |
|
1013 | + $addon->initialize_db_if_no_migrations_required($verify_db); |
|
1014 | 1014 | break; |
1015 | 1015 | } |
1016 | 1016 | } |
@@ -1020,7 +1020,7 @@ discard block |
||
1020 | 1020 | // EEH_Debug_Tools::instance()->show_times(); |
1021 | 1021 | //because we just initialized the DBs for the enqueued ee plugins |
1022 | 1022 | //we don't need to keep remembering which ones needed to be initialized |
1023 | - delete_option( self::db_init_queue_option_name ); |
|
1023 | + delete_option(self::db_init_queue_option_name); |
|
1024 | 1024 | } |
1025 | 1025 | |
1026 | 1026 | /** |
@@ -1029,8 +1029,8 @@ discard block |
||
1029 | 1029 | * 'Core', or the return value of EE_Addon::name() for an addon |
1030 | 1030 | * @return array |
1031 | 1031 | */ |
1032 | - public function get_db_initialization_queue(){ |
|
1033 | - return get_option ( self::db_init_queue_option_name, array() ); |
|
1032 | + public function get_db_initialization_queue() { |
|
1033 | + return get_option(self::db_init_queue_option_name, array()); |
|
1034 | 1034 | } |
1035 | 1035 | |
1036 | 1036 | /** |
@@ -1039,13 +1039,13 @@ discard block |
||
1039 | 1039 | * @throws \EE_Error |
1040 | 1040 | */ |
1041 | 1041 | protected function _get_table_analysis() { |
1042 | - if( $this->_table_analysis instanceof TableAnalysis ) { |
|
1042 | + if ($this->_table_analysis instanceof TableAnalysis) { |
|
1043 | 1043 | return $this->_table_analysis; |
1044 | 1044 | } else { |
1045 | 1045 | throw new \EE_Error( |
1046 | 1046 | sprintf( |
1047 | - __( 'Table analysis class on class %1$s is not set properly.', 'event_espresso'), |
|
1048 | - get_class( $this ) |
|
1047 | + __('Table analysis class on class %1$s is not set properly.', 'event_espresso'), |
|
1048 | + get_class($this) |
|
1049 | 1049 | ) |
1050 | 1050 | ); |
1051 | 1051 | } |
@@ -1057,13 +1057,13 @@ discard block |
||
1057 | 1057 | * @throws \EE_Error |
1058 | 1058 | */ |
1059 | 1059 | protected function _get_table_manager() { |
1060 | - if( $this->_table_manager instanceof TableManager ) { |
|
1060 | + if ($this->_table_manager instanceof TableManager) { |
|
1061 | 1061 | return $this->_table_manager; |
1062 | 1062 | } else { |
1063 | 1063 | throw new \EE_Error( |
1064 | 1064 | sprintf( |
1065 | - __( 'Table manager class on class %1$s is not set properly.', 'event_espresso'), |
|
1066 | - get_class( $this ) |
|
1065 | + __('Table manager class on class %1$s is not set properly.', 'event_espresso'), |
|
1066 | + get_class($this) |
|
1067 | 1067 | ) |
1068 | 1068 | ); |
1069 | 1069 | } |
@@ -71,10 +71,10 @@ discard block |
||
71 | 71 | */ |
72 | 72 | public function __construct(){ |
73 | 73 | if( ! $this->_model_name_extended){ |
74 | - throw new EE_Error( |
|
75 | - __( "When declaring a model extension, you must define its _model_name_extended property. It should be a model name like 'Attendee' or 'Event'", |
|
76 | - "event_espresso" ) |
|
77 | - ); |
|
74 | + throw new EE_Error( |
|
75 | + __( "When declaring a model extension, you must define its _model_name_extended property. It should be a model name like 'Attendee' or 'Event'", |
|
76 | + "event_espresso" ) |
|
77 | + ); |
|
78 | 78 | } |
79 | 79 | $construct_end_action = 'AHEE__EEM_'.$this->_model_name_extended.'__construct__end'; |
80 | 80 | if ( did_action( $construct_end_action )) { |
@@ -95,30 +95,30 @@ discard block |
||
95 | 95 | |
96 | 96 | |
97 | 97 | |
98 | - /** |
|
99 | - * @param array $existing_tables |
|
100 | - * @return array |
|
101 | - */ |
|
102 | - public function add_extra_tables_on_filter( $existing_tables ){ |
|
103 | - return array_merge( (array)$existing_tables, $this->_extra_tables ); |
|
98 | + /** |
|
99 | + * @param array $existing_tables |
|
100 | + * @return array |
|
101 | + */ |
|
102 | + public function add_extra_tables_on_filter( $existing_tables ){ |
|
103 | + return array_merge( (array)$existing_tables, $this->_extra_tables ); |
|
104 | 104 | } |
105 | 105 | |
106 | 106 | |
107 | 107 | |
108 | - /** |
|
109 | - * @param array $existing_fields |
|
110 | - * @return array |
|
111 | - */ |
|
112 | - public function add_extra_fields_on_filter( $existing_fields ){ |
|
108 | + /** |
|
109 | + * @param array $existing_fields |
|
110 | + * @return array |
|
111 | + */ |
|
112 | + public function add_extra_fields_on_filter( $existing_fields ){ |
|
113 | 113 | if( $this->_extra_fields){ |
114 | 114 | foreach($this->_extra_fields as $table_alias => $fields){ |
115 | 115 | if( ! isset( $existing_fields[ $table_alias ] ) ){ |
116 | 116 | $existing_fields[ $table_alias ] = array(); |
117 | 117 | } |
118 | 118 | $existing_fields[$table_alias] = array_merge( |
119 | - (array)$existing_fields[$table_alias], |
|
120 | - $this->_extra_fields[$table_alias] |
|
121 | - ); |
|
119 | + (array)$existing_fields[$table_alias], |
|
120 | + $this->_extra_fields[$table_alias] |
|
121 | + ); |
|
122 | 122 | |
123 | 123 | } |
124 | 124 | } |
@@ -127,12 +127,12 @@ discard block |
||
127 | 127 | |
128 | 128 | |
129 | 129 | |
130 | - /** |
|
131 | - * @param array $existing_relations |
|
132 | - * @return array |
|
133 | - */ |
|
134 | - public function add_extra_relations_on_filter( $existing_relations ){ |
|
135 | - return array_merge((array)$existing_relations,$this->_extra_relations); |
|
130 | + /** |
|
131 | + * @param array $existing_relations |
|
132 | + * @return array |
|
133 | + */ |
|
134 | + public function add_extra_relations_on_filter( $existing_relations ){ |
|
135 | + return array_merge((array)$existing_relations,$this->_extra_relations); |
|
136 | 136 | } |
137 | 137 | |
138 | 138 | |
@@ -168,8 +168,8 @@ discard block |
||
168 | 168 | remove_filter($callback_name,array($this,self::dynamic_callback_method_prefix.$method_name_on_model),10); |
169 | 169 | } |
170 | 170 | } |
171 | - /** @var EEM_Base $model_to_reset */ |
|
172 | - $model_to_reset = 'EEM_' . $this->_model_name_extended; |
|
171 | + /** @var EEM_Base $model_to_reset */ |
|
172 | + $model_to_reset = 'EEM_' . $this->_model_name_extended; |
|
173 | 173 | if ( class_exists( $model_to_reset ) ) { |
174 | 174 | $model_to_reset::reset(); |
175 | 175 | } |
@@ -177,13 +177,13 @@ discard block |
||
177 | 177 | |
178 | 178 | |
179 | 179 | |
180 | - /** |
|
181 | - * @param string $callback_method_name |
|
182 | - * @param array $args |
|
183 | - * @return mixed |
|
184 | - * @throws EE_Error |
|
185 | - */ |
|
186 | - public function __call( $callback_method_name, $args){ |
|
180 | + /** |
|
181 | + * @param string $callback_method_name |
|
182 | + * @param array $args |
|
183 | + * @return mixed |
|
184 | + * @throws EE_Error |
|
185 | + */ |
|
186 | + public function __call( $callback_method_name, $args){ |
|
187 | 187 | if(strpos($callback_method_name, self::dynamic_callback_method_prefix) === 0){ |
188 | 188 | //it's a dynamic callback for a method name |
189 | 189 | $method_called_on_model = str_replace(self::dynamic_callback_method_prefix, '', $callback_method_name); |
@@ -194,23 +194,23 @@ discard block |
||
194 | 194 | return call_user_func_array(array($this,$extending_method), $args_provided_to_method_on_model); |
195 | 195 | }else{ |
196 | 196 | throw new EE_Error( |
197 | - sprintf( |
|
198 | - __("An odd error occurred. Model '%s' had a method called on it that it didn't recognize. So it passed it onto the model extension '%s' (because it had a function named '%s' which should be able to handle it), but the function '%s' doesnt exist!)", "event_espresso"), |
|
199 | - $this->_model_name_extended, |
|
200 | - get_class($this), |
|
201 | - $extending_method,$extending_method |
|
202 | - ) |
|
203 | - ); |
|
197 | + sprintf( |
|
198 | + __("An odd error occurred. Model '%s' had a method called on it that it didn't recognize. So it passed it onto the model extension '%s' (because it had a function named '%s' which should be able to handle it), but the function '%s' doesnt exist!)", "event_espresso"), |
|
199 | + $this->_model_name_extended, |
|
200 | + get_class($this), |
|
201 | + $extending_method,$extending_method |
|
202 | + ) |
|
203 | + ); |
|
204 | 204 | } |
205 | 205 | |
206 | 206 | }else{ |
207 | 207 | throw new EE_Error( |
208 | - sprintf( |
|
209 | - __("There is no method named '%s' on '%s'", "event_espresso"), |
|
210 | - $callback_method_name, |
|
211 | - get_class($this) |
|
212 | - ) |
|
213 | - ); |
|
208 | + sprintf( |
|
209 | + __("There is no method named '%s' on '%s'", "event_espresso"), |
|
210 | + $callback_method_name, |
|
211 | + get_class($this) |
|
212 | + ) |
|
213 | + ); |
|
214 | 214 | } |
215 | 215 | } |
216 | 216 |
@@ -1,6 +1,6 @@ discard block |
||
1 | 1 | <?php |
2 | 2 | |
3 | -if (!defined('EVENT_ESPRESSO_VERSION')) |
|
3 | +if ( ! defined('EVENT_ESPRESSO_VERSION')) |
|
4 | 4 | exit('No direct script access allowed'); |
5 | 5 | |
6 | 6 | /** |
@@ -69,27 +69,27 @@ discard block |
||
69 | 69 | /** |
70 | 70 | * @throws \EE_Error |
71 | 71 | */ |
72 | - public function __construct(){ |
|
73 | - if( ! $this->_model_name_extended){ |
|
72 | + public function __construct() { |
|
73 | + if ( ! $this->_model_name_extended) { |
|
74 | 74 | throw new EE_Error( |
75 | - __( "When declaring a model extension, you must define its _model_name_extended property. It should be a model name like 'Attendee' or 'Event'", |
|
76 | - "event_espresso" ) |
|
75 | + __("When declaring a model extension, you must define its _model_name_extended property. It should be a model name like 'Attendee' or 'Event'", |
|
76 | + "event_espresso") |
|
77 | 77 | ); |
78 | 78 | } |
79 | 79 | $construct_end_action = 'AHEE__EEM_'.$this->_model_name_extended.'__construct__end'; |
80 | - if ( did_action( $construct_end_action )) { |
|
80 | + if (did_action($construct_end_action)) { |
|
81 | 81 | throw new EE_Error( |
82 | 82 | sprintf( |
83 | - __( "Hooked in model extension '%s' too late! The model %s has already been used! We know because the action %s has been fired", "event_espresso"), |
|
83 | + __("Hooked in model extension '%s' too late! The model %s has already been used! We know because the action %s has been fired", "event_espresso"), |
|
84 | 84 | get_class($this), |
85 | 85 | $this->_model_name_extended, |
86 | 86 | $construct_end_action |
87 | 87 | ) |
88 | 88 | ); |
89 | 89 | } |
90 | - add_filter('FHEE__EEM_'.$this->_model_name_extended.'__construct__tables',array($this,'add_extra_tables_on_filter')); |
|
91 | - add_filter('FHEE__EEM_'.$this->_model_name_extended.'__construct__fields',array($this,'add_extra_fields_on_filter')); |
|
92 | - add_filter('FHEE__EEM_'.$this->_model_name_extended.'__construct__model_relations',array($this,'add_extra_relations_on_filter')); |
|
90 | + add_filter('FHEE__EEM_'.$this->_model_name_extended.'__construct__tables', array($this, 'add_extra_tables_on_filter')); |
|
91 | + add_filter('FHEE__EEM_'.$this->_model_name_extended.'__construct__fields', array($this, 'add_extra_fields_on_filter')); |
|
92 | + add_filter('FHEE__EEM_'.$this->_model_name_extended.'__construct__model_relations', array($this, 'add_extra_relations_on_filter')); |
|
93 | 93 | $this->_register_extending_methods(); |
94 | 94 | } |
95 | 95 | |
@@ -99,8 +99,8 @@ discard block |
||
99 | 99 | * @param array $existing_tables |
100 | 100 | * @return array |
101 | 101 | */ |
102 | - public function add_extra_tables_on_filter( $existing_tables ){ |
|
103 | - return array_merge( (array)$existing_tables, $this->_extra_tables ); |
|
102 | + public function add_extra_tables_on_filter($existing_tables) { |
|
103 | + return array_merge((array) $existing_tables, $this->_extra_tables); |
|
104 | 104 | } |
105 | 105 | |
106 | 106 | |
@@ -109,14 +109,14 @@ discard block |
||
109 | 109 | * @param array $existing_fields |
110 | 110 | * @return array |
111 | 111 | */ |
112 | - public function add_extra_fields_on_filter( $existing_fields ){ |
|
113 | - if( $this->_extra_fields){ |
|
114 | - foreach($this->_extra_fields as $table_alias => $fields){ |
|
115 | - if( ! isset( $existing_fields[ $table_alias ] ) ){ |
|
116 | - $existing_fields[ $table_alias ] = array(); |
|
112 | + public function add_extra_fields_on_filter($existing_fields) { |
|
113 | + if ($this->_extra_fields) { |
|
114 | + foreach ($this->_extra_fields as $table_alias => $fields) { |
|
115 | + if ( ! isset($existing_fields[$table_alias])) { |
|
116 | + $existing_fields[$table_alias] = array(); |
|
117 | 117 | } |
118 | 118 | $existing_fields[$table_alias] = array_merge( |
119 | - (array)$existing_fields[$table_alias], |
|
119 | + (array) $existing_fields[$table_alias], |
|
120 | 120 | $this->_extra_fields[$table_alias] |
121 | 121 | ); |
122 | 122 | |
@@ -131,8 +131,8 @@ discard block |
||
131 | 131 | * @param array $existing_relations |
132 | 132 | * @return array |
133 | 133 | */ |
134 | - public function add_extra_relations_on_filter( $existing_relations ){ |
|
135 | - return array_merge((array)$existing_relations,$this->_extra_relations); |
|
134 | + public function add_extra_relations_on_filter($existing_relations) { |
|
135 | + return array_merge((array) $existing_relations, $this->_extra_relations); |
|
136 | 136 | } |
137 | 137 | |
138 | 138 | |
@@ -141,13 +141,13 @@ discard block |
||
141 | 141 | * scans the child of EEME_Base for functions starting with ext_, and magically makes them functions on the |
142 | 142 | * model extended. (Internally uses filters, and the __call magic method) |
143 | 143 | */ |
144 | - protected function _register_extending_methods(){ |
|
144 | + protected function _register_extending_methods() { |
|
145 | 145 | $all_methods = get_class_methods(get_class($this)); |
146 | - foreach($all_methods as $method_name){ |
|
147 | - if(strpos($method_name, self::extending_method_prefix) === 0){ |
|
146 | + foreach ($all_methods as $method_name) { |
|
147 | + if (strpos($method_name, self::extending_method_prefix) === 0) { |
|
148 | 148 | $method_name_on_model = str_replace(self::extending_method_prefix, '', $method_name); |
149 | 149 | $callback_name = "FHEE__EEM_{$this->_model_name_extended}__$method_name_on_model"; |
150 | - add_filter($callback_name,array($this,self::dynamic_callback_method_prefix.$method_name_on_model),10,10); |
|
150 | + add_filter($callback_name, array($this, self::dynamic_callback_method_prefix.$method_name_on_model), 10, 10); |
|
151 | 151 | } |
152 | 152 | } |
153 | 153 | } |
@@ -156,21 +156,21 @@ discard block |
||
156 | 156 | * scans the child of EEME_Base for functions starting with ext_, and magically REMOVES them as functions on the |
157 | 157 | * model extended. (Internally uses filters, and the __call magic method) |
158 | 158 | */ |
159 | - public function deregister(){ |
|
160 | - remove_filter('FHEE__EEM_'.$this->_model_name_extended.'__construct__tables',array($this,'add_extra_tables_on_filter')); |
|
161 | - remove_filter('FHEE__EEM_'.$this->_model_name_extended.'__construct__fields',array($this,'add_extra_fields_on_filter')); |
|
162 | - remove_filter('FHEE__EEM_'.$this->_model_name_extended.'__construct__model_relations',array($this,'add_extra_relations_on_filter')); |
|
159 | + public function deregister() { |
|
160 | + remove_filter('FHEE__EEM_'.$this->_model_name_extended.'__construct__tables', array($this, 'add_extra_tables_on_filter')); |
|
161 | + remove_filter('FHEE__EEM_'.$this->_model_name_extended.'__construct__fields', array($this, 'add_extra_fields_on_filter')); |
|
162 | + remove_filter('FHEE__EEM_'.$this->_model_name_extended.'__construct__model_relations', array($this, 'add_extra_relations_on_filter')); |
|
163 | 163 | $all_methods = get_class_methods(get_class($this)); |
164 | - foreach($all_methods as $method_name){ |
|
165 | - if(strpos($method_name, self::extending_method_prefix) === 0){ |
|
164 | + foreach ($all_methods as $method_name) { |
|
165 | + if (strpos($method_name, self::extending_method_prefix) === 0) { |
|
166 | 166 | $method_name_on_model = str_replace(self::extending_method_prefix, '', $method_name); |
167 | 167 | $callback_name = "FHEE__EEM_{$this->_model_name_extended}__$method_name_on_model"; |
168 | - remove_filter($callback_name,array($this,self::dynamic_callback_method_prefix.$method_name_on_model),10); |
|
168 | + remove_filter($callback_name, array($this, self::dynamic_callback_method_prefix.$method_name_on_model), 10); |
|
169 | 169 | } |
170 | 170 | } |
171 | 171 | /** @var EEM_Base $model_to_reset */ |
172 | - $model_to_reset = 'EEM_' . $this->_model_name_extended; |
|
173 | - if ( class_exists( $model_to_reset ) ) { |
|
172 | + $model_to_reset = 'EEM_'.$this->_model_name_extended; |
|
173 | + if (class_exists($model_to_reset)) { |
|
174 | 174 | $model_to_reset::reset(); |
175 | 175 | } |
176 | 176 | } |
@@ -183,27 +183,27 @@ discard block |
||
183 | 183 | * @return mixed |
184 | 184 | * @throws EE_Error |
185 | 185 | */ |
186 | - public function __call( $callback_method_name, $args){ |
|
187 | - if(strpos($callback_method_name, self::dynamic_callback_method_prefix) === 0){ |
|
186 | + public function __call($callback_method_name, $args) { |
|
187 | + if (strpos($callback_method_name, self::dynamic_callback_method_prefix) === 0) { |
|
188 | 188 | //it's a dynamic callback for a method name |
189 | 189 | $method_called_on_model = str_replace(self::dynamic_callback_method_prefix, '', $callback_method_name); |
190 | - list( $original_return_val, $model_called, $args_provided_to_method_on_model ) = (array) $args; |
|
190 | + list($original_return_val, $model_called, $args_provided_to_method_on_model) = (array) $args; |
|
191 | 191 | $this->_ = $model_called; |
192 | 192 | $extending_method = self::extending_method_prefix.$method_called_on_model; |
193 | - if(method_exists($this, $extending_method)){ |
|
194 | - return call_user_func_array(array($this,$extending_method), $args_provided_to_method_on_model); |
|
195 | - }else{ |
|
193 | + if (method_exists($this, $extending_method)) { |
|
194 | + return call_user_func_array(array($this, $extending_method), $args_provided_to_method_on_model); |
|
195 | + } else { |
|
196 | 196 | throw new EE_Error( |
197 | 197 | sprintf( |
198 | 198 | __("An odd error occurred. Model '%s' had a method called on it that it didn't recognize. So it passed it onto the model extension '%s' (because it had a function named '%s' which should be able to handle it), but the function '%s' doesnt exist!)", "event_espresso"), |
199 | 199 | $this->_model_name_extended, |
200 | 200 | get_class($this), |
201 | - $extending_method,$extending_method |
|
201 | + $extending_method, $extending_method |
|
202 | 202 | ) |
203 | 203 | ); |
204 | 204 | } |
205 | 205 | |
206 | - }else{ |
|
206 | + } else { |
|
207 | 207 | throw new EE_Error( |
208 | 208 | sprintf( |
209 | 209 | __("There is no method named '%s' on '%s'", "event_espresso"), |
@@ -1,7 +1,8 @@ discard block |
||
1 | 1 | <?php |
2 | 2 | |
3 | -if (!defined('EVENT_ESPRESSO_VERSION')) |
|
3 | +if (!defined('EVENT_ESPRESSO_VERSION')) { |
|
4 | 4 | exit('No direct script access allowed'); |
5 | +} |
|
5 | 6 | |
6 | 7 | /** |
7 | 8 | * |
@@ -192,7 +193,7 @@ discard block |
||
192 | 193 | $extending_method = self::extending_method_prefix.$method_called_on_model; |
193 | 194 | if(method_exists($this, $extending_method)){ |
194 | 195 | return call_user_func_array(array($this,$extending_method), $args_provided_to_method_on_model); |
195 | - }else{ |
|
196 | + } else{ |
|
196 | 197 | throw new EE_Error( |
197 | 198 | sprintf( |
198 | 199 | __("An odd error occurred. Model '%s' had a method called on it that it didn't recognize. So it passed it onto the model extension '%s' (because it had a function named '%s' which should be able to handle it), but the function '%s' doesnt exist!)", "event_espresso"), |
@@ -203,7 +204,7 @@ discard block |
||
203 | 204 | ); |
204 | 205 | } |
205 | 206 | |
206 | - }else{ |
|
207 | + } else{ |
|
207 | 208 | throw new EE_Error( |
208 | 209 | sprintf( |
209 | 210 | __("There is no method named '%s' on '%s'", "event_espresso"), |
@@ -1,5 +1,5 @@ |
||
1 | 1 | <p><strong><?php esc_html_e('Message Types', 'event_espresso'); ?></strong></p> |
2 | -<p><?php printf( esc_html__('Messages are email notifications that are sent out by Event Espresso. Message Types are the %1$skinds%2$s of messages that get delivered. They can be thought of as the "type" of package that is being delivered by the messenger. For example, Event Espresso comes with two Message Types attached to the Email Messenger:', 'event_espresso'), '<em>', '</em>'); ?></p> |
|
2 | +<p><?php printf(esc_html__('Messages are email notifications that are sent out by Event Espresso. Message Types are the %1$skinds%2$s of messages that get delivered. They can be thought of as the "type" of package that is being delivered by the messenger. For example, Event Espresso comes with two Message Types attached to the Email Messenger:', 'event_espresso'), '<em>', '</em>'); ?></p> |
|
3 | 3 | <p> |
4 | 4 | <ul> |
5 | 5 | <li> |
@@ -1,4 +1,4 @@ |
||
1 | 1 | <p><strong><?php esc_html_e('Message Templates', 'event_espresso'); ?></strong></p> |
2 | -<p><?php printf( esc_html__('Message Templates are the %1$sformat%2$s of the messages going out. Think of them as a “form letter”. Templates tell the Messages system how to style your messages and the content (information) they will have when they are delivered.', 'event_espresso'), '<em>', '</em>'); ?></p> |
|
2 | +<p><?php printf(esc_html__('Message Templates are the %1$sformat%2$s of the messages going out. Think of them as a “form letter”. Templates tell the Messages system how to style your messages and the content (information) they will have when they are delivered.', 'event_espresso'), '<em>', '</em>'); ?></p> |
|
3 | 3 | <p><?php esc_html_e('There is a template created for each Messenger / Message Type and context combination. For example, messages that are sent for Payment Confirmation have a template for Event Administrator and a different one for Primary Registrant. Whereas, messages that are sent for the Registration confirmation have 3 templates: one for Event Administrator, one for the Primary Registrant, and another for each additional Registrant(s).', 'event_espresso'); ?></p> |
4 | -<p><?php esc_html_e('With the Event Espresso Messages system, every Messenger, Message Type, and context will have a global template created with some default content on creation. You have the ability to edit the global template that will be used for all events you create. Additionally, you have the ability to create custom templates for each event on the edit event page for the event (in a metabox labelled "Notifications").', 'event_espresso' ); ?></p> |
|
5 | 4 | \ No newline at end of file |
5 | +<p><?php esc_html_e('With the Event Espresso Messages system, every Messenger, Message Type, and context will have a global template created with some default content on creation. You have the ability to edit the global template that will be used for all events you create. Additionally, you have the ability to create custom templates for each event on the edit event page for the event (in a metabox labelled "Notifications").', 'event_espresso'); ?></p> |
|
6 | 6 | \ No newline at end of file |
@@ -1,4 +1,4 @@ |
||
1 | 1 | <h2><?php esc_html_e('What are Message Templates', 'event_espresso'); ?></h2> |
2 | -<p><?php printf( esc_html__('Message Templates are the %1$sformat%2$s of the messages going out. Think of them like a “Form letter”. Templates are used to tell the system what you want your messages to look like and the content they will have when they are delivered.', 'event_espresso'), '<em>', '</em>' ); ?></p> |
|
2 | +<p><?php printf(esc_html__('Message Templates are the %1$sformat%2$s of the messages going out. Think of them like a “Form letter”. Templates are used to tell the system what you want your messages to look like and the content they will have when they are delivered.', 'event_espresso'), '<em>', '</em>'); ?></p> |
|
3 | 3 | <p><?php esc_html_e('There is a template created for each messenger/message type AND context combination. So example, Emails that are sent for the Payment confirmation have a template for Event Administrator and a different one for Primary Registrant. Whereas, emails that are sent for the Registration confirmation have 3 templates, one for Event Administrator, Primary Registrant, and Registrant.', 'event_espresso'); ?></p> |
4 | -<p><?php esc_html_e('With the Event Espresso Messages system, every Messenger, Message Type and Context will have a global template created with some default content on creation. You have the ability to edit this global template that will be used for all events you create. However, you also have the ability to create custom templates for each event on the edit event page for the event (in a metabox labelled "Notifications").', 'event_espresso' ); ?></p> |
|
5 | 4 | \ No newline at end of file |
5 | +<p><?php esc_html_e('With the Event Espresso Messages system, every Messenger, Message Type and Context will have a global template created with some default content on creation. You have the ability to edit this global template that will be used for all events you create. However, you also have the ability to create custom templates for each event on the edit event page for the event (in a metabox labelled "Notifications").', 'event_espresso'); ?></p> |
|
6 | 6 | \ No newline at end of file |
@@ -2,29 +2,29 @@ |
||
2 | 2 | <p><?php _e('Here are a few things that you should know about the Message Template Editor:', 'event_espresso'); ?></p> |
3 | 3 | <p><strong><?php esc_html_e('1. The Event Editor Title', 'event_espresso'); ?></strong></p> |
4 | 4 | <p><?php echo $img1; ?></p> |
5 | -<p><?php printf( esc_html__( 'The Event Editor title is very helpful in indicating which template you are currently editing. In the example above, we can see that we are editing the template that for the %1$sEmail%2$s messenger, the %1$sPayment%2$s message type, and the %1$sEvent Admin%2$s context (which for this message type means "recipient").', 'event_espresso'), '<strong>','</strong>' ); ?></p> |
|
5 | +<p><?php printf(esc_html__('The Event Editor title is very helpful in indicating which template you are currently editing. In the example above, we can see that we are editing the template that for the %1$sEmail%2$s messenger, the %1$sPayment%2$s message type, and the %1$sEvent Admin%2$s context (which for this message type means "recipient").', 'event_espresso'), '<strong>', '</strong>'); ?></p> |
|
6 | 6 | <p><strong><?php esc_html_e('2. "Context Switcher" and Preview Button', 'event_espresso'); ?></strong></p> |
7 | 7 | <p><?php echo $img2; ?></p> |
8 | 8 | <p><?php esc_html_e('The context switcher allows you to quickly switch between templates. The current context you are working on is displayed in the dropdown. You can switch to any other template for contexts available to the messenger and message type template group you are working on.', 'event_espresso'); ?></p> |
9 | 9 | <p><?php esc_html_e('Remember that contexts can represent different things. In this example they represent "recipients" and so they are labelled as such. In this example (for email payment confirmations), you may want Event Administrators to receive different information than Primary Registrants (the other context available to edit).', 'event_espresso'); ?></p> |
10 | -<p><?php printf( esc_html__('The %sPreview%s button is simply a link to a special view of the current template displayed to give you an idea of how the actual message will look when delivered. More information on what the preview displays is available in the content of the help tab on the preview page.', 'event_espresso'), '<strong>', '</strong>' ); ?> |
|
10 | +<p><?php printf(esc_html__('The %sPreview%s button is simply a link to a special view of the current template displayed to give you an idea of how the actual message will look when delivered. More information on what the preview displays is available in the content of the help tab on the preview page.', 'event_espresso'), '<strong>', '</strong>'); ?> |
|
11 | 11 | </p> |
12 | 12 | <p><strong><?php esc_html_e('3. Template Form Fields', 'event_espresso'); ?></strong></p> |
13 | 13 | <p><?php echo $img3; ?><?php esc_html_e('The middle area of the page is dedicated to all the fields related to the message template. These fields are dynamic in the sense that different messengers may require different fields (and sometimes different message types will add or subtract fields as well.', 'event_espresso'); ?></p> |
14 | -<p><?php printf( esc_html__('When editing a "Email Payment Template", you will notice that there is a field labelled "Event List" along with "Main Content". The Event List field is a special field that holds the template for whenever the %1$s[EVENT_LIST]%2$s shortcode is used in the "Main Content" field. This is so you can more finely control how each "event" in the event list displays when shown in the Main content. The "Email Registration Template", has an additional field called "Registration List". It functions much the same except that the contents of the "Registration List" field are used to indicate how each registrant is listed in the Main Content when the %1$s[ATTENDEE_LIST]%2$s shortcode is parsed.', 'event_espresso'), '<strong>', '</strong>' ); ?></p> |
|
14 | +<p><?php printf(esc_html__('When editing a "Email Payment Template", you will notice that there is a field labelled "Event List" along with "Main Content". The Event List field is a special field that holds the template for whenever the %1$s[EVENT_LIST]%2$s shortcode is used in the "Main Content" field. This is so you can more finely control how each "event" in the event list displays when shown in the Main content. The "Email Registration Template", has an additional field called "Registration List". It functions much the same except that the contents of the "Registration List" field are used to indicate how each registrant is listed in the Main Content when the %1$s[ATTENDEE_LIST]%2$s shortcode is parsed.', 'event_espresso'), '<strong>', '</strong>'); ?></p> |
|
15 | 15 | <div style="clear:both"></div> |
16 | 16 | <p><strong><?php esc_html_e('4. Valid Shortcodes Metabox', 'event_espresso'); ?></strong></p> |
17 | 17 | <p> |
18 | 18 | <?php echo $img4; ?><?php esc_html_e('The "Valid Shortcodes" metabox contains a list of all the shortcodes that can be used for the displayed template. This list is dynamic and will vary between templates.', 'event_espresso'); ?> |
19 | 19 | </p> |
20 | 20 | <p><?php _e('This box is at a fixed height, but contents are scrollable. You can click the question mark to find out what the given shortcode will parse to when used in your template.', 'event_espresso'); ?></p> |
21 | -<p><?php printf( esc_html__('%sAn important note:%s The system has been designed so that when you save the template, checks will be performed on each field to make sure that only valid shortcodes (or values) are used within them. You will get a warning box with clear instructions if you\'ve tried to use a particular shortcode in a field that does not support it. Also, you\'ll want to try the Preview button if you\'ve made any changes to the template to see if the changes are as you expected!', 'event_espresso'), '<strong>', '</strong>' ); ?> |
|
21 | +<p><?php printf(esc_html__('%sAn important note:%s The system has been designed so that when you save the template, checks will be performed on each field to make sure that only valid shortcodes (or values) are used within them. You will get a warning box with clear instructions if you\'ve tried to use a particular shortcode in a field that does not support it. Also, you\'ll want to try the Preview button if you\'ve made any changes to the template to see if the changes are as you expected!', 'event_espresso'), '<strong>', '</strong>'); ?> |
|
22 | 22 | </p> |
23 | 23 | <div style="clear:both"></div> |
24 | 24 | <p><strong><?php esc_html_e('5. Override All Custom', 'event_espresso'); ?></strong></p> |
25 | 25 | <p> |
26 | 26 | <?php echo $img5; ?> |
27 | - <?php printf( esc_html__( 'When you are editing a template that is a global template (not a custom event template), you\'ll see an option in the Publish metabox in the right column labelled "Override all custom". When this option is selected, custom event templates for that %1$smessenger%2$s, %1$smessage type%2$s, and %1$scontext%2$s will be ignored and the global template will be used. Why would you want to do this? For this given example, you may want to be able to allow custom event templates to be able to modify the looks and content of what goes out to Primary Registrant but to never affect what the Event Administrator receives (as set by the global template).', 'event_espresso'), '<em>', '</em>' ); ?> |
|
27 | + <?php printf(esc_html__('When you are editing a template that is a global template (not a custom event template), you\'ll see an option in the Publish metabox in the right column labelled "Override all custom". When this option is selected, custom event templates for that %1$smessenger%2$s, %1$smessage type%2$s, and %1$scontext%2$s will be ignored and the global template will be used. Why would you want to do this? For this given example, you may want to be able to allow custom event templates to be able to modify the looks and content of what goes out to Primary Registrant but to never affect what the Event Administrator receives (as set by the global template).', 'event_espresso'), '<em>', '</em>'); ?> |
|
28 | 28 | </p> |
29 | 29 | <p> |
30 | 30 | <strong><?php esc_html_e('Recommendations', 'event_espresso'); ?></strong><br /> |
@@ -41,7 +41,7 @@ |
||
41 | 41 | </li> |
42 | 42 | <li> |
43 | 43 | <?php esc_html_e('Messenger', 'event_espresso'); ?><br /> |
44 | - <?php printf( esc_html__('This column displays a number of different elements for the listed template. First is the messenger that this template is delivered by. The messenger title is linked to the editor for the first %1$scontext%2$s listed (context is labelled "recipients" for payment message types)', 'event_espresso'), '<em>', '</em>'); ?><br /> |
|
44 | + <?php printf(esc_html__('This column displays a number of different elements for the listed template. First is the messenger that this template is delivered by. The messenger title is linked to the editor for the first %1$scontext%2$s listed (context is labelled "recipients" for payment message types)', 'event_espresso'), '<em>', '</em>'); ?><br /> |
|
45 | 45 | <?php esc_html_e('Below the Messenger title, is a list of different contexts. The context label varies for each message type but it is usually labelled "Recipients". You can click on each context title to go to the specific template for that context and edit it as desired.', 'event_espresso'); ?> |
46 | 46 | </li> |
47 | 47 | </ul> |
@@ -1,7 +1,7 @@ |
||
1 | 1 | <h2><?php esc_html_e('What are Message Types?', 'event_espresso'); ?></h2> |
2 | -<p><?php printf( esc_html__('Message Types are the %1$skinds%2$s of messages that get delivered. Think of them as the "type" of package that is being delivered by the messenger. For example, Event Espresso comes with two Message Types attached to the Email messenger: Registration Confirmation (which is triggered by frontend event registrations), and Payment Confirmation (which is triggered by frontend payments).', 'event_espresso'), '<em>', '</em>'); ?></p> |
|
2 | +<p><?php printf(esc_html__('Message Types are the %1$skinds%2$s of messages that get delivered. Think of them as the "type" of package that is being delivered by the messenger. For example, Event Espresso comes with two Message Types attached to the Email messenger: Registration Confirmation (which is triggered by frontend event registrations), and Payment Confirmation (which is triggered by frontend payments).', 'event_espresso'), '<em>', '</em>'); ?></p> |
|
3 | 3 | <p><?php esc_html_e('Future iterations of Event Espresso 4.0 (premium versions), will include more and more different message types that can be attached to the various messengers that are available', 'event_espresso'); ?></p> |
4 | 4 | |
5 | 5 | <h3><?php esc_html_e('Contexts', 'event_espresso'); ?></h3> |
6 | -<p><?php printf( esc_html__('Each message type (or %1$skind%1$s of message remember!) has different contexts for messages created for that message type. Contexts are dynamic but generally speaking they tend to represent recipients. So for example, Registration Confirmation message type has three types of recipients for every time a registration confirmation is triggered: Event Administrator, Primary Registrant, and Registrant (which may be multiple messages if there are more than one attendee per event). Whereas the Payment Message Type only has two recipients (Event Administrator, Primary Registrant [the one making the payment]).', 'event_espresso' ), '<em>', '</em>'); ?></p> |
|
6 | +<p><?php printf(esc_html__('Each message type (or %1$skind%1$s of message remember!) has different contexts for messages created for that message type. Contexts are dynamic but generally speaking they tend to represent recipients. So for example, Registration Confirmation message type has three types of recipients for every time a registration confirmation is triggered: Event Administrator, Primary Registrant, and Registrant (which may be multiple messages if there are more than one attendee per event). Whereas the Payment Message Type only has two recipients (Event Administrator, Primary Registrant [the one making the payment]).', 'event_espresso'), '<em>', '</em>'); ?></p> |
|
7 | 7 | <p><?php esc_html_e('You will most likely never see the word "context" in any of the Messages system labelling because they are dynamic per message type. Usually, contexts will be labelled "Recipients" but there may be cases down the road where a message type might use contexts to represent something totally different', 'event_espresso'); ?></p> |
8 | 8 | \ No newline at end of file |