| @@ 54-78 (lines=25) @@ | ||
| 51 | * |
|
| 52 | * @return stdClass Return the first batch from the queue. |
|
| 53 | */ |
|
| 54 | protected function get_batch() { |
|
| 55 | global $wpdb; |
|
| 56 | ||
| 57 | $table = $wpdb->options; |
|
| 58 | $column = 'option_name'; |
|
| 59 | $key_column = 'option_id'; |
|
| 60 | $value_column = 'option_value'; |
|
| 61 | ||
| 62 | if ( is_multisite() ) { |
|
| 63 | $table = $wpdb->sitemeta; |
|
| 64 | $column = 'meta_key'; |
|
| 65 | $key_column = 'meta_id'; |
|
| 66 | $value_column = 'meta_value'; |
|
| 67 | } |
|
| 68 | ||
| 69 | $key = $wpdb->esc_like( $this->identifier . '_batch_' ) . '%'; |
|
| 70 | ||
| 71 | $query = $wpdb->get_row( $wpdb->prepare( "SELECT * FROM {$table} WHERE {$column} LIKE %s ORDER BY {$key_column} ASC LIMIT 1", $key ) ); // @codingStandardsIgnoreLine. |
|
| 72 | ||
| 73 | $batch = new stdClass(); |
|
| 74 | $batch->key = $query->$column; |
|
| 75 | $batch->data = array_filter( (array) maybe_unserialize( $query->$value_column ) ); |
|
| 76 | ||
| 77 | return $batch; |
|
| 78 | } |
|
| 79 | ||
| 80 | /** |
|
| 81 | * See if the batch limit has been exceeded. |
|
| @@ 256-286 (lines=31) @@ | ||
| 253 | * |
|
| 254 | * @return stdClass Return the first batch from the queue |
|
| 255 | */ |
|
| 256 | protected function get_batch() { |
|
| 257 | global $wpdb; |
|
| 258 | ||
| 259 | $table = $wpdb->options; |
|
| 260 | $column = 'option_name'; |
|
| 261 | $key_column = 'option_id'; |
|
| 262 | $value_column = 'option_value'; |
|
| 263 | ||
| 264 | if ( is_multisite() ) { |
|
| 265 | $table = $wpdb->sitemeta; |
|
| 266 | $column = 'meta_key'; |
|
| 267 | $key_column = 'meta_id'; |
|
| 268 | $value_column = 'meta_value'; |
|
| 269 | } |
|
| 270 | ||
| 271 | $key = $this->identifier . '_batch_%'; |
|
| 272 | ||
| 273 | $query = $wpdb->get_row( $wpdb->prepare( " |
|
| 274 | SELECT * |
|
| 275 | FROM {$table} |
|
| 276 | WHERE {$column} LIKE %s |
|
| 277 | ORDER BY {$key_column} ASC |
|
| 278 | LIMIT 1 |
|
| 279 | ", $key ) ); |
|
| 280 | ||
| 281 | $batch = new stdClass(); |
|
| 282 | $batch->key = $query->$column; |
|
| 283 | $batch->data = maybe_unserialize( $query->$value_column ); |
|
| 284 | ||
| 285 | return $batch; |
|
| 286 | } |
|
| 287 | ||
| 288 | /** |
|
| 289 | * Handle |
|