NextGEN Gallery – WordPress Gallery Plugin - Version 2.0.24

Version Description

  • 09.18.2013 =
  • Fixed: Reduce performance impact of purging displayed gallery transients
Download this release

Release Info

Developer photocrati
Plugin Icon 128x128 NextGEN Gallery – WordPress Gallery Plugin
Version 2.0.24
Comparing to
See all releases

Code changes from version 2.0.23 to 2.0.24

changelog.txt CHANGED
@@ -1,6 +1,9 @@
1
  NextGEN Gallery
2
  by Photocrati Media
3
 
 
 
 
4
  = V2.0.23 - 09.12.2013 =
5
  * NEW: WP-Cron job to periodically clean-up displayed gallery transients
6
  * NEW: Added "excluded_container_ids" as parameter for ngg_images shortcode
1
  NextGEN Gallery
2
  by Photocrati Media
3
 
4
+ = V2.0.24 - 09.18.2013 =
5
+ * Fixed: Reduce performance impact of purging displayed gallery transients
6
+
7
  = V2.0.23 - 09.12.2013 =
8
  * NEW: WP-Cron job to periodically clean-up displayed gallery transients
9
  * NEW: Added "excluded_container_ids" as parameter for ngg_images shortcode
nggallery.php CHANGED
@@ -4,7 +4,7 @@ if(preg_match('#' . basename(__FILE__) . '#', $_SERVER['PHP_SELF'])) { die('You
4
  /**
5
  * Plugin Name: NextGEN Gallery by Photocrati
6
  * Description: The most popular gallery plugin for WordPress and one of the most popular plugins of all time with over 7 million downloads.
7
- * Version: 2.0.23
8
  * Author: Photocrati Media
9
  * Plugin URI: http://www.nextgen-gallery.com
10
  * Author URI: http://www.photocrati.com
@@ -200,7 +200,7 @@ class C_NextGEN_Bootstrap
200
 
201
  // Delete displayed gallery transients periodically
202
  add_action('ngg_delete_expired_transients', array(&$this, 'delete_expired_transients'));
203
- if (!wp_next_scheduled('ngg_delete_transients')) {
204
  wp_schedule_event(time(), 'hourly', 'ngg_delete_expired_transients');
205
  }
206
 
@@ -332,7 +332,7 @@ class C_NextGEN_Bootstrap
332
  define('NEXTGEN_GALLERY_MODULE_URL', path_join(NEXTGEN_GALLERY_PRODUCT_URL, 'photocrati_nextgen/modules'));
333
  define('NEXTGEN_GALLERY_PLUGIN_CLASS', path_join(NEXTGEN_GALLERY_PLUGIN_DIR, 'module.NEXTGEN_GALLERY_PLUGIN.php'));
334
  define('NEXTGEN_GALLERY_PLUGIN_STARTED_AT', microtime());
335
- define('NEXTGEN_GALLERY_PLUGIN_VERSION', '2.0.23');
336
  }
337
 
338
 
4
  /**
5
  * Plugin Name: NextGEN Gallery by Photocrati
6
  * Description: The most popular gallery plugin for WordPress and one of the most popular plugins of all time with over 7 million downloads.
7
+ * Version: 2.0.24
8
  * Author: Photocrati Media
9
  * Plugin URI: http://www.nextgen-gallery.com
10
  * Author URI: http://www.photocrati.com
200
 
201
  // Delete displayed gallery transients periodically
202
  add_action('ngg_delete_expired_transients', array(&$this, 'delete_expired_transients'));
203
+ if (!wp_next_scheduled('ngg_delete_expired_transients')) {
204
  wp_schedule_event(time(), 'hourly', 'ngg_delete_expired_transients');
205
  }
206
 
332
  define('NEXTGEN_GALLERY_MODULE_URL', path_join(NEXTGEN_GALLERY_PRODUCT_URL, 'photocrati_nextgen/modules'));
333
  define('NEXTGEN_GALLERY_PLUGIN_CLASS', path_join(NEXTGEN_GALLERY_PLUGIN_DIR, 'module.NEXTGEN_GALLERY_PLUGIN.php'));
334
  define('NEXTGEN_GALLERY_PLUGIN_STARTED_AT', microtime());
335
+ define('NEXTGEN_GALLERY_PLUGIN_VERSION', '2.0.24');
336
  }
337
 
338
 
non_pope/class.photocrati_cache.php CHANGED
@@ -101,38 +101,68 @@ class C_Photocrati_Cache
101
  // Delete items from a single cache in particular
102
  else {
103
  $cache = self::get_instance($group);
104
- foreach (($expired_only ? self::get_expired_key_list($group) : self::get_key_list($group)) as $key) {
105
- $cache->delete($key, $expired_only);
106
- }
107
 
108
- // Delete list of cached items
109
- if (!$expired_only) {
110
- global $wpdb;
111
- $sql = $wpdb->prepare("DELETE FROM {$wpdb->options} WHERE option_name LIKE %s", '%'.$cache->group.'%');
 
 
 
 
112
  $retval = $wpdb->query($sql);
113
  }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
114
  }
115
  }
116
 
117
  return $retval;
118
  }
119
 
120
- static function get_key_list($group=NULL)
121
  {
122
  global $wpdb;
123
 
124
  $cache = self::get_instance($group);
125
- $sql = $wpdb->prepare("SELECT REPLACE(option_name, %s, '') FROM {$wpdb->options} WHERE option_name LIKE %s", $cache->group, '%'.$cache->group.'%');
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
126
  return $wpdb->get_col($sql);
127
  }
128
 
129
- static function get_expired_key_list($group=NULL)
130
  {
131
- global $wpdb;
132
-
133
- $cache = self::get_instance($group);
134
- $sql = $wpdb->prepare("SELECT REPLACE(option_name, %s, '') FROM {$wpdb->options} WHERE option_name LIKE %s AND option_value < %d", $cache->group, '%'.$cache->group.'%', time());
135
- return $wpdb->get_col($sql);
136
  }
137
 
138
 
101
  // Delete items from a single cache in particular
102
  else {
103
  $cache = self::get_instance($group);
 
 
 
104
 
105
+ // Determine if the object cache is external, and not stored in the DB
106
+ // If it's external, we have to delete each transient, one by one
107
+ global $_wp_using_ext_object_cache, $wpdb;
108
+ if ($_wp_using_ext_object_cache) {
109
+ $keys = ($expired_only ? self::get_expired_key_list($group) : self::get_key_list($group));
110
+ foreach ($keys as $key) $cache->delete($key, FALSE);
111
+ $sql = $wpdb->prepare("DELETE FROM wp_options WHERE option_name LIKE %s", "%%{$cache->group}%%");
112
+ if ($expired_only) $sql .= " AND option_value < ".time();
113
  $retval = $wpdb->query($sql);
114
  }
115
+
116
+ // Transients are stored in the database
117
+ else {
118
+ $keys = ($expired_only ? self::get_expired_key_list($group) : self::get_key_list($group));
119
+ if ($keys) {
120
+ $all_keys = array();
121
+ foreach ($keys as $value) {
122
+ $all_keys[] = "'{$cache->group}{$value}'";
123
+ $all_keys[] = "'_transient_timeout_{$value}'";
124
+ $all_keys[] = "'_transient_{$value}'";
125
+ }
126
+ unset($keys);
127
+ $all_keys = implode(',', $all_keys);
128
+ $sql = "DELETE FROM {$wpdb->options} WHERE option_name IN (". $all_keys. ')';
129
+ $retval = $wpdb->query($sql);
130
+ }
131
+ }
132
  }
133
  }
134
 
135
  return $retval;
136
  }
137
 
138
+ static function get_key_list($group=NULL, $strip_group_name=TRUE, $expired_only=FALSE)
139
  {
140
  global $wpdb;
141
 
142
  $cache = self::get_instance($group);
143
+
144
+ $sql = '';
145
+ if ($strip_group_name) {
146
+ $sql = $wpdb->prepare(
147
+ "SELECT REPLACE(option_name, %s, '') FROM {$wpdb->options} WHERE option_name LIKE %s",
148
+ $cache->group, '%'.$cache->group.'%'
149
+ );
150
+ }
151
+ else {
152
+ $sql = $wpdb->prepare(
153
+ "SELECT option_name FROM {$wpdb->options} WHERE option_name LIKE %s",
154
+ '%'.$cache->group.'%'
155
+ );
156
+ }
157
+
158
+ if ($expired_only) $sql .= " AND option_value < ".time();
159
+
160
  return $wpdb->get_col($sql);
161
  }
162
 
163
+ static function get_expired_key_list($group=NULL, $strip_group_name=TRUE)
164
  {
165
+ return self::get_key_list($group, $strip_group_name, TRUE);
 
 
 
 
166
  }
167
 
168
 
non_pope/class.photocrati_installer.php CHANGED
@@ -104,6 +104,9 @@ if (!class_exists('C_Photocrati_Installer'))
104
  // The cache should be flushed
105
  C_Photocrati_Cache::flush();
106
 
 
 
 
107
  // Delete auto-update cache
108
  update_option('photocrati_auto_update_admin_update_list', null);
109
  update_option('photocrati_auto_update_admin_check_date', '');
104
  // The cache should be flushed
105
  C_Photocrati_Cache::flush();
106
 
107
+ // Remove the cron schedule. It will be re-added later.
108
+ wp_clear_scheduled_hook('ngg_delete_expired_transients');
109
+
110
  // Delete auto-update cache
111
  update_option('photocrati_auto_update_admin_update_list', null);
112
  update_option('photocrati_auto_update_admin_check_date', '');
non_pope/class.photocrati_resource_manager.php CHANGED
@@ -129,7 +129,7 @@ class C_Photocrati_Resource_Manager
129
  // If W3TC is installed and activated, we can't output the
130
  // scripts and manipulate the buffer, so we can only provide a warning
131
  if (defined('W3TC') && defined('WP_DEBUG') && WP_DEBUG) {
132
- define('DONOTCACHEPAGE', TRUE);
133
  if (!did_action('wp_footer')) {
134
  error_log("We're sorry, but your theme's page template didn't make a call to wp_footer(), which is required by NextGEN Gallery. Please add this call to your page templates.");
135
  }
129
  // If W3TC is installed and activated, we can't output the
130
  // scripts and manipulate the buffer, so we can only provide a warning
131
  if (defined('W3TC') && defined('WP_DEBUG') && WP_DEBUG) {
132
+ if (defined('DONOTCACHEPAGE')) define('DONOTCACHEPAGE', TRUE);
133
  if (!did_action('wp_footer')) {
134
  error_log("We're sorry, but your theme's page template didn't make a call to wp_footer(), which is required by NextGEN Gallery. Please add this call to your page templates.");
135
  }
products/photocrati_nextgen/modules/datamapper/module.datamapper.php CHANGED
@@ -48,14 +48,16 @@ class M_DataMapper extends C_Base_Module
48
  */
49
  function set_custom_wp_query($sql, &$wp_query)
50
  {
51
- // Set the custom query
52
- if (($custom_sql = $wp_query->get('custom_sql'))) {
53
- $sql = $custom_sql;
54
- }
55
-
56
- // Perhaps we're to initiate a delete query instead?
57
- elseif ($wp_query->get('is_delete')) {
58
- $sql = preg_replace("/^SELECT.*FROM/i", "DELETE FROM", $sql);
 
 
59
  }
60
 
61
  return $sql;
@@ -69,8 +71,13 @@ class M_DataMapper extends C_Base_Module
69
  */
70
  function set_custom_wp_query_fields($fields, &$wp_query)
71
  {
72
- $custom_fields = $wp_query->get('fields');
73
- return $custom_fields ? $custom_fields : $fields;
 
 
 
 
 
74
  }
75
 
76
 
@@ -82,8 +89,11 @@ class M_DataMapper extends C_Base_Module
82
  */
83
  function set_custom_wp_query_where($where, &$wp_query)
84
  {
85
- $this->add_post_title_where_clauses($where, $wp_query);
86
- $this->add_post_name_where_clauses($where, $wp_query);
 
 
 
87
  return $where;
88
  }
89
 
48
  */
49
  function set_custom_wp_query($sql, &$wp_query)
50
  {
51
+ if ($wp_query->get('datamapper')) {
52
+ // Set the custom query
53
+ if (($custom_sql = $wp_query->get('custom_sql'))) {
54
+ $sql = $custom_sql;
55
+ }
56
+
57
+ // Perhaps we're to initiate a delete query instead?
58
+ elseif ($wp_query->get('is_delete')) {
59
+ $sql = preg_replace("/^SELECT.*FROM/i", "DELETE FROM", $sql);
60
+ }
61
  }
62
 
63
  return $sql;
71
  */
72
  function set_custom_wp_query_fields($fields, &$wp_query)
73
  {
74
+ if ($wp_query->get('datmapper')) {
75
+ if (($custom_fields = $wp_query->get('fields'))) {
76
+ $fields = $custom_fields;
77
+ }
78
+ }
79
+
80
+ return $fields;
81
  }
82
 
83
 
89
  */
90
  function set_custom_wp_query_where($where, &$wp_query)
91
  {
92
+ if ($wp_query->get('datamapper')) {
93
+ $this->add_post_title_where_clauses($where, $wp_query);
94
+ $this->add_post_name_where_clauses($where, $wp_query);
95
+ }
96
+
97
  return $where;
98
  }
99
 
products/photocrati_nextgen/modules/fs/class.fs.php CHANGED
@@ -295,11 +295,13 @@ class Mixin_Fs_Instance_Methods extends Mixin
295
  $one = (FALSE === $one ? 0 : count($one) + 1);
296
  $two = (FALSE === $two ? 0 : count($two) + 1);
297
  if (!empty($protocol)) {
298
- if (@$retval[$ndx] !== $val || $two >= $one)
 
299
  $retval[] = $val;
300
  }
301
  else {
302
- if (@$retval[$ndx] !== $val && $two >= $one)
 
303
  $retval[] = $val;
304
  }
305
  }
295
  $one = (FALSE === $one ? 0 : count($one) + 1);
296
  $two = (FALSE === $two ? 0 : count($two) + 1);
297
  if (!empty($protocol)) {
298
+ $existing_val = isset($retval[$ndx]) ? $retval[$ndx] : NULL;
299
+ if ($existing_val !== $val || $two >= $one)
300
  $retval[] = $val;
301
  }
302
  else {
303
+ $existing_val = isset($retval[$ndx]) ? $retval[$ndx] : NULL;
304
+ if ($existing_val !== $val && $two >= $one)
305
  $retval[] = $val;
306
  }
307
  }
products/photocrati_nextgen/modules/nextgen_gallery_display/class.displayed_gallery.php CHANGED
@@ -890,7 +890,9 @@ class Mixin_Displayed_Gallery_Instance_Methods extends Mixin
890
 
891
  $group = 'displayed_galleries';
892
  $key = C_Photocrati_Cache::generate_key($this->object->get_entity(), $group);
893
- C_Photocrati_Cache::set($key, $this->object->get_entity(), $group, 1800);
 
 
894
 
895
  return $key;
896
  }
890
 
891
  $group = 'displayed_galleries';
892
  $key = C_Photocrati_Cache::generate_key($this->object->get_entity(), $group);
893
+ if (is_null(C_Photocrati_Cache::get($key, NULL, $group))) {
894
+ C_Photocrati_Cache::set($key, $this->object->get_entity(), $group, 1800);
895
+ }
896
 
897
  return $key;
898
  }
products/photocrati_nextgen/product.photocrati_nextgen.php CHANGED
@@ -52,7 +52,7 @@ class P_Photocrati_NextGen extends C_Base_Product
52
  'photocrati-nextgen',
53
  'Photocrati NextGen',
54
  'Photocrati NextGen',
55
- '2.0.23',
56
  'http://www.nextgen-gallery.com',
57
  'Photocrati Media',
58
  'http://www.photocrati.com'
52
  'photocrati-nextgen',
53
  'Photocrati NextGen',
54
  'Photocrati NextGen',
55
+ '2.0.24',
56
  'http://www.nextgen-gallery.com',
57
  'Photocrati Media',
58
  'http://www.photocrati.com'
readme.txt CHANGED
@@ -195,6 +195,9 @@ For more information, feel free to visit the official website for the NextGEN Ga
195
 
196
  == Changelog ==
197
 
 
 
 
198
  = V2.0.23 - 09.16.2013 =
199
  * NEW: WP-Cron job to periodically clean-up displayed gallery transients
200
  * NEW: Added "excluded_container_ids" as parameter for ngg_images shortcode
195
 
196
  == Changelog ==
197
 
198
+ = V2.0.24 - 09.18.2013 =
199
+ * Fixed: Reduce performance impact of purging displayed gallery transients
200
+
201
  = V2.0.23 - 09.16.2013 =
202
  * NEW: WP-Cron job to periodically clean-up displayed gallery transients
203
  * NEW: Added "excluded_container_ids" as parameter for ngg_images shortcode