@@ -30,7 +30,7 @@ discard block |
||
30 | 30 | $email_address, |
31 | 31 | $this->getAtIndex($email_address) |
32 | 32 | ); |
33 | - if (! checkdnsrr($domain, 'MX')) { |
|
33 | + if ( ! checkdnsrr($domain, 'MX')) { |
|
34 | 34 | // domain not found in MX records |
35 | 35 | throw new EmailValidationException( |
36 | 36 | esc_html__( |
@@ -41,7 +41,7 @@ discard block |
||
41 | 41 | ) |
42 | 42 | ); |
43 | 43 | } |
44 | - if (! checkdnsrr($domain, 'A')) { |
|
44 | + if ( ! checkdnsrr($domain, 'A')) { |
|
45 | 45 | // domain not found in A records |
46 | 46 | throw new EmailValidationException( |
47 | 47 | esc_html__( |
@@ -14,43 +14,43 @@ |
||
14 | 14 | */ |
15 | 15 | class InternationalDNS extends International |
16 | 16 | { |
17 | - /** |
|
18 | - * Validates the email in teh same way as the parent, but also |
|
19 | - * verifies the domain exists. |
|
20 | - * |
|
21 | - * @param string $email_address |
|
22 | - * @return bool |
|
23 | - * @throws EmailValidationException |
|
24 | - */ |
|
25 | - public function validate($email_address) |
|
26 | - { |
|
27 | - parent::validate($email_address); |
|
28 | - $domain = $this->getDomainPartOfEmail( |
|
29 | - $email_address, |
|
30 | - $this->getAtIndex($email_address) |
|
31 | - ); |
|
32 | - if (! checkdnsrr($domain, 'MX')) { |
|
33 | - // domain not found in MX records |
|
34 | - throw new EmailValidationException( |
|
35 | - esc_html__( |
|
36 | - // @codingStandardsIgnoreStart |
|
37 | - 'Although the email address provided is formatted correctly, a valid "MX record" could not be located for that address and domain. Please enter a valid email address.', |
|
38 | - // @codingStandardsIgnoreEnd |
|
39 | - 'event_espresso' |
|
40 | - ) |
|
41 | - ); |
|
42 | - } |
|
43 | - if (! checkdnsrr($domain, 'A')) { |
|
44 | - // domain not found in A records |
|
45 | - throw new EmailValidationException( |
|
46 | - esc_html__( |
|
47 | - // @codingStandardsIgnoreStart |
|
48 | - 'Although the email address provided is formatted correctly, a valid "A record" could not be located for that address and domain. Please enter a valid email address.', |
|
49 | - // @codingStandardsIgnoreEnd |
|
50 | - 'event_espresso' |
|
51 | - ) |
|
52 | - ); |
|
53 | - } |
|
54 | - return true; |
|
55 | - } |
|
17 | + /** |
|
18 | + * Validates the email in teh same way as the parent, but also |
|
19 | + * verifies the domain exists. |
|
20 | + * |
|
21 | + * @param string $email_address |
|
22 | + * @return bool |
|
23 | + * @throws EmailValidationException |
|
24 | + */ |
|
25 | + public function validate($email_address) |
|
26 | + { |
|
27 | + parent::validate($email_address); |
|
28 | + $domain = $this->getDomainPartOfEmail( |
|
29 | + $email_address, |
|
30 | + $this->getAtIndex($email_address) |
|
31 | + ); |
|
32 | + if (! checkdnsrr($domain, 'MX')) { |
|
33 | + // domain not found in MX records |
|
34 | + throw new EmailValidationException( |
|
35 | + esc_html__( |
|
36 | + // @codingStandardsIgnoreStart |
|
37 | + 'Although the email address provided is formatted correctly, a valid "MX record" could not be located for that address and domain. Please enter a valid email address.', |
|
38 | + // @codingStandardsIgnoreEnd |
|
39 | + 'event_espresso' |
|
40 | + ) |
|
41 | + ); |
|
42 | + } |
|
43 | + if (! checkdnsrr($domain, 'A')) { |
|
44 | + // domain not found in A records |
|
45 | + throw new EmailValidationException( |
|
46 | + esc_html__( |
|
47 | + // @codingStandardsIgnoreStart |
|
48 | + 'Although the email address provided is formatted correctly, a valid "A record" could not be located for that address and domain. Please enter a valid email address.', |
|
49 | + // @codingStandardsIgnoreEnd |
|
50 | + 'event_espresso' |
|
51 | + ) |
|
52 | + ); |
|
53 | + } |
|
54 | + return true; |
|
55 | + } |
|
56 | 56 | } |
@@ -60,7 +60,7 @@ discard block |
||
60 | 60 | // assume this if first route being called |
61 | 61 | $previous_route = false; |
62 | 62 | // but is it really ??? |
63 | - if (! empty(self::$_previous_routes)) { |
|
63 | + if ( ! empty(self::$_previous_routes)) { |
|
64 | 64 | // get last run route |
65 | 65 | $previous_routes = array_values(self::$_previous_routes); |
66 | 66 | $previous_route = array_pop($previous_routes); |
@@ -71,7 +71,7 @@ discard block |
||
71 | 71 | $current_route = $this->get_forward($previous_route); |
72 | 72 | try { |
73 | 73 | // check for recursive forwarding |
74 | - if (isset(self::$_previous_routes[ $current_route ])) { |
|
74 | + if (isset(self::$_previous_routes[$current_route])) { |
|
75 | 75 | throw new EE_Error( |
76 | 76 | sprintf( |
77 | 77 | esc_html__( |
@@ -144,38 +144,38 @@ discard block |
||
144 | 144 | return false; |
145 | 145 | } |
146 | 146 | // verify that result is an array |
147 | - if (! is_array($module_method)) { |
|
147 | + if ( ! is_array($module_method)) { |
|
148 | 148 | $msg = sprintf(esc_html__('The %s route has not been properly registered.', 'event_espresso'), $current_route); |
149 | - EE_Error::add_error($msg . '||' . $msg, __FILE__, __FUNCTION__, __LINE__); |
|
149 | + EE_Error::add_error($msg.'||'.$msg, __FILE__, __FUNCTION__, __LINE__); |
|
150 | 150 | return false; |
151 | 151 | } |
152 | 152 | // grab module name |
153 | 153 | $module_name = $module_method[0]; |
154 | 154 | // verify that a class method was registered properly |
155 | - if (! isset($module_method[1])) { |
|
155 | + if ( ! isset($module_method[1])) { |
|
156 | 156 | $msg = sprintf( |
157 | 157 | esc_html__('A class method for the %s route has not been properly registered.', 'event_espresso'), |
158 | 158 | $current_route |
159 | 159 | ); |
160 | - EE_Error::add_error($msg . '||' . $msg, __FILE__, __FUNCTION__, __LINE__); |
|
160 | + EE_Error::add_error($msg.'||'.$msg, __FILE__, __FUNCTION__, __LINE__); |
|
161 | 161 | return false; |
162 | 162 | } |
163 | 163 | // grab method |
164 | 164 | $method = $module_method[1]; |
165 | 165 | // verify that class exists |
166 | - if (! class_exists($module_name)) { |
|
166 | + if ( ! class_exists($module_name)) { |
|
167 | 167 | $msg = sprintf(esc_html__('The requested %s class could not be found.', 'event_espresso'), $module_name); |
168 | 168 | EE_Error::add_error($msg, __FILE__, __FUNCTION__, __LINE__); |
169 | 169 | return false; |
170 | 170 | } |
171 | 171 | // verify that method exists |
172 | - if (! method_exists($module_name, $method)) { |
|
172 | + if ( ! method_exists($module_name, $method)) { |
|
173 | 173 | $msg = sprintf( |
174 | 174 | esc_html__('The class method %s for the %s route is in invalid.', 'event_espresso'), |
175 | 175 | $method, |
176 | 176 | $current_route |
177 | 177 | ); |
178 | - EE_Error::add_error($msg . '||' . $msg, __FILE__, __FUNCTION__, __LINE__); |
|
178 | + EE_Error::add_error($msg.'||'.$msg, __FILE__, __FUNCTION__, __LINE__); |
|
179 | 179 | return false; |
180 | 180 | } |
181 | 181 | // instantiate module and call route method |
@@ -209,7 +209,7 @@ discard block |
||
209 | 209 | // instantiate module class |
210 | 210 | $module = new $module_name(); |
211 | 211 | // ensure that class is actually a module |
212 | - if (! $module instanceof EED_Module) { |
|
212 | + if ( ! $module instanceof EED_Module) { |
|
213 | 213 | EE_Error::add_error( |
214 | 214 | sprintf(esc_html__('The requested %s module is not of the class EED_Module.', 'event_espresso'), $module_name), |
215 | 215 | __FILE__, |
@@ -15,254 +15,254 @@ |
||
15 | 15 | */ |
16 | 16 | final class EE_Module_Request_Router implements InterminableInterface |
17 | 17 | { |
18 | - /** |
|
19 | - * @var RequestInterface $request |
|
20 | - */ |
|
21 | - private $request; |
|
18 | + /** |
|
19 | + * @var RequestInterface $request |
|
20 | + */ |
|
21 | + private $request; |
|
22 | 22 | |
23 | - /** |
|
24 | - * @var array $_previous_routes |
|
25 | - */ |
|
26 | - private static $_previous_routes = array(); |
|
23 | + /** |
|
24 | + * @var array $_previous_routes |
|
25 | + */ |
|
26 | + private static $_previous_routes = array(); |
|
27 | 27 | |
28 | - /** |
|
29 | - * @var WP_Query $WP_Query |
|
30 | - */ |
|
31 | - public $WP_Query; |
|
28 | + /** |
|
29 | + * @var WP_Query $WP_Query |
|
30 | + */ |
|
31 | + public $WP_Query; |
|
32 | 32 | |
33 | 33 | |
34 | - /** |
|
35 | - * EE_Module_Request_Router constructor. |
|
36 | - * |
|
37 | - * @param RequestInterface $request |
|
38 | - */ |
|
39 | - public function __construct(RequestInterface $request) |
|
40 | - { |
|
41 | - $this->request = $request; |
|
42 | - } |
|
34 | + /** |
|
35 | + * EE_Module_Request_Router constructor. |
|
36 | + * |
|
37 | + * @param RequestInterface $request |
|
38 | + */ |
|
39 | + public function __construct(RequestInterface $request) |
|
40 | + { |
|
41 | + $this->request = $request; |
|
42 | + } |
|
43 | 43 | |
44 | 44 | |
45 | - /** |
|
46 | - * on the first call to this method, it checks the Request for a "route" |
|
47 | - * on subsequent calls to this method, |
|
48 | - * instead of checking the Request for a route, it checks the previous routes array, |
|
49 | - * and checks if the last called route has any forwarding routes registered for it |
|
50 | - * |
|
51 | - * @param WP_Query $WP_Query |
|
52 | - * @return NULL|string |
|
53 | - * @throws EE_Error |
|
54 | - * @throws ReflectionException |
|
55 | - */ |
|
56 | - public function get_route(WP_Query $WP_Query) |
|
57 | - { |
|
58 | - $this->WP_Query = $WP_Query; |
|
59 | - // assume this if first route being called |
|
60 | - $previous_route = false; |
|
61 | - // but is it really ??? |
|
62 | - if (! empty(self::$_previous_routes)) { |
|
63 | - // get last run route |
|
64 | - $previous_routes = array_values(self::$_previous_routes); |
|
65 | - $previous_route = array_pop($previous_routes); |
|
66 | - } |
|
67 | - // has another route already been run ? |
|
68 | - if ($previous_route) { |
|
69 | - // check if forwarding has been set |
|
70 | - $current_route = $this->get_forward($previous_route); |
|
71 | - try { |
|
72 | - // check for recursive forwarding |
|
73 | - if (isset(self::$_previous_routes[ $current_route ])) { |
|
74 | - throw new EE_Error( |
|
75 | - sprintf( |
|
76 | - esc_html__( |
|
77 | - 'An error occurred. The %s route has already been called, and therefore can not be forwarded to, because an infinite loop would be created and break the interweb.', |
|
78 | - 'event_espresso' |
|
79 | - ), |
|
80 | - $current_route |
|
81 | - ) |
|
82 | - ); |
|
83 | - } |
|
84 | - } catch (EE_Error $e) { |
|
85 | - $e->get_error(); |
|
86 | - return null; |
|
87 | - } |
|
88 | - } else { |
|
89 | - // first route called |
|
90 | - $current_route = null; |
|
91 | - // grab all routes |
|
92 | - $routes = EE_Config::get_routes(); |
|
93 | - foreach ($routes as $key => $route) { |
|
94 | - // first determine if route key uses w?ldc*rds |
|
95 | - $uses_wildcards = strpos($key, '?') !== false |
|
96 | - || strpos($key, '*') !== false; |
|
97 | - // check request for module route |
|
98 | - $route_found = $uses_wildcards |
|
99 | - ? $this->request->matches($key) |
|
100 | - : $this->request->requestParamIsSet($key); |
|
101 | - if ($route_found) { |
|
102 | - $current_route = $uses_wildcards |
|
103 | - ? $this->request->getMatch($key) |
|
104 | - : $this->request->getRequestParam($key); |
|
105 | - $current_route = sanitize_text_field($current_route); |
|
106 | - if ($current_route) { |
|
107 | - $current_route = array($key, $current_route); |
|
108 | - break; |
|
109 | - } |
|
110 | - } |
|
111 | - } |
|
112 | - } |
|
113 | - // sorry, but I can't read what you route ! |
|
114 | - if (empty($current_route)) { |
|
115 | - return null; |
|
116 | - } |
|
117 | - // add route to previous routes array |
|
118 | - self::$_previous_routes[] = $current_route; |
|
119 | - return $current_route; |
|
120 | - } |
|
45 | + /** |
|
46 | + * on the first call to this method, it checks the Request for a "route" |
|
47 | + * on subsequent calls to this method, |
|
48 | + * instead of checking the Request for a route, it checks the previous routes array, |
|
49 | + * and checks if the last called route has any forwarding routes registered for it |
|
50 | + * |
|
51 | + * @param WP_Query $WP_Query |
|
52 | + * @return NULL|string |
|
53 | + * @throws EE_Error |
|
54 | + * @throws ReflectionException |
|
55 | + */ |
|
56 | + public function get_route(WP_Query $WP_Query) |
|
57 | + { |
|
58 | + $this->WP_Query = $WP_Query; |
|
59 | + // assume this if first route being called |
|
60 | + $previous_route = false; |
|
61 | + // but is it really ??? |
|
62 | + if (! empty(self::$_previous_routes)) { |
|
63 | + // get last run route |
|
64 | + $previous_routes = array_values(self::$_previous_routes); |
|
65 | + $previous_route = array_pop($previous_routes); |
|
66 | + } |
|
67 | + // has another route already been run ? |
|
68 | + if ($previous_route) { |
|
69 | + // check if forwarding has been set |
|
70 | + $current_route = $this->get_forward($previous_route); |
|
71 | + try { |
|
72 | + // check for recursive forwarding |
|
73 | + if (isset(self::$_previous_routes[ $current_route ])) { |
|
74 | + throw new EE_Error( |
|
75 | + sprintf( |
|
76 | + esc_html__( |
|
77 | + 'An error occurred. The %s route has already been called, and therefore can not be forwarded to, because an infinite loop would be created and break the interweb.', |
|
78 | + 'event_espresso' |
|
79 | + ), |
|
80 | + $current_route |
|
81 | + ) |
|
82 | + ); |
|
83 | + } |
|
84 | + } catch (EE_Error $e) { |
|
85 | + $e->get_error(); |
|
86 | + return null; |
|
87 | + } |
|
88 | + } else { |
|
89 | + // first route called |
|
90 | + $current_route = null; |
|
91 | + // grab all routes |
|
92 | + $routes = EE_Config::get_routes(); |
|
93 | + foreach ($routes as $key => $route) { |
|
94 | + // first determine if route key uses w?ldc*rds |
|
95 | + $uses_wildcards = strpos($key, '?') !== false |
|
96 | + || strpos($key, '*') !== false; |
|
97 | + // check request for module route |
|
98 | + $route_found = $uses_wildcards |
|
99 | + ? $this->request->matches($key) |
|
100 | + : $this->request->requestParamIsSet($key); |
|
101 | + if ($route_found) { |
|
102 | + $current_route = $uses_wildcards |
|
103 | + ? $this->request->getMatch($key) |
|
104 | + : $this->request->getRequestParam($key); |
|
105 | + $current_route = sanitize_text_field($current_route); |
|
106 | + if ($current_route) { |
|
107 | + $current_route = array($key, $current_route); |
|
108 | + break; |
|
109 | + } |
|
110 | + } |
|
111 | + } |
|
112 | + } |
|
113 | + // sorry, but I can't read what you route ! |
|
114 | + if (empty($current_route)) { |
|
115 | + return null; |
|
116 | + } |
|
117 | + // add route to previous routes array |
|
118 | + self::$_previous_routes[] = $current_route; |
|
119 | + return $current_route; |
|
120 | + } |
|
121 | 121 | |
122 | 122 | |
123 | - /** |
|
124 | - * this method simply takes a valid route, and resolves what module class method the route points to |
|
125 | - * |
|
126 | - * @param string $key |
|
127 | - * @param string $current_route |
|
128 | - * @return EED_Module|object|boolean|null |
|
129 | - * @throws EE_Error |
|
130 | - * @throws ReflectionException |
|
131 | - */ |
|
132 | - public function resolve_route($key, $current_route) |
|
133 | - { |
|
134 | - // get module method that route has been mapped to |
|
135 | - $module_method = EE_Config::get_route($current_route, $key); |
|
136 | - // verify result was returned |
|
137 | - if (empty($module_method)) { |
|
138 | - $msg = sprintf( |
|
139 | - esc_html__('The requested route %s could not be mapped to any registered modules.', 'event_espresso'), |
|
140 | - $current_route |
|
141 | - ); |
|
142 | - EE_Error::add_error($msg, __FILE__, __FUNCTION__, __LINE__); |
|
143 | - return false; |
|
144 | - } |
|
145 | - // verify that result is an array |
|
146 | - if (! is_array($module_method)) { |
|
147 | - $msg = sprintf(esc_html__('The %s route has not been properly registered.', 'event_espresso'), $current_route); |
|
148 | - EE_Error::add_error($msg . '||' . $msg, __FILE__, __FUNCTION__, __LINE__); |
|
149 | - return false; |
|
150 | - } |
|
151 | - // grab module name |
|
152 | - $module_name = $module_method[0]; |
|
153 | - // verify that a class method was registered properly |
|
154 | - if (! isset($module_method[1])) { |
|
155 | - $msg = sprintf( |
|
156 | - esc_html__('A class method for the %s route has not been properly registered.', 'event_espresso'), |
|
157 | - $current_route |
|
158 | - ); |
|
159 | - EE_Error::add_error($msg . '||' . $msg, __FILE__, __FUNCTION__, __LINE__); |
|
160 | - return false; |
|
161 | - } |
|
162 | - // grab method |
|
163 | - $method = $module_method[1]; |
|
164 | - // verify that class exists |
|
165 | - if (! class_exists($module_name)) { |
|
166 | - $msg = sprintf(esc_html__('The requested %s class could not be found.', 'event_espresso'), $module_name); |
|
167 | - EE_Error::add_error($msg, __FILE__, __FUNCTION__, __LINE__); |
|
168 | - return false; |
|
169 | - } |
|
170 | - // verify that method exists |
|
171 | - if (! method_exists($module_name, $method)) { |
|
172 | - $msg = sprintf( |
|
173 | - esc_html__('The class method %s for the %s route is in invalid.', 'event_espresso'), |
|
174 | - $method, |
|
175 | - $current_route |
|
176 | - ); |
|
177 | - EE_Error::add_error($msg . '||' . $msg, __FILE__, __FUNCTION__, __LINE__); |
|
178 | - return false; |
|
179 | - } |
|
180 | - // instantiate module and call route method |
|
181 | - return $this->_module_router($module_name, $method); |
|
182 | - } |
|
123 | + /** |
|
124 | + * this method simply takes a valid route, and resolves what module class method the route points to |
|
125 | + * |
|
126 | + * @param string $key |
|
127 | + * @param string $current_route |
|
128 | + * @return EED_Module|object|boolean|null |
|
129 | + * @throws EE_Error |
|
130 | + * @throws ReflectionException |
|
131 | + */ |
|
132 | + public function resolve_route($key, $current_route) |
|
133 | + { |
|
134 | + // get module method that route has been mapped to |
|
135 | + $module_method = EE_Config::get_route($current_route, $key); |
|
136 | + // verify result was returned |
|
137 | + if (empty($module_method)) { |
|
138 | + $msg = sprintf( |
|
139 | + esc_html__('The requested route %s could not be mapped to any registered modules.', 'event_espresso'), |
|
140 | + $current_route |
|
141 | + ); |
|
142 | + EE_Error::add_error($msg, __FILE__, __FUNCTION__, __LINE__); |
|
143 | + return false; |
|
144 | + } |
|
145 | + // verify that result is an array |
|
146 | + if (! is_array($module_method)) { |
|
147 | + $msg = sprintf(esc_html__('The %s route has not been properly registered.', 'event_espresso'), $current_route); |
|
148 | + EE_Error::add_error($msg . '||' . $msg, __FILE__, __FUNCTION__, __LINE__); |
|
149 | + return false; |
|
150 | + } |
|
151 | + // grab module name |
|
152 | + $module_name = $module_method[0]; |
|
153 | + // verify that a class method was registered properly |
|
154 | + if (! isset($module_method[1])) { |
|
155 | + $msg = sprintf( |
|
156 | + esc_html__('A class method for the %s route has not been properly registered.', 'event_espresso'), |
|
157 | + $current_route |
|
158 | + ); |
|
159 | + EE_Error::add_error($msg . '||' . $msg, __FILE__, __FUNCTION__, __LINE__); |
|
160 | + return false; |
|
161 | + } |
|
162 | + // grab method |
|
163 | + $method = $module_method[1]; |
|
164 | + // verify that class exists |
|
165 | + if (! class_exists($module_name)) { |
|
166 | + $msg = sprintf(esc_html__('The requested %s class could not be found.', 'event_espresso'), $module_name); |
|
167 | + EE_Error::add_error($msg, __FILE__, __FUNCTION__, __LINE__); |
|
168 | + return false; |
|
169 | + } |
|
170 | + // verify that method exists |
|
171 | + if (! method_exists($module_name, $method)) { |
|
172 | + $msg = sprintf( |
|
173 | + esc_html__('The class method %s for the %s route is in invalid.', 'event_espresso'), |
|
174 | + $method, |
|
175 | + $current_route |
|
176 | + ); |
|
177 | + EE_Error::add_error($msg . '||' . $msg, __FILE__, __FUNCTION__, __LINE__); |
|
178 | + return false; |
|
179 | + } |
|
180 | + // instantiate module and call route method |
|
181 | + return $this->_module_router($module_name, $method); |
|
182 | + } |
|
183 | 183 | |
184 | 184 | |
185 | - /** |
|
186 | - * this method instantiates modules and calls the method that was defined when the route was registered |
|
187 | - * |
|
188 | - * @param string $module_name |
|
189 | - * @return EED_Module|object|null |
|
190 | - */ |
|
191 | - public static function module_factory($module_name) |
|
192 | - { |
|
193 | - if ($module_name === 'EED_Module') { |
|
194 | - EE_Error::add_error( |
|
195 | - sprintf( |
|
196 | - esc_html__( |
|
197 | - 'EED_Module is an abstract parent class an can not be instantiated. Please provide a proper module name.', |
|
198 | - 'event_espresso' |
|
199 | - ), |
|
200 | - $module_name |
|
201 | - ), |
|
202 | - __FILE__, |
|
203 | - __FUNCTION__, |
|
204 | - __LINE__ |
|
205 | - ); |
|
206 | - return null; |
|
207 | - } |
|
208 | - // instantiate module class |
|
209 | - $module = new $module_name(); |
|
210 | - // ensure that class is actually a module |
|
211 | - if (! $module instanceof EED_Module) { |
|
212 | - EE_Error::add_error( |
|
213 | - sprintf(esc_html__('The requested %s module is not of the class EED_Module.', 'event_espresso'), $module_name), |
|
214 | - __FILE__, |
|
215 | - __FUNCTION__, |
|
216 | - __LINE__ |
|
217 | - ); |
|
218 | - return null; |
|
219 | - } |
|
220 | - return $module; |
|
221 | - } |
|
185 | + /** |
|
186 | + * this method instantiates modules and calls the method that was defined when the route was registered |
|
187 | + * |
|
188 | + * @param string $module_name |
|
189 | + * @return EED_Module|object|null |
|
190 | + */ |
|
191 | + public static function module_factory($module_name) |
|
192 | + { |
|
193 | + if ($module_name === 'EED_Module') { |
|
194 | + EE_Error::add_error( |
|
195 | + sprintf( |
|
196 | + esc_html__( |
|
197 | + 'EED_Module is an abstract parent class an can not be instantiated. Please provide a proper module name.', |
|
198 | + 'event_espresso' |
|
199 | + ), |
|
200 | + $module_name |
|
201 | + ), |
|
202 | + __FILE__, |
|
203 | + __FUNCTION__, |
|
204 | + __LINE__ |
|
205 | + ); |
|
206 | + return null; |
|
207 | + } |
|
208 | + // instantiate module class |
|
209 | + $module = new $module_name(); |
|
210 | + // ensure that class is actually a module |
|
211 | + if (! $module instanceof EED_Module) { |
|
212 | + EE_Error::add_error( |
|
213 | + sprintf(esc_html__('The requested %s module is not of the class EED_Module.', 'event_espresso'), $module_name), |
|
214 | + __FILE__, |
|
215 | + __FUNCTION__, |
|
216 | + __LINE__ |
|
217 | + ); |
|
218 | + return null; |
|
219 | + } |
|
220 | + return $module; |
|
221 | + } |
|
222 | 222 | |
223 | 223 | |
224 | - /** |
|
225 | - * this method instantiates modules and calls the method that was defined when the route was registered |
|
226 | - * |
|
227 | - * @param string $module_name |
|
228 | - * @param string $method |
|
229 | - * @return EED_Module|null |
|
230 | - * @throws EE_Error |
|
231 | - * @throws ReflectionException |
|
232 | - */ |
|
233 | - private function _module_router($module_name, $method) |
|
234 | - { |
|
235 | - // instantiate module class |
|
236 | - $module = EE_Module_Request_Router::module_factory($module_name); |
|
237 | - if ($module instanceof EED_Module) { |
|
238 | - // and call whatever action the route was for |
|
239 | - try { |
|
240 | - $module->{$method}($this->WP_Query); |
|
241 | - } catch (EE_Error $e) { |
|
242 | - $e->get_error(); |
|
243 | - return null; |
|
244 | - } |
|
245 | - } |
|
246 | - return $module; |
|
247 | - } |
|
224 | + /** |
|
225 | + * this method instantiates modules and calls the method that was defined when the route was registered |
|
226 | + * |
|
227 | + * @param string $module_name |
|
228 | + * @param string $method |
|
229 | + * @return EED_Module|null |
|
230 | + * @throws EE_Error |
|
231 | + * @throws ReflectionException |
|
232 | + */ |
|
233 | + private function _module_router($module_name, $method) |
|
234 | + { |
|
235 | + // instantiate module class |
|
236 | + $module = EE_Module_Request_Router::module_factory($module_name); |
|
237 | + if ($module instanceof EED_Module) { |
|
238 | + // and call whatever action the route was for |
|
239 | + try { |
|
240 | + $module->{$method}($this->WP_Query); |
|
241 | + } catch (EE_Error $e) { |
|
242 | + $e->get_error(); |
|
243 | + return null; |
|
244 | + } |
|
245 | + } |
|
246 | + return $module; |
|
247 | + } |
|
248 | 248 | |
249 | 249 | |
250 | - /** |
|
251 | - * @param $current_route |
|
252 | - * @return string |
|
253 | - */ |
|
254 | - public function get_forward($current_route) |
|
255 | - { |
|
256 | - return EE_Config::get_forward($current_route); |
|
257 | - } |
|
250 | + /** |
|
251 | + * @param $current_route |
|
252 | + * @return string |
|
253 | + */ |
|
254 | + public function get_forward($current_route) |
|
255 | + { |
|
256 | + return EE_Config::get_forward($current_route); |
|
257 | + } |
|
258 | 258 | |
259 | 259 | |
260 | - /** |
|
261 | - * @param $current_route |
|
262 | - * @return string |
|
263 | - */ |
|
264 | - public function get_view($current_route) |
|
265 | - { |
|
266 | - return EE_Config::get_view($current_route); |
|
267 | - } |
|
260 | + /** |
|
261 | + * @param $current_route |
|
262 | + * @return string |
|
263 | + */ |
|
264 | + public function get_view($current_route) |
|
265 | + { |
|
266 | + return EE_Config::get_view($current_route); |
|
267 | + } |
|
268 | 268 | } |
@@ -185,7 +185,7 @@ discard block |
||
185 | 185 | */ |
186 | 186 | public function add_error($error, $force = false) |
187 | 187 | { |
188 | - if (! defined('EE_DMS_ERROR_LIMIT')) { |
|
188 | + if ( ! defined('EE_DMS_ERROR_LIMIT')) { |
|
189 | 189 | $limit = 50; |
190 | 190 | } else { |
191 | 191 | $limit = EE_DMS_ERROR_LIMIT; |
@@ -201,7 +201,7 @@ discard block |
||
201 | 201 | $this->_errors[] = "Limit reached; removed first half of errors to save space"; |
202 | 202 | $this->_errors[] = $error; |
203 | 203 | } else { |
204 | - $this->_errors[ $limit ] = 'More, but limit reached...'; |
|
204 | + $this->_errors[$limit] = 'More, but limit reached...'; |
|
205 | 205 | } |
206 | 206 | } else { |
207 | 207 | $this->_errors[] = $error; |
@@ -345,7 +345,7 @@ discard block |
||
345 | 345 | $new_columns_and_values_for_string = array(); |
346 | 346 | $count = 0; |
347 | 347 | foreach ($new_row_as_array as $column => $value) { |
348 | - $new_columns_and_values_for_string[] = " $column => $value (" . $data_types[ $count++ ] . ")"; |
|
348 | + $new_columns_and_values_for_string[] = " $column => $value (".$data_types[$count++].")"; |
|
349 | 349 | } |
350 | 350 | return sprintf( |
351 | 351 | esc_html__( |
@@ -376,7 +376,7 @@ discard block |
||
376 | 376 | foreach ($array_of_data as $name => $value) { |
377 | 377 | $unserialized_data = @unserialize($value); |
378 | 378 | if ($unserialized_data === false) { |
379 | - $fields_to_include[ $name ] = $value; |
|
379 | + $fields_to_include[$name] = $value; |
|
380 | 380 | } |
381 | 381 | } |
382 | 382 | return wp_json_encode($fields_to_include); |
@@ -16,408 +16,408 @@ |
||
16 | 16 | */ |
17 | 17 | abstract class EE_Data_Migration_Class_Base |
18 | 18 | { |
19 | - /** |
|
20 | - * @var $records_to_migrate int count of all that have been migrated |
|
21 | - */ |
|
22 | - protected $_records_to_migrate = 0; |
|
23 | - |
|
24 | - /** |
|
25 | - * |
|
26 | - * @var $records_migrated int |
|
27 | - */ |
|
28 | - protected $_records_migrated = 0; |
|
29 | - |
|
30 | - /** |
|
31 | - * Whether this migration script is done or not. This COULD be deduced by |
|
32 | - * _records_to_migrate and _records_migrated, but that might nto be accurate |
|
33 | - * |
|
34 | - * @var string one of EE_Data_migration_Manager::status_* constants |
|
35 | - */ |
|
36 | - protected $_status = null; |
|
37 | - |
|
38 | - /** |
|
39 | - * internationalized name of this class. Convention is to NOT restate that |
|
40 | - * this class if a migration script or a migration script stage |
|
41 | - * |
|
42 | - * @var string (i18ned) |
|
43 | - */ |
|
44 | - protected $_pretty_name = null; |
|
45 | - |
|
46 | - /** |
|
47 | - * @var array |
|
48 | - */ |
|
49 | - protected $_errors = array(); |
|
50 | - |
|
51 | - /** |
|
52 | - * @var \EventEspresso\core\services\database\TableManager $table_manager |
|
53 | - */ |
|
54 | - protected $_table_manager; |
|
55 | - |
|
56 | - /** |
|
57 | - * @var \EventEspresso\core\services\database\TableAnalysis $table_analysis |
|
58 | - */ |
|
59 | - protected $_table_analysis; |
|
60 | - |
|
61 | - |
|
62 | - /** |
|
63 | - * Just initializes the status of the migration |
|
64 | - * |
|
65 | - * @param TableManager $table_manager |
|
66 | - * @param TableAnalysis $table_analysis |
|
67 | - */ |
|
68 | - public function __construct(TableManager $table_manager = null, TableAnalysis $table_analysis = null) |
|
69 | - { |
|
70 | - $this->_table_manager = $table_manager; |
|
71 | - $this->_table_analysis = $table_analysis; |
|
72 | - $this->set_status(EE_Data_Migration_Manager::status_continue); |
|
73 | - } |
|
74 | - |
|
75 | - |
|
76 | - /** |
|
77 | - * Just gets the pretty name for this migration script or stage |
|
78 | - * |
|
79 | - * @throws EE_Error |
|
80 | - * @return string |
|
81 | - */ |
|
82 | - public function pretty_name() |
|
83 | - { |
|
84 | - if ($this->_pretty_name === null) { |
|
85 | - throw new EE_Error( |
|
86 | - sprintf( |
|
87 | - esc_html__( |
|
88 | - "Please give a pretty name to the migration script stage %s by assigning the property _pretty_name in the constructor", |
|
89 | - "event_espresso" |
|
90 | - ), |
|
91 | - get_class($this) |
|
92 | - ) |
|
93 | - ); |
|
94 | - } |
|
95 | - return $this->_pretty_name; |
|
96 | - } |
|
97 | - |
|
98 | - /** |
|
99 | - * |
|
100 | - * @return int |
|
101 | - */ |
|
102 | - public function count_records_to_migrate() |
|
103 | - { |
|
104 | - if ($this->_records_to_migrate == null) { |
|
105 | - $this->_records_to_migrate = $this->_count_records_to_migrate(); |
|
106 | - } |
|
107 | - return $this->_records_to_migrate; |
|
108 | - } |
|
109 | - |
|
110 | - /** |
|
111 | - * Counts records already migrated. This should only be implemented by EE_Data_Migration_Script_base and |
|
112 | - * EE_Data_migration_Script_Stage |
|
113 | - * |
|
114 | - * @return int |
|
115 | - */ |
|
116 | - abstract public function count_records_migrated(); |
|
117 | - |
|
118 | - /** |
|
119 | - * Counts the records to migrate; the public version may cache it |
|
120 | - * |
|
121 | - * @return int |
|
122 | - */ |
|
123 | - abstract protected function _count_records_to_migrate(); |
|
124 | - |
|
125 | - /** |
|
126 | - * Returns a string indicating the migration script's status. |
|
127 | - * |
|
128 | - * @return string one of EE_Data_Migration_Manager::status_* constants |
|
129 | - * @throws EE_Error |
|
130 | - */ |
|
131 | - public function get_status() |
|
132 | - { |
|
133 | - if ($this->_status === null) { |
|
134 | - throw new EE_Error( |
|
135 | - sprintf( |
|
136 | - esc_html__( |
|
137 | - "Trying to get status of Migration class %s, but it has not been initialized yet. It should be set in the constructor.", |
|
138 | - "event_espresso" |
|
139 | - ), |
|
140 | - get_class($this) |
|
141 | - ) |
|
142 | - ); |
|
143 | - } |
|
144 | - return $this->_status; |
|
145 | - } |
|
146 | - |
|
147 | - /** |
|
148 | - * |
|
149 | - * @param string $status |
|
150 | - * @return void |
|
151 | - */ |
|
152 | - protected function set_status($status) |
|
153 | - { |
|
154 | - $this->_status = $status; |
|
155 | - } |
|
156 | - |
|
157 | - /** |
|
158 | - * @return array of strings |
|
159 | - */ |
|
160 | - abstract public function get_errors(); |
|
161 | - |
|
162 | - /** |
|
163 | - * Returns the last error that occurred. If none occurred, returns null |
|
164 | - * |
|
165 | - * @return string |
|
166 | - */ |
|
167 | - public function get_last_error() |
|
168 | - { |
|
169 | - $errors = $this->get_errors(); |
|
170 | - if ($errors) { |
|
171 | - return end($errors); |
|
172 | - } else { |
|
173 | - return null; |
|
174 | - } |
|
175 | - } |
|
176 | - |
|
177 | - /** |
|
178 | - * Adds an error to the array of errors on this class. |
|
179 | - * |
|
180 | - * @param string $error a string describing the error that will be useful for debugging. Consider including all |
|
181 | - * the data that led to the error, and a stack trace etc. |
|
182 | - * @param boolean $force force the error to be added (because otherwise we have a limit). If forcing and errors are |
|
183 | - * already at their limit, we will purposefully forget the first half |
|
184 | - */ |
|
185 | - public function add_error($error, $force = false) |
|
186 | - { |
|
187 | - if (! defined('EE_DMS_ERROR_LIMIT')) { |
|
188 | - $limit = 50; |
|
189 | - } else { |
|
190 | - $limit = EE_DMS_ERROR_LIMIT; |
|
191 | - } |
|
192 | - // make sure errors is an array, see ticket #8261 |
|
193 | - if (is_string($this->_errors)) { |
|
194 | - $this->_errors = array($this->_errors); |
|
195 | - } |
|
196 | - if (count($this->_errors) >= $limit) { |
|
197 | - if ($force) { |
|
198 | - // get rid of the first half of the errors and any above the limit |
|
199 | - $this->_errors = array_slice($this->_errors, $limit / 2, $limit / 2); |
|
200 | - $this->_errors[] = "Limit reached; removed first half of errors to save space"; |
|
201 | - $this->_errors[] = $error; |
|
202 | - } else { |
|
203 | - $this->_errors[ $limit ] = 'More, but limit reached...'; |
|
204 | - } |
|
205 | - } else { |
|
206 | - $this->_errors[] = $error; |
|
207 | - } |
|
208 | - } |
|
209 | - |
|
210 | - /** |
|
211 | - * Indicates there was a fatal error and the migration cannot possibly continue |
|
212 | - * |
|
213 | - * @return boolean |
|
214 | - */ |
|
215 | - public function is_broken() |
|
216 | - { |
|
217 | - return $this->get_status() == EE_Data_Migration_Manager::status_fatal_error; |
|
218 | - } |
|
219 | - |
|
220 | - /** |
|
221 | - * @deprecated since 4.6.12 |
|
222 | - */ |
|
223 | - public function is_borked() |
|
224 | - { |
|
225 | - EE_Error::doing_it_wrong( |
|
226 | - 'is_borked', |
|
227 | - esc_html__( |
|
228 | - 'The cheeky "is_borked" method had been replaced with the more proper "is_broken"', |
|
229 | - 'event_espresso' |
|
230 | - ), |
|
231 | - '4.6.12' |
|
232 | - ); |
|
233 | - return $this->is_broken(); |
|
234 | - } |
|
235 | - |
|
236 | - /** |
|
237 | - * Sets the status to as having a fatal error |
|
238 | - */ |
|
239 | - public function set_broken() |
|
240 | - { |
|
241 | - $this->_status = EE_Data_Migration_Manager::status_fatal_error; |
|
242 | - } |
|
243 | - |
|
244 | - /** |
|
245 | - * |
|
246 | - * @deprecated since 4.6.12 |
|
247 | - */ |
|
248 | - public function set_borked() |
|
249 | - { |
|
250 | - EE_Error::doing_it_wrong( |
|
251 | - 'is_borked', |
|
252 | - esc_html__( |
|
253 | - 'The cheeky "is_borked" method had been replaced with the more proper "is_broken"', |
|
254 | - 'event_espresso' |
|
255 | - ), |
|
256 | - '4.6.12' |
|
257 | - ); |
|
258 | - return $this->set_broken(); |
|
259 | - } |
|
260 | - |
|
261 | - /** |
|
262 | - * Checks if this thing believes it is completed |
|
263 | - * |
|
264 | - * @return boolean |
|
265 | - */ |
|
266 | - public function is_completed() |
|
267 | - { |
|
268 | - return $this->get_status() == EE_Data_Migration_Manager::status_completed; |
|
269 | - } |
|
270 | - |
|
271 | - /** |
|
272 | - * Checks if the current script has more to do or not (ie, if it's status is CONTINUE) |
|
273 | - * |
|
274 | - * @return boolean |
|
275 | - */ |
|
276 | - public function has_more_to_do() |
|
277 | - { |
|
278 | - return $this->get_status() == EE_Data_Migration_Manager::status_continue; |
|
279 | - } |
|
280 | - |
|
281 | - /** |
|
282 | - * Marks that we believe this migration thing is completed |
|
283 | - */ |
|
284 | - public function set_completed() |
|
285 | - { |
|
286 | - $this->_status = EE_Data_Migration_Manager::status_completed; |
|
287 | - } |
|
288 | - |
|
289 | - /** |
|
290 | - * Marks that we think this migration class can continue to migrate |
|
291 | - */ |
|
292 | - public function reattempt() |
|
293 | - { |
|
294 | - $this->_status = EE_Data_Migration_Manager::status_continue; |
|
295 | - $this->add_error(esc_html__('Reattempt migration', 'event_espresso'), true); |
|
296 | - } |
|
297 | - |
|
298 | - /** |
|
299 | - * A lot like "__sleep()" magic method in purpose, this is meant for persisting this class' |
|
300 | - * properties to the DB. However, we don't want to use __sleep() because its quite |
|
301 | - * possible that this class is defined when it goes to sleep, but NOT available when it |
|
302 | - * awakes (eg, this class is part of an addon that is deactivated at some point). |
|
303 | - */ |
|
304 | - public function properties_as_array() |
|
305 | - { |
|
306 | - $properties = get_object_vars($this); |
|
307 | - $properties['class'] = get_class($this); |
|
308 | - unset($properties['_migration_script']); |
|
309 | - unset($properties['_table_manager']); |
|
310 | - unset($properties['_table_analysis']); |
|
311 | - return $properties; |
|
312 | - } |
|
313 | - |
|
314 | - /** |
|
315 | - * Sets all of the properties of this script stage to match what's in the array, which is assumed |
|
316 | - * to have been made from the properties_as_array() function. |
|
317 | - * |
|
318 | - * @param array $array_of_properties like what's produced from properties_as_array() method |
|
319 | - */ |
|
320 | - abstract public function instantiate_from_array_of_properties($array_of_properties); |
|
321 | - |
|
322 | - /** |
|
323 | - * Convenience method for showing a database insertion error |
|
324 | - * |
|
325 | - * @param string $old_table |
|
326 | - * @param array $old_row_as_array |
|
327 | - * @param string $new_table |
|
328 | - * @param array $new_row_as_array columns=>values like used in wpdb->insert |
|
329 | - * @param array $data_types numerically indexed |
|
330 | - * @return string |
|
331 | - */ |
|
332 | - protected function _create_error_message_for_db_insertion( |
|
333 | - $old_table, |
|
334 | - $old_row_as_array, |
|
335 | - $new_table, |
|
336 | - $new_row_as_array, |
|
337 | - $data_types |
|
338 | - ) { |
|
339 | - global $wpdb; |
|
340 | - $old_columns_and_values_for_string = array(); |
|
341 | - foreach ($old_row_as_array as $column => $value) { |
|
342 | - $old_columns_and_values_for_string[] = "$column => $value"; |
|
343 | - } |
|
344 | - $new_columns_and_values_for_string = array(); |
|
345 | - $count = 0; |
|
346 | - foreach ($new_row_as_array as $column => $value) { |
|
347 | - $new_columns_and_values_for_string[] = " $column => $value (" . $data_types[ $count++ ] . ")"; |
|
348 | - } |
|
349 | - return sprintf( |
|
350 | - esc_html__( |
|
351 | - 'Received error "%6$s" inserting row %5$s %1$s %5$s into table %2$s.%5$s Data used was %5$s %3$s %5$s from table %4$s.', |
|
352 | - 'event_espresso' |
|
353 | - ), |
|
354 | - implode(", ", $new_columns_and_values_for_string), |
|
355 | - $new_table, |
|
356 | - implode(", ", $old_columns_and_values_for_string), |
|
357 | - $old_table, |
|
358 | - '<br/>', |
|
359 | - $wpdb->last_error |
|
360 | - ); |
|
361 | - } |
|
362 | - |
|
363 | - |
|
364 | - /** |
|
365 | - * Same as json_encode, just avoids putting |
|
366 | - * serialized arrays into the http build query, as that would |
|
367 | - * |
|
368 | - * @param array $array_of_data |
|
369 | - * @return string |
|
370 | - */ |
|
371 | - protected function _json_encode($array_of_data) |
|
372 | - { |
|
373 | - // we'd rather NOT serialize the transaction details |
|
374 | - $fields_to_include = array(); |
|
375 | - foreach ($array_of_data as $name => $value) { |
|
376 | - $unserialized_data = @unserialize($value); |
|
377 | - if ($unserialized_data === false) { |
|
378 | - $fields_to_include[ $name ] = $value; |
|
379 | - } |
|
380 | - } |
|
381 | - return wp_json_encode($fields_to_include); |
|
382 | - } |
|
383 | - |
|
384 | - /** |
|
385 | - * Gets the table manager (or throws an exception if it cannot be retrieved) |
|
386 | - * |
|
387 | - * @return TableManager |
|
388 | - * @throws EE_Error |
|
389 | - */ |
|
390 | - protected function _get_table_manager() |
|
391 | - { |
|
392 | - if ($this->_table_manager instanceof TableManager) { |
|
393 | - return $this->_table_manager; |
|
394 | - } else { |
|
395 | - throw new EE_Error( |
|
396 | - sprintf( |
|
397 | - esc_html__('Table manager on migration class %1$s is not set properly.', 'event_espresso'), |
|
398 | - get_class($this) |
|
399 | - ) |
|
400 | - ); |
|
401 | - } |
|
402 | - } |
|
403 | - |
|
404 | - /** |
|
405 | - * Gets the injected table analyzer, or throws an exception |
|
406 | - * |
|
407 | - * @return TableAnalysis |
|
408 | - * @throws EE_Error |
|
409 | - */ |
|
410 | - protected function _get_table_analysis() |
|
411 | - { |
|
412 | - if ($this->_table_analysis instanceof TableAnalysis) { |
|
413 | - return $this->_table_analysis; |
|
414 | - } else { |
|
415 | - throw new EE_Error( |
|
416 | - sprintf( |
|
417 | - esc_html__('Table analysis class on migration class %1$s is not set properly.', 'event_espresso'), |
|
418 | - get_class($this) |
|
419 | - ) |
|
420 | - ); |
|
421 | - } |
|
422 | - } |
|
19 | + /** |
|
20 | + * @var $records_to_migrate int count of all that have been migrated |
|
21 | + */ |
|
22 | + protected $_records_to_migrate = 0; |
|
23 | + |
|
24 | + /** |
|
25 | + * |
|
26 | + * @var $records_migrated int |
|
27 | + */ |
|
28 | + protected $_records_migrated = 0; |
|
29 | + |
|
30 | + /** |
|
31 | + * Whether this migration script is done or not. This COULD be deduced by |
|
32 | + * _records_to_migrate and _records_migrated, but that might nto be accurate |
|
33 | + * |
|
34 | + * @var string one of EE_Data_migration_Manager::status_* constants |
|
35 | + */ |
|
36 | + protected $_status = null; |
|
37 | + |
|
38 | + /** |
|
39 | + * internationalized name of this class. Convention is to NOT restate that |
|
40 | + * this class if a migration script or a migration script stage |
|
41 | + * |
|
42 | + * @var string (i18ned) |
|
43 | + */ |
|
44 | + protected $_pretty_name = null; |
|
45 | + |
|
46 | + /** |
|
47 | + * @var array |
|
48 | + */ |
|
49 | + protected $_errors = array(); |
|
50 | + |
|
51 | + /** |
|
52 | + * @var \EventEspresso\core\services\database\TableManager $table_manager |
|
53 | + */ |
|
54 | + protected $_table_manager; |
|
55 | + |
|
56 | + /** |
|
57 | + * @var \EventEspresso\core\services\database\TableAnalysis $table_analysis |
|
58 | + */ |
|
59 | + protected $_table_analysis; |
|
60 | + |
|
61 | + |
|
62 | + /** |
|
63 | + * Just initializes the status of the migration |
|
64 | + * |
|
65 | + * @param TableManager $table_manager |
|
66 | + * @param TableAnalysis $table_analysis |
|
67 | + */ |
|
68 | + public function __construct(TableManager $table_manager = null, TableAnalysis $table_analysis = null) |
|
69 | + { |
|
70 | + $this->_table_manager = $table_manager; |
|
71 | + $this->_table_analysis = $table_analysis; |
|
72 | + $this->set_status(EE_Data_Migration_Manager::status_continue); |
|
73 | + } |
|
74 | + |
|
75 | + |
|
76 | + /** |
|
77 | + * Just gets the pretty name for this migration script or stage |
|
78 | + * |
|
79 | + * @throws EE_Error |
|
80 | + * @return string |
|
81 | + */ |
|
82 | + public function pretty_name() |
|
83 | + { |
|
84 | + if ($this->_pretty_name === null) { |
|
85 | + throw new EE_Error( |
|
86 | + sprintf( |
|
87 | + esc_html__( |
|
88 | + "Please give a pretty name to the migration script stage %s by assigning the property _pretty_name in the constructor", |
|
89 | + "event_espresso" |
|
90 | + ), |
|
91 | + get_class($this) |
|
92 | + ) |
|
93 | + ); |
|
94 | + } |
|
95 | + return $this->_pretty_name; |
|
96 | + } |
|
97 | + |
|
98 | + /** |
|
99 | + * |
|
100 | + * @return int |
|
101 | + */ |
|
102 | + public function count_records_to_migrate() |
|
103 | + { |
|
104 | + if ($this->_records_to_migrate == null) { |
|
105 | + $this->_records_to_migrate = $this->_count_records_to_migrate(); |
|
106 | + } |
|
107 | + return $this->_records_to_migrate; |
|
108 | + } |
|
109 | + |
|
110 | + /** |
|
111 | + * Counts records already migrated. This should only be implemented by EE_Data_Migration_Script_base and |
|
112 | + * EE_Data_migration_Script_Stage |
|
113 | + * |
|
114 | + * @return int |
|
115 | + */ |
|
116 | + abstract public function count_records_migrated(); |
|
117 | + |
|
118 | + /** |
|
119 | + * Counts the records to migrate; the public version may cache it |
|
120 | + * |
|
121 | + * @return int |
|
122 | + */ |
|
123 | + abstract protected function _count_records_to_migrate(); |
|
124 | + |
|
125 | + /** |
|
126 | + * Returns a string indicating the migration script's status. |
|
127 | + * |
|
128 | + * @return string one of EE_Data_Migration_Manager::status_* constants |
|
129 | + * @throws EE_Error |
|
130 | + */ |
|
131 | + public function get_status() |
|
132 | + { |
|
133 | + if ($this->_status === null) { |
|
134 | + throw new EE_Error( |
|
135 | + sprintf( |
|
136 | + esc_html__( |
|
137 | + "Trying to get status of Migration class %s, but it has not been initialized yet. It should be set in the constructor.", |
|
138 | + "event_espresso" |
|
139 | + ), |
|
140 | + get_class($this) |
|
141 | + ) |
|
142 | + ); |
|
143 | + } |
|
144 | + return $this->_status; |
|
145 | + } |
|
146 | + |
|
147 | + /** |
|
148 | + * |
|
149 | + * @param string $status |
|
150 | + * @return void |
|
151 | + */ |
|
152 | + protected function set_status($status) |
|
153 | + { |
|
154 | + $this->_status = $status; |
|
155 | + } |
|
156 | + |
|
157 | + /** |
|
158 | + * @return array of strings |
|
159 | + */ |
|
160 | + abstract public function get_errors(); |
|
161 | + |
|
162 | + /** |
|
163 | + * Returns the last error that occurred. If none occurred, returns null |
|
164 | + * |
|
165 | + * @return string |
|
166 | + */ |
|
167 | + public function get_last_error() |
|
168 | + { |
|
169 | + $errors = $this->get_errors(); |
|
170 | + if ($errors) { |
|
171 | + return end($errors); |
|
172 | + } else { |
|
173 | + return null; |
|
174 | + } |
|
175 | + } |
|
176 | + |
|
177 | + /** |
|
178 | + * Adds an error to the array of errors on this class. |
|
179 | + * |
|
180 | + * @param string $error a string describing the error that will be useful for debugging. Consider including all |
|
181 | + * the data that led to the error, and a stack trace etc. |
|
182 | + * @param boolean $force force the error to be added (because otherwise we have a limit). If forcing and errors are |
|
183 | + * already at their limit, we will purposefully forget the first half |
|
184 | + */ |
|
185 | + public function add_error($error, $force = false) |
|
186 | + { |
|
187 | + if (! defined('EE_DMS_ERROR_LIMIT')) { |
|
188 | + $limit = 50; |
|
189 | + } else { |
|
190 | + $limit = EE_DMS_ERROR_LIMIT; |
|
191 | + } |
|
192 | + // make sure errors is an array, see ticket #8261 |
|
193 | + if (is_string($this->_errors)) { |
|
194 | + $this->_errors = array($this->_errors); |
|
195 | + } |
|
196 | + if (count($this->_errors) >= $limit) { |
|
197 | + if ($force) { |
|
198 | + // get rid of the first half of the errors and any above the limit |
|
199 | + $this->_errors = array_slice($this->_errors, $limit / 2, $limit / 2); |
|
200 | + $this->_errors[] = "Limit reached; removed first half of errors to save space"; |
|
201 | + $this->_errors[] = $error; |
|
202 | + } else { |
|
203 | + $this->_errors[ $limit ] = 'More, but limit reached...'; |
|
204 | + } |
|
205 | + } else { |
|
206 | + $this->_errors[] = $error; |
|
207 | + } |
|
208 | + } |
|
209 | + |
|
210 | + /** |
|
211 | + * Indicates there was a fatal error and the migration cannot possibly continue |
|
212 | + * |
|
213 | + * @return boolean |
|
214 | + */ |
|
215 | + public function is_broken() |
|
216 | + { |
|
217 | + return $this->get_status() == EE_Data_Migration_Manager::status_fatal_error; |
|
218 | + } |
|
219 | + |
|
220 | + /** |
|
221 | + * @deprecated since 4.6.12 |
|
222 | + */ |
|
223 | + public function is_borked() |
|
224 | + { |
|
225 | + EE_Error::doing_it_wrong( |
|
226 | + 'is_borked', |
|
227 | + esc_html__( |
|
228 | + 'The cheeky "is_borked" method had been replaced with the more proper "is_broken"', |
|
229 | + 'event_espresso' |
|
230 | + ), |
|
231 | + '4.6.12' |
|
232 | + ); |
|
233 | + return $this->is_broken(); |
|
234 | + } |
|
235 | + |
|
236 | + /** |
|
237 | + * Sets the status to as having a fatal error |
|
238 | + */ |
|
239 | + public function set_broken() |
|
240 | + { |
|
241 | + $this->_status = EE_Data_Migration_Manager::status_fatal_error; |
|
242 | + } |
|
243 | + |
|
244 | + /** |
|
245 | + * |
|
246 | + * @deprecated since 4.6.12 |
|
247 | + */ |
|
248 | + public function set_borked() |
|
249 | + { |
|
250 | + EE_Error::doing_it_wrong( |
|
251 | + 'is_borked', |
|
252 | + esc_html__( |
|
253 | + 'The cheeky "is_borked" method had been replaced with the more proper "is_broken"', |
|
254 | + 'event_espresso' |
|
255 | + ), |
|
256 | + '4.6.12' |
|
257 | + ); |
|
258 | + return $this->set_broken(); |
|
259 | + } |
|
260 | + |
|
261 | + /** |
|
262 | + * Checks if this thing believes it is completed |
|
263 | + * |
|
264 | + * @return boolean |
|
265 | + */ |
|
266 | + public function is_completed() |
|
267 | + { |
|
268 | + return $this->get_status() == EE_Data_Migration_Manager::status_completed; |
|
269 | + } |
|
270 | + |
|
271 | + /** |
|
272 | + * Checks if the current script has more to do or not (ie, if it's status is CONTINUE) |
|
273 | + * |
|
274 | + * @return boolean |
|
275 | + */ |
|
276 | + public function has_more_to_do() |
|
277 | + { |
|
278 | + return $this->get_status() == EE_Data_Migration_Manager::status_continue; |
|
279 | + } |
|
280 | + |
|
281 | + /** |
|
282 | + * Marks that we believe this migration thing is completed |
|
283 | + */ |
|
284 | + public function set_completed() |
|
285 | + { |
|
286 | + $this->_status = EE_Data_Migration_Manager::status_completed; |
|
287 | + } |
|
288 | + |
|
289 | + /** |
|
290 | + * Marks that we think this migration class can continue to migrate |
|
291 | + */ |
|
292 | + public function reattempt() |
|
293 | + { |
|
294 | + $this->_status = EE_Data_Migration_Manager::status_continue; |
|
295 | + $this->add_error(esc_html__('Reattempt migration', 'event_espresso'), true); |
|
296 | + } |
|
297 | + |
|
298 | + /** |
|
299 | + * A lot like "__sleep()" magic method in purpose, this is meant for persisting this class' |
|
300 | + * properties to the DB. However, we don't want to use __sleep() because its quite |
|
301 | + * possible that this class is defined when it goes to sleep, but NOT available when it |
|
302 | + * awakes (eg, this class is part of an addon that is deactivated at some point). |
|
303 | + */ |
|
304 | + public function properties_as_array() |
|
305 | + { |
|
306 | + $properties = get_object_vars($this); |
|
307 | + $properties['class'] = get_class($this); |
|
308 | + unset($properties['_migration_script']); |
|
309 | + unset($properties['_table_manager']); |
|
310 | + unset($properties['_table_analysis']); |
|
311 | + return $properties; |
|
312 | + } |
|
313 | + |
|
314 | + /** |
|
315 | + * Sets all of the properties of this script stage to match what's in the array, which is assumed |
|
316 | + * to have been made from the properties_as_array() function. |
|
317 | + * |
|
318 | + * @param array $array_of_properties like what's produced from properties_as_array() method |
|
319 | + */ |
|
320 | + abstract public function instantiate_from_array_of_properties($array_of_properties); |
|
321 | + |
|
322 | + /** |
|
323 | + * Convenience method for showing a database insertion error |
|
324 | + * |
|
325 | + * @param string $old_table |
|
326 | + * @param array $old_row_as_array |
|
327 | + * @param string $new_table |
|
328 | + * @param array $new_row_as_array columns=>values like used in wpdb->insert |
|
329 | + * @param array $data_types numerically indexed |
|
330 | + * @return string |
|
331 | + */ |
|
332 | + protected function _create_error_message_for_db_insertion( |
|
333 | + $old_table, |
|
334 | + $old_row_as_array, |
|
335 | + $new_table, |
|
336 | + $new_row_as_array, |
|
337 | + $data_types |
|
338 | + ) { |
|
339 | + global $wpdb; |
|
340 | + $old_columns_and_values_for_string = array(); |
|
341 | + foreach ($old_row_as_array as $column => $value) { |
|
342 | + $old_columns_and_values_for_string[] = "$column => $value"; |
|
343 | + } |
|
344 | + $new_columns_and_values_for_string = array(); |
|
345 | + $count = 0; |
|
346 | + foreach ($new_row_as_array as $column => $value) { |
|
347 | + $new_columns_and_values_for_string[] = " $column => $value (" . $data_types[ $count++ ] . ")"; |
|
348 | + } |
|
349 | + return sprintf( |
|
350 | + esc_html__( |
|
351 | + 'Received error "%6$s" inserting row %5$s %1$s %5$s into table %2$s.%5$s Data used was %5$s %3$s %5$s from table %4$s.', |
|
352 | + 'event_espresso' |
|
353 | + ), |
|
354 | + implode(", ", $new_columns_and_values_for_string), |
|
355 | + $new_table, |
|
356 | + implode(", ", $old_columns_and_values_for_string), |
|
357 | + $old_table, |
|
358 | + '<br/>', |
|
359 | + $wpdb->last_error |
|
360 | + ); |
|
361 | + } |
|
362 | + |
|
363 | + |
|
364 | + /** |
|
365 | + * Same as json_encode, just avoids putting |
|
366 | + * serialized arrays into the http build query, as that would |
|
367 | + * |
|
368 | + * @param array $array_of_data |
|
369 | + * @return string |
|
370 | + */ |
|
371 | + protected function _json_encode($array_of_data) |
|
372 | + { |
|
373 | + // we'd rather NOT serialize the transaction details |
|
374 | + $fields_to_include = array(); |
|
375 | + foreach ($array_of_data as $name => $value) { |
|
376 | + $unserialized_data = @unserialize($value); |
|
377 | + if ($unserialized_data === false) { |
|
378 | + $fields_to_include[ $name ] = $value; |
|
379 | + } |
|
380 | + } |
|
381 | + return wp_json_encode($fields_to_include); |
|
382 | + } |
|
383 | + |
|
384 | + /** |
|
385 | + * Gets the table manager (or throws an exception if it cannot be retrieved) |
|
386 | + * |
|
387 | + * @return TableManager |
|
388 | + * @throws EE_Error |
|
389 | + */ |
|
390 | + protected function _get_table_manager() |
|
391 | + { |
|
392 | + if ($this->_table_manager instanceof TableManager) { |
|
393 | + return $this->_table_manager; |
|
394 | + } else { |
|
395 | + throw new EE_Error( |
|
396 | + sprintf( |
|
397 | + esc_html__('Table manager on migration class %1$s is not set properly.', 'event_espresso'), |
|
398 | + get_class($this) |
|
399 | + ) |
|
400 | + ); |
|
401 | + } |
|
402 | + } |
|
403 | + |
|
404 | + /** |
|
405 | + * Gets the injected table analyzer, or throws an exception |
|
406 | + * |
|
407 | + * @return TableAnalysis |
|
408 | + * @throws EE_Error |
|
409 | + */ |
|
410 | + protected function _get_table_analysis() |
|
411 | + { |
|
412 | + if ($this->_table_analysis instanceof TableAnalysis) { |
|
413 | + return $this->_table_analysis; |
|
414 | + } else { |
|
415 | + throw new EE_Error( |
|
416 | + sprintf( |
|
417 | + esc_html__('Table analysis class on migration class %1$s is not set properly.', 'event_espresso'), |
|
418 | + get_class($this) |
|
419 | + ) |
|
420 | + ); |
|
421 | + } |
|
422 | + } |
|
423 | 423 | } |
@@ -13,12 +13,12 @@ discard block |
||
13 | 13 | // unfortunately, this needs to be done upon INCLUSION of this file, |
14 | 14 | // instead of construction, because it only gets constructed on first page load |
15 | 15 | // (all other times it gets resurrected from a wordpress option) |
16 | -$stages = glob(EE_CORE . 'data_migration_scripts/4_6_0_stages/*'); |
|
16 | +$stages = glob(EE_CORE.'data_migration_scripts/4_6_0_stages/*'); |
|
17 | 17 | $class_to_filepath = array(); |
18 | 18 | foreach ($stages as $filepath) { |
19 | 19 | $matches = array(); |
20 | 20 | preg_match('~4_6_0_stages/(.*).dmsstage.php~', $filepath, $matches); |
21 | - $class_to_filepath[ $matches[1] ] = $filepath; |
|
21 | + $class_to_filepath[$matches[1]] = $filepath; |
|
22 | 22 | } |
23 | 23 | // give addons a chance to autoload their stages too |
24 | 24 | $class_to_filepath = apply_filters('FHEE__EE_DMS_4_6_0__autoloaded_stages', $class_to_filepath); |
@@ -72,10 +72,10 @@ discard block |
||
72 | 72 | if (version_compare($version_string, '4.6.0.decaf', '<') && version_compare($version_string, '4.5.0.decaf', '>=')) { |
73 | 73 | // echo "$version_string can be migrated from"; |
74 | 74 | return true; |
75 | - } elseif (! $version_string) { |
|
75 | + } elseif ( ! $version_string) { |
|
76 | 76 | // echo "no version string provided: $version_string"; |
77 | 77 | // no version string provided... this must be pre 4.3 |
78 | - return false;// changed mind. dont want people thinking they should migrate yet because they cant |
|
78 | + return false; // changed mind. dont want people thinking they should migrate yet because they cant |
|
79 | 79 | } else { |
80 | 80 | // echo "$version_string doesnt apply"; |
81 | 81 | return false; |
@@ -90,7 +90,7 @@ discard block |
||
90 | 90 | public function schema_changes_before_migration() |
91 | 91 | { |
92 | 92 | // relies on 4.1's EEH_Activation::create_table |
93 | - require_once(EE_HELPERS . 'EEH_Activation.helper.php'); |
|
93 | + require_once(EE_HELPERS.'EEH_Activation.helper.php'); |
|
94 | 94 | $table_name = 'esp_answer'; |
95 | 95 | $sql = "ANS_ID int(10) unsigned NOT NULL AUTO_INCREMENT, |
96 | 96 | REG_ID int(10) unsigned NOT NULL, |
@@ -537,7 +537,7 @@ discard block |
||
537 | 537 | public function add_default_admin_only_payments() |
538 | 538 | { |
539 | 539 | global $wpdb; |
540 | - $table_name = $wpdb->prefix . "esp_payment_method"; |
|
540 | + $table_name = $wpdb->prefix."esp_payment_method"; |
|
541 | 541 | $user_id = EEH_Activation::get_default_creator_id(); |
542 | 542 | if ($this->_get_table_analysis()->tableExists($table_name)) { |
543 | 543 | $SQL = "SELECT COUNT( * ) FROM $table_name"; |
@@ -565,7 +565,7 @@ discard block |
||
565 | 565 | $slug = sanitize_key($nicename); |
566 | 566 | // check that such a payment method exists |
567 | 567 | $exists = $wpdb->get_var($wpdb->prepare("SELECT count(*) FROM $table_name WHERE PMD_slug = %s", $slug)); |
568 | - if (! $exists) { |
|
568 | + if ( ! $exists) { |
|
569 | 569 | $values = array( |
570 | 570 | 'PMD_type' => 'Admin_Only', |
571 | 571 | 'PMD_name' => $nicename, |
@@ -579,16 +579,16 @@ discard block |
||
579 | 579 | $table_name, |
580 | 580 | $values, |
581 | 581 | array( |
582 | - '%s',// PMD_type |
|
583 | - '%s',// PMD_name |
|
584 | - '%s',// PMD_admin_name |
|
585 | - '%s',// PMD_admin_desc |
|
586 | - '%s',// PMD_slug |
|
587 | - '%d',// PMD_wp_user |
|
588 | - '%s',// PMD_scope |
|
582 | + '%s', // PMD_type |
|
583 | + '%s', // PMD_name |
|
584 | + '%s', // PMD_admin_name |
|
585 | + '%s', // PMD_admin_desc |
|
586 | + '%s', // PMD_slug |
|
587 | + '%d', // PMD_wp_user |
|
588 | + '%s', // PMD_scope |
|
589 | 589 | ) |
590 | 590 | ); |
591 | - if (! $success) { |
|
591 | + if ( ! $success) { |
|
592 | 592 | $this->add_error(sprintf(esc_html__( |
593 | 593 | "Could not insert new admin-only payment method with values %s during migration", |
594 | 594 | "event_espresso" |
@@ -610,11 +610,11 @@ discard block |
||
610 | 610 | public function insert_default_currencies() |
611 | 611 | { |
612 | 612 | global $wpdb; |
613 | - $currency_table = $wpdb->prefix . "esp_currency"; |
|
613 | + $currency_table = $wpdb->prefix."esp_currency"; |
|
614 | 614 | if ($this->_get_table_analysis()->tableExists($currency_table)) { |
615 | 615 | $SQL = "SELECT COUNT('CUR_code') FROM $currency_table"; |
616 | 616 | $countries = $wpdb->get_var($SQL); |
617 | - if (! $countries) { |
|
617 | + if ( ! $countries) { |
|
618 | 618 | $SQL = "INSERT INTO $currency_table |
619 | 619 | ( CUR_code, CUR_single, CUR_plural, CUR_sign, CUR_dec_plc, CUR_active) VALUES |
620 | 620 | ( 'EUR', 'Euro', 'Euros', '€', 2,1), |
@@ -10,9 +10,9 @@ discard block |
||
10 | 10 | $stages = glob(EE_CORE . 'data_migration_scripts/4_6_0_stages/*'); |
11 | 11 | $class_to_filepath = array(); |
12 | 12 | foreach ($stages as $filepath) { |
13 | - $matches = array(); |
|
14 | - preg_match('~4_6_0_stages/(.*).dmsstage.php~', $filepath, $matches); |
|
15 | - $class_to_filepath[ $matches[1] ] = $filepath; |
|
13 | + $matches = array(); |
|
14 | + preg_match('~4_6_0_stages/(.*).dmsstage.php~', $filepath, $matches); |
|
15 | + $class_to_filepath[ $matches[1] ] = $filepath; |
|
16 | 16 | } |
17 | 17 | // give addons a chance to autoload their stages too |
18 | 18 | $class_to_filepath = apply_filters('FHEE__EE_DMS_4_6_0__autoloaded_stages', $class_to_filepath); |
@@ -33,69 +33,69 @@ discard block |
||
33 | 33 | */ |
34 | 34 | class EE_DMS_Core_4_6_0 extends EE_Data_Migration_Script_Base |
35 | 35 | { |
36 | - /** |
|
37 | - * return EE_DMS_Core_4_6_0 |
|
38 | - * |
|
39 | - * @param TableManager $table_manager |
|
40 | - * @param TableAnalysis $table_analysis |
|
41 | - */ |
|
42 | - public function __construct(TableManager $table_manager = null, TableAnalysis $table_analysis = null) |
|
43 | - { |
|
44 | - $this->_pretty_name = esc_html__("Data Update to Event Espresso 4.6.0", "event_espresso"); |
|
45 | - $this->_priority = 10; |
|
46 | - $this->_migration_stages = array( |
|
47 | - new EE_DMS_4_6_0_gateways(), |
|
48 | - new EE_DMS_4_6_0_question_types(), |
|
49 | - new EE_DMS_4_6_0_country_system_question(), |
|
50 | - new EE_DMS_4_6_0_state_system_question(), |
|
51 | - new EE_DMS_4_6_0_billing_info(), |
|
52 | - new EE_DMS_4_6_0_transactions(), |
|
53 | - new EE_DMS_4_6_0_payments(), |
|
54 | - new EE_DMS_4_6_0_invoice_settings(), |
|
55 | - ); |
|
56 | - parent::__construct($table_manager, $table_analysis); |
|
57 | - } |
|
36 | + /** |
|
37 | + * return EE_DMS_Core_4_6_0 |
|
38 | + * |
|
39 | + * @param TableManager $table_manager |
|
40 | + * @param TableAnalysis $table_analysis |
|
41 | + */ |
|
42 | + public function __construct(TableManager $table_manager = null, TableAnalysis $table_analysis = null) |
|
43 | + { |
|
44 | + $this->_pretty_name = esc_html__("Data Update to Event Espresso 4.6.0", "event_espresso"); |
|
45 | + $this->_priority = 10; |
|
46 | + $this->_migration_stages = array( |
|
47 | + new EE_DMS_4_6_0_gateways(), |
|
48 | + new EE_DMS_4_6_0_question_types(), |
|
49 | + new EE_DMS_4_6_0_country_system_question(), |
|
50 | + new EE_DMS_4_6_0_state_system_question(), |
|
51 | + new EE_DMS_4_6_0_billing_info(), |
|
52 | + new EE_DMS_4_6_0_transactions(), |
|
53 | + new EE_DMS_4_6_0_payments(), |
|
54 | + new EE_DMS_4_6_0_invoice_settings(), |
|
55 | + ); |
|
56 | + parent::__construct($table_manager, $table_analysis); |
|
57 | + } |
|
58 | 58 | |
59 | 59 | |
60 | 60 | |
61 | - /** |
|
62 | - * @param array $version_array |
|
63 | - * @return bool |
|
64 | - */ |
|
65 | - public function can_migrate_from_version($version_array) |
|
66 | - { |
|
67 | - $version_string = $version_array['Core']; |
|
68 | - if (version_compare($version_string, '4.6.0.decaf', '<') && version_compare($version_string, '4.5.0.decaf', '>=')) { |
|
61 | + /** |
|
62 | + * @param array $version_array |
|
63 | + * @return bool |
|
64 | + */ |
|
65 | + public function can_migrate_from_version($version_array) |
|
66 | + { |
|
67 | + $version_string = $version_array['Core']; |
|
68 | + if (version_compare($version_string, '4.6.0.decaf', '<') && version_compare($version_string, '4.5.0.decaf', '>=')) { |
|
69 | 69 | // echo "$version_string can be migrated from"; |
70 | - return true; |
|
71 | - } elseif (! $version_string) { |
|
70 | + return true; |
|
71 | + } elseif (! $version_string) { |
|
72 | 72 | // echo "no version string provided: $version_string"; |
73 | - // no version string provided... this must be pre 4.3 |
|
74 | - return false;// changed mind. dont want people thinking they should migrate yet because they cant |
|
75 | - } else { |
|
73 | + // no version string provided... this must be pre 4.3 |
|
74 | + return false;// changed mind. dont want people thinking they should migrate yet because they cant |
|
75 | + } else { |
|
76 | 76 | // echo "$version_string doesnt apply"; |
77 | - return false; |
|
78 | - } |
|
79 | - } |
|
77 | + return false; |
|
78 | + } |
|
79 | + } |
|
80 | 80 | |
81 | 81 | |
82 | 82 | |
83 | - /** |
|
84 | - * @return bool |
|
85 | - */ |
|
86 | - public function schema_changes_before_migration() |
|
87 | - { |
|
88 | - // relies on 4.1's EEH_Activation::create_table |
|
89 | - require_once(EE_HELPERS . 'EEH_Activation.helper.php'); |
|
90 | - $table_name = 'esp_answer'; |
|
91 | - $sql = "ANS_ID int(10) unsigned NOT NULL AUTO_INCREMENT, |
|
83 | + /** |
|
84 | + * @return bool |
|
85 | + */ |
|
86 | + public function schema_changes_before_migration() |
|
87 | + { |
|
88 | + // relies on 4.1's EEH_Activation::create_table |
|
89 | + require_once(EE_HELPERS . 'EEH_Activation.helper.php'); |
|
90 | + $table_name = 'esp_answer'; |
|
91 | + $sql = "ANS_ID int(10) unsigned NOT NULL AUTO_INCREMENT, |
|
92 | 92 | REG_ID int(10) unsigned NOT NULL, |
93 | 93 | QST_ID int(10) unsigned NOT NULL, |
94 | 94 | ANS_value text NOT NULL, |
95 | 95 | PRIMARY KEY (ANS_ID)"; |
96 | - $this->_table_should_exist_previously($table_name, $sql, 'ENGINE=InnoDB'); |
|
97 | - $table_name = 'esp_attendee_meta'; |
|
98 | - $sql = "ATTM_ID int(10) unsigned NOT NULL AUTO_INCREMENT, |
|
96 | + $this->_table_should_exist_previously($table_name, $sql, 'ENGINE=InnoDB'); |
|
97 | + $table_name = 'esp_attendee_meta'; |
|
98 | + $sql = "ATTM_ID int(10) unsigned NOT NULL AUTO_INCREMENT, |
|
99 | 99 | ATT_ID bigint(20) unsigned NOT NULL, |
100 | 100 | ATT_fname varchar(45) NOT NULL, |
101 | 101 | ATT_lname varchar(45) NOT NULL, |
@@ -111,9 +111,9 @@ discard block |
||
111 | 111 | KEY ATT_fname (ATT_fname), |
112 | 112 | KEY ATT_lname (ATT_lname), |
113 | 113 | KEY ATT_email (ATT_email(191))"; |
114 | - $this->_table_should_exist_previously($table_name, $sql, 'ENGINE=InnoDB '); |
|
115 | - $table_name = 'esp_country'; |
|
116 | - $sql = "CNT_ISO varchar(2) COLLATE utf8_bin NOT NULL, |
|
114 | + $this->_table_should_exist_previously($table_name, $sql, 'ENGINE=InnoDB '); |
|
115 | + $table_name = 'esp_country'; |
|
116 | + $sql = "CNT_ISO varchar(2) COLLATE utf8_bin NOT NULL, |
|
117 | 117 | CNT_ISO3 varchar(3) COLLATE utf8_bin NOT NULL, |
118 | 118 | RGN_ID tinyint(3) unsigned DEFAULT NULL, |
119 | 119 | CNT_name varchar(45) COLLATE utf8_bin NOT NULL, |
@@ -129,18 +129,18 @@ discard block |
||
129 | 129 | CNT_is_EU tinyint(1) DEFAULT '0', |
130 | 130 | CNT_active tinyint(1) DEFAULT '0', |
131 | 131 | PRIMARY KEY (CNT_ISO)"; |
132 | - $this->_table_should_exist_previously($table_name, $sql, 'ENGINE=InnoDB'); |
|
133 | - $table_name = 'esp_currency'; |
|
134 | - $sql = "CUR_code varchar(6) COLLATE utf8_bin NOT NULL, |
|
132 | + $this->_table_should_exist_previously($table_name, $sql, 'ENGINE=InnoDB'); |
|
133 | + $table_name = 'esp_currency'; |
|
134 | + $sql = "CUR_code varchar(6) COLLATE utf8_bin NOT NULL, |
|
135 | 135 | CUR_single varchar(45) COLLATE utf8_bin DEFAULT 'dollar', |
136 | 136 | CUR_plural varchar(45) COLLATE utf8_bin DEFAULT 'dollars', |
137 | 137 | CUR_sign varchar(45) COLLATE utf8_bin DEFAULT '$', |
138 | 138 | CUR_dec_plc varchar(1) COLLATE utf8_bin NOT NULL DEFAULT '2', |
139 | 139 | CUR_active tinyint(1) DEFAULT '0', |
140 | 140 | PRIMARY KEY (CUR_code)"; |
141 | - $this->_table_is_new_in_this_version($table_name, $sql, 'ENGINE=InnoDB'); |
|
142 | - $table_name = 'esp_datetime'; |
|
143 | - $sql = "DTT_ID int(10) unsigned NOT NULL AUTO_INCREMENT, |
|
141 | + $this->_table_is_new_in_this_version($table_name, $sql, 'ENGINE=InnoDB'); |
|
142 | + $table_name = 'esp_datetime'; |
|
143 | + $sql = "DTT_ID int(10) unsigned NOT NULL AUTO_INCREMENT, |
|
144 | 144 | EVT_ID bigint(20) unsigned NOT NULL, |
145 | 145 | DTT_name varchar(255) NOT NULL DEFAULT '', |
146 | 146 | DTT_description text NOT NULL, |
@@ -155,9 +155,9 @@ discard block |
||
155 | 155 | PRIMARY KEY (DTT_ID), |
156 | 156 | KEY EVT_ID (EVT_ID), |
157 | 157 | KEY DTT_is_primary (DTT_is_primary)"; |
158 | - $this->_table_should_exist_previously($table_name, $sql, 'ENGINE=InnoDB'); |
|
159 | - $table_name = 'esp_event_meta'; |
|
160 | - $sql = " |
|
158 | + $this->_table_should_exist_previously($table_name, $sql, 'ENGINE=InnoDB'); |
|
159 | + $table_name = 'esp_event_meta'; |
|
160 | + $sql = " |
|
161 | 161 | EVTM_ID int(10) NOT NULL AUTO_INCREMENT, |
162 | 162 | EVT_ID bigint(20) unsigned NOT NULL, |
163 | 163 | EVT_display_desc tinyint(1) unsigned NOT NULL DEFAULT 1, |
@@ -172,31 +172,31 @@ discard block |
||
172 | 172 | EVT_external_URL varchar(200) NULL, |
173 | 173 | EVT_donations tinyint(1) NULL, |
174 | 174 | PRIMARY KEY (EVTM_ID)"; |
175 | - $this->_table_should_exist_previously($table_name, $sql, 'ENGINE=InnoDB'); |
|
176 | - $table_name = 'esp_event_question_group'; |
|
177 | - $sql = "EQG_ID int(10) unsigned NOT NULL AUTO_INCREMENT, |
|
175 | + $this->_table_should_exist_previously($table_name, $sql, 'ENGINE=InnoDB'); |
|
176 | + $table_name = 'esp_event_question_group'; |
|
177 | + $sql = "EQG_ID int(10) unsigned NOT NULL AUTO_INCREMENT, |
|
178 | 178 | EVT_ID bigint(20) unsigned NOT NULL, |
179 | 179 | QSG_ID int(10) unsigned NOT NULL, |
180 | 180 | EQG_primary tinyint(1) unsigned NOT NULL DEFAULT 0, |
181 | 181 | PRIMARY KEY (EQG_ID)"; |
182 | - $this->_table_should_exist_previously($table_name, $sql, 'ENGINE=InnoDB'); |
|
183 | - $table_name = 'esp_event_venue'; |
|
184 | - $sql = "EVV_ID int(11) NOT NULL AUTO_INCREMENT, |
|
182 | + $this->_table_should_exist_previously($table_name, $sql, 'ENGINE=InnoDB'); |
|
183 | + $table_name = 'esp_event_venue'; |
|
184 | + $sql = "EVV_ID int(11) NOT NULL AUTO_INCREMENT, |
|
185 | 185 | EVT_ID bigint(20) unsigned NOT NULL, |
186 | 186 | VNU_ID bigint(20) unsigned NOT NULL, |
187 | 187 | EVV_primary tinyint(1) unsigned NOT NULL DEFAULT 0, |
188 | 188 | PRIMARY KEY (EVV_ID)"; |
189 | - $this->_table_should_exist_previously($table_name, $sql, 'ENGINE=InnoDB'); |
|
190 | - $table_name = 'esp_extra_meta'; |
|
191 | - $sql = "EXM_ID int(11) NOT NULL AUTO_INCREMENT, |
|
189 | + $this->_table_should_exist_previously($table_name, $sql, 'ENGINE=InnoDB'); |
|
190 | + $table_name = 'esp_extra_meta'; |
|
191 | + $sql = "EXM_ID int(11) NOT NULL AUTO_INCREMENT, |
|
192 | 192 | OBJ_ID int(11) DEFAULT NULL, |
193 | 193 | EXM_type varchar(45) DEFAULT NULL, |
194 | 194 | EXM_key varchar(45) DEFAULT NULL, |
195 | 195 | EXM_value text, |
196 | 196 | PRIMARY KEY (EXM_ID)"; |
197 | - $this->_table_should_exist_previously($table_name, $sql, 'ENGINE=InnoDB'); |
|
198 | - $table_name = 'esp_line_item'; |
|
199 | - $sql = "LIN_ID int(11) NOT NULL AUTO_INCREMENT, |
|
197 | + $this->_table_should_exist_previously($table_name, $sql, 'ENGINE=InnoDB'); |
|
198 | + $table_name = 'esp_line_item'; |
|
199 | + $sql = "LIN_ID int(11) NOT NULL AUTO_INCREMENT, |
|
200 | 200 | LIN_code varchar(245) NOT NULL DEFAULT '', |
201 | 201 | TXN_ID int(11) DEFAULT NULL, |
202 | 202 | LIN_name varchar(245) NOT NULL DEFAULT '', |
@@ -212,9 +212,9 @@ discard block |
||
212 | 212 | OBJ_ID int(11) DEFAULT NULL, |
213 | 213 | OBJ_type varchar(45)DEFAULT NULL, |
214 | 214 | PRIMARY KEY (LIN_ID)"; |
215 | - $this->_table_should_exist_previously($table_name, $sql, 'ENGINE=InnoDB'); |
|
216 | - $table_name = 'esp_log'; |
|
217 | - $sql = "LOG_ID int(11) NOT NULL AUTO_INCREMENT, |
|
215 | + $this->_table_should_exist_previously($table_name, $sql, 'ENGINE=InnoDB'); |
|
216 | + $table_name = 'esp_log'; |
|
217 | + $sql = "LOG_ID int(11) NOT NULL AUTO_INCREMENT, |
|
218 | 218 | LOG_time datetime DEFAULT NULL, |
219 | 219 | OBJ_ID varchar(45) DEFAULT NULL, |
220 | 220 | OBJ_type varchar(45) DEFAULT NULL, |
@@ -222,19 +222,19 @@ discard block |
||
222 | 222 | LOG_message text, |
223 | 223 | LOG_wp_user int(11) DEFAULT NULL, |
224 | 224 | PRIMARY KEY (LOG_ID)"; |
225 | - $this->_table_is_new_in_this_version($table_name, $sql, 'ENGINE=InnoDB'); |
|
226 | - $table_name = 'esp_message_template'; |
|
227 | - $sql = "MTP_ID int(10) unsigned NOT NULL AUTO_INCREMENT, |
|
225 | + $this->_table_is_new_in_this_version($table_name, $sql, 'ENGINE=InnoDB'); |
|
226 | + $table_name = 'esp_message_template'; |
|
227 | + $sql = "MTP_ID int(10) unsigned NOT NULL AUTO_INCREMENT, |
|
228 | 228 | GRP_ID int(10) unsigned NOT NULL, |
229 | 229 | MTP_context varchar(50) NOT NULL, |
230 | 230 | MTP_template_field varchar(30) NOT NULL, |
231 | 231 | MTP_content text NOT NULL, |
232 | 232 | PRIMARY KEY (MTP_ID), |
233 | 233 | KEY GRP_ID (GRP_ID)"; |
234 | - $this->_table_should_exist_previously($table_name, $sql, 'ENGINE=InnoDB'); |
|
235 | - $this->_get_table_manager()->dropIndex('esp_message_template_group', 'EVT_ID'); |
|
236 | - $table_name = 'esp_message_template_group'; |
|
237 | - $sql = "GRP_ID int(10) unsigned NOT NULL AUTO_INCREMENT, |
|
234 | + $this->_table_should_exist_previously($table_name, $sql, 'ENGINE=InnoDB'); |
|
235 | + $this->_get_table_manager()->dropIndex('esp_message_template_group', 'EVT_ID'); |
|
236 | + $table_name = 'esp_message_template_group'; |
|
237 | + $sql = "GRP_ID int(10) unsigned NOT NULL AUTO_INCREMENT, |
|
238 | 238 | MTP_user_id int(10) NOT NULL DEFAULT '1', |
239 | 239 | MTP_name varchar(245) NOT NULL DEFAULT '', |
240 | 240 | MTP_description varchar(245) NOT NULL DEFAULT '', |
@@ -246,17 +246,17 @@ discard block |
||
246 | 246 | MTP_is_active tinyint(1) NOT NULL DEFAULT '1', |
247 | 247 | PRIMARY KEY (GRP_ID), |
248 | 248 | KEY MTP_user_id (MTP_user_id)"; |
249 | - $this->_table_should_exist_previously($table_name, $sql, 'ENGINE=InnoDB'); |
|
250 | - $table_name = 'esp_event_message_template'; |
|
251 | - $sql = "EMT_ID bigint(20) unsigned NOT NULL AUTO_INCREMENT, |
|
249 | + $this->_table_should_exist_previously($table_name, $sql, 'ENGINE=InnoDB'); |
|
250 | + $table_name = 'esp_event_message_template'; |
|
251 | + $sql = "EMT_ID bigint(20) unsigned NOT NULL AUTO_INCREMENT, |
|
252 | 252 | EVT_ID bigint(20) unsigned NOT NULL DEFAULT 0, |
253 | 253 | GRP_ID int(10) unsigned NOT NULL DEFAULT 0, |
254 | 254 | PRIMARY KEY (EMT_ID), |
255 | 255 | KEY EVT_ID (EVT_ID), |
256 | 256 | KEY GRP_ID (GRP_ID)"; |
257 | - $this->_table_should_exist_previously($table_name, $sql, 'ENGINE=InnoDB'); |
|
258 | - $table_name = 'esp_payment'; |
|
259 | - $sql = "PAY_ID int(10) unsigned NOT NULL AUTO_INCREMENT, |
|
257 | + $this->_table_should_exist_previously($table_name, $sql, 'ENGINE=InnoDB'); |
|
258 | + $table_name = 'esp_payment'; |
|
259 | + $sql = "PAY_ID int(10) unsigned NOT NULL AUTO_INCREMENT, |
|
260 | 260 | TXN_ID int(10) unsigned DEFAULT NULL, |
261 | 261 | STS_ID varchar(3) COLLATE utf8_bin DEFAULT NULL, |
262 | 262 | PAY_timestamp datetime NOT NULL DEFAULT '0000-00-00 00:00:00', |
@@ -273,9 +273,9 @@ discard block |
||
273 | 273 | PRIMARY KEY (PAY_ID), |
274 | 274 | KEY TXN_ID (TXN_ID), |
275 | 275 | KEY PAY_timestamp (PAY_timestamp)"; |
276 | - $this->_table_should_exist_previously($table_name, $sql, 'ENGINE=InnoDB '); |
|
277 | - $table_name = 'esp_payment_method'; |
|
278 | - $sql = "PMD_ID int(11) NOT NULL AUTO_INCREMENT, |
|
276 | + $this->_table_should_exist_previously($table_name, $sql, 'ENGINE=InnoDB '); |
|
277 | + $table_name = 'esp_payment_method'; |
|
278 | + $sql = "PMD_ID int(11) NOT NULL AUTO_INCREMENT, |
|
279 | 279 | PMD_type varchar(124) DEFAULT NULL, |
280 | 280 | PMD_name varchar(255) DEFAULT NULL, |
281 | 281 | PMD_desc text, |
@@ -290,28 +290,28 @@ discard block |
||
290 | 290 | PMD_scope varchar(255) NULL DEFAULT 'frontend', |
291 | 291 | PRIMARY KEY (PMD_ID), |
292 | 292 | UNIQUE KEY PMD_slug_UNIQUE (PMD_slug)"; |
293 | - $this->_table_is_new_in_this_version($table_name, $sql, 'ENGINE=InnoDB '); |
|
294 | - $table_name = "esp_ticket_price"; |
|
295 | - $sql = "TKP_ID int(10) unsigned NOT NULL AUTO_INCREMENT, |
|
293 | + $this->_table_is_new_in_this_version($table_name, $sql, 'ENGINE=InnoDB '); |
|
294 | + $table_name = "esp_ticket_price"; |
|
295 | + $sql = "TKP_ID int(10) unsigned NOT NULL AUTO_INCREMENT, |
|
296 | 296 | TKT_ID int(10) unsigned NOT NULL, |
297 | 297 | PRC_ID int(10) unsigned NOT NULL, |
298 | 298 | PRIMARY KEY (TKP_ID)"; |
299 | - $this->_table_should_exist_previously($table_name, $sql, 'ENGINE=InnoDB'); |
|
300 | - $table_name = "esp_datetime_ticket"; |
|
301 | - $sql = "DTK_ID int(10) unsigned NOT NULL AUTO_INCREMENT, |
|
299 | + $this->_table_should_exist_previously($table_name, $sql, 'ENGINE=InnoDB'); |
|
300 | + $table_name = "esp_datetime_ticket"; |
|
301 | + $sql = "DTK_ID int(10) unsigned NOT NULL AUTO_INCREMENT, |
|
302 | 302 | DTT_ID int(10) unsigned NOT NULL, |
303 | 303 | TKT_ID int(10) unsigned NOT NULL, |
304 | 304 | PRIMARY KEY (DTK_ID)"; |
305 | - $this->_table_should_exist_previously($table_name, $sql, 'ENGINE=InnoDB'); |
|
306 | - $table_name = "esp_ticket_template"; |
|
307 | - $sql = "TTM_ID int(10) unsigned NOT NULL AUTO_INCREMENT, |
|
305 | + $this->_table_should_exist_previously($table_name, $sql, 'ENGINE=InnoDB'); |
|
306 | + $table_name = "esp_ticket_template"; |
|
307 | + $sql = "TTM_ID int(10) unsigned NOT NULL AUTO_INCREMENT, |
|
308 | 308 | TTM_name varchar(45) NOT NULL, |
309 | 309 | TTM_description text, |
310 | 310 | TTM_file varchar(45), |
311 | 311 | PRIMARY KEY (TTM_ID)"; |
312 | - $this->_table_should_exist_previously($table_name, $sql, 'ENGINE=InnoDB'); |
|
313 | - $table_name = 'esp_question'; |
|
314 | - $sql = 'QST_ID int(10) unsigned NOT NULL AUTO_INCREMENT, |
|
312 | + $this->_table_should_exist_previously($table_name, $sql, 'ENGINE=InnoDB'); |
|
313 | + $table_name = 'esp_question'; |
|
314 | + $sql = 'QST_ID int(10) unsigned NOT NULL AUTO_INCREMENT, |
|
315 | 315 | QST_display_text text NOT NULL, |
316 | 316 | QST_admin_label varchar(255) NOT NULL, |
317 | 317 | QST_system varchar(25) DEFAULT NULL, |
@@ -323,25 +323,25 @@ discard block |
||
323 | 323 | QST_wp_user bigint(20) unsigned NULL, |
324 | 324 | QST_deleted tinyint(1) unsigned NOT NULL DEFAULT 0, |
325 | 325 | PRIMARY KEY (QST_ID)'; |
326 | - $this->_table_should_exist_previously($table_name, $sql, 'ENGINE=InnoDB'); |
|
327 | - $table_name = 'esp_question_group_question'; |
|
328 | - $sql = "QGQ_ID int(10) unsigned NOT NULL AUTO_INCREMENT, |
|
326 | + $this->_table_should_exist_previously($table_name, $sql, 'ENGINE=InnoDB'); |
|
327 | + $table_name = 'esp_question_group_question'; |
|
328 | + $sql = "QGQ_ID int(10) unsigned NOT NULL AUTO_INCREMENT, |
|
329 | 329 | QSG_ID int(10) unsigned NOT NULL, |
330 | 330 | QST_ID int(10) unsigned NOT NULL, |
331 | 331 | QGQ_order int(10) unsigned NOT NULL DEFAULT 0, |
332 | 332 | PRIMARY KEY (QGQ_ID) "; |
333 | - $this->_table_should_exist_previously($table_name, $sql, 'ENGINE=InnoDB'); |
|
334 | - $table_name = 'esp_question_option'; |
|
335 | - $sql = "QSO_ID int(10) unsigned NOT NULL AUTO_INCREMENT, |
|
333 | + $this->_table_should_exist_previously($table_name, $sql, 'ENGINE=InnoDB'); |
|
334 | + $table_name = 'esp_question_option'; |
|
335 | + $sql = "QSO_ID int(10) unsigned NOT NULL AUTO_INCREMENT, |
|
336 | 336 | QSO_value varchar(255) NOT NULL, |
337 | 337 | QSO_desc text NOT NULL, |
338 | 338 | QST_ID int(10) unsigned NOT NULL, |
339 | 339 | QSO_order int(10) unsigned NOT NULL DEFAULT 0, |
340 | 340 | QSO_deleted tinyint(1) unsigned NOT NULL DEFAULT 0, |
341 | 341 | PRIMARY KEY (QSO_ID)"; |
342 | - $this->_table_should_exist_previously($table_name, $sql, 'ENGINE=InnoDB'); |
|
343 | - $table_name = 'esp_registration'; |
|
344 | - $sql = "REG_ID int(10) unsigned NOT NULL AUTO_INCREMENT, |
|
342 | + $this->_table_should_exist_previously($table_name, $sql, 'ENGINE=InnoDB'); |
|
343 | + $table_name = 'esp_registration'; |
|
344 | + $sql = "REG_ID int(10) unsigned NOT NULL AUTO_INCREMENT, |
|
345 | 345 | EVT_ID bigint(20) unsigned NOT NULL, |
346 | 346 | ATT_ID bigint(20) unsigned NOT NULL, |
347 | 347 | TXN_ID int(10) unsigned NOT NULL, |
@@ -364,25 +364,25 @@ discard block |
||
364 | 364 | KEY STS_ID (STS_ID), |
365 | 365 | KEY REG_url_link (REG_url_link), |
366 | 366 | KEY REG_code (REG_code)"; |
367 | - $this->_table_should_exist_previously($table_name, $sql, 'ENGINE=InnoDB '); |
|
368 | - $table_name = 'esp_checkin'; |
|
369 | - $sql = "CHK_ID int(10) unsigned NOT NULL AUTO_INCREMENT, |
|
367 | + $this->_table_should_exist_previously($table_name, $sql, 'ENGINE=InnoDB '); |
|
368 | + $table_name = 'esp_checkin'; |
|
369 | + $sql = "CHK_ID int(10) unsigned NOT NULL AUTO_INCREMENT, |
|
370 | 370 | REG_ID int(10) unsigned NOT NULL, |
371 | 371 | DTT_ID int(10) unsigned NOT NULL, |
372 | 372 | CHK_in tinyint(1) unsigned NOT NULL DEFAULT 1, |
373 | 373 | CHK_timestamp datetime NOT NULL DEFAULT '0000-00-00 00:00:00', |
374 | 374 | PRIMARY KEY (CHK_ID)"; |
375 | - $this->_table_should_exist_previously($table_name, $sql, 'ENGINE=InnoDB'); |
|
376 | - $table_name = 'esp_state'; |
|
377 | - $sql = "STA_ID smallint(5) unsigned NOT NULL AUTO_INCREMENT, |
|
375 | + $this->_table_should_exist_previously($table_name, $sql, 'ENGINE=InnoDB'); |
|
376 | + $table_name = 'esp_state'; |
|
377 | + $sql = "STA_ID smallint(5) unsigned NOT NULL AUTO_INCREMENT, |
|
378 | 378 | CNT_ISO varchar(2) COLLATE utf8_bin NOT NULL, |
379 | 379 | STA_abbrev varchar(24) COLLATE utf8_bin NOT NULL, |
380 | 380 | STA_name varchar(100) COLLATE utf8_bin NOT NULL, |
381 | 381 | STA_active tinyint(1) DEFAULT '1', |
382 | 382 | PRIMARY KEY (STA_ID)"; |
383 | - $this->_table_should_exist_previously($table_name, $sql, 'ENGINE=InnoDB'); |
|
384 | - $table_name = 'esp_status'; |
|
385 | - $sql = "STS_ID varchar(3) COLLATE utf8_bin NOT NULL, |
|
383 | + $this->_table_should_exist_previously($table_name, $sql, 'ENGINE=InnoDB'); |
|
384 | + $table_name = 'esp_status'; |
|
385 | + $sql = "STS_ID varchar(3) COLLATE utf8_bin NOT NULL, |
|
386 | 386 | STS_code varchar(45) COLLATE utf8_bin NOT NULL, |
387 | 387 | STS_type set('event','registration','transaction','payment','email') COLLATE utf8_bin NOT NULL, |
388 | 388 | STS_can_edit tinyint(1) NOT NULL DEFAULT 0, |
@@ -390,9 +390,9 @@ discard block |
||
390 | 390 | STS_open tinyint(1) NOT NULL DEFAULT 1, |
391 | 391 | UNIQUE KEY STS_ID_UNIQUE (STS_ID), |
392 | 392 | KEY STS_type (STS_type)"; |
393 | - $this->_table_should_exist_previously($table_name, $sql, 'ENGINE=InnoDB'); |
|
394 | - $table_name = 'esp_transaction'; |
|
395 | - $sql = "TXN_ID int(10) unsigned NOT NULL AUTO_INCREMENT, |
|
393 | + $this->_table_should_exist_previously($table_name, $sql, 'ENGINE=InnoDB'); |
|
394 | + $table_name = 'esp_transaction'; |
|
395 | + $sql = "TXN_ID int(10) unsigned NOT NULL AUTO_INCREMENT, |
|
396 | 396 | TXN_timestamp datetime NOT NULL DEFAULT '0000-00-00 00:00:00', |
397 | 397 | TXN_total decimal(10,3) DEFAULT '0.00', |
398 | 398 | TXN_paid decimal(10,3) NOT NULL DEFAULT '0.00', |
@@ -404,9 +404,9 @@ discard block |
||
404 | 404 | PRIMARY KEY (TXN_ID), |
405 | 405 | KEY TXN_timestamp (TXN_timestamp), |
406 | 406 | KEY STS_ID (STS_ID)"; |
407 | - $this->_table_should_exist_previously($table_name, $sql, 'ENGINE=InnoDB'); |
|
408 | - $table_name = 'esp_venue_meta'; |
|
409 | - $sql = "VNUM_ID int(11) NOT NULL AUTO_INCREMENT, |
|
407 | + $this->_table_should_exist_previously($table_name, $sql, 'ENGINE=InnoDB'); |
|
408 | + $table_name = 'esp_venue_meta'; |
|
409 | + $sql = "VNUM_ID int(11) NOT NULL AUTO_INCREMENT, |
|
410 | 410 | VNU_ID bigint(20) unsigned NOT NULL DEFAULT 0, |
411 | 411 | VNU_address varchar(255) DEFAULT NULL, |
412 | 412 | VNU_address2 varchar(255) DEFAULT NULL, |
@@ -424,10 +424,10 @@ discard block |
||
424 | 424 | PRIMARY KEY (VNUM_ID), |
425 | 425 | KEY STA_ID (STA_ID), |
426 | 426 | KEY CNT_ISO (CNT_ISO)"; |
427 | - $this->_table_should_exist_previously($table_name, $sql, 'ENGINE=InnoDB'); |
|
428 | - // modified tables |
|
429 | - $table_name = "esp_price"; |
|
430 | - $sql = "PRC_ID int(10) unsigned NOT NULL AUTO_INCREMENT, |
|
427 | + $this->_table_should_exist_previously($table_name, $sql, 'ENGINE=InnoDB'); |
|
428 | + // modified tables |
|
429 | + $table_name = "esp_price"; |
|
430 | + $sql = "PRC_ID int(10) unsigned NOT NULL AUTO_INCREMENT, |
|
431 | 431 | PRT_ID tinyint(3) unsigned NOT NULL, |
432 | 432 | PRC_amount decimal(10,3) NOT NULL DEFAULT '0.00', |
433 | 433 | PRC_name varchar(245) NOT NULL, |
@@ -439,9 +439,9 @@ discard block |
||
439 | 439 | PRC_wp_user bigint(20) unsigned NULL, |
440 | 440 | PRC_parent int(10) unsigned DEFAULT 0, |
441 | 441 | PRIMARY KEY (PRC_ID)"; |
442 | - $this->_table_should_exist_previously($table_name, $sql, 'ENGINE=InnoDB'); |
|
443 | - $table_name = "esp_price_type"; |
|
444 | - $sql = "PRT_ID tinyint(3) unsigned NOT NULL AUTO_INCREMENT, |
|
442 | + $this->_table_should_exist_previously($table_name, $sql, 'ENGINE=InnoDB'); |
|
443 | + $table_name = "esp_price_type"; |
|
444 | + $sql = "PRT_ID tinyint(3) unsigned NOT NULL AUTO_INCREMENT, |
|
445 | 445 | PRT_name varchar(45) NOT NULL, |
446 | 446 | PBT_ID tinyint(3) unsigned NOT NULL DEFAULT '1', |
447 | 447 | PRT_is_percent tinyint(1) NOT NULL DEFAULT '0', |
@@ -450,9 +450,9 @@ discard block |
||
450 | 450 | PRT_deleted tinyint(1) NOT NULL DEFAULT '0', |
451 | 451 | UNIQUE KEY PRT_name_UNIQUE (PRT_name), |
452 | 452 | PRIMARY KEY (PRT_ID)"; |
453 | - $this->_table_should_exist_previously($table_name, $sql, 'ENGINE=InnoDB '); |
|
454 | - $table_name = "esp_ticket"; |
|
455 | - $sql = "TKT_ID int(10) unsigned NOT NULL AUTO_INCREMENT, |
|
453 | + $this->_table_should_exist_previously($table_name, $sql, 'ENGINE=InnoDB '); |
|
454 | + $table_name = "esp_ticket"; |
|
455 | + $sql = "TKT_ID int(10) unsigned NOT NULL AUTO_INCREMENT, |
|
456 | 456 | TTM_ID int(10) unsigned NOT NULL, |
457 | 457 | TKT_name varchar(245) NOT NULL DEFAULT '', |
458 | 458 | TKT_description text NOT NULL, |
@@ -473,10 +473,10 @@ discard block |
||
473 | 473 | TKT_parent int(10) unsigned DEFAULT '0', |
474 | 474 | TKT_deleted tinyint(1) NOT NULL DEFAULT '0', |
475 | 475 | PRIMARY KEY (TKT_ID)"; |
476 | - $this->_table_should_exist_previously($table_name, $sql, 'ENGINE=InnoDB'); |
|
477 | - $this->_get_table_manager()->dropIndex('esp_question_group', 'QSG_identifier_UNIQUE'); |
|
478 | - $table_name = 'esp_question_group'; |
|
479 | - $sql = 'QSG_ID int(10) unsigned NOT NULL AUTO_INCREMENT, |
|
476 | + $this->_table_should_exist_previously($table_name, $sql, 'ENGINE=InnoDB'); |
|
477 | + $this->_get_table_manager()->dropIndex('esp_question_group', 'QSG_identifier_UNIQUE'); |
|
478 | + $table_name = 'esp_question_group'; |
|
479 | + $sql = 'QSG_ID int(10) unsigned NOT NULL AUTO_INCREMENT, |
|
480 | 480 | QSG_name varchar(255) NOT NULL, |
481 | 481 | QSG_identifier varchar(100) NOT NULL, |
482 | 482 | QSG_desc text NULL, |
@@ -488,124 +488,124 @@ discard block |
||
488 | 488 | QSG_wp_user bigint(20) unsigned NULL, |
489 | 489 | PRIMARY KEY (QSG_ID), |
490 | 490 | UNIQUE KEY QSG_identifier_UNIQUE (QSG_identifier ASC)'; |
491 | - $this->_table_should_exist_previously($table_name, $sql, 'ENGINE=InnoDB'); |
|
492 | - /** @var EE_DMS_Core_4_1_0 $script_4_1_defaults */ |
|
493 | - $script_4_1_defaults = EE_Registry::instance()->load_dms('Core_4_1_0'); |
|
494 | - // (because many need to convert old string states to foreign keys into the states table) |
|
495 | - $script_4_1_defaults->insert_default_states(); |
|
496 | - $script_4_1_defaults->insert_default_countries(); |
|
497 | - /** @var EE_DMS_Core_4_5_0 $script_4_5_defaults */ |
|
498 | - $script_4_5_defaults = EE_Registry::instance()->load_dms('Core_4_5_0'); |
|
499 | - $script_4_5_defaults->insert_default_price_types(); |
|
500 | - $script_4_5_defaults->insert_default_prices(); |
|
501 | - $script_4_5_defaults->insert_default_tickets(); |
|
502 | - // setting up the config wp option pretty well counts as a 'schema change', or at least should happen here |
|
503 | - EE_Config::instance()->update_espresso_config(false, true); |
|
504 | - $this->add_default_admin_only_payments(); |
|
505 | - $this->insert_default_currencies(); |
|
506 | - return true; |
|
507 | - } |
|
491 | + $this->_table_should_exist_previously($table_name, $sql, 'ENGINE=InnoDB'); |
|
492 | + /** @var EE_DMS_Core_4_1_0 $script_4_1_defaults */ |
|
493 | + $script_4_1_defaults = EE_Registry::instance()->load_dms('Core_4_1_0'); |
|
494 | + // (because many need to convert old string states to foreign keys into the states table) |
|
495 | + $script_4_1_defaults->insert_default_states(); |
|
496 | + $script_4_1_defaults->insert_default_countries(); |
|
497 | + /** @var EE_DMS_Core_4_5_0 $script_4_5_defaults */ |
|
498 | + $script_4_5_defaults = EE_Registry::instance()->load_dms('Core_4_5_0'); |
|
499 | + $script_4_5_defaults->insert_default_price_types(); |
|
500 | + $script_4_5_defaults->insert_default_prices(); |
|
501 | + $script_4_5_defaults->insert_default_tickets(); |
|
502 | + // setting up the config wp option pretty well counts as a 'schema change', or at least should happen here |
|
503 | + EE_Config::instance()->update_espresso_config(false, true); |
|
504 | + $this->add_default_admin_only_payments(); |
|
505 | + $this->insert_default_currencies(); |
|
506 | + return true; |
|
507 | + } |
|
508 | 508 | |
509 | 509 | |
510 | 510 | |
511 | - /** |
|
512 | - * @return boolean |
|
513 | - */ |
|
514 | - public function schema_changes_after_migration() |
|
515 | - { |
|
516 | - return true; |
|
517 | - } |
|
511 | + /** |
|
512 | + * @return boolean |
|
513 | + */ |
|
514 | + public function schema_changes_after_migration() |
|
515 | + { |
|
516 | + return true; |
|
517 | + } |
|
518 | 518 | |
519 | 519 | |
520 | 520 | |
521 | - public function migration_page_hooks() |
|
522 | - { |
|
523 | - } |
|
521 | + public function migration_page_hooks() |
|
522 | + { |
|
523 | + } |
|
524 | 524 | |
525 | 525 | |
526 | 526 | |
527 | - public function add_default_admin_only_payments() |
|
528 | - { |
|
529 | - global $wpdb; |
|
530 | - $table_name = $wpdb->prefix . "esp_payment_method"; |
|
531 | - $user_id = EEH_Activation::get_default_creator_id(); |
|
532 | - if ($this->_get_table_analysis()->tableExists($table_name)) { |
|
533 | - $SQL = "SELECT COUNT( * ) FROM $table_name"; |
|
534 | - $existing_payment_methods = $wpdb->get_var($SQL); |
|
535 | - $default_admin_only_payment_methods = apply_filters( |
|
536 | - 'FHEE__EEH_Activation__add_default_admin_only_payments__default_admin_only_payment_methods', |
|
537 | - array( |
|
538 | - (string) esc_html__("Bank", 'event_espresso') => esc_html__("Bank Draft", 'event_espresso'), |
|
539 | - (string) esc_html__("Cash", 'event_espresso') => esc_html__("Cash Delivered Physically", 'event_espresso'), |
|
540 | - (string) esc_html__("Check", 'event_espresso') => esc_html__("Paper Check", 'event_espresso'), |
|
541 | - (string) esc_html__("Credit Card", 'event_espresso') => esc_html__("Offline Credit Card Payment", 'event_espresso'), |
|
542 | - (string) esc_html__("Debit Card", 'event_espresso') => esc_html__("Offline Debit Payment", 'event_espresso'), |
|
543 | - (string) esc_html__("Invoice", 'event_espresso') => esc_html__( |
|
544 | - "Invoice received with monies included", |
|
545 | - 'event_espresso' |
|
546 | - ), |
|
547 | - (string) esc_html__("Money Order", 'event_espresso') => '', |
|
548 | - (string) esc_html__("Paypal", 'event_espresso') => esc_html__("Paypal eCheck, Invoice, etc", 'event_espresso'), |
|
549 | - (string) esc_html__('Other', 'event_espresso') => esc_html__('Other method of payment', 'event_espresso'), |
|
550 | - ) |
|
551 | - ); |
|
552 | - // make sure we hae payment method records for the following |
|
553 | - // so admins can record payments for them from the admin page |
|
554 | - foreach ($default_admin_only_payment_methods as $nicename => $description) { |
|
555 | - $slug = sanitize_key($nicename); |
|
556 | - // check that such a payment method exists |
|
557 | - $exists = $wpdb->get_var($wpdb->prepare("SELECT count(*) FROM $table_name WHERE PMD_slug = %s", $slug)); |
|
558 | - if (! $exists) { |
|
559 | - $values = array( |
|
560 | - 'PMD_type' => 'Admin_Only', |
|
561 | - 'PMD_name' => $nicename, |
|
562 | - 'PMD_admin_name' => $nicename, |
|
563 | - 'PMD_admin_desc' => $description, |
|
564 | - 'PMD_slug' => $slug, |
|
565 | - 'PMD_wp_user' => $user_id, |
|
566 | - 'PMD_scope' => serialize(array('ADMIN')), |
|
567 | - ); |
|
568 | - $success = $wpdb->insert( |
|
569 | - $table_name, |
|
570 | - $values, |
|
571 | - array( |
|
572 | - '%s',// PMD_type |
|
573 | - '%s',// PMD_name |
|
574 | - '%s',// PMD_admin_name |
|
575 | - '%s',// PMD_admin_desc |
|
576 | - '%s',// PMD_slug |
|
577 | - '%d',// PMD_wp_user |
|
578 | - '%s',// PMD_scope |
|
579 | - ) |
|
580 | - ); |
|
581 | - if (! $success) { |
|
582 | - $this->add_error(sprintf(esc_html__( |
|
583 | - "Could not insert new admin-only payment method with values %s during migration", |
|
584 | - "event_espresso" |
|
585 | - ), $this->_json_encode($values))); |
|
586 | - } |
|
587 | - } |
|
588 | - } |
|
589 | - } |
|
590 | - } |
|
527 | + public function add_default_admin_only_payments() |
|
528 | + { |
|
529 | + global $wpdb; |
|
530 | + $table_name = $wpdb->prefix . "esp_payment_method"; |
|
531 | + $user_id = EEH_Activation::get_default_creator_id(); |
|
532 | + if ($this->_get_table_analysis()->tableExists($table_name)) { |
|
533 | + $SQL = "SELECT COUNT( * ) FROM $table_name"; |
|
534 | + $existing_payment_methods = $wpdb->get_var($SQL); |
|
535 | + $default_admin_only_payment_methods = apply_filters( |
|
536 | + 'FHEE__EEH_Activation__add_default_admin_only_payments__default_admin_only_payment_methods', |
|
537 | + array( |
|
538 | + (string) esc_html__("Bank", 'event_espresso') => esc_html__("Bank Draft", 'event_espresso'), |
|
539 | + (string) esc_html__("Cash", 'event_espresso') => esc_html__("Cash Delivered Physically", 'event_espresso'), |
|
540 | + (string) esc_html__("Check", 'event_espresso') => esc_html__("Paper Check", 'event_espresso'), |
|
541 | + (string) esc_html__("Credit Card", 'event_espresso') => esc_html__("Offline Credit Card Payment", 'event_espresso'), |
|
542 | + (string) esc_html__("Debit Card", 'event_espresso') => esc_html__("Offline Debit Payment", 'event_espresso'), |
|
543 | + (string) esc_html__("Invoice", 'event_espresso') => esc_html__( |
|
544 | + "Invoice received with monies included", |
|
545 | + 'event_espresso' |
|
546 | + ), |
|
547 | + (string) esc_html__("Money Order", 'event_espresso') => '', |
|
548 | + (string) esc_html__("Paypal", 'event_espresso') => esc_html__("Paypal eCheck, Invoice, etc", 'event_espresso'), |
|
549 | + (string) esc_html__('Other', 'event_espresso') => esc_html__('Other method of payment', 'event_espresso'), |
|
550 | + ) |
|
551 | + ); |
|
552 | + // make sure we hae payment method records for the following |
|
553 | + // so admins can record payments for them from the admin page |
|
554 | + foreach ($default_admin_only_payment_methods as $nicename => $description) { |
|
555 | + $slug = sanitize_key($nicename); |
|
556 | + // check that such a payment method exists |
|
557 | + $exists = $wpdb->get_var($wpdb->prepare("SELECT count(*) FROM $table_name WHERE PMD_slug = %s", $slug)); |
|
558 | + if (! $exists) { |
|
559 | + $values = array( |
|
560 | + 'PMD_type' => 'Admin_Only', |
|
561 | + 'PMD_name' => $nicename, |
|
562 | + 'PMD_admin_name' => $nicename, |
|
563 | + 'PMD_admin_desc' => $description, |
|
564 | + 'PMD_slug' => $slug, |
|
565 | + 'PMD_wp_user' => $user_id, |
|
566 | + 'PMD_scope' => serialize(array('ADMIN')), |
|
567 | + ); |
|
568 | + $success = $wpdb->insert( |
|
569 | + $table_name, |
|
570 | + $values, |
|
571 | + array( |
|
572 | + '%s',// PMD_type |
|
573 | + '%s',// PMD_name |
|
574 | + '%s',// PMD_admin_name |
|
575 | + '%s',// PMD_admin_desc |
|
576 | + '%s',// PMD_slug |
|
577 | + '%d',// PMD_wp_user |
|
578 | + '%s',// PMD_scope |
|
579 | + ) |
|
580 | + ); |
|
581 | + if (! $success) { |
|
582 | + $this->add_error(sprintf(esc_html__( |
|
583 | + "Could not insert new admin-only payment method with values %s during migration", |
|
584 | + "event_espresso" |
|
585 | + ), $this->_json_encode($values))); |
|
586 | + } |
|
587 | + } |
|
588 | + } |
|
589 | + } |
|
590 | + } |
|
591 | 591 | |
592 | 592 | |
593 | 593 | |
594 | - /** |
|
595 | - * insert_default_countries |
|
596 | - * |
|
597 | - * @static |
|
598 | - * @return void |
|
599 | - */ |
|
600 | - public function insert_default_currencies() |
|
601 | - { |
|
602 | - global $wpdb; |
|
603 | - $currency_table = $wpdb->prefix . "esp_currency"; |
|
604 | - if ($this->_get_table_analysis()->tableExists($currency_table)) { |
|
605 | - $SQL = "SELECT COUNT('CUR_code') FROM $currency_table"; |
|
606 | - $countries = $wpdb->get_var($SQL); |
|
607 | - if (! $countries) { |
|
608 | - $SQL = "INSERT INTO $currency_table |
|
594 | + /** |
|
595 | + * insert_default_countries |
|
596 | + * |
|
597 | + * @static |
|
598 | + * @return void |
|
599 | + */ |
|
600 | + public function insert_default_currencies() |
|
601 | + { |
|
602 | + global $wpdb; |
|
603 | + $currency_table = $wpdb->prefix . "esp_currency"; |
|
604 | + if ($this->_get_table_analysis()->tableExists($currency_table)) { |
|
605 | + $SQL = "SELECT COUNT('CUR_code') FROM $currency_table"; |
|
606 | + $countries = $wpdb->get_var($SQL); |
|
607 | + if (! $countries) { |
|
608 | + $SQL = "INSERT INTO $currency_table |
|
609 | 609 | ( CUR_code, CUR_single, CUR_plural, CUR_sign, CUR_dec_plc, CUR_active) VALUES |
610 | 610 | ( 'EUR', 'Euro', 'Euros', '€', 2,1), |
611 | 611 | ( 'AED', 'Dirham', 'Dirhams', 'د.إ',2,1), |
@@ -759,8 +759,8 @@ discard block |
||
759 | 759 | ( 'ZAR', 'Rand', 'Rands', 'R', 2,1), |
760 | 760 | ( 'ZMK', 'Kwacha', 'Kwachas', '', 2,1), |
761 | 761 | ( 'ZWD', 'Dollar', 'Dollars', 'Z$', 2,1);"; |
762 | - $wpdb->query($SQL); |
|
763 | - } |
|
764 | - } |
|
765 | - } |
|
762 | + $wpdb->query($SQL); |
|
763 | + } |
|
764 | + } |
|
765 | + } |
|
766 | 766 | } |
@@ -24,8 +24,8 @@ discard block |
||
24 | 24 | { |
25 | 25 | global $wpdb; |
26 | 26 | $this->_pretty_name = esc_html__('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"; |
|
27 | + $this->_old_table = $wpdb->prefix."esp_message_template_group"; |
|
28 | + $this->_emt_table = $wpdb->prefix."esp_event_message_template"; |
|
29 | 29 | parent::__construct(); |
30 | 30 | } |
31 | 31 | |
@@ -37,7 +37,7 @@ discard block |
||
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 |
||
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 |
||
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) { |
@@ -12,59 +12,59 @@ |
||
12 | 12 | */ |
13 | 13 | class EE_DMS_4_3_0_event_message_templates extends EE_Data_Migration_Script_Stage_Table |
14 | 14 | { |
15 | - /** |
|
16 | - * This property will hold the table name for event_message_templates |
|
17 | - * @var string |
|
18 | - */ |
|
19 | - private $_emt_table; |
|
15 | + /** |
|
16 | + * This property will hold the table name for event_message_templates |
|
17 | + * @var string |
|
18 | + */ |
|
19 | + private $_emt_table; |
|
20 | 20 | |
21 | 21 | |
22 | - public function __construct() |
|
23 | - { |
|
24 | - global $wpdb; |
|
25 | - $this->_pretty_name = esc_html__('Event Message Templates', 'event_espresso'); |
|
26 | - $this->_old_table = $wpdb->prefix . "esp_message_template_group"; |
|
27 | - $this->_emt_table = $wpdb->prefix . "esp_event_message_template"; |
|
28 | - parent::__construct(); |
|
29 | - } |
|
22 | + public function __construct() |
|
23 | + { |
|
24 | + global $wpdb; |
|
25 | + $this->_pretty_name = esc_html__('Event Message Templates', 'event_espresso'); |
|
26 | + $this->_old_table = $wpdb->prefix . "esp_message_template_group"; |
|
27 | + $this->_emt_table = $wpdb->prefix . "esp_event_message_template"; |
|
28 | + parent::__construct(); |
|
29 | + } |
|
30 | 30 | |
31 | 31 | |
32 | 32 | |
33 | - protected function _migrate_old_row($old_row) |
|
34 | - { |
|
35 | - // 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 ) |
|
36 | - global $wpdb; |
|
37 | - if ($old_row['EVT_ID'] > 0) { |
|
38 | - // let's get the EVT for this id so we can update the custom name on the old row. |
|
39 | - $event_name = 'Custom Template for ' . $wpdb->get_var($wpdb->prepare("SELECT post_title from $wpdb->posts WHERE ID = %d", absint($old_row['EVT_ID']))); |
|
33 | + protected function _migrate_old_row($old_row) |
|
34 | + { |
|
35 | + // 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 ) |
|
36 | + global $wpdb; |
|
37 | + if ($old_row['EVT_ID'] > 0) { |
|
38 | + // let's get the EVT for this id so we can update the custom name on the old row. |
|
39 | + $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 | 40 | |
41 | - // update name |
|
42 | - $updated = $wpdb->update( |
|
43 | - $this->_old_table, |
|
44 | - array( |
|
45 | - 'MTP_name' => $event_name |
|
46 | - ), |
|
47 | - array( 'GRP_ID' => (int) $old_row['GRP_ID'] ), |
|
48 | - array( '%s' ), |
|
49 | - array( '%d' ) |
|
50 | - ); |
|
41 | + // update name |
|
42 | + $updated = $wpdb->update( |
|
43 | + $this->_old_table, |
|
44 | + array( |
|
45 | + 'MTP_name' => $event_name |
|
46 | + ), |
|
47 | + array( 'GRP_ID' => (int) $old_row['GRP_ID'] ), |
|
48 | + array( '%s' ), |
|
49 | + array( '%d' ) |
|
50 | + ); |
|
51 | 51 | |
52 | - $inserted = $wpdb->insert( |
|
53 | - $this->_emt_table, |
|
54 | - array( |
|
55 | - 'EVT_ID' => (int) $old_row['EVT_ID'], |
|
56 | - 'GRP_ID' => (int) $old_row['GRP_ID'], |
|
57 | - ), |
|
58 | - array( '%d', '%d' ) |
|
59 | - ); |
|
52 | + $inserted = $wpdb->insert( |
|
53 | + $this->_emt_table, |
|
54 | + array( |
|
55 | + 'EVT_ID' => (int) $old_row['EVT_ID'], |
|
56 | + 'GRP_ID' => (int) $old_row['GRP_ID'], |
|
57 | + ), |
|
58 | + array( '%d', '%d' ) |
|
59 | + ); |
|
60 | 60 | |
61 | - if (false === $updated) { |
|
62 | - $this->add_error(sprintf(esc_html__("Error in updating the row in %s setting 'MTP_name = %s", 'event_espresso'), $this->_old_table, $event_name)); |
|
63 | - } |
|
61 | + if (false === $updated) { |
|
62 | + $this->add_error(sprintf(esc_html__("Error in updating the row in %s setting 'MTP_name = %s", 'event_espresso'), $this->_old_table, $event_name)); |
|
63 | + } |
|
64 | 64 | |
65 | - if (false === $inserted) { |
|
66 | - $this->add_error(sprintf(esc_html__("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'])); |
|
67 | - } |
|
68 | - } |
|
69 | - } |
|
65 | + if (false === $inserted) { |
|
66 | + $this->add_error(sprintf(esc_html__("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'])); |
|
67 | + } |
|
68 | + } |
|
69 | + } |
|
70 | 70 | } |
@@ -7,39 +7,39 @@ |
||
7 | 7 | |
8 | 8 | class EE_DMS_4_3_0_question_option_order extends EE_Data_Migration_Script_Stage_Table |
9 | 9 | { |
10 | - public function __construct() |
|
11 | - { |
|
12 | - global $wpdb; |
|
13 | - $this->_pretty_name = esc_html__("Question Options", "event_espresso"); |
|
14 | - $this->_old_table = $wpdb->prefix . "esp_question_option"; |
|
15 | - parent::__construct(); |
|
16 | - } |
|
17 | - protected function _migrate_old_row($old_row) |
|
18 | - { |
|
19 | - // foreach question_group_question entry with this QST_ID, we want to set its |
|
20 | - // QSG_order equal to this question's QST_order |
|
21 | - global $wpdb; |
|
22 | - $updated = $wpdb->update( |
|
23 | - $this->_old_table, |
|
24 | - array('QSO_order' => $old_row['QSO_ID']), |
|
25 | - array('QSO_ID' => $old_row['QSO_ID']), |
|
26 | - array('%d',// QSO_order |
|
27 | - ), |
|
28 | - array('%d',// QSO_ID |
|
29 | - ) |
|
30 | - ); |
|
31 | - if (false === $updated) { |
|
32 | - $this->add_error( |
|
33 | - sprintf( |
|
34 | - esc_html__( |
|
35 | - "Error in updating table %s setting QSO_order = %d where QSO_ID = %d", |
|
36 | - 'event_espresso' |
|
37 | - ), |
|
38 | - $this->_old_table, |
|
39 | - $old_row['QSO_ID'], |
|
40 | - $old_row['QSO_ID'] |
|
41 | - ) |
|
42 | - ); |
|
43 | - } |
|
44 | - } |
|
10 | + public function __construct() |
|
11 | + { |
|
12 | + global $wpdb; |
|
13 | + $this->_pretty_name = esc_html__("Question Options", "event_espresso"); |
|
14 | + $this->_old_table = $wpdb->prefix . "esp_question_option"; |
|
15 | + parent::__construct(); |
|
16 | + } |
|
17 | + protected function _migrate_old_row($old_row) |
|
18 | + { |
|
19 | + // foreach question_group_question entry with this QST_ID, we want to set its |
|
20 | + // QSG_order equal to this question's QST_order |
|
21 | + global $wpdb; |
|
22 | + $updated = $wpdb->update( |
|
23 | + $this->_old_table, |
|
24 | + array('QSO_order' => $old_row['QSO_ID']), |
|
25 | + array('QSO_ID' => $old_row['QSO_ID']), |
|
26 | + array('%d',// QSO_order |
|
27 | + ), |
|
28 | + array('%d',// QSO_ID |
|
29 | + ) |
|
30 | + ); |
|
31 | + if (false === $updated) { |
|
32 | + $this->add_error( |
|
33 | + sprintf( |
|
34 | + esc_html__( |
|
35 | + "Error in updating table %s setting QSO_order = %d where QSO_ID = %d", |
|
36 | + 'event_espresso' |
|
37 | + ), |
|
38 | + $this->_old_table, |
|
39 | + $old_row['QSO_ID'], |
|
40 | + $old_row['QSO_ID'] |
|
41 | + ) |
|
42 | + ); |
|
43 | + } |
|
44 | + } |
|
45 | 45 | } |
@@ -11,7 +11,7 @@ discard block |
||
11 | 11 | { |
12 | 12 | global $wpdb; |
13 | 13 | $this->_pretty_name = esc_html__("Question Options", "event_espresso"); |
14 | - $this->_old_table = $wpdb->prefix . "esp_question_option"; |
|
14 | + $this->_old_table = $wpdb->prefix."esp_question_option"; |
|
15 | 15 | parent::__construct(); |
16 | 16 | } |
17 | 17 | protected function _migrate_old_row($old_row) |
@@ -23,9 +23,9 @@ discard block |
||
23 | 23 | $this->_old_table, |
24 | 24 | array('QSO_order' => $old_row['QSO_ID']), |
25 | 25 | array('QSO_ID' => $old_row['QSO_ID']), |
26 | - array('%d',// QSO_order |
|
26 | + array('%d', // QSO_order |
|
27 | 27 | ), |
28 | - array('%d',// QSO_ID |
|
28 | + array('%d', // QSO_ID |
|
29 | 29 | ) |
30 | 30 | ); |
31 | 31 | if (false === $updated) { |
@@ -11,77 +11,77 @@ |
||
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 = esc_html__('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' => esc_html__('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 | - esc_html__('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 = esc_html__('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' => esc_html__('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 | + esc_html__('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 | } |
@@ -14,7 +14,7 @@ discard block |
||
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 = esc_html__('Event Sub-total line items', 'event_espresso'); |
20 | 20 | parent::__construct(); |
@@ -23,9 +23,9 @@ discard block |
||
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' => esc_html__('Event', 'event_espresso'), |
31 | 31 | 'LIN_desc' => $line_item_row['LIN_desc'], |
@@ -41,24 +41,24 @@ discard block |
||
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; |
@@ -22,7 +22,7 @@ discard block |
||
22 | 22 | public function __construct() |
23 | 23 | { |
24 | 24 | global $wpdb; |
25 | - $this->_line_item_table_name = $wpdb->prefix . "esp_line_item"; |
|
25 | + $this->_line_item_table_name = $wpdb->prefix."esp_line_item"; |
|
26 | 26 | $this->_pretty_name = esc_html__('Pre-tax total line items', 'event_espresso'); |
27 | 27 | parent::__construct(); |
28 | 28 | } |
@@ -54,10 +54,10 @@ discard block |
||
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; |
@@ -12,53 +12,53 @@ |
||
12 | 12 | */ |
13 | 13 | class EE_DMS_4_8_0_pretax_totals extends EE_Data_Migration_Script_Stage |
14 | 14 | { |
15 | - protected $_line_item_table_name; |
|
15 | + protected $_line_item_table_name; |
|
16 | 16 | |
17 | 17 | |
18 | - /** |
|
19 | - * Just initializes the status of the migration |
|
20 | - */ |
|
21 | - public function __construct() |
|
22 | - { |
|
23 | - global $wpdb; |
|
24 | - $this->_line_item_table_name = $wpdb->prefix . "esp_line_item"; |
|
25 | - $this->_pretty_name = esc_html__('Pre-tax total line items', 'event_espresso'); |
|
26 | - parent::__construct(); |
|
27 | - } |
|
18 | + /** |
|
19 | + * Just initializes the status of the migration |
|
20 | + */ |
|
21 | + public function __construct() |
|
22 | + { |
|
23 | + global $wpdb; |
|
24 | + $this->_line_item_table_name = $wpdb->prefix . "esp_line_item"; |
|
25 | + $this->_pretty_name = esc_html__('Pre-tax total line items', 'event_espresso'); |
|
26 | + parent::__construct(); |
|
27 | + } |
|
28 | 28 | |
29 | 29 | |
30 | 30 | |
31 | - /** |
|
32 | - * Counts the records to migrate; the public version may cache it |
|
33 | - * @return int |
|
34 | - */ |
|
35 | - protected function _count_records_to_migrate() |
|
36 | - { |
|
37 | - return 1; |
|
38 | - } |
|
31 | + /** |
|
32 | + * Counts the records to migrate; the public version may cache it |
|
33 | + * @return int |
|
34 | + */ |
|
35 | + protected function _count_records_to_migrate() |
|
36 | + { |
|
37 | + return 1; |
|
38 | + } |
|
39 | 39 | |
40 | 40 | |
41 | 41 | |
42 | - /** |
|
43 | - * IMPORTANT: if an error is encountered, or everything is finished, this stage should update its status property accordingly. |
|
44 | - * Note: it should not alter the count of items migrated. That is done in the public function that calls this. |
|
45 | - * IMPORTANT: The count of items migrated should ONLY be less than $num_items_to_migrate when it's the last migration step, otherwise it |
|
46 | - * 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, |
|
47 | - * then we SHOULD actually migrate 50 rows,but at very least we MUST report/return 50 items migrated) |
|
48 | - * @param int $num_items_to_migrate |
|
49 | - * @return int number of items ACTUALLY migrated |
|
50 | - */ |
|
51 | - protected function _migration_step($num_items_to_migrate = 50) |
|
52 | - { |
|
53 | - global $wpdb; |
|
54 | - $rows_updated = $wpdb->update( |
|
55 | - $this->_line_item_table_name, |
|
56 | - array( 'LIN_code' => 'pre-tax-subtotal' ), |
|
57 | - array( 'LIN_code' => 'tickets' ), |
|
58 | - array( '%s' ), |
|
59 | - array( '%s' ) |
|
60 | - ); |
|
61 | - $this->set_completed(); |
|
62 | - return 1; |
|
63 | - } |
|
42 | + /** |
|
43 | + * IMPORTANT: if an error is encountered, or everything is finished, this stage should update its status property accordingly. |
|
44 | + * Note: it should not alter the count of items migrated. That is done in the public function that calls this. |
|
45 | + * IMPORTANT: The count of items migrated should ONLY be less than $num_items_to_migrate when it's the last migration step, otherwise it |
|
46 | + * 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, |
|
47 | + * then we SHOULD actually migrate 50 rows,but at very least we MUST report/return 50 items migrated) |
|
48 | + * @param int $num_items_to_migrate |
|
49 | + * @return int number of items ACTUALLY migrated |
|
50 | + */ |
|
51 | + protected function _migration_step($num_items_to_migrate = 50) |
|
52 | + { |
|
53 | + global $wpdb; |
|
54 | + $rows_updated = $wpdb->update( |
|
55 | + $this->_line_item_table_name, |
|
56 | + array( 'LIN_code' => 'pre-tax-subtotal' ), |
|
57 | + array( 'LIN_code' => 'tickets' ), |
|
58 | + array( '%s' ), |
|
59 | + array( '%s' ) |
|
60 | + ); |
|
61 | + $this->set_completed(); |
|
62 | + return 1; |
|
63 | + } |
|
64 | 64 | } |
@@ -16,15 +16,13 @@ discard block |
||
16 | 16 | 'EQG_primary'=>new EE_Boolean_Field('EQG_primary', esc_html__('Flag indicating question is only for primary attendees','event_espresso'), false, false) |
17 | 17 | ) |
18 | 18 | ); |
19 | - |
|
20 | - |
|
21 | 19 | * |
22 | 20 | */ |
23 | 21 | class EE_DMS_4_1_0_event_question_group extends EE_Data_Migration_Script_Stage_Table |
24 | 22 | { |
25 | - private $_new_table; |
|
26 | - public function _migrate_old_row($old_row) |
|
27 | - { |
|
23 | + private $_new_table; |
|
24 | + public function _migrate_old_row($old_row) |
|
25 | + { |
|
28 | 26 | // $txn_id = $this->get_migration_script()->get_mapping_new_pk($this->_old_table, $old_row['id'], $this->_new_transaction_table); |
29 | 27 | // if ( ! $txn_id ){ |
30 | 28 | // $this->add_error(sprintf(esc_html__("Could not find the transaction for the 3.1 attendee %d from row %s", "event_espresso"),$old_row['id'],$this->_json_encode($old_row))); |
@@ -34,8 +32,8 @@ discard block |
||
34 | 32 | // $new_line_items = $this->_insert_new_line_items($txn,$old_row); |
35 | 33 | // $this->get_migration_script()->set_mapping($this->_old_table,$old_row['id'],$this->_new_line_table,$new_line_items); |
36 | 34 | |
37 | - $this->_insert_new_event_question_groups($old_row); |
|
38 | - } |
|
35 | + $this->_insert_new_event_question_groups($old_row); |
|
36 | + } |
|
39 | 37 | // function _migration_step($num_items=50){ |
40 | 38 | // global $wpdb; |
41 | 39 | // $start_at_record = $this->count_records_migrated(); |
@@ -55,109 +53,109 @@ discard block |
||
55 | 53 | // $count = $wpdb->get_var("SELECT COUNT(id) FROM ".$this->_old_table); |
56 | 54 | // return $count; |
57 | 55 | // } |
58 | - public function __construct() |
|
59 | - { |
|
60 | - global $wpdb; |
|
61 | - $this->_old_table = $wpdb->prefix . "events_detail"; |
|
62 | - $this->_extra_where_sql = 'WHERE event_status!="D"'; |
|
63 | - $this->_new_table = $wpdb->prefix . "esp_event_question_group"; |
|
64 | - $this->_pretty_name = esc_html__("Question Groups in each Event", "event_espresso"); |
|
65 | - parent::__construct(); |
|
66 | - } |
|
56 | + public function __construct() |
|
57 | + { |
|
58 | + global $wpdb; |
|
59 | + $this->_old_table = $wpdb->prefix . "events_detail"; |
|
60 | + $this->_extra_where_sql = 'WHERE event_status!="D"'; |
|
61 | + $this->_new_table = $wpdb->prefix . "esp_event_question_group"; |
|
62 | + $this->_pretty_name = esc_html__("Question Groups in each Event", "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 |
|
72 | - * @return void |
|
73 | - */ |
|
74 | - private function _insert_new_event_question_groups($old_event) |
|
75 | - { |
|
76 | - $new_event_question_group_ids = array(); |
|
77 | - $question_groups_for_primary = maybe_unserialize($old_event['question_groups']); |
|
78 | - if (is_array($question_groups_for_primary)) { |
|
79 | - foreach ($question_groups_for_primary as $old_question_group_id) { |
|
80 | - $new_id = $this->_insert_event_question_group($old_event, $old_question_group_id, true); |
|
81 | - if ($new_id) { |
|
82 | - $new_event_question_group_ids[] = $new_id; |
|
83 | - } |
|
84 | - } |
|
85 | - } |
|
86 | - $event_meta = maybe_unserialize($old_event['event_meta']); |
|
87 | - if (isset($event_meta['add_attendee_question_groups'])) { |
|
88 | - if (is_array($event_meta['add_attendee_question_groups'])) { |
|
89 | - foreach ($event_meta['add_attendee_question_groups'] as $old_question_group_id) { |
|
90 | - $new_id = $this->_insert_event_question_group($old_event, $old_question_group_id, false); |
|
91 | - if ($new_id) { |
|
92 | - $new_event_question_group_ids[] = $new_id; |
|
93 | - } |
|
94 | - } |
|
95 | - } |
|
96 | - } |
|
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 |
|
70 | + * @return void |
|
71 | + */ |
|
72 | + private function _insert_new_event_question_groups($old_event) |
|
73 | + { |
|
74 | + $new_event_question_group_ids = array(); |
|
75 | + $question_groups_for_primary = maybe_unserialize($old_event['question_groups']); |
|
76 | + if (is_array($question_groups_for_primary)) { |
|
77 | + foreach ($question_groups_for_primary as $old_question_group_id) { |
|
78 | + $new_id = $this->_insert_event_question_group($old_event, $old_question_group_id, true); |
|
79 | + if ($new_id) { |
|
80 | + $new_event_question_group_ids[] = $new_id; |
|
81 | + } |
|
82 | + } |
|
83 | + } |
|
84 | + $event_meta = maybe_unserialize($old_event['event_meta']); |
|
85 | + if (isset($event_meta['add_attendee_question_groups'])) { |
|
86 | + if (is_array($event_meta['add_attendee_question_groups'])) { |
|
87 | + foreach ($event_meta['add_attendee_question_groups'] as $old_question_group_id) { |
|
88 | + $new_id = $this->_insert_event_question_group($old_event, $old_question_group_id, false); |
|
89 | + if ($new_id) { |
|
90 | + $new_event_question_group_ids[] = $new_id; |
|
91 | + } |
|
92 | + } |
|
93 | + } |
|
94 | + } |
|
97 | 95 | |
98 | 96 | |
99 | - $this->get_migration_script()->set_mapping($this->_old_table, $old_event['id'], $this->_new_table, $new_event_question_group_ids); |
|
100 | - } |
|
97 | + $this->get_migration_script()->set_mapping($this->_old_table, $old_event['id'], $this->_new_table, $new_event_question_group_ids); |
|
98 | + } |
|
101 | 99 | |
102 | - private function _insert_event_question_group($old_event, $old_question_group_id, $primary) |
|
103 | - { |
|
104 | - global $wpdb; |
|
105 | - $new_question_group_id = $this->get_migration_script()->get_mapping_new_pk( |
|
106 | - $wpdb->prefix . "events_qst_group", |
|
107 | - intval($old_question_group_id), |
|
108 | - $wpdb->prefix . "esp_question_group" |
|
109 | - ); |
|
100 | + private function _insert_event_question_group($old_event, $old_question_group_id, $primary) |
|
101 | + { |
|
102 | + global $wpdb; |
|
103 | + $new_question_group_id = $this->get_migration_script()->get_mapping_new_pk( |
|
104 | + $wpdb->prefix . "events_qst_group", |
|
105 | + intval($old_question_group_id), |
|
106 | + $wpdb->prefix . "esp_question_group" |
|
107 | + ); |
|
110 | 108 | |
111 | - if (! $new_question_group_id) { |
|
112 | - $this->add_error( |
|
113 | - sprintf( |
|
114 | - // translators: %s question ID, %s event ID |
|
115 | - esc_html__("Could not find 4.1 question ID for 3.1 question id #%s on event $%s", "event_espresso"), |
|
116 | - $old_question_group_id, |
|
117 | - $old_event['id'] |
|
118 | - ) |
|
119 | - ); |
|
120 | - return 0; |
|
121 | - } |
|
122 | - $new_event_id = $this->get_migration_script()->get_mapping_new_pk( |
|
123 | - $wpdb->prefix . "events_detail", |
|
124 | - intval($old_event['id']), |
|
125 | - $wpdb->posts |
|
126 | - ); |
|
127 | - if (! $new_question_group_id) { |
|
128 | - $this->add_error( |
|
129 | - sprintf( |
|
130 | - // translators: %s event ID |
|
131 | - esc_html__("Could not find 4.1 event 3.1 event id #%s", "event_espresso"), |
|
132 | - $old_event['id'] |
|
133 | - ) |
|
134 | - ); |
|
135 | - return 0; |
|
136 | - } |
|
137 | - $cols_n_values = array( |
|
138 | - 'EVT_ID' => $new_event_id, |
|
139 | - 'QSG_ID' => $new_question_group_id, |
|
140 | - 'EQG_primary' => $primary |
|
141 | - ); |
|
109 | + if (! $new_question_group_id) { |
|
110 | + $this->add_error( |
|
111 | + sprintf( |
|
112 | + // translators: %s question ID, %s event ID |
|
113 | + esc_html__("Could not find 4.1 question ID for 3.1 question id #%s on event $%s", "event_espresso"), |
|
114 | + $old_question_group_id, |
|
115 | + $old_event['id'] |
|
116 | + ) |
|
117 | + ); |
|
118 | + return 0; |
|
119 | + } |
|
120 | + $new_event_id = $this->get_migration_script()->get_mapping_new_pk( |
|
121 | + $wpdb->prefix . "events_detail", |
|
122 | + intval($old_event['id']), |
|
123 | + $wpdb->posts |
|
124 | + ); |
|
125 | + if (! $new_question_group_id) { |
|
126 | + $this->add_error( |
|
127 | + sprintf( |
|
128 | + // translators: %s event ID |
|
129 | + esc_html__("Could not find 4.1 event 3.1 event id #%s", "event_espresso"), |
|
130 | + $old_event['id'] |
|
131 | + ) |
|
132 | + ); |
|
133 | + return 0; |
|
134 | + } |
|
135 | + $cols_n_values = array( |
|
136 | + 'EVT_ID' => $new_event_id, |
|
137 | + 'QSG_ID' => $new_question_group_id, |
|
138 | + 'EQG_primary' => $primary |
|
139 | + ); |
|
142 | 140 | |
143 | - $datatypes = array( |
|
144 | - '%d',// EVT_ID |
|
145 | - '%d',// QSG_ID |
|
146 | - '%d',// EQG_primary |
|
147 | - ); |
|
148 | - $success = $wpdb->insert($this->_new_table, $cols_n_values, $datatypes); |
|
149 | - if (! $success) { |
|
150 | - $this->add_error( |
|
151 | - $this->get_migration_script()->_create_error_message_for_db_insertion( |
|
152 | - $this->_old_table, |
|
153 | - $old_event, |
|
154 | - $this->_new_table, |
|
155 | - $cols_n_values, |
|
156 | - $datatypes |
|
157 | - ) |
|
158 | - ); |
|
159 | - return 0; |
|
160 | - } |
|
161 | - return $wpdb->insert_id; |
|
162 | - } |
|
141 | + $datatypes = array( |
|
142 | + '%d',// EVT_ID |
|
143 | + '%d',// QSG_ID |
|
144 | + '%d',// EQG_primary |
|
145 | + ); |
|
146 | + $success = $wpdb->insert($this->_new_table, $cols_n_values, $datatypes); |
|
147 | + if (! $success) { |
|
148 | + $this->add_error( |
|
149 | + $this->get_migration_script()->_create_error_message_for_db_insertion( |
|
150 | + $this->_old_table, |
|
151 | + $old_event, |
|
152 | + $this->_new_table, |
|
153 | + $cols_n_values, |
|
154 | + $datatypes |
|
155 | + ) |
|
156 | + ); |
|
157 | + return 0; |
|
158 | + } |
|
159 | + return $wpdb->insert_id; |
|
160 | + } |
|
163 | 161 | } |
@@ -58,9 +58,9 @@ discard block |
||
58 | 58 | public function __construct() |
59 | 59 | { |
60 | 60 | global $wpdb; |
61 | - $this->_old_table = $wpdb->prefix . "events_detail"; |
|
61 | + $this->_old_table = $wpdb->prefix."events_detail"; |
|
62 | 62 | $this->_extra_where_sql = 'WHERE event_status!="D"'; |
63 | - $this->_new_table = $wpdb->prefix . "esp_event_question_group"; |
|
63 | + $this->_new_table = $wpdb->prefix."esp_event_question_group"; |
|
64 | 64 | $this->_pretty_name = esc_html__("Question Groups in each Event", "event_espresso"); |
65 | 65 | parent::__construct(); |
66 | 66 | } |
@@ -103,12 +103,12 @@ discard block |
||
103 | 103 | { |
104 | 104 | global $wpdb; |
105 | 105 | $new_question_group_id = $this->get_migration_script()->get_mapping_new_pk( |
106 | - $wpdb->prefix . "events_qst_group", |
|
106 | + $wpdb->prefix."events_qst_group", |
|
107 | 107 | intval($old_question_group_id), |
108 | - $wpdb->prefix . "esp_question_group" |
|
108 | + $wpdb->prefix."esp_question_group" |
|
109 | 109 | ); |
110 | 110 | |
111 | - if (! $new_question_group_id) { |
|
111 | + if ( ! $new_question_group_id) { |
|
112 | 112 | $this->add_error( |
113 | 113 | sprintf( |
114 | 114 | // translators: %s question ID, %s event ID |
@@ -120,11 +120,11 @@ discard block |
||
120 | 120 | return 0; |
121 | 121 | } |
122 | 122 | $new_event_id = $this->get_migration_script()->get_mapping_new_pk( |
123 | - $wpdb->prefix . "events_detail", |
|
123 | + $wpdb->prefix."events_detail", |
|
124 | 124 | intval($old_event['id']), |
125 | 125 | $wpdb->posts |
126 | 126 | ); |
127 | - if (! $new_question_group_id) { |
|
127 | + if ( ! $new_question_group_id) { |
|
128 | 128 | $this->add_error( |
129 | 129 | sprintf( |
130 | 130 | // translators: %s event ID |
@@ -141,12 +141,12 @@ discard block |
||
141 | 141 | ); |
142 | 142 | |
143 | 143 | $datatypes = array( |
144 | - '%d',// EVT_ID |
|
145 | - '%d',// QSG_ID |
|
146 | - '%d',// EQG_primary |
|
144 | + '%d', // EVT_ID |
|
145 | + '%d', // QSG_ID |
|
146 | + '%d', // EQG_primary |
|
147 | 147 | ); |
148 | 148 | $success = $wpdb->insert($this->_new_table, $cols_n_values, $datatypes); |
149 | - if (! $success) { |
|
149 | + if ( ! $success) { |
|
150 | 150 | $this->add_error( |
151 | 151 | $this->get_migration_script()->_create_error_message_for_db_insertion( |
152 | 152 | $this->_old_table, |