← All changes
|
libraries/action-scheduler/classes/ActionScheduler_DataController.php
+33
-10
1.0.2
→
3.1.1
View file →
| @@ -17,12 +17,12 @@ | ||
| 17 | 17 | /** Action data store class name. */ |
| 18 | 18 | const DATASTORE_CLASS = 'ActionScheduler_DBStore'; |
| 19 | 19 | |
| 20 | 20 | /** Logger data store class name. */ |
| 21 | - const LOGGER_CLASS = 'ActionScheduler_DBLogger'; | |
| 21 | + const LOGGER_CLASS = 'ActionScheduler_DBLogger'; | |
| 22 | 22 | |
| 23 | 23 | /** Migration status option name. */ |
| 24 | - const STATUS_FLAG = 'action_scheduler_migration_status'; | |
| 24 | + const STATUS_FLAG = 'action_scheduler_migration_status'; | |
| 25 | 25 | |
| 26 | 26 | /** Migration status option value. */ |
| 27 | 27 | const STATUS_COMPLETE = 'complete'; |
| 28 | 28 | |
| @@ -28,15 +28,27 @@ | ||
| 28 | 28 | |
| 29 | 29 | /** Migration minimum required PHP version. */ |
| 30 | 30 | const MIN_PHP_VERSION = '5.5'; |
| 31 | 31 | |
| 32 | - /** @var ActionScheduler_DataController */ | |
| 32 | + /** | |
| 33 | + * Instance. | |
| 34 | + * | |
| 35 | + * @var ActionScheduler_DataController | |
| 36 | + */ | |
| 33 | 37 | private static $instance; |
| 34 | 38 | |
| 35 | - /** @var int */ | |
| 39 | + /** | |
| 40 | + * Sleep time in seconds. | |
| 41 | + * | |
| 42 | + * @var int | |
| 43 | + */ | |
| 36 | 44 | private static $sleep_time = 0; |
| 37 | 45 | |
| 38 | - /** @var int */ | |
| 46 | + /** | |
| 47 | + * Tick count required for freeing memory. | |
| 48 | + * | |
| 49 | + * @var int | |
| 50 | + */ | |
| 39 | 51 | private static $free_ticks = 50; |
| 40 | 52 | |
| 41 | 53 | /** |
| 42 | 54 | * Get a flag indicating whether the migration environment dependencies are met. |
| @@ -136,8 +148,10 @@ | ||
| 136 | 148 | |
| 137 | 149 | \WP_CLI::warning( __( 'Attempting to reduce used memory...', 'action-scheduler' ) ); |
| 138 | 150 | |
| 139 | 151 | /** |
| 152 | + * Globals. | |
| 153 | + * | |
| 140 | 154 | * @var $wpdb \wpdb |
| 141 | 155 | * @var $wp_object_cache \WP_Object_Cache |
| 142 | 156 | */ |
| 143 | 157 | global $wpdb, $wp_object_cache; |
| @@ -147,15 +161,24 @@ | ||
| 147 | 161 | if ( ! is_a( $wp_object_cache, 'WP_Object_Cache' ) ) { |
| 148 | 162 | return; |
| 149 | 163 | } |
| 150 | 164 | |
| 151 | - $wp_object_cache->group_ops = array(); | |
| 152 | - $wp_object_cache->stats = array(); | |
| 153 | - $wp_object_cache->memcache_debug = array(); | |
| 154 | - $wp_object_cache->cache = array(); | |
| 165 | + // Not all drop-ins support these props, however, there may be existing installations that rely on these being cleared. | |
| 166 | + if ( property_exists( $wp_object_cache, 'group_ops' ) ) { | |
| 167 | + $wp_object_cache->group_ops = array(); | |
| 168 | + } | |
| 169 | + if ( property_exists( $wp_object_cache, 'stats' ) ) { | |
| 170 | + $wp_object_cache->stats = array(); | |
| 171 | + } | |
| 172 | + if ( property_exists( $wp_object_cache, 'memcache_debug' ) ) { | |
| 173 | + $wp_object_cache->memcache_debug = array(); | |
| 174 | + } | |
| 175 | + if ( property_exists( $wp_object_cache, 'cache' ) ) { | |
| 176 | + $wp_object_cache->cache = array(); | |
| 177 | + } | |
| 155 | 178 | |
| 156 | 179 | if ( is_callable( array( $wp_object_cache, '__remoteset' ) ) ) { |
| 157 | - call_user_func( array( $wp_object_cache, '__remoteset' ) ); // important | |
| 180 | + call_user_func( array( $wp_object_cache, '__remoteset' ) ); // important! | |
| 158 | 181 | } |
| 159 | 182 | } |
| 160 | 183 | |
| 161 | 184 | /** |