WP_CLI\Iterators

Query::adjust_offset_for_shrinking_result_set()privateWP-CLI 1.0

Reduces the offset when the query row count shrinks

In cases where the iterated rows are being updated such that they will no longer be returned by the original query, the offset must be reduced to iterate over all remaining rows.

Method of the class: Query{}

No Hooks.

Return

null. Nothing.

Usage

// private - for code of main (parent) class only
$result = $this->adjust_offset_for_shrinking_result_set();

Query::adjust_offset_for_shrinking_result_set() code WP-CLI 2.8.0-alpha

private function adjust_offset_for_shrinking_result_set() {
	if ( empty( $this->count_query ) ) {
		return;
	}

	$row_count = $this->db->get_var( $this->count_query );

	if ( $row_count < $this->row_count ) {
		$this->offset -= $this->row_count - $row_count;
	}

	$this->row_count = $row_count;
}