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.

Метод класса: Query{}

Хуков нет.

Возвращает

null. Ничего.

Использование

// private - только в коде основоного (родительского) класса
$result = $this->adjust_offset_for_shrinking_result_set();

Код Query::adjust_offset_for_shrinking_result_set() 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;
}