WP_Background_Process::handle()
Handle
Contents
Description Description
Pass each queue item to the task handler, while remaining within server memory and time limit constraints.
Source Source
File: vendor/deliciousbrains/wp-background-processing/classes/wp-background-process.php
294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 | protected function handle() { $this ->lock_process(); do { $batch = $this ->get_batch(); foreach ( $batch ->data as $key => $value ) { $task = $this ->task( $value ); if ( false !== $task ) { $batch ->data[ $key ] = $task ; } else { unset( $batch ->data[ $key ] ); } if ( $this ->time_exceeded() || $this ->memory_exceeded() ) { // Batch limits reached. break ; } } // Update or delete current batch. if ( ! empty ( $batch ->data ) ) { $this ->update( $batch ->key, $batch ->data ); } else { $this -> delete ( $batch ->key ); } } while ( ! $this ->time_exceeded() && ! $this ->memory_exceeded() && ! $this ->is_queue_empty() ); $this ->unlock_process(); // Start next batch or complete process. if ( ! $this ->is_queue_empty() ) { $this ->dispatch(); } else { $this ->complete(); } wp_die(); } |
Expand full source code Collapse full source code View on GitHub