Completed
Branch foreign-key-alias-objects (c91d1e)
by
unknown
64:06 queued 55:30
created
4_1_0_stages/EE_DMS_4_1_0_category_details.dmsstage.php 1 patch
Indentation   +49 added lines, -49 removed lines patch added patch discarded remove patch
@@ -8,53 +8,53 @@
 block discarded – undo
8 8
  */
9 9
 class EE_DMS_4_1_0_category_details extends EE_Data_Migration_Script_Stage
10 10
 {
11
-    private $_old_table;
12
-    private $_new_table;
13
-    private $_new_term_table;
14
-    public function _migration_step($num_items = 50)
15
-    {
16
-        global $wpdb;
17
-        $start_at_record = $this->count_records_migrated();
18
-        $rows = $wpdb->get_results($wpdb->prepare("SELECT * FROM $this->_old_table LIMIT %d,%d", $start_at_record, $num_items), ARRAY_A);
19
-        $items_actually_migrated = 0;
20
-        foreach ($rows as $category_detail_row) {
21
-            $term_and_taxonomy_ids = wp_insert_term(
22
-                stripslashes($category_detail_row['category_name']),
23
-                'espresso_event_categories',
24
-                array(
25
-                    'description'=>  stripslashes($category_detail_row['category_desc']),
26
-                    'slug'=>$category_detail_row['category_identifier']
27
-                )
28
-            );
29
-            if ($term_and_taxonomy_ids instanceof WP_Error) {
30
-                $this->add_error(sprintf(__("Could not create WP Term_Taxonomy from old category: %s. The Error was: %s", "event_espresso"), $this->_json_encode($category_detail_row), $term_and_taxonomy_ids->get_error_message()));
31
-                $items_actually_migrated++;
32
-                continue;
33
-            }
34
-            $term_id = $term_and_taxonomy_ids['term_id'];
35
-            $term_taxonomy_id = $term_and_taxonomy_ids['term_taxonomy_id'];
36
-            $this->get_migration_script()->set_mapping($this->_old_table, $category_detail_row['id'], $this->_new_term_table, $term_id);
37
-            $this->get_migration_script()->set_mapping($this->_old_table, $category_detail_row['id'], $this->_new_table, $term_taxonomy_id);
38
-            $items_actually_migrated++;
39
-        }
40
-        if ($this->count_records_migrated() + $items_actually_migrated >= $this->count_records_to_migrate()) {
41
-            $this->set_completed();
42
-        }
43
-        return $items_actually_migrated;
44
-    }
45
-    public function _count_records_to_migrate()
46
-    {
47
-        global $wpdb;
48
-        $count = $wpdb->get_var("SELECT COUNT(id) FROM $this->_old_table");
49
-        return $count;
50
-    }
51
-    public function __construct()
52
-    {
53
-        $this->_pretty_name = __("Category Details", "event_espresso");
54
-        global $wpdb;
55
-        $this->_old_table = $wpdb->prefix."events_category_detail";
56
-        $this->_new_table = $wpdb->prefix."term_taxonomy";
57
-        $this->_new_term_table = $wpdb->prefix."terms";
58
-        parent::__construct();
59
-    }
11
+	private $_old_table;
12
+	private $_new_table;
13
+	private $_new_term_table;
14
+	public function _migration_step($num_items = 50)
15
+	{
16
+		global $wpdb;
17
+		$start_at_record = $this->count_records_migrated();
18
+		$rows = $wpdb->get_results($wpdb->prepare("SELECT * FROM $this->_old_table LIMIT %d,%d", $start_at_record, $num_items), ARRAY_A);
19
+		$items_actually_migrated = 0;
20
+		foreach ($rows as $category_detail_row) {
21
+			$term_and_taxonomy_ids = wp_insert_term(
22
+				stripslashes($category_detail_row['category_name']),
23
+				'espresso_event_categories',
24
+				array(
25
+					'description'=>  stripslashes($category_detail_row['category_desc']),
26
+					'slug'=>$category_detail_row['category_identifier']
27
+				)
28
+			);
29
+			if ($term_and_taxonomy_ids instanceof WP_Error) {
30
+				$this->add_error(sprintf(__("Could not create WP Term_Taxonomy from old category: %s. The Error was: %s", "event_espresso"), $this->_json_encode($category_detail_row), $term_and_taxonomy_ids->get_error_message()));
31
+				$items_actually_migrated++;
32
+				continue;
33
+			}
34
+			$term_id = $term_and_taxonomy_ids['term_id'];
35
+			$term_taxonomy_id = $term_and_taxonomy_ids['term_taxonomy_id'];
36
+			$this->get_migration_script()->set_mapping($this->_old_table, $category_detail_row['id'], $this->_new_term_table, $term_id);
37
+			$this->get_migration_script()->set_mapping($this->_old_table, $category_detail_row['id'], $this->_new_table, $term_taxonomy_id);
38
+			$items_actually_migrated++;
39
+		}
40
+		if ($this->count_records_migrated() + $items_actually_migrated >= $this->count_records_to_migrate()) {
41
+			$this->set_completed();
42
+		}
43
+		return $items_actually_migrated;
44
+	}
45
+	public function _count_records_to_migrate()
46
+	{
47
+		global $wpdb;
48
+		$count = $wpdb->get_var("SELECT COUNT(id) FROM $this->_old_table");
49
+		return $count;
50
+	}
51
+	public function __construct()
52
+	{
53
+		$this->_pretty_name = __("Category Details", "event_espresso");
54
+		global $wpdb;
55
+		$this->_old_table = $wpdb->prefix."events_category_detail";
56
+		$this->_new_table = $wpdb->prefix."term_taxonomy";
57
+		$this->_new_term_table = $wpdb->prefix."terms";
58
+		parent::__construct();
59
+	}
60 60
 }
Please login to merge, or discard this patch.
4_1_0_stages/EE_DMS_4_1_0_event_category.dmsstage.php 2 patches
Indentation   +76 added lines, -78 removed lines patch added patch discarded remove patch
@@ -24,87 +24,85 @@
 block discarded – undo
24 24
                 'term_taxonomy_id'=>new EE_Foreign_Key_Int_Field('term_taxonomy_id', __('Term (in context of a taxonomy) ID','event_espresso'), false, 0, 'Term_Taxonomy'),
25 25
                 'term_order'=>new EE_Integer_Field('term_order', __('Term Order','event_espresso'), false, 0)
26 26
             ));
27
-
28
-
29 27
  *
30 28
  */
31 29
 class EE_DMS_4_1_0_event_category extends EE_Data_Migration_Script_Stage
32 30
 {
33
-    private $_old_table;
34
-    private $_new_table;
35
-    public function _migration_step($num_items = 50)
36
-    {
37
-        global $wpdb;
38
-        $start_at_record = $this->count_records_migrated();
39
-        $rows = $wpdb->get_results($wpdb->prepare("SELECT * FROM $this->_old_table LIMIT %d,%d", $start_at_record, $num_items), ARRAY_A);
40
-        $items_actually_migrated = 0;
41
-        foreach ($rows as $event_venue_rel) {
42
-            $term_relation_id = $this->_add_relation_from_event_to_term_taxonomy($event_venue_rel);
43
-            if ($term_relation_id) {
44
-                $this->get_migration_script()->set_mapping($this->_old_table, $event_venue_rel['id'], $this->_new_table, $term_relation_id);
45
-            }
46
-            $items_actually_migrated++;
47
-        }
48
-        if ($this->count_records_migrated() + $items_actually_migrated >= $this->count_records_to_migrate()) {
49
-            $this->set_completed();
50
-        }
51
-        return $items_actually_migrated;
52
-    }
53
-    public function _count_records_to_migrate()
54
-    {
55
-        global $wpdb;
56
-        $count = $wpdb->get_var("SELECT COUNT(id) FROM ".$this->_old_table);
57
-        return $count;
58
-    }
59
-    public function __construct()
60
-    {
61
-        global $wpdb;
62
-        $this->_old_table = $wpdb->prefix."events_category_rel";
63
-        $this->_new_table = $wpdb->prefix."term_relationships";
64
-        $this->_pretty_name = __("Event to Category (4.1 Term Relationships)", "event_espresso");
65
-        parent::__construct();
66
-    }
31
+	private $_old_table;
32
+	private $_new_table;
33
+	public function _migration_step($num_items = 50)
34
+	{
35
+		global $wpdb;
36
+		$start_at_record = $this->count_records_migrated();
37
+		$rows = $wpdb->get_results($wpdb->prepare("SELECT * FROM $this->_old_table LIMIT %d,%d", $start_at_record, $num_items), ARRAY_A);
38
+		$items_actually_migrated = 0;
39
+		foreach ($rows as $event_venue_rel) {
40
+			$term_relation_id = $this->_add_relation_from_event_to_term_taxonomy($event_venue_rel);
41
+			if ($term_relation_id) {
42
+				$this->get_migration_script()->set_mapping($this->_old_table, $event_venue_rel['id'], $this->_new_table, $term_relation_id);
43
+			}
44
+			$items_actually_migrated++;
45
+		}
46
+		if ($this->count_records_migrated() + $items_actually_migrated >= $this->count_records_to_migrate()) {
47
+			$this->set_completed();
48
+		}
49
+		return $items_actually_migrated;
50
+	}
51
+	public function _count_records_to_migrate()
52
+	{
53
+		global $wpdb;
54
+		$count = $wpdb->get_var("SELECT COUNT(id) FROM ".$this->_old_table);
55
+		return $count;
56
+	}
57
+	public function __construct()
58
+	{
59
+		global $wpdb;
60
+		$this->_old_table = $wpdb->prefix."events_category_rel";
61
+		$this->_new_table = $wpdb->prefix."term_relationships";
62
+		$this->_pretty_name = __("Event to Category (4.1 Term Relationships)", "event_espresso");
63
+		parent::__construct();
64
+	}
67 65
 
68
-    /**
69
-     * Attempts to insert a new question group inthe new format given an old one
70
-     * @global type $wpdb
71
-     * @param array $old_event_cat_relation
72
-     * @return int
73
-     */
74
-    private function _add_relation_from_event_to_term_taxonomy($old_event_cat_relation)
75
-    {
76
-        global $wpdb;
77
-        $new_event_id = $this->get_migration_script()->get_mapping_new_pk($wpdb->prefix."events_detail", intval($old_event_cat_relation['event_id']), $wpdb->prefix."posts");
78
-        $new_term_taxonomy_id = $this->get_migration_script()->get_mapping_new_pk($wpdb->prefix."events_category_detail", intval($old_event_cat_relation['cat_id']), $wpdb->prefix."term_taxonomy");
79
-        if (! $new_event_id) {
80
-            $this->add_error(sprintf(__("Could not find 4.1 event id for 3.1 event #%d.", "event_espresso"), $old_event_cat_relation['event_id']));
81
-            return 0;
82
-        }
83
-        if (! $new_term_taxonomy_id) {
84
-            $this->add_error(sprintf(__("Could not find 4.1 term-taxonomy id for 3.1 category #%d.", "event_espresso"), $old_event_cat_relation['cat_id']));
85
-            return 0;
86
-        }
87
-        $cols_n_values = array(
88
-            'object_id'=>$new_event_id,
89
-            'term_taxonomy_id'=>$new_term_taxonomy_id,
90
-            'term_order'=>0
91
-        );
92
-        $datatypes = array(
93
-            '%d',// object_id
94
-            '%d',// term_taxonomy_id
95
-            '%d',// term_order
96
-        );
97
-        $success = $wpdb->insert($this->_new_table, $cols_n_values, $datatypes);
98
-        if (! $success) {
99
-            $this->add_error($this->get_migration_script()->_create_error_message_for_db_insertion($this->_old_table, $old_event_cat_relation, $this->_new_table, $cols_n_values, $datatypes));
100
-            return 0;
101
-        } else {
102
-            // increment the term-taxonomie's count
103
-            $success = $wpdb->query($wpdb->prepare("UPDATE {$wpdb->term_taxonomy} SET count = count +1 WHERE term_taxonomy_id=%d", $new_term_taxonomy_id));
104
-            if (! $success) {
105
-                $this->add_error(sprintf(__('Could not increment term_taxonomy\'s count because %s', 'event_espresso'), $wpdb->last_error));
106
-            }
107
-        }
108
-        return $wpdb->insert_id;
109
-    }
66
+	/**
67
+	 * Attempts to insert a new question group inthe new format given an old one
68
+	 * @global type $wpdb
69
+	 * @param array $old_event_cat_relation
70
+	 * @return int
71
+	 */
72
+	private function _add_relation_from_event_to_term_taxonomy($old_event_cat_relation)
73
+	{
74
+		global $wpdb;
75
+		$new_event_id = $this->get_migration_script()->get_mapping_new_pk($wpdb->prefix."events_detail", intval($old_event_cat_relation['event_id']), $wpdb->prefix."posts");
76
+		$new_term_taxonomy_id = $this->get_migration_script()->get_mapping_new_pk($wpdb->prefix."events_category_detail", intval($old_event_cat_relation['cat_id']), $wpdb->prefix."term_taxonomy");
77
+		if (! $new_event_id) {
78
+			$this->add_error(sprintf(__("Could not find 4.1 event id for 3.1 event #%d.", "event_espresso"), $old_event_cat_relation['event_id']));
79
+			return 0;
80
+		}
81
+		if (! $new_term_taxonomy_id) {
82
+			$this->add_error(sprintf(__("Could not find 4.1 term-taxonomy id for 3.1 category #%d.", "event_espresso"), $old_event_cat_relation['cat_id']));
83
+			return 0;
84
+		}
85
+		$cols_n_values = array(
86
+			'object_id'=>$new_event_id,
87
+			'term_taxonomy_id'=>$new_term_taxonomy_id,
88
+			'term_order'=>0
89
+		);
90
+		$datatypes = array(
91
+			'%d',// object_id
92
+			'%d',// term_taxonomy_id
93
+			'%d',// term_order
94
+		);
95
+		$success = $wpdb->insert($this->_new_table, $cols_n_values, $datatypes);
96
+		if (! $success) {
97
+			$this->add_error($this->get_migration_script()->_create_error_message_for_db_insertion($this->_old_table, $old_event_cat_relation, $this->_new_table, $cols_n_values, $datatypes));
98
+			return 0;
99
+		} else {
100
+			// increment the term-taxonomie's count
101
+			$success = $wpdb->query($wpdb->prepare("UPDATE {$wpdb->term_taxonomy} SET count = count +1 WHERE term_taxonomy_id=%d", $new_term_taxonomy_id));
102
+			if (! $success) {
103
+				$this->add_error(sprintf(__('Could not increment term_taxonomy\'s count because %s', 'event_espresso'), $wpdb->last_error));
104
+			}
105
+		}
106
+		return $wpdb->insert_id;
107
+	}
110 108
 }
Please login to merge, or discard this patch.
Spacing   +7 added lines, -7 removed lines patch added patch discarded remove patch
@@ -76,11 +76,11 @@  discard block
 block discarded – undo
76 76
         global $wpdb;
77 77
         $new_event_id = $this->get_migration_script()->get_mapping_new_pk($wpdb->prefix."events_detail", intval($old_event_cat_relation['event_id']), $wpdb->prefix."posts");
78 78
         $new_term_taxonomy_id = $this->get_migration_script()->get_mapping_new_pk($wpdb->prefix."events_category_detail", intval($old_event_cat_relation['cat_id']), $wpdb->prefix."term_taxonomy");
79
-        if (! $new_event_id) {
79
+        if ( ! $new_event_id) {
80 80
             $this->add_error(sprintf(__("Could not find 4.1 event id for 3.1 event #%d.", "event_espresso"), $old_event_cat_relation['event_id']));
81 81
             return 0;
82 82
         }
83
-        if (! $new_term_taxonomy_id) {
83
+        if ( ! $new_term_taxonomy_id) {
84 84
             $this->add_error(sprintf(__("Could not find 4.1 term-taxonomy id for 3.1 category #%d.", "event_espresso"), $old_event_cat_relation['cat_id']));
85 85
             return 0;
86 86
         }
@@ -90,18 +90,18 @@  discard block
 block discarded – undo
90 90
             'term_order'=>0
91 91
         );
92 92
         $datatypes = array(
93
-            '%d',// object_id
94
-            '%d',// term_taxonomy_id
95
-            '%d',// term_order
93
+            '%d', // object_id
94
+            '%d', // term_taxonomy_id
95
+            '%d', // term_order
96 96
         );
97 97
         $success = $wpdb->insert($this->_new_table, $cols_n_values, $datatypes);
98
-        if (! $success) {
98
+        if ( ! $success) {
99 99
             $this->add_error($this->get_migration_script()->_create_error_message_for_db_insertion($this->_old_table, $old_event_cat_relation, $this->_new_table, $cols_n_values, $datatypes));
100 100
             return 0;
101 101
         } else {
102 102
             // increment the term-taxonomie's count
103 103
             $success = $wpdb->query($wpdb->prepare("UPDATE {$wpdb->term_taxonomy} SET count = count +1 WHERE term_taxonomy_id=%d", $new_term_taxonomy_id));
104
-            if (! $success) {
104
+            if ( ! $success) {
105 105
                 $this->add_error(sprintf(__('Could not increment term_taxonomy\'s count because %s', 'event_espresso'), $wpdb->last_error));
106 106
             }
107 107
         }
Please login to merge, or discard this patch.
4_1_0_stages/EE_DMS_4_1_0_question_groups.dmsstage.php 2 patches
Indentation   +111 added lines, -111 removed lines patch added patch discarded remove patch
@@ -40,119 +40,119 @@
 block discarded – undo
40 40
  */
41 41
 class EE_DMS_4_1_0_question_groups extends EE_Data_Migration_Script_Stage
42 42
 {
43
-    private $_old_table;
44
-    private $_new_table;
45
-    /**
46
-     * Keeps track of whether or not we've already added a system question group,
47
-     * in order to avoid adding more than 1 (basically, in 3.1 this would happen
48
-     * with the Roles & Permissions addon, because each user had their own set of
49
-     * question groups and questions),
50
-     * @var boolean
51
-     */
52
-    private $_already_got_system_question_group_1 = false;
53
-    public function _migration_step($num_items = 50)
54
-    {
43
+	private $_old_table;
44
+	private $_new_table;
45
+	/**
46
+	 * Keeps track of whether or not we've already added a system question group,
47
+	 * in order to avoid adding more than 1 (basically, in 3.1 this would happen
48
+	 * with the Roles & Permissions addon, because each user had their own set of
49
+	 * question groups and questions),
50
+	 * @var boolean
51
+	 */
52
+	private $_already_got_system_question_group_1 = false;
53
+	public function _migration_step($num_items = 50)
54
+	{
55 55
         
56
-        global $wpdb;
57
-        $start_at_record = $this->count_records_migrated();
58
-        $rows = $wpdb->get_results($wpdb->prepare("SELECT * FROM $this->_old_table LIMIT %d,%d", $start_at_record, $num_items), ARRAY_A);
59
-        $items_actually_migrated = 0;
60
-        foreach ($rows as $question_group) {
61
-            $new_id = $this->_insert_new_question_group($question_group);
56
+		global $wpdb;
57
+		$start_at_record = $this->count_records_migrated();
58
+		$rows = $wpdb->get_results($wpdb->prepare("SELECT * FROM $this->_old_table LIMIT %d,%d", $start_at_record, $num_items), ARRAY_A);
59
+		$items_actually_migrated = 0;
60
+		foreach ($rows as $question_group) {
61
+			$new_id = $this->_insert_new_question_group($question_group);
62 62
 
63
-            $this->get_migration_script()->set_mapping($this->_old_table, $question_group['id'], $this->_new_table, $new_id);
64
-            $items_actually_migrated++;
65
-        }
66
-        if ($this->count_records_migrated() + $items_actually_migrated >= $this->count_records_to_migrate()) {
67
-            $this->set_completed();
68
-        }
69
-        return $items_actually_migrated;
70
-    }
71
-    public function _count_records_to_migrate()
72
-    {
73
-        global $wpdb;
74
-        $count = $wpdb->get_var("SELECT COUNT(id) FROM ".$this->_old_table);
75
-        return $count;
76
-    }
77
-    public function __construct()
78
-    {
79
-        global $wpdb;
80
-        $this->_old_table = $wpdb->prefix."events_qst_group";
81
-        $this->_new_table = $wpdb->prefix."esp_question_group";
82
-        $this->_pretty_name = __("Question Groups", "event_espresso");
83
-        parent::__construct();
84
-    }
63
+			$this->get_migration_script()->set_mapping($this->_old_table, $question_group['id'], $this->_new_table, $new_id);
64
+			$items_actually_migrated++;
65
+		}
66
+		if ($this->count_records_migrated() + $items_actually_migrated >= $this->count_records_to_migrate()) {
67
+			$this->set_completed();
68
+		}
69
+		return $items_actually_migrated;
70
+	}
71
+	public function _count_records_to_migrate()
72
+	{
73
+		global $wpdb;
74
+		$count = $wpdb->get_var("SELECT COUNT(id) FROM ".$this->_old_table);
75
+		return $count;
76
+	}
77
+	public function __construct()
78
+	{
79
+		global $wpdb;
80
+		$this->_old_table = $wpdb->prefix."events_qst_group";
81
+		$this->_new_table = $wpdb->prefix."esp_question_group";
82
+		$this->_pretty_name = __("Question Groups", "event_espresso");
83
+		parent::__construct();
84
+	}
85 85
     
86
-    /**
87
-     * Attempts to insert a new question group inthe new format given an old one
88
-     * @global type $wpdb
89
-     * @param array $old_question_group
90
-     * @return int
91
-     */
92
-    private function _insert_new_question_group($old_question_group)
93
-    {
94
-        global $wpdb;
95
-        // try to guess what the QST_system int should be... finding the Personal info system
96
-        // question group is quite easy. But in 3.1 address info WASN'T a system group, it just exitsed by default but
97
-        // could be easily removed.
98
-        if ($old_question_group['system_group'] && ! $this->_already_got_system_question_group_1()) {
99
-            $guess_at_system_number = 1;
100
-        } elseif ($old_question_group['id'] == '2' && strpos($old_question_group['group_name'], 'Address')!==false) {
101
-            $guess_at_system_number = 2;
102
-        } else {
103
-            $guess_at_system_number = 0;
104
-        }
105
-        // if the question group wasn't made by the normal admin,
106
-        // we'd like to keep track of who made it
107
-        if (intval($old_question_group['wp_user'])!=1) {
108
-            $username = $wpdb->get_var($wpdb->prepare("SELECT user_nicename FROM ".$wpdb->users." WHERE ID = %d", $old_question_group['wp_user']));
109
-            $identifier = $old_question_group['group_identifier']."-by-".$username;
110
-        } else {
111
-            $identifier = $old_question_group['group_identifier'];
112
-        }
113
-        $cols_n_values = array(
114
-            'QSG_name'=>stripslashes($old_question_group['group_name']),
115
-            'QSG_identifier'=>$identifier,
116
-            'QSG_desc'=>stripslashes($old_question_group['group_description']),
117
-            'QSG_order'=>$old_question_group['group_order'],
118
-            'QSG_show_group_name'=>$old_question_group['show_group_name'],
119
-            'QSG_show_group_desc'=>$old_question_group['show_group_description'],
120
-            'QSG_system'=>$guess_at_system_number,
121
-            'QSG_deleted'=>false
122
-        );
123
-        $datatypes = array(
124
-            '%s',// QSG_name
125
-            '%s',// QSG_identifier
126
-            '%s',// QSG_desc
127
-            '%d',// QSG_order
128
-            '%d',// QSG_show_group_name
129
-            '%d',// QSG_show_group_desc
130
-            '%d',// QSG_system
131
-            '%d',// QSG_deleted
132
-        );
133
-        $success = $wpdb->insert($this->_new_table, $cols_n_values, $datatypes);
134
-        if (! $success) {
135
-            $this->add_error($this->get_migration_script()->_create_error_message_for_db_insertion($this->_old_table, $old_question_group, $this->_new_table, $cols_n_values, $datatypes));
136
-            return 0;
137
-        }
138
-        return $wpdb->insert_id;
139
-    }
86
+	/**
87
+	 * Attempts to insert a new question group inthe new format given an old one
88
+	 * @global type $wpdb
89
+	 * @param array $old_question_group
90
+	 * @return int
91
+	 */
92
+	private function _insert_new_question_group($old_question_group)
93
+	{
94
+		global $wpdb;
95
+		// try to guess what the QST_system int should be... finding the Personal info system
96
+		// question group is quite easy. But in 3.1 address info WASN'T a system group, it just exitsed by default but
97
+		// could be easily removed.
98
+		if ($old_question_group['system_group'] && ! $this->_already_got_system_question_group_1()) {
99
+			$guess_at_system_number = 1;
100
+		} elseif ($old_question_group['id'] == '2' && strpos($old_question_group['group_name'], 'Address')!==false) {
101
+			$guess_at_system_number = 2;
102
+		} else {
103
+			$guess_at_system_number = 0;
104
+		}
105
+		// if the question group wasn't made by the normal admin,
106
+		// we'd like to keep track of who made it
107
+		if (intval($old_question_group['wp_user'])!=1) {
108
+			$username = $wpdb->get_var($wpdb->prepare("SELECT user_nicename FROM ".$wpdb->users." WHERE ID = %d", $old_question_group['wp_user']));
109
+			$identifier = $old_question_group['group_identifier']."-by-".$username;
110
+		} else {
111
+			$identifier = $old_question_group['group_identifier'];
112
+		}
113
+		$cols_n_values = array(
114
+			'QSG_name'=>stripslashes($old_question_group['group_name']),
115
+			'QSG_identifier'=>$identifier,
116
+			'QSG_desc'=>stripslashes($old_question_group['group_description']),
117
+			'QSG_order'=>$old_question_group['group_order'],
118
+			'QSG_show_group_name'=>$old_question_group['show_group_name'],
119
+			'QSG_show_group_desc'=>$old_question_group['show_group_description'],
120
+			'QSG_system'=>$guess_at_system_number,
121
+			'QSG_deleted'=>false
122
+		);
123
+		$datatypes = array(
124
+			'%s',// QSG_name
125
+			'%s',// QSG_identifier
126
+			'%s',// QSG_desc
127
+			'%d',// QSG_order
128
+			'%d',// QSG_show_group_name
129
+			'%d',// QSG_show_group_desc
130
+			'%d',// QSG_system
131
+			'%d',// QSG_deleted
132
+		);
133
+		$success = $wpdb->insert($this->_new_table, $cols_n_values, $datatypes);
134
+		if (! $success) {
135
+			$this->add_error($this->get_migration_script()->_create_error_message_for_db_insertion($this->_old_table, $old_question_group, $this->_new_table, $cols_n_values, $datatypes));
136
+			return 0;
137
+		}
138
+		return $wpdb->insert_id;
139
+	}
140 140
     
141
-    /**
142
-     * Checks if we've already added a system question 1 to the new question groups table
143
-     * @global type $wpdb
144
-     * @return boolean
145
-     */
146
-    private function _already_got_system_question_group_1()
147
-    {
148
-        if (! $this->_already_got_system_question_group_1) {
149
-            // check the db
150
-            global $wpdb;
151
-            $exists = $wpdb->get_var("SELECT COUNT(*) FROM {$this->_new_table} WHERE QSG_system=1");
152
-            if (intval($exists)>0) {
153
-                $this->_already_got_system_question_group_1 = true;
154
-            }
155
-        }
156
-        return $this->_already_got_system_question_group_1;
157
-    }
141
+	/**
142
+	 * Checks if we've already added a system question 1 to the new question groups table
143
+	 * @global type $wpdb
144
+	 * @return boolean
145
+	 */
146
+	private function _already_got_system_question_group_1()
147
+	{
148
+		if (! $this->_already_got_system_question_group_1) {
149
+			// check the db
150
+			global $wpdb;
151
+			$exists = $wpdb->get_var("SELECT COUNT(*) FROM {$this->_new_table} WHERE QSG_system=1");
152
+			if (intval($exists)>0) {
153
+				$this->_already_got_system_question_group_1 = true;
154
+			}
155
+		}
156
+		return $this->_already_got_system_question_group_1;
157
+	}
158 158
 }
Please login to merge, or discard this patch.
Spacing   +13 added lines, -13 removed lines patch added patch discarded remove patch
@@ -97,14 +97,14 @@  discard block
 block discarded – undo
97 97
         // could be easily removed.
98 98
         if ($old_question_group['system_group'] && ! $this->_already_got_system_question_group_1()) {
99 99
             $guess_at_system_number = 1;
100
-        } elseif ($old_question_group['id'] == '2' && strpos($old_question_group['group_name'], 'Address')!==false) {
100
+        } elseif ($old_question_group['id'] == '2' && strpos($old_question_group['group_name'], 'Address') !== false) {
101 101
             $guess_at_system_number = 2;
102 102
         } else {
103 103
             $guess_at_system_number = 0;
104 104
         }
105 105
         // if the question group wasn't made by the normal admin,
106 106
         // we'd like to keep track of who made it
107
-        if (intval($old_question_group['wp_user'])!=1) {
107
+        if (intval($old_question_group['wp_user']) != 1) {
108 108
             $username = $wpdb->get_var($wpdb->prepare("SELECT user_nicename FROM ".$wpdb->users." WHERE ID = %d", $old_question_group['wp_user']));
109 109
             $identifier = $old_question_group['group_identifier']."-by-".$username;
110 110
         } else {
@@ -121,17 +121,17 @@  discard block
 block discarded – undo
121 121
             'QSG_deleted'=>false
122 122
         );
123 123
         $datatypes = array(
124
-            '%s',// QSG_name
125
-            '%s',// QSG_identifier
126
-            '%s',// QSG_desc
127
-            '%d',// QSG_order
128
-            '%d',// QSG_show_group_name
129
-            '%d',// QSG_show_group_desc
130
-            '%d',// QSG_system
131
-            '%d',// QSG_deleted
124
+            '%s', // QSG_name
125
+            '%s', // QSG_identifier
126
+            '%s', // QSG_desc
127
+            '%d', // QSG_order
128
+            '%d', // QSG_show_group_name
129
+            '%d', // QSG_show_group_desc
130
+            '%d', // QSG_system
131
+            '%d', // QSG_deleted
132 132
         );
133 133
         $success = $wpdb->insert($this->_new_table, $cols_n_values, $datatypes);
134
-        if (! $success) {
134
+        if ( ! $success) {
135 135
             $this->add_error($this->get_migration_script()->_create_error_message_for_db_insertion($this->_old_table, $old_question_group, $this->_new_table, $cols_n_values, $datatypes));
136 136
             return 0;
137 137
         }
@@ -145,11 +145,11 @@  discard block
 block discarded – undo
145 145
      */
146 146
     private function _already_got_system_question_group_1()
147 147
     {
148
-        if (! $this->_already_got_system_question_group_1) {
148
+        if ( ! $this->_already_got_system_question_group_1) {
149 149
             // check the db
150 150
             global $wpdb;
151 151
             $exists = $wpdb->get_var("SELECT COUNT(*) FROM {$this->_new_table} WHERE QSG_system=1");
152
-            if (intval($exists)>0) {
152
+            if (intval($exists) > 0) {
153 153
                 $this->_already_got_system_question_group_1 = true;
154 154
             }
155 155
         }
Please login to merge, or discard this patch.
4_8_0_stages/EE_DMS_4_8_0_event_subtotals.dmsstage.php 2 patches
Indentation   +73 added lines, -73 removed lines patch added patch discarded remove patch
@@ -11,77 +11,77 @@
 block discarded – undo
11 11
  */
12 12
 class EE_DMS_4_8_0_event_subtotals extends EE_Data_Migration_Script_Stage_Table
13 13
 {
14
-    public function __construct()
15
-    {
16
-        global $wpdb;
17
-        $this->_old_table = $wpdb->prefix . 'esp_line_item';
18
-        $this->_extra_where_sql = ' WHERE LIN_type="sub-total" AND LIN_code="pre-tax-subtotal"';
19
-        $this->_pretty_name = __('Event Sub-total line items', 'event_espresso');
20
-        parent::__construct();
21
-    }
22
-    protected function _migrate_old_row($line_item_row)
23
-    {
24
-        global $wpdb;
25
-        // what event is this line item for? this can be found by looking at its transaction's registration's EVT_ID
26
-        $event_id = $wpdb->get_var($wpdb->prepare('SELECT EVT_ID FROM ' . $wpdb->prefix . 'esp_registration WHERE TXN_ID=%d LIMIT 1', $line_item_row['TXN_ID']));
27
-        $new_line_item_data = array(
28
-                    'LIN_code' => 'event-' . $event_id,
29
-                    'TXN_ID' => $line_item_row['TXN_ID'],
30
-                    'LIN_name' => __('Event', 'event_espresso'),
31
-                    'LIN_desc' => $line_item_row['LIN_desc'],
32
-                    'LIN_unit_price' => $line_item_row['LIN_unit_price'],
33
-                    'LIN_percent' => $line_item_row['LIN_percent'],
34
-                    'LIN_is_taxable' => $line_item_row['LIN_is_taxable'],
35
-                    'LIN_order' => $line_item_row['LIN_order'],
36
-                    'LIN_total' => $line_item_row['LIN_total'],
37
-                    'LIN_quantity' => $line_item_row['LIN_quantity'],
38
-                    'LIN_parent' => $line_item_row['LIN_ID'],
39
-                    'LIN_type' => 'sub-total',
40
-                    'OBJ_type' => 'Event',
41
-                    'OBJ_ID' => $event_id,
42
-                );
43
-        $new_line_item_datatypes = array(
44
-                    '%s',// LIN_code
45
-                    '%d',// TXN_ID
46
-                    '%s',// LIN_name
47
-                    '%s',// LIN_desc
48
-                    '%f',// LIN_unit_price
49
-                    '%f',// LIN_percent
50
-                    '%d',// LIN_is_taxable
51
-                    '%d',// LIN_order
52
-                    '%f',// LIN_total
53
-                    '%d',// LIN_quantity
54
-                    '%d',// LIN_parent
55
-                    '%s',// LIN_type
56
-                    '%s',// OBJ_type
57
-                    '%d',// OBJ_ID
58
-                );
59
-        // insert the new event subtotal line item, pointing to this line item
60
-        $success = $wpdb->insert($this->_old_table, $new_line_item_data, $new_line_item_datatypes);
61
-        if (! $success) {
62
-            $this->add_error($this->_create_error_message_for_db_insertion($this->_old_table, $line_item_row, $this->_old_table, $new_line_item_data, $new_line_item_datatypes));
63
-        }
64
-        $new_line_item_id = $wpdb->insert_id;
65
-        $this->get_migration_script()->set_mapping($this->_old_table, $line_item_row['LIN_ID'], $this->_old_table, $new_line_item_id);
66
-        $query = $wpdb->prepare(
67
-            "UPDATE {$this->_old_table} SET LIN_parent=%d WHERE LIN_parent = %d AND LIN_ID != %d LIMIT 100",
68
-            $new_line_item_id,
69
-            $line_item_row['LIN_ID'],
70
-            $new_line_item_id
71
-        );
72
-        $success = $wpdb->query($query);
73
-        if ($success === false) {
74
-            $this->add_error(
75
-                sprintf(
76
-                    __('Error updating rows to new event subtotal %1$s from %2$s. Error was: %3$s, while using query %4$s which had a result of %5$s', 'event_espresso'),
77
-                    $new_line_item_id,
78
-                    $line_item_row['LIN_ID'],
79
-                    $wpdb->last_error,
80
-                    $query,
81
-                    $success
82
-                )
83
-            );
84
-        }
85
-        return 1;
86
-    }
14
+	public function __construct()
15
+	{
16
+		global $wpdb;
17
+		$this->_old_table = $wpdb->prefix . 'esp_line_item';
18
+		$this->_extra_where_sql = ' WHERE LIN_type="sub-total" AND LIN_code="pre-tax-subtotal"';
19
+		$this->_pretty_name = __('Event Sub-total line items', 'event_espresso');
20
+		parent::__construct();
21
+	}
22
+	protected function _migrate_old_row($line_item_row)
23
+	{
24
+		global $wpdb;
25
+		// what event is this line item for? this can be found by looking at its transaction's registration's EVT_ID
26
+		$event_id = $wpdb->get_var($wpdb->prepare('SELECT EVT_ID FROM ' . $wpdb->prefix . 'esp_registration WHERE TXN_ID=%d LIMIT 1', $line_item_row['TXN_ID']));
27
+		$new_line_item_data = array(
28
+					'LIN_code' => 'event-' . $event_id,
29
+					'TXN_ID' => $line_item_row['TXN_ID'],
30
+					'LIN_name' => __('Event', 'event_espresso'),
31
+					'LIN_desc' => $line_item_row['LIN_desc'],
32
+					'LIN_unit_price' => $line_item_row['LIN_unit_price'],
33
+					'LIN_percent' => $line_item_row['LIN_percent'],
34
+					'LIN_is_taxable' => $line_item_row['LIN_is_taxable'],
35
+					'LIN_order' => $line_item_row['LIN_order'],
36
+					'LIN_total' => $line_item_row['LIN_total'],
37
+					'LIN_quantity' => $line_item_row['LIN_quantity'],
38
+					'LIN_parent' => $line_item_row['LIN_ID'],
39
+					'LIN_type' => 'sub-total',
40
+					'OBJ_type' => 'Event',
41
+					'OBJ_ID' => $event_id,
42
+				);
43
+		$new_line_item_datatypes = array(
44
+					'%s',// LIN_code
45
+					'%d',// TXN_ID
46
+					'%s',// LIN_name
47
+					'%s',// LIN_desc
48
+					'%f',// LIN_unit_price
49
+					'%f',// LIN_percent
50
+					'%d',// LIN_is_taxable
51
+					'%d',// LIN_order
52
+					'%f',// LIN_total
53
+					'%d',// LIN_quantity
54
+					'%d',// LIN_parent
55
+					'%s',// LIN_type
56
+					'%s',// OBJ_type
57
+					'%d',// OBJ_ID
58
+				);
59
+		// insert the new event subtotal line item, pointing to this line item
60
+		$success = $wpdb->insert($this->_old_table, $new_line_item_data, $new_line_item_datatypes);
61
+		if (! $success) {
62
+			$this->add_error($this->_create_error_message_for_db_insertion($this->_old_table, $line_item_row, $this->_old_table, $new_line_item_data, $new_line_item_datatypes));
63
+		}
64
+		$new_line_item_id = $wpdb->insert_id;
65
+		$this->get_migration_script()->set_mapping($this->_old_table, $line_item_row['LIN_ID'], $this->_old_table, $new_line_item_id);
66
+		$query = $wpdb->prepare(
67
+			"UPDATE {$this->_old_table} SET LIN_parent=%d WHERE LIN_parent = %d AND LIN_ID != %d LIMIT 100",
68
+			$new_line_item_id,
69
+			$line_item_row['LIN_ID'],
70
+			$new_line_item_id
71
+		);
72
+		$success = $wpdb->query($query);
73
+		if ($success === false) {
74
+			$this->add_error(
75
+				sprintf(
76
+					__('Error updating rows to new event subtotal %1$s from %2$s. Error was: %3$s, while using query %4$s which had a result of %5$s', 'event_espresso'),
77
+					$new_line_item_id,
78
+					$line_item_row['LIN_ID'],
79
+					$wpdb->last_error,
80
+					$query,
81
+					$success
82
+				)
83
+			);
84
+		}
85
+		return 1;
86
+	}
87 87
 }
Please login to merge, or discard this patch.
Spacing   +18 added lines, -18 removed lines patch added patch discarded remove patch
@@ -14,7 +14,7 @@  discard block
 block discarded – undo
14 14
     public function __construct()
15 15
     {
16 16
         global $wpdb;
17
-        $this->_old_table = $wpdb->prefix . 'esp_line_item';
17
+        $this->_old_table = $wpdb->prefix.'esp_line_item';
18 18
         $this->_extra_where_sql = ' WHERE LIN_type="sub-total" AND LIN_code="pre-tax-subtotal"';
19 19
         $this->_pretty_name = __('Event Sub-total line items', 'event_espresso');
20 20
         parent::__construct();
@@ -23,9 +23,9 @@  discard block
 block discarded – undo
23 23
     {
24 24
         global $wpdb;
25 25
         // what event is this line item for? this can be found by looking at its transaction's registration's EVT_ID
26
-        $event_id = $wpdb->get_var($wpdb->prepare('SELECT EVT_ID FROM ' . $wpdb->prefix . 'esp_registration WHERE TXN_ID=%d LIMIT 1', $line_item_row['TXN_ID']));
26
+        $event_id = $wpdb->get_var($wpdb->prepare('SELECT EVT_ID FROM '.$wpdb->prefix.'esp_registration WHERE TXN_ID=%d LIMIT 1', $line_item_row['TXN_ID']));
27 27
         $new_line_item_data = array(
28
-                    'LIN_code' => 'event-' . $event_id,
28
+                    'LIN_code' => 'event-'.$event_id,
29 29
                     'TXN_ID' => $line_item_row['TXN_ID'],
30 30
                     'LIN_name' => __('Event', 'event_espresso'),
31 31
                     'LIN_desc' => $line_item_row['LIN_desc'],
@@ -41,24 +41,24 @@  discard block
 block discarded – undo
41 41
                     'OBJ_ID' => $event_id,
42 42
                 );
43 43
         $new_line_item_datatypes = array(
44
-                    '%s',// LIN_code
45
-                    '%d',// TXN_ID
46
-                    '%s',// LIN_name
47
-                    '%s',// LIN_desc
48
-                    '%f',// LIN_unit_price
49
-                    '%f',// LIN_percent
50
-                    '%d',// LIN_is_taxable
51
-                    '%d',// LIN_order
52
-                    '%f',// LIN_total
53
-                    '%d',// LIN_quantity
54
-                    '%d',// LIN_parent
55
-                    '%s',// LIN_type
56
-                    '%s',// OBJ_type
57
-                    '%d',// OBJ_ID
44
+                    '%s', // LIN_code
45
+                    '%d', // TXN_ID
46
+                    '%s', // LIN_name
47
+                    '%s', // LIN_desc
48
+                    '%f', // LIN_unit_price
49
+                    '%f', // LIN_percent
50
+                    '%d', // LIN_is_taxable
51
+                    '%d', // LIN_order
52
+                    '%f', // LIN_total
53
+                    '%d', // LIN_quantity
54
+                    '%d', // LIN_parent
55
+                    '%s', // LIN_type
56
+                    '%s', // OBJ_type
57
+                    '%d', // OBJ_ID
58 58
                 );
59 59
         // insert the new event subtotal line item, pointing to this line item
60 60
         $success = $wpdb->insert($this->_old_table, $new_line_item_data, $new_line_item_datatypes);
61
-        if (! $success) {
61
+        if ( ! $success) {
62 62
             $this->add_error($this->_create_error_message_for_db_insertion($this->_old_table, $line_item_row, $this->_old_table, $new_line_item_data, $new_line_item_datatypes));
63 63
         }
64 64
         $new_line_item_id = $wpdb->insert_id;
Please login to merge, or discard this patch.
data_migration_scripts/4_8_0_stages/EE_DMS_4_8_0_pretax_totals.dmsstage.php 2 patches
Indentation   +41 added lines, -41 removed lines patch added patch discarded remove patch
@@ -13,53 +13,53 @@
 block discarded – undo
13 13
 class EE_DMS_4_8_0_pretax_totals extends EE_Data_Migration_Script_Stage
14 14
 {
15 15
 
16
-    protected $_line_item_table_name;
16
+	protected $_line_item_table_name;
17 17
 
18 18
 
19
-    /**
20
-     * Just initializes the status of the migration
21
-     */
22
-    public function __construct()
23
-    {
24
-        global $wpdb;
25
-        $this->_line_item_table_name = $wpdb->prefix."esp_line_item";
26
-        $this->_pretty_name = __('Pre-tax total line items', 'event_espresso');
27
-        parent::__construct();
28
-    }
19
+	/**
20
+	 * Just initializes the status of the migration
21
+	 */
22
+	public function __construct()
23
+	{
24
+		global $wpdb;
25
+		$this->_line_item_table_name = $wpdb->prefix."esp_line_item";
26
+		$this->_pretty_name = __('Pre-tax total line items', 'event_espresso');
27
+		parent::__construct();
28
+	}
29 29
 
30 30
 
31 31
 
32
-    /**
33
-     * Counts the records to migrate; the public version may cache it
34
-     * @return int
35
-     */
36
-    protected function _count_records_to_migrate()
37
-    {
38
-        return 1;
39
-    }
32
+	/**
33
+	 * Counts the records to migrate; the public version may cache it
34
+	 * @return int
35
+	 */
36
+	protected function _count_records_to_migrate()
37
+	{
38
+		return 1;
39
+	}
40 40
 
41 41
 
42 42
 
43
-    /**
44
-     * IMPORTANT: if an error is encountered, or everything is finished, this stage should update its status property accordingly.
45
-     * Note: it should not alter the count of items migrated. That is done in the public function that calls this.
46
-     * IMPORTANT: The count of items migrated should ONLY be less than $num_items_to_migrate when it's the last migration step, otherwise it
47
-     * should always return $num_items_to_migrate. (Eg, if we're migrating attendees rows from the database, and $num_items_to_migrate is set to 50,
48
-     * then we SHOULD actually migrate 50 rows,but at very least we MUST report/return 50 items migrated)
49
-     * @param int $num_items_to_migrate
50
-     * @return int number of items ACTUALLY migrated
51
-     */
52
-    protected function _migration_step($num_items_to_migrate = 50)
53
-    {
54
-        global $wpdb;
55
-        $rows_updated = $wpdb->update(
56
-            $this->_line_item_table_name,
57
-            array( 'LIN_code' => 'pre-tax-subtotal' ),
58
-            array( 'LIN_code' => 'tickets' ),
59
-            array( '%s' ),
60
-            array( '%s' )
61
-        );
62
-        $this->set_completed();
63
-        return 1;
64
-    }
43
+	/**
44
+	 * IMPORTANT: if an error is encountered, or everything is finished, this stage should update its status property accordingly.
45
+	 * Note: it should not alter the count of items migrated. That is done in the public function that calls this.
46
+	 * IMPORTANT: The count of items migrated should ONLY be less than $num_items_to_migrate when it's the last migration step, otherwise it
47
+	 * should always return $num_items_to_migrate. (Eg, if we're migrating attendees rows from the database, and $num_items_to_migrate is set to 50,
48
+	 * then we SHOULD actually migrate 50 rows,but at very least we MUST report/return 50 items migrated)
49
+	 * @param int $num_items_to_migrate
50
+	 * @return int number of items ACTUALLY migrated
51
+	 */
52
+	protected function _migration_step($num_items_to_migrate = 50)
53
+	{
54
+		global $wpdb;
55
+		$rows_updated = $wpdb->update(
56
+			$this->_line_item_table_name,
57
+			array( 'LIN_code' => 'pre-tax-subtotal' ),
58
+			array( 'LIN_code' => 'tickets' ),
59
+			array( '%s' ),
60
+			array( '%s' )
61
+		);
62
+		$this->set_completed();
63
+		return 1;
64
+	}
65 65
 }
Please login to merge, or discard this patch.
Spacing   +4 added lines, -4 removed lines patch added patch discarded remove patch
@@ -54,10 +54,10 @@
 block discarded – undo
54 54
         global $wpdb;
55 55
         $rows_updated = $wpdb->update(
56 56
             $this->_line_item_table_name,
57
-            array( 'LIN_code' => 'pre-tax-subtotal' ),
58
-            array( 'LIN_code' => 'tickets' ),
59
-            array( '%s' ),
60
-            array( '%s' )
57
+            array('LIN_code' => 'pre-tax-subtotal'),
58
+            array('LIN_code' => 'tickets'),
59
+            array('%s'),
60
+            array('%s')
61 61
         );
62 62
         $this->set_completed();
63 63
         return 1;
Please login to merge, or discard this patch.
4_2_0_stages/EE_DMS_4_2_0_datetime_fields.dmsstage.php 2 patches
Indentation   +43 added lines, -43 removed lines patch added patch discarded remove patch
@@ -8,49 +8,49 @@
 block discarded – undo
8 8
 
9 9
 class EE_DMS_4_2_0_datetime_fields extends EE_Data_Migration_Script_Stage_Table
10 10
 {
11
-    public function __construct()
12
-    {
13
-        global $wpdb;
14
-        $this->_pretty_name = __("Datetime Fields", "event_espresso");
15
-        $this->_old_table = $wpdb->prefix . "esp_datetime";
16
-        parent::__construct();
17
-    }
11
+	public function __construct()
12
+	{
13
+		global $wpdb;
14
+		$this->_pretty_name = __("Datetime Fields", "event_espresso");
15
+		$this->_old_table = $wpdb->prefix . "esp_datetime";
16
+		parent::__construct();
17
+	}
18 18
 
19
-    protected function _migrate_old_row($old_row)
20
-    {
21
-        // foreach question_group_question entry with this QST_ID, we want to set its
22
-        // QSG_order equal to this question's QST_order
23
-        global $wpdb;
19
+	protected function _migrate_old_row($old_row)
20
+	{
21
+		// foreach question_group_question entry with this QST_ID, we want to set its
22
+		// QSG_order equal to this question's QST_order
23
+		global $wpdb;
24 24
 
25
-        $updated = $wpdb->update(
26
-            $this->_old_table,
27
-            array(
28
-                'DTT_name' => '',
29
-                'DTT_description' => '',
30
-            ),
31
-            array(
32
-                'DTT_ID' => $old_row['DTT_ID'],
33
-            ),
34
-            array(
35
-                '%s',// DTT_name,
36
-                '%s',// DTT_description
37
-            ),
38
-            array(
39
-                '%d',// DTT_ID
40
-            )
41
-        );
42
-        if (false === $updated) {
43
-            $this->add_error(
44
-                sprintf(
45
-                    __(
46
-                        "Error in updating table %s setting DTT_name = '' and DTT_description = '' where DTT_ID = %d",
47
-                        'event_espresso'
48
-                    ),
49
-                    $this->_old_table,
50
-                    $old_row['QST_ID']
51
-                )
52
-            );
53
-        }
54
-        // nothing to map really
55
-    }
25
+		$updated = $wpdb->update(
26
+			$this->_old_table,
27
+			array(
28
+				'DTT_name' => '',
29
+				'DTT_description' => '',
30
+			),
31
+			array(
32
+				'DTT_ID' => $old_row['DTT_ID'],
33
+			),
34
+			array(
35
+				'%s',// DTT_name,
36
+				'%s',// DTT_description
37
+			),
38
+			array(
39
+				'%d',// DTT_ID
40
+			)
41
+		);
42
+		if (false === $updated) {
43
+			$this->add_error(
44
+				sprintf(
45
+					__(
46
+						"Error in updating table %s setting DTT_name = '' and DTT_description = '' where DTT_ID = %d",
47
+						'event_espresso'
48
+					),
49
+					$this->_old_table,
50
+					$old_row['QST_ID']
51
+				)
52
+			);
53
+		}
54
+		// nothing to map really
55
+	}
56 56
 }
Please login to merge, or discard this patch.
Spacing   +4 added lines, -4 removed lines patch added patch discarded remove patch
@@ -12,7 +12,7 @@  discard block
 block discarded – undo
12 12
     {
13 13
         global $wpdb;
14 14
         $this->_pretty_name = __("Datetime Fields", "event_espresso");
15
-        $this->_old_table = $wpdb->prefix . "esp_datetime";
15
+        $this->_old_table = $wpdb->prefix."esp_datetime";
16 16
         parent::__construct();
17 17
     }
18 18
 
@@ -32,11 +32,11 @@  discard block
 block discarded – undo
32 32
                 'DTT_ID' => $old_row['DTT_ID'],
33 33
             ),
34 34
             array(
35
-                '%s',// DTT_name,
36
-                '%s',// DTT_description
35
+                '%s', // DTT_name,
36
+                '%s', // DTT_description
37 37
             ),
38 38
             array(
39
-                '%d',// DTT_ID
39
+                '%d', // DTT_ID
40 40
             )
41 41
         );
42 42
         if (false === $updated) {
Please login to merge, or discard this patch.
4_2_0_stages/EE_DMS_4_2_0_question_group_questions.dmsstage.php 2 patches
Indentation   +38 added lines, -38 removed lines patch added patch discarded remove patch
@@ -6,42 +6,42 @@
 block discarded – undo
6 6
 
7 7
 class EE_DMS_4_2_0_question_group_questions extends EE_Data_Migration_Script_Stage_Table
8 8
 {
9
-    private $_qgq_table;
10
-    public function __construct()
11
-    {
12
-        global $wpdb;
13
-        $this->_pretty_name = __("Question Group Questions", "event_espresso");
14
-        $this->_old_table = $wpdb->prefix."esp_question";
15
-        $this->_qgq_table = $wpdb->prefix."esp_question_group_question";
16
-        parent::__construct();
17
-    }
18
-    protected function _migrate_old_row($old_row)
19
-    {
20
-        // foreach question_group_question entry with this QST_ID, we want to set its
21
-        // QSG_order equal to this question's QST_order
22
-        global $wpdb;
23
-        $updated = $wpdb->update(
24
-            $this->_qgq_table,
25
-            array('QGQ_order'=>$old_row['QST_order']),
26
-            array('QST_ID'=>$old_row['QST_ID']),
27
-            array('%d',// QGQ_order
28
-                    ),
29
-            array('%d',// QST_ID
30
-                    )
31
-        );
32
-        if (false === $updated) {
33
-            $this->add_error(
34
-                sprintf(
35
-                    __(
36
-                        "Error in updating table %s setting QGQ_order = %d where QST_ID = %d",
37
-                        'event_espresso'
38
-                    ),
39
-                    $this->_qgq_table,
40
-                    $old_row['QST_order'],
41
-                    $old_row['QST_ID']
42
-                )
43
-            );
44
-        }
45
-        // nothing to map really
46
-    }
9
+	private $_qgq_table;
10
+	public function __construct()
11
+	{
12
+		global $wpdb;
13
+		$this->_pretty_name = __("Question Group Questions", "event_espresso");
14
+		$this->_old_table = $wpdb->prefix."esp_question";
15
+		$this->_qgq_table = $wpdb->prefix."esp_question_group_question";
16
+		parent::__construct();
17
+	}
18
+	protected function _migrate_old_row($old_row)
19
+	{
20
+		// foreach question_group_question entry with this QST_ID, we want to set its
21
+		// QSG_order equal to this question's QST_order
22
+		global $wpdb;
23
+		$updated = $wpdb->update(
24
+			$this->_qgq_table,
25
+			array('QGQ_order'=>$old_row['QST_order']),
26
+			array('QST_ID'=>$old_row['QST_ID']),
27
+			array('%d',// QGQ_order
28
+					),
29
+			array('%d',// QST_ID
30
+					)
31
+		);
32
+		if (false === $updated) {
33
+			$this->add_error(
34
+				sprintf(
35
+					__(
36
+						"Error in updating table %s setting QGQ_order = %d where QST_ID = %d",
37
+						'event_espresso'
38
+					),
39
+					$this->_qgq_table,
40
+					$old_row['QST_order'],
41
+					$old_row['QST_ID']
42
+				)
43
+			);
44
+		}
45
+		// nothing to map really
46
+	}
47 47
 }
Please login to merge, or discard this patch.
Spacing   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -24,9 +24,9 @@
 block discarded – undo
24 24
             $this->_qgq_table,
25 25
             array('QGQ_order'=>$old_row['QST_order']),
26 26
             array('QST_ID'=>$old_row['QST_ID']),
27
-            array('%d',// QGQ_order
27
+            array('%d', // QGQ_order
28 28
                     ),
29
-            array('%d',// QST_ID
29
+            array('%d', // QST_ID
30 30
                     )
31 31
         );
32 32
         if (false === $updated) {
Please login to merge, or discard this patch.
core/data_migration_scripts/EE_Data_Migration_Script_Stage.core.php 1 patch
Indentation   +90 added lines, -90 removed lines patch added patch discarded remove patch
@@ -37,103 +37,103 @@
 block discarded – undo
37 37
  */
38 38
 abstract class EE_Data_Migration_Script_Stage extends EE_Data_Migration_Class_Base
39 39
 {
40
-    /**
41
-     * The migration script this is a stage of
42
-     *
43
-     * @var EE_Data_Migration_Script_Base
44
-     */
45
-    protected $_migration_script;
40
+	/**
41
+	 * The migration script this is a stage of
42
+	 *
43
+	 * @var EE_Data_Migration_Script_Base
44
+	 */
45
+	protected $_migration_script;
46 46
 
47
-    /**
48
-     * This should eb called to essentially 'finalize' construction of the stage.
49
-     * This isn't done on the main constructor in order to avoid repetitive code. Instead, this is
50
-     * called by EE_Data_Migration_Script_Base's __construct() method so children don't have to
51
-     *
52
-     * @param EE_Data_Migration_Script_Base $migration_script
53
-     */
54
-    public function _construct_finalize($migration_script)
55
-    {
56
-        $this->_migration_script = $migration_script;
57
-    }
47
+	/**
48
+	 * This should eb called to essentially 'finalize' construction of the stage.
49
+	 * This isn't done on the main constructor in order to avoid repetitive code. Instead, this is
50
+	 * called by EE_Data_Migration_Script_Base's __construct() method so children don't have to
51
+	 *
52
+	 * @param EE_Data_Migration_Script_Base $migration_script
53
+	 */
54
+	public function _construct_finalize($migration_script)
55
+	{
56
+		$this->_migration_script = $migration_script;
57
+	}
58 58
 
59
-    /**
60
-     * Migrates X old records to the new format. If a fatal error is encountered it is NOT caught here,
61
-     * but is propagated upwards for catching. So basically, the _migration_step() function implemented by children
62
-     * needs to catch exceptions and decide what's a fatal error and what isn't.
63
-     *
64
-     * @param int $num_items_to_migrate
65
-     * @return int
66
-     */
67
-    public function migration_step($num_items_to_migrate = 50)
68
-    {
69
-        // before we run the migration step, we want ot take note of warnings that get outputted
70
-        ob_start();
71
-        $items_migrated = $this->_migration_step($num_items_to_migrate);
72
-        $output = ob_get_contents();
73
-        ob_end_clean();
74
-        if ($output) {
75
-            $this->add_error($output);
76
-        }
77
-        $this->_records_migrated += $items_migrated;
78
-        return $items_migrated;
79
-    }
59
+	/**
60
+	 * Migrates X old records to the new format. If a fatal error is encountered it is NOT caught here,
61
+	 * but is propagated upwards for catching. So basically, the _migration_step() function implemented by children
62
+	 * needs to catch exceptions and decide what's a fatal error and what isn't.
63
+	 *
64
+	 * @param int $num_items_to_migrate
65
+	 * @return int
66
+	 */
67
+	public function migration_step($num_items_to_migrate = 50)
68
+	{
69
+		// before we run the migration step, we want ot take note of warnings that get outputted
70
+		ob_start();
71
+		$items_migrated = $this->_migration_step($num_items_to_migrate);
72
+		$output = ob_get_contents();
73
+		ob_end_clean();
74
+		if ($output) {
75
+			$this->add_error($output);
76
+		}
77
+		$this->_records_migrated += $items_migrated;
78
+		return $items_migrated;
79
+	}
80 80
 
81 81
 
82
-    /**
83
-     * IMPORTANT: if an error is encountered, or everything is finished, this stage should update its status property
84
-     * accordingly. Note: it should not alter the count of items migrated. That is done in the public function that
85
-     * calls this. IMPORTANT: The count of items migrated should ONLY be less than $num_items_to_migrate when it's the
86
-     * last migration step, otherwise it should always return $num_items_to_migrate. (Eg, if we're migrating attendees
87
-     * rows from the database, and $num_items_to_migrate is set to 50, then we SHOULD actually migrate 50 rows,but at
88
-     * very least we MUST report/return 50 items migrated)
89
-     *
90
-     * @param int $num_items_to_migrate
91
-     * @return int number of items ACTUALLY migrated
92
-     */
93
-    abstract protected function _migration_step($num_items_to_migrate = 50);
82
+	/**
83
+	 * IMPORTANT: if an error is encountered, or everything is finished, this stage should update its status property
84
+	 * accordingly. Note: it should not alter the count of items migrated. That is done in the public function that
85
+	 * calls this. IMPORTANT: The count of items migrated should ONLY be less than $num_items_to_migrate when it's the
86
+	 * last migration step, otherwise it should always return $num_items_to_migrate. (Eg, if we're migrating attendees
87
+	 * rows from the database, and $num_items_to_migrate is set to 50, then we SHOULD actually migrate 50 rows,but at
88
+	 * very least we MUST report/return 50 items migrated)
89
+	 *
90
+	 * @param int $num_items_to_migrate
91
+	 * @return int number of items ACTUALLY migrated
92
+	 */
93
+	abstract protected function _migration_step($num_items_to_migrate = 50);
94 94
 
95
-    /**
96
-     * Counts the records that have been migrated so far
97
-     *
98
-     * @return int
99
-     */
100
-    public function count_records_migrated()
101
-    {
102
-        return $this->_records_migrated;
103
-    }
95
+	/**
96
+	 * Counts the records that have been migrated so far
97
+	 *
98
+	 * @return int
99
+	 */
100
+	public function count_records_migrated()
101
+	{
102
+		return $this->_records_migrated;
103
+	}
104 104
 
105
-    /**
106
-     * returns an array of strings describing errors
107
-     *
108
-     * @return array
109
-     */
110
-    public function get_errors()
111
-    {
112
-        return $this->_errors;
113
-    }
105
+	/**
106
+	 * returns an array of strings describing errors
107
+	 *
108
+	 * @return array
109
+	 */
110
+	public function get_errors()
111
+	{
112
+		return $this->_errors;
113
+	}
114 114
 
115 115
 
116
-    /**
117
-     * Sets all of the properties of this script stage to match what's in the array, which is assumed
118
-     * to have been made from the properties_as_array() function.
119
-     *
120
-     * @param array $array_of_properties like what's produced from properties_as_array() method
121
-     */
122
-    public function instantiate_from_array_of_properties($array_of_properties)
123
-    {
124
-        unset($array_of_properties['class']);
125
-        foreach ($array_of_properties as $property_name => $property_value) {
126
-            $this->{$property_name} = $property_value;
127
-        }
128
-    }
116
+	/**
117
+	 * Sets all of the properties of this script stage to match what's in the array, which is assumed
118
+	 * to have been made from the properties_as_array() function.
119
+	 *
120
+	 * @param array $array_of_properties like what's produced from properties_as_array() method
121
+	 */
122
+	public function instantiate_from_array_of_properties($array_of_properties)
123
+	{
124
+		unset($array_of_properties['class']);
125
+		foreach ($array_of_properties as $property_name => $property_value) {
126
+			$this->{$property_name} = $property_value;
127
+		}
128
+	}
129 129
 
130
-    /**
131
-     * Gets the script this is a stage of
132
-     *
133
-     * @return EE_Data_Migration_Script_Base
134
-     */
135
-    protected function get_migration_script()
136
-    {
137
-        return $this->_migration_script;
138
-    }
130
+	/**
131
+	 * Gets the script this is a stage of
132
+	 *
133
+	 * @return EE_Data_Migration_Script_Base
134
+	 */
135
+	protected function get_migration_script()
136
+	{
137
+		return $this->_migration_script;
138
+	}
139 139
 }
Please login to merge, or discard this patch.
4_3_0_stages/EE_DMS_4_3_0_event_message_templates.dmsstage.php 2 patches
Indentation   +46 added lines, -46 removed lines patch added patch discarded remove patch
@@ -13,59 +13,59 @@
 block discarded – undo
13 13
 class EE_DMS_4_3_0_event_message_templates extends EE_Data_Migration_Script_Stage_Table
14 14
 {
15 15
 
16
-    /**
17
-     * This property will hold the table name for event_message_templates
18
-     * @var string
19
-     */
20
-    private $_emt_table;
16
+	/**
17
+	 * This property will hold the table name for event_message_templates
18
+	 * @var string
19
+	 */
20
+	private $_emt_table;
21 21
 
22 22
 
23
-    public function __construct()
24
-    {
25
-        global $wpdb;
26
-        $this->_pretty_name = __('Event Message Templates', 'event_espresso');
27
-        $this->_old_table = $wpdb->prefix."esp_message_template_group";
28
-        $this->_emt_table = $wpdb->prefix."esp_event_message_template";
29
-        parent::__construct();
30
-    }
23
+	public function __construct()
24
+	{
25
+		global $wpdb;
26
+		$this->_pretty_name = __('Event Message Templates', 'event_espresso');
27
+		$this->_old_table = $wpdb->prefix."esp_message_template_group";
28
+		$this->_emt_table = $wpdb->prefix."esp_event_message_template";
29
+		parent::__construct();
30
+	}
31 31
 
32 32
 
33 33
 
34
-    protected function _migrate_old_row($old_row)
35
-    {
36
-        // foreach row that has an evt_id ..let's create an equivalent entry in the new event_messages_template table to link the message template to the event (since EVT_ID is no longer referenced in esp_message_template_groups )
37
-        global $wpdb;
38
-        if ($old_row['EVT_ID'] > 0) {
39
-                                    // let's get the EVT for this id so we can update the custom name on the old row.
40
-                                    $event_name = 'Custom Template for ' . $wpdb->get_var($wpdb->prepare("SELECT post_title from $wpdb->posts WHERE ID = %d", absint($old_row['EVT_ID'])));
34
+	protected function _migrate_old_row($old_row)
35
+	{
36
+		// foreach row that has an evt_id ..let's create an equivalent entry in the new event_messages_template table to link the message template to the event (since EVT_ID is no longer referenced in esp_message_template_groups )
37
+		global $wpdb;
38
+		if ($old_row['EVT_ID'] > 0) {
39
+									// let's get the EVT for this id so we can update the custom name on the old row.
40
+									$event_name = 'Custom Template for ' . $wpdb->get_var($wpdb->prepare("SELECT post_title from $wpdb->posts WHERE ID = %d", absint($old_row['EVT_ID'])));
41 41
 
42
-                                    // update name
43
-                                    $updated = $wpdb->update(
44
-                                        $this->_old_table,
45
-                                        array(
46
-                                            'MTP_name' =>$event_name
47
-                                            ),
48
-                                        array( 'GRP_ID' => (int) $old_row['GRP_ID'] ),
49
-                                        array( '%s' ),
50
-                                        array( '%d' )
51
-                                    );
42
+									// update name
43
+									$updated = $wpdb->update(
44
+										$this->_old_table,
45
+										array(
46
+											'MTP_name' =>$event_name
47
+											),
48
+										array( 'GRP_ID' => (int) $old_row['GRP_ID'] ),
49
+										array( '%s' ),
50
+										array( '%d' )
51
+									);
52 52
 
53
-            $inserted = $wpdb->insert(
54
-                $this->_emt_table,
55
-                array(
56
-                    'EVT_ID' => (int) $old_row['EVT_ID'],
57
-                    'GRP_ID' => (int) $old_row['GRP_ID'],
58
-                    ),
59
-                array( '%d', '%d' )
60
-            );
53
+			$inserted = $wpdb->insert(
54
+				$this->_emt_table,
55
+				array(
56
+					'EVT_ID' => (int) $old_row['EVT_ID'],
57
+					'GRP_ID' => (int) $old_row['GRP_ID'],
58
+					),
59
+				array( '%d', '%d' )
60
+			);
61 61
 
62
-            if (false === $updated) {
63
-                $this->add_error(sprintf(__("Error in updating the row in %s setting 'MTP_name = %s", 'event_espresso'), $this->_old_table, $event_name));
64
-            }
62
+			if (false === $updated) {
63
+				$this->add_error(sprintf(__("Error in updating the row in %s setting 'MTP_name = %s", 'event_espresso'), $this->_old_table, $event_name));
64
+			}
65 65
 
66
-            if (false === $inserted) {
67
-                $this->add_error(sprintf(__("Error in inserting a row into  setting EVT_ID = %d and GRP_ID = %d", "event_espresso"), $this->_emt_table, $old_row['EVT_ID'], $old_row['GRP_ID']));
68
-            }
69
-        }
70
-    }
66
+			if (false === $inserted) {
67
+				$this->add_error(sprintf(__("Error in inserting a row into  setting EVT_ID = %d and GRP_ID = %d", "event_espresso"), $this->_emt_table, $old_row['EVT_ID'], $old_row['GRP_ID']));
68
+			}
69
+		}
70
+	}
71 71
 }
Please login to merge, or discard this patch.
Spacing   +5 added lines, -5 removed lines patch added patch discarded remove patch
@@ -37,7 +37,7 @@  discard block
 block discarded – undo
37 37
         global $wpdb;
38 38
         if ($old_row['EVT_ID'] > 0) {
39 39
                                     // let's get the EVT for this id so we can update the custom name on the old row.
40
-                                    $event_name = 'Custom Template for ' . $wpdb->get_var($wpdb->prepare("SELECT post_title from $wpdb->posts WHERE ID = %d", absint($old_row['EVT_ID'])));
40
+                                    $event_name = 'Custom Template for '.$wpdb->get_var($wpdb->prepare("SELECT post_title from $wpdb->posts WHERE ID = %d", absint($old_row['EVT_ID'])));
41 41
 
42 42
                                     // update name
43 43
                                     $updated = $wpdb->update(
@@ -45,9 +45,9 @@  discard block
 block discarded – undo
45 45
                                         array(
46 46
                                             'MTP_name' =>$event_name
47 47
                                             ),
48
-                                        array( 'GRP_ID' => (int) $old_row['GRP_ID'] ),
49
-                                        array( '%s' ),
50
-                                        array( '%d' )
48
+                                        array('GRP_ID' => (int) $old_row['GRP_ID']),
49
+                                        array('%s'),
50
+                                        array('%d')
51 51
                                     );
52 52
 
53 53
             $inserted = $wpdb->insert(
@@ -56,7 +56,7 @@  discard block
 block discarded – undo
56 56
                     'EVT_ID' => (int) $old_row['EVT_ID'],
57 57
                     'GRP_ID' => (int) $old_row['GRP_ID'],
58 58
                     ),
59
-                array( '%d', '%d' )
59
+                array('%d', '%d')
60 60
             );
61 61
 
62 62
             if (false === $updated) {
Please login to merge, or discard this patch.