public function _confirm_migration_crash_report_sent() { try { $most_recent_migration = EE_Data_Migration_Manager::instance()->get_last_ran_script(true); } catch (EE_Error $e) { EE_Data_Migration_Manager::instance()->add_error_to_migrations_ran($e->getMessage()); //now, just so we can display the page correctly, make a error migration script stage object //and also put the error on it. It only persists for the duration of this request $most_recent_migration = new EE_DMS_Unknown_1_0_0(); $most_recent_migration->add_error($e->getMessage()); } $success = $this->_req_data['success'] == '1' ? true : false; $this->_template_args['success'] = $success; $this->_template_args['most_recent_migration'] = $most_recent_migration; $this->_template_args['reset_db_action_url'] = EE_Admin_Page::add_query_args_and_nonce(array('action' => 'reset_db'), EE_MAINTENANCE_ADMIN_URL); $this->_template_args['reset_db_page_url'] = EE_Admin_Page::add_query_args_and_nonce(array('action' => 'data_reset'), EE_MAINTENANCE_ADMIN_URL); $this->_template_args['reattempt_action_url'] = EE_Admin_Page::add_query_args_and_nonce(array('action' => 'reattempt_migration'), EE_MAINTENANCE_ADMIN_URL); $this->_template_path = EE_MAINTENANCE_TEMPLATE_PATH . 'ee_confirm_migration_crash_report_sent.template.php'; $this->_template_args['admin_page_content'] = EEH_Template::display_template($this->_template_path, $this->_template_args, TRUE); $this->display_admin_page_with_sidebar(); }
/** * Adds this error string to the data_migrations_ran array, but we dont necessarily know * where to put it, so we just throw it in there... better than nothing... * @param string $error_message * @throws EE_Error */ public function add_error_to_migrations_ran($error_message) { //get last-ran migration script global $wpdb; $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); $last_ran_migration_script_properties = isset($last_migration_script_option['option_value']) ? maybe_unserialize($last_migration_script_option['option_value']) : null; //now, tread lightly because we're here because a FATAL non-catchable error //was thrown last time when we were trying to run a data migration script //so the fatal error could have happened while getting the migration script //or doing running it... $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; //check if it THINKS its a data migration script and especially if it's one that HASN'T finished yet //because if it has finished, then it obviously couldn't be the cause of this error, right? (because its all done) if (isset($last_ran_migration_script_properties['class']) && isset($last_ran_migration_script_properties['_status']) && $last_ran_migration_script_properties['_status'] != self::status_completed) { //ok then just add this error to its list of errors $last_ran_migration_script_properties['_errors'][] = $error_message; $last_ran_migration_script_properties['_status'] = self::status_fatal_error; } else { //so we don't even know which script was last running //use the data migration error stub, which is designed specifically for this type of thing $general_migration_error = new EE_DMS_Unknown_1_0_0(); $general_migration_error->add_error($error_message); $general_migration_error->set_broken(); $last_ran_migration_script_properties = $general_migration_error->properties_as_array(); $versions_migrated_to = 'Unknown.1.0.0'; //now just to make sure appears as last (in case the were previously a fatal error like this) //delete the old one delete_option(self::data_migration_script_option_prefix . $versions_migrated_to); } update_option(self::data_migration_script_option_prefix . $versions_migrated_to, $last_ran_migration_script_properties); }