Events Manager - Version 6.1.0.1

Version Description

(dev) = * tweaked installation SQL so it's MariaDB-compatible

Download this release

Release Info

Developer netweblogic
Plugin Icon 128x128 Events Manager
Version 6.1.0.1
Comparing to
See all releases

Code changes from version 6.1 to 6.1.0.1

classes/em-booking.php CHANGED
@@ -285,6 +285,11 @@ class EM_Booking extends EM_Object{
285
  $data_types = $this->get_types($data);
286
  $data['booking_date'] = $this->booking_date = gmdate('Y-m-d H:i:s');
287
  $data_types[] = '%s';
 
 
 
 
 
288
  $result = $wpdb->insert($table, $data, $data_types);
289
  $this->booking_id = $wpdb->insert_id;
290
  $this->feedback_message = __('Your booking has been recorded','events-manager');
285
  $data_types = $this->get_types($data);
286
  $data['booking_date'] = $this->booking_date = gmdate('Y-m-d H:i:s');
287
  $data_types[] = '%s';
288
+ // first check that the uuid is unique, if not change it and repeat until unique
289
+ while( $wpdb->get_var( $wpdb->prepare("SELECT booking_uuid FROM $table WHERE booking_uuid=%s", $this->booking_uuid) ) ){
290
+ $this->booking_uuid = $data['booking_uuid'] = $this->generate_uuid();
291
+ }
292
+ // now insert
293
  $result = $wpdb->insert($table, $data, $data_types);
294
  $this->booking_id = $wpdb->insert_id;
295
  $this->feedback_message = __('Your booking has been recorded','events-manager');
classes/em-ticket-booking.php CHANGED
@@ -126,6 +126,11 @@ class EM_Ticket_Booking extends EM_Object{
126
  }else{
127
  if($this->get_spaces() > 0){
128
  //TODO better error handling
 
 
 
 
 
129
  $result = $wpdb->insert($table, $data, $this->get_types($data));
130
  $this->ticket_booking_id = $wpdb->insert_id;
131
  $this->feedback_message = __('Ticket booking created','events-manager');
126
  }else{
127
  if($this->get_spaces() > 0){
128
  //TODO better error handling
129
+ // first check that the uuid is unique, if not change it and repeat until unique
130
+ while( $wpdb->get_var( $wpdb->prepare("SELECT ticket_uuid FROM $table WHERE ticket_uuid=%s", $this->ticket_uuid) ) ){
131
+ $this->ticket_uuid = $data['ticket_uuid'] = $this->generate_uuid();
132
+ }
133
+ // now insert with unique uuid
134
  $result = $wpdb->insert($table, $data, $this->get_types($data));
135
  $this->ticket_booking_id = $wpdb->insert_id;
136
  $this->feedback_message = __('Ticket booking created','events-manager');
em-install.php CHANGED
@@ -1203,25 +1203,52 @@ function em_upgrade_current_installation(){
1203
  update_option('dbem_css_theme_line_height', 1);
1204
  }
1205
  if( $current_version != '' && version_compare($current_version, '6.0.1.2', '<') ){
1206
- // slated for 6.1 - atomic tickets
1207
- $query = "UPDATE ". EM_TICKETS_BOOKINGS_TABLE ." SET ticket_uuid= LOWER(CONCAT( HEX(RANDOM_BYTES(4)), '', HEX(RANDOM_BYTES(2)), '4', SUBSTR(HEX(RANDOM_BYTES(2)), 2, 3), '', HEX(FLOOR(ASCII(RANDOM_BYTES(1)) / 64) + 8), SUBSTR(HEX(RANDOM_BYTES(2)), 2, 3), '', hex(RANDOM_BYTES(6)) ))";
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1208
  $result = $wpdb->query($query. " WHERE ticket_uuid=''");
 
 
 
 
 
 
 
 
 
 
 
1209
  // do the same for regular bookings, allowing for unique IDs that can be used by guest users to access (future feature)
1210
- $query = "UPDATE ". EM_BOOKINGS_TABLE ." SET booking_uuid= LOWER(CONCAT( HEX(RANDOM_BYTES(4)), '', HEX(RANDOM_BYTES(2)), '4', SUBSTR(HEX(RANDOM_BYTES(2)), 2, 3), '', HEX(FLOOR(ASCII(RANDOM_BYTES(1)) / 64) + 8), SUBSTR(HEX(RANDOM_BYTES(2)), 2, 3), '', hex(RANDOM_BYTES(6)) ))";
1211
- $bookings_result = $wpdb->query( $query . " WHERE booking_uuid=''" );
1212
- if( $result === false || $bookings_result === false ){
1213
- $message = "<strong>Events Manager is trying to update your database, but the following error occured:</strong>";
1214
- $message .= '</p><p>'.'<code>'. $wpdb->last_error .'</code>';
1215
- $message .= '</p><p>It might be that reloading this page one or more times may complete the process, if you have a large number of bookings in your database. Alternatively, you can run one of these two queries directly into your WP database:';
1216
- $message .= '</p><p>'.'<code>'. $query .'</code>';
1217
- $message .= '</p>OR<p>'.'<code>'. "UPDATE ". EM_TICKETS_BOOKINGS_TABLE ." SET ticket_uuid= UUID()" .'</code>';
1218
- $EM_Admin_Notice = new EM_Admin_Notice(array( 'name' => 'v6.1-atomic-error', 'who' => 'admin', 'where' => 'all', 'message' => $message, 'what'=>'warning' ));
1219
- EM_Admin_Notices::add($EM_Admin_Notice, is_multisite());
1220
- global $em_do_not_finalize_upgrade;
1221
- $em_do_not_finalize_upgrade = true;
1222
- }else{
1223
- EM_Admin_Notices::remove('v6.1-atomic-error', is_multisite());
1224
  }
 
1225
  // Now go through current bookings and split the tickets up, 100 at a time
1226
  $query = 'SELECT ticket_booking_id, ticket_id, booking_id, ticket_booking_spaces, ticket_booking_price FROM '.EM_TICKETS_BOOKINGS_TABLE .' WHERE ticket_booking_spaces > 1 LIMIT 100';
1227
  $results = $wpdb->get_results( $query, ARRAY_A );
1203
  update_option('dbem_css_theme_line_height', 1);
1204
  }
1205
  if( $current_version != '' && version_compare($current_version, '6.0.1.2', '<') ){
1206
+ function v6012_sql_check_error( $result, $query, $table ){
1207
+ global $wpdb;
1208
+ if( $result === false ){
1209
+ $message = "<strong>Events Manager is trying to update your database, but the following error occured:</strong>";
1210
+ $message .= '</p><p>'.'<code>'. $wpdb->last_error .'</code>';
1211
+ $message .= '</p><p>It might be that reloading this page one or more times may complete the process, if you have a large number of bookings in your database. Alternatively, you can run one of these two queries directly into your WP database:';
1212
+ $message .= '</p><p>'.'<code>'. $query .'</code>';
1213
+ $message .= '</p>OR<p>'.'<code>'. "UPDATE ". $table ." SET ticket_uuid= UUID()" .'</code>';
1214
+ $EM_Admin_Notice = new EM_Admin_Notice(array( 'name' => 'v6.1-'.$table.'atomic-error', 'who' => 'admin', 'where' => 'all', 'message' => $message, 'what'=>'warning' ));
1215
+ EM_Admin_Notices::add($EM_Admin_Notice, is_multisite());
1216
+ global $em_do_not_finalize_upgrade;
1217
+ $em_do_not_finalize_upgrade = true;
1218
+ }else{
1219
+ EM_Admin_Notices::remove('v6.1-'.$table.'atomic-error', is_multisite());
1220
+ }
1221
+ }
1222
+ // slated for 6.1 - atomic tickets - tweaked for mariadb < 10.0 compatiability
1223
+ $query = "UPDATE ". EM_TICKETS_BOOKINGS_TABLE ." SET ticket_uuid= MD5(RAND())";
1224
+ //$query = "UPDATE ". EM_TICKETS_BOOKINGS_TABLE ." SET ticket_uuid= LOWER(CONCAT( HEX(RANDOM_BYTES(4)), '', HEX(RANDOM_BYTES(2)), '4', SUBSTR(HEX(RANDOM_BYTES(2)), 2, 3), '', HEX(FLOOR(ASCII(RANDOM_BYTES(1)) / 64) + 8), SUBSTR(HEX(RANDOM_BYTES(2)), 2, 3), '', hex(RANDOM_BYTES(6)) ))";
1225
  $result = $wpdb->query($query. " WHERE ticket_uuid=''");
1226
+ if( $result !== false ) {
1227
+ // check for duplicates, md5 has much more chnace of collision
1228
+ $duplicate_check = 'SELECT ticket_booking_id FROM ' . EM_TICKETS_BOOKINGS_TABLE . ' GROUP BY ticket_uuid HAVING COUNT(ticket_uuid) > 1 LIMIT 1';
1229
+ while( $result !== false && $wpdb->get_var($duplicate_check) !== null ) {
1230
+ $query_recheck = 'UPDATE ' . EM_TICKETS_BOOKINGS_TABLE . ' SET ticket_uuid= MD5(RAND()) WHERE ticket_uuid IN (
1231
+ SELECT ticket_uuid FROM (SELECT ticket_uuid FROM ' . EM_TICKETS_BOOKINGS_TABLE . ' GROUP BY ticket_uuid HAVING COUNT(ticket_uuid) > 1) t2
1232
+ )';
1233
+ $result = $wpdb->query($query_recheck);
1234
+ }
1235
+ }
1236
+ v6012_sql_check_error($result, $query, EM_TICKETS_BOOKINGS_TABLE);
1237
  // do the same for regular bookings, allowing for unique IDs that can be used by guest users to access (future feature)
1238
+ $query = "UPDATE ". EM_BOOKINGS_TABLE ." SET booking_uuid= MD5(RAND())";
1239
+ //$query = "UPDATE ". EM_BOOKINGS_TABLE ." SET booking_uuid= LOWER(CONCAT( HEX(RANDOM_BYTES(4)), '', HEX(RANDOM_BYTES(2)), '4', SUBSTR(HEX(RANDOM_BYTES(2)), 2, 3), '', HEX(FLOOR(ASCII(RANDOM_BYTES(1)) / 64) + 8), SUBSTR(HEX(RANDOM_BYTES(2)), 2, 3), '', hex(RANDOM_BYTES(6)) ))";
1240
+ $result = $wpdb->query( $query . " WHERE booking_uuid=''" );
1241
+ if( $result !== false ) {
1242
+ // check for duplicates, md5 has much more chnace of collision
1243
+ $duplicate_check = 'SELECT booking_id FROM ' . EM_BOOKINGS_TABLE . ' GROUP BY booking_uuid HAVING COUNT(booking_uuid) > 1 LIMIT 1';
1244
+ while( $result !== false && $wpdb->get_var($duplicate_check) !== null ) {
1245
+ $query_recheck = 'UPDATE ' . EM_BOOKINGS_TABLE . ' SET booking_uuid= MD5(RAND()) WHERE booking_uuid IN (
1246
+ SELECT booking_uuid FROM (SELECT booking_uuid FROM ' . EM_BOOKINGS_TABLE . ' GROUP BY booking_uuid HAVING COUNT(booking_uuid) > 1) t2
1247
+ )';
1248
+ $result = $wpdb->query($query_recheck);
1249
+ }
 
 
1250
  }
1251
+ v6012_sql_check_error($result, $query, EM_BOOKINGS_TABLE);
1252
  // Now go through current bookings and split the tickets up, 100 at a time
1253
  $query = 'SELECT ticket_booking_id, ticket_id, booking_id, ticket_booking_spaces, ticket_booking_price FROM '.EM_TICKETS_BOOKINGS_TABLE .' WHERE ticket_booking_spaces > 1 LIMIT 100';
1254
  $results = $wpdb->get_results( $query, ARRAY_A );
events-manager.php CHANGED
@@ -1,7 +1,7 @@
1
  <?php
2
  /*
3
  Plugin Name: Events Manager
4
- Version: 6.1
5
  Plugin URI: http://wp-events-plugin.com
6
  Description: Event registration and booking management for WordPress. Recurring events, locations, webinars, google maps, rss, ical, booking registration and more!
7
  Author: Marcus Sykes
@@ -28,7 +28,7 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
28
  */
29
 
30
  // Setting constants
31
- define('EM_VERSION', '6.1'); //self expanatory, although version currently may not correspond directly with published version number. until 6.0 we're stuck updating 5.999.x
32
  define('EM_PRO_MIN_VERSION', '3.0'); //self expanatory
33
  define('EM_PRO_MIN_VERSION_CRITICAL', '3.0'); //self expanatory
34
  define('EM_DIR', dirname( __FILE__ )); //an absolute path to this directory
1
  <?php
2
  /*
3
  Plugin Name: Events Manager
4
+ Version: 6.1.0.1
5
  Plugin URI: http://wp-events-plugin.com
6
  Description: Event registration and booking management for WordPress. Recurring events, locations, webinars, google maps, rss, ical, booking registration and more!
7
  Author: Marcus Sykes
28
  */
29
 
30
  // Setting constants
31
+ define('EM_VERSION', '6.1.0.1'); //self expanatory, although version currently may not correspond directly with published version number. until 6.0 we're stuck updating 5.999.x
32
  define('EM_PRO_MIN_VERSION', '3.0'); //self expanatory
33
  define('EM_PRO_MIN_VERSION_CRITICAL', '3.0'); //self expanatory
34
  define('EM_DIR', dirname( __FILE__ )); //an absolute path to this directory
readme.txt CHANGED
@@ -135,6 +135,9 @@ See our [FAQ](http://wp-events-plugin.com/documentation/faq/) page, which is upd
135
  15. Clean forms for submitting and managing events, as well as booking events for users.
136
 
137
  == Changelog ==
 
 
 
138
  = 6.1 =
139
  * WARNING! MAJOR architecture change for how tickets are stored. This should be backward compatible and a well-tested migration process, but (as you should always do anyway) back up before upgrading!
140
  * fixed CSS issues in the bookings admin dashboard
135
  15. Clean forms for submitting and managing events, as well as booking events for users.
136
 
137
  == Changelog ==
138
+ = 6.1.0.1 (dev) =
139
+ * tweaked installation SQL so it's MariaDB-compatible
140
+
141
  = 6.1 =
142
  * WARNING! MAJOR architecture change for how tickets are stored. This should be backward compatible and a well-tested migration process, but (as you should always do anyway) back up before upgrading!
143
  * fixed CSS issues in the bookings admin dashboard