Groups - Version 1.0.0-beta-3d

Version Description

  • Fixed issues caused by an excessively long index for the capability DB table. Some installations wouldn't work correctly, showing no capabilities and making it impossible to add new ones.
  • Taking into account blog charset/collation on newly created tables.
Download this release

Release Info

Developer itthinx
Plugin Icon 128x128 Groups
Version 1.0.0-beta-3d
Comparing to
See all releases

Code changes from version 1.0.0-beta-3c to 1.0.0-beta-3d

Files changed (3) hide show
  1. groups.php +2 -2
  2. lib/core/class-groups-controller.php +32 -16
  3. readme.txt +9 -1
groups.php CHANGED
@@ -21,13 +21,13 @@
21
  * Plugin Name: Groups
22
  * Plugin URI: http://www.itthinx.com/plugins/groups
23
  * Description: Groups provides group-based user membership management, group-based capabilities and content access control.
24
- * Version: 1.0.0-beta-3c
25
  * Author: itthinx (Karim Rahimpur)
26
  * Author URI: http://www.itthinx.com
27
  * Donate-Link: http://www.itthinx.com
28
  * License: GPLv3
29
  */
30
- define( 'GROUPS_CORE_VERSION', '1.0.0' );
31
  define( 'GROUPS_FILE', __FILE__ );
32
  if ( !defined( 'GROUPS_CORE_DIR' ) ) {
33
  define( 'GROUPS_CORE_DIR', WP_PLUGIN_DIR . '/groups' );
21
  * Plugin Name: Groups
22
  * Plugin URI: http://www.itthinx.com/plugins/groups
23
  * Description: Groups provides group-based user membership management, group-based capabilities and content access control.
24
+ * Version: 1.0.0-beta-3d
25
  * Author: itthinx (Karim Rahimpur)
26
  * Author URI: http://www.itthinx.com
27
  * Donate-Link: http://www.itthinx.com
28
  * License: GPLv3
29
  */
30
+ define( 'GROUPS_CORE_VERSION', '1.0.0-beta-3d' );
31
  define( 'GROUPS_FILE', __FILE__ );
32
  if ( !defined( 'GROUPS_CORE_DIR' ) ) {
33
  define( 'GROUPS_CORE_DIR', WP_PLUGIN_DIR . '/groups' );
lib/core/class-groups-controller.php CHANGED
@@ -106,11 +106,19 @@ class Groups_Controller {
106
 
107
  // create WP capabilities
108
  Groups_Controller::set_default_capabilities();
 
 
 
 
 
 
 
 
109
 
110
  // create tables
111
  $group_table = _groups_get_tablename( 'group' );
112
- if ( $wpdb->get_var( "SHOW TABLES LIKE '" . $group_table . "'" ) != $group_table ) {
113
- $queries[] = "CREATE TABLE " . $group_table . " (
114
  group_id BIGINT(20) UNSIGNED NOT NULL auto_increment,
115
  parent_id BIGINT(20) DEFAULT NULL,
116
  creator_id BIGINT(20) DEFAULT NULL,
@@ -119,11 +127,11 @@ class Groups_Controller {
119
  description LONGTEXT DEFAULT NULL,
120
  PRIMARY KEY (group_id),
121
  UNIQUE INDEX group_n (name)
122
- );";
123
  }
124
  $capability_table = _groups_get_tablename( 'capability' );
125
- if ( $wpdb->get_var( "SHOW TABLES LIKE '" . $capability_table . "'" ) != $capability_table ) {
126
- $queries[] = "CREATE TABLE " . $capability_table . " (
127
  capability_id BIGINT(20) UNSIGNED NOT NULL auto_increment,
128
  capability VARCHAR(255) UNIQUE NOT NULL,
129
  class VARCHAR(255) DEFAULT NULL,
@@ -131,35 +139,35 @@ class Groups_Controller {
131
  name VARCHAR(100) DEFAULT NULL,
132
  description LONGTEXT DEFAULT NULL,
133
  PRIMARY KEY (capability_id),
134
- INDEX capability_kco (capability,class,object)
135
- );";
136
  }
137
  $user_group_table = _groups_get_tablename( 'user_group' );
138
- if ( $wpdb->get_var( "SHOW TABLES LIKE '" . $user_group_table . "'" ) != $user_group_table ) {
139
- $queries[] = "CREATE TABLE " . $user_group_table . " (
140
  user_id bigint(20) unsigned NOT NULL,
141
  group_id bigint(20) unsigned NOT NULL,
142
  PRIMARY KEY (user_id, group_id),
143
  INDEX user_group_gu (group_id,user_id)
144
- );";
145
  }
146
  $user_capability_table = _groups_get_tablename( 'user_capability' );
147
- if ( $wpdb->get_var( "SHOW TABLES LIKE '" . $user_capability_table . "'" ) != $user_capability_table ) {
148
- $queries[] = "CREATE TABLE " . $user_capability_table . " (
149
  user_id bigint(20) unsigned NOT NULL,
150
  capability_id bigint(20) unsigned NOT NULL,
151
  PRIMARY KEY (user_id, capability_id),
152
  INDEX user_capability_cu (capability_id,user_id)
153
- );";
154
  }
155
  $group_capability_table = _groups_get_tablename( 'group_capability' );
156
- if ( $wpdb->get_var( "SHOW TABLES LIKE '" . $group_capability_table . "'" ) != $group_capability_table ) {
157
- $queries[] = "CREATE TABLE " . $group_capability_table . " (
158
  group_id bigint(20) unsigned NOT NULL,
159
  capability_id bigint(20) unsigned NOT NULL,
160
  PRIMARY KEY (group_id, capability_id),
161
  INDEX group_capability_cg (capability_id,group_id)
162
- );";
163
  }
164
  if ( !empty( $queries ) ) {
165
  require_once( ABSPATH . 'wp-admin/includes/upgrade.php' );
@@ -198,6 +206,14 @@ class Groups_Controller {
198
  $result = true;
199
  $queries = array();
200
  switch ( $previous_version ) {
 
 
 
 
 
 
 
 
201
  default :
202
  } // switch
203
  foreach ( $queries as $query ) {
106
 
107
  // create WP capabilities
108
  Groups_Controller::set_default_capabilities();
109
+
110
+ $charset_collate = '';
111
+ if ( ! empty( $wpdb->charset ) ) {
112
+ $charset_collate = "DEFAULT CHARACTER SET $wpdb->charset";
113
+ }
114
+ if ( ! empty( $wpdb->collate ) ) {
115
+ $charset_collate .= " COLLATE $wpdb->collate";
116
+ }
117
 
118
  // create tables
119
  $group_table = _groups_get_tablename( 'group' );
120
+ if ( $wpdb->get_var( "SHOW TABLES LIKE '$group_table'" ) != $group_table ) {
121
+ $queries[] = "CREATE TABLE $group_table (
122
  group_id BIGINT(20) UNSIGNED NOT NULL auto_increment,
123
  parent_id BIGINT(20) DEFAULT NULL,
124
  creator_id BIGINT(20) DEFAULT NULL,
127
  description LONGTEXT DEFAULT NULL,
128
  PRIMARY KEY (group_id),
129
  UNIQUE INDEX group_n (name)
130
+ ) $charset_collate;";
131
  }
132
  $capability_table = _groups_get_tablename( 'capability' );
133
+ if ( $wpdb->get_var( "SHOW TABLES LIKE '$capability_table'" ) != $capability_table ) {
134
+ $queries[] = "CREATE TABLE $capability_table (
135
  capability_id BIGINT(20) UNSIGNED NOT NULL auto_increment,
136
  capability VARCHAR(255) UNIQUE NOT NULL,
137
  class VARCHAR(255) DEFAULT NULL,
139
  name VARCHAR(100) DEFAULT NULL,
140
  description LONGTEXT DEFAULT NULL,
141
  PRIMARY KEY (capability_id),
142
+ INDEX capability_kco (capability(20),class(20),object(20))
143
+ ) $charset_collate;";
144
  }
145
  $user_group_table = _groups_get_tablename( 'user_group' );
146
+ if ( $wpdb->get_var( "SHOW TABLES LIKE '$user_group_table'" ) != $user_group_table ) {
147
+ $queries[] = "CREATE TABLE $user_group_table (
148
  user_id bigint(20) unsigned NOT NULL,
149
  group_id bigint(20) unsigned NOT NULL,
150
  PRIMARY KEY (user_id, group_id),
151
  INDEX user_group_gu (group_id,user_id)
152
+ ) $charset_collate;";
153
  }
154
  $user_capability_table = _groups_get_tablename( 'user_capability' );
155
+ if ( $wpdb->get_var( "SHOW TABLES LIKE '$user_capability_table'" ) != $user_capability_table ) {
156
+ $queries[] = "CREATE TABLE $user_capability_table (
157
  user_id bigint(20) unsigned NOT NULL,
158
  capability_id bigint(20) unsigned NOT NULL,
159
  PRIMARY KEY (user_id, capability_id),
160
  INDEX user_capability_cu (capability_id,user_id)
161
+ ) $charset_collate;";
162
  }
163
  $group_capability_table = _groups_get_tablename( 'group_capability' );
164
+ if ( $wpdb->get_var( "SHOW TABLES LIKE '$group_capability_table'" ) != $group_capability_table ) {
165
+ $queries[] = "CREATE TABLE $group_capability_table (
166
  group_id bigint(20) unsigned NOT NULL,
167
  capability_id bigint(20) unsigned NOT NULL,
168
  PRIMARY KEY (group_id, capability_id),
169
  INDEX group_capability_cg (capability_id,group_id)
170
+ ) $charset_collate;";
171
  }
172
  if ( !empty( $queries ) ) {
173
  require_once( ABSPATH . 'wp-admin/includes/upgrade.php' );
206
  $result = true;
207
  $queries = array();
208
  switch ( $previous_version ) {
209
+ case '1.0.0' :
210
+ // fix hideously big index
211
+ $capability_table = _groups_get_tablename( 'capability' );
212
+ if ( $wpdb->get_var( "SHOW TABLES LIKE '$capability_table'" ) == $capability_table ) {
213
+ $queries[] = "ALTER TABLE $capability_table DROP INDEX capability_kco;";
214
+ $queries[] = "ALTER TABLE $capability_table ADD INDEX capability_kco (capability(20),class(20),object(20));";
215
+ }
216
+ break;
217
  default :
218
  } // switch
219
  foreach ( $queries as $query ) {
readme.txt CHANGED
@@ -4,7 +4,7 @@ Donate link: http://www.itthinx.com/plugins/groups
4
  Tags: access, access control, capability, capabilities, content, group, groups, member, members, membership, permission, permissions
5
  Requires at least: 3.0
6
  Tested up to: 3.3.1
7
- Stable tag: 1.0.0-beta-3c
8
 
9
  Groups provides group-based user membership management, group-based capabilities and content access control.
10
 
@@ -232,6 +232,11 @@ See also [Groups](http://www.itthinx.com/plugins/groups/)
232
 
233
  == Changelog ==
234
 
 
 
 
 
 
235
  = 1.0.0-beta-3c =
236
  * Groups shortcodes now allow nesting.
237
 
@@ -252,6 +257,9 @@ See also [Groups](http://www.itthinx.com/plugins/groups/)
252
 
253
  == Upgrade Notice ==
254
 
 
 
 
255
  = 1.0.0-beta-3c =
256
  * Groups shortcodes now allow nesting: [groups_member], [groups_non_member], [groups_can], [groups_can_not]
257
 
4
  Tags: access, access control, capability, capabilities, content, group, groups, member, members, membership, permission, permissions
5
  Requires at least: 3.0
6
  Tested up to: 3.3.1
7
+ Stable tag: 1.0.0-beta-3d
8
 
9
  Groups provides group-based user membership management, group-based capabilities and content access control.
10
 
232
 
233
  == Changelog ==
234
 
235
+ = 1.0.0-beta-3d =
236
+ * Fixed issues caused by an excessively long index for the capability DB table.
237
+ Some installations wouldn't work correctly, showing no capabilities and making it impossible to add new ones.
238
+ * Taking into account blog charset/collation on newly created tables.
239
+
240
  = 1.0.0-beta-3c =
241
  * Groups shortcodes now allow nesting.
242
 
257
 
258
  == Upgrade Notice ==
259
 
260
+ = 1.0.0-beta-3d =
261
+ * The capability DB table had a ridiculously long index, this update fixes it.
262
+
263
  = 1.0.0-beta-3c =
264
  * Groups shortcodes now allow nesting: [groups_member], [groups_non_member], [groups_can], [groups_can_not]
265