WP_Background_Process::get_batch PHP Method

get_batch() protected method

Get batch
protected get_batch ( ) : stdClass
return stdClass Return the first batch from the queue
        protected function get_batch()
        {
            global $wpdb;
            $table = $wpdb->options;
            $column = 'option_name';
            $key_column = 'option_id';
            $value_column = 'option_value';
            if (is_multisite()) {
                $table = $wpdb->sitemeta;
                $column = 'meta_key';
                $key_column = 'meta_id';
                $value_column = 'meta_value';
            }
            $key = $this->identifier . '_batch_%';
            $query = $wpdb->get_row($wpdb->prepare("\n\t\t\tSELECT *\n\t\t\tFROM {$table}\n\t\t\tWHERE {$column} LIKE %s\n\t\t\tORDER BY {$key_column} ASC\n\t\t\tLIMIT 1\n\t\t", $key));
            $batch = new stdClass();
            $batch->key = $query->{$column};
            $batch->data = maybe_unserialize($query->{$value_column});
            return $batch;
        }