Automattic\WooCommerce\Internal\PushNotifications\Services
StepLogQuery::query
Reads the sources, keeps the rows the filter accepts, and assembles the answer.
Метод класса: StepLogQuery{}
Хуков нет.
Возвращает
array{rows: array, counts: array<string, int>, covered_from: int, next_to: int|null, logging: array}.
Использование
// private - только в коде основоного (родительского) класса $result = $this->query( $sources, $from, $to, $limit, ?callable $expand ): array;
- $sources(string[]) (обязательный)
- The log sources to read.
- $from(int) (обязательный)
- Earliest timestamp, inclusive.
- $to(int) (обязательный)
- Latest timestamp, inclusive.
- $limit(int) (обязательный)
- Rows to return, before the whole-second rule.
- ?callable $expand
- .
По умолчанию:null
Код StepLogQuery::query() StepLogQuery::query WC 11.3.0
private function query( array $sources, int $from, int $to, int $limit, ?callable $expand = null ): array {
$rows = array();
$covered_from = $from;
$has_more = false;
foreach ( $sources as $source ) {
/*
* The readers apply the expansion as each line is read and stop
* once they hold enough, so neither the range nor one large file
* decides how much is held here.
*/
$result = $this->read( $source, $from, $to, $limit, $expand );
$covered_from = max( $covered_from, $result['covered_from'] );
$has_more = $has_more || $result['has_more'];
$rows = array_merge( $rows, $result['rows'] );
}
usort(
$rows,
function ( array $a, array $b ): int {
if ( $a['timestamp'] !== $b['timestamp'] ) {
return $b['timestamp'] <=> $a['timestamp'];
}
return self::get_order_within_a_second( $b ) <=> self::get_order_within_a_second( $a );
}
);
list( $rows, $next_to ) = self::take_page( $rows, $limit, $has_more );
return array(
'rows' => array_map( array( self::class, 'format_row' ), $rows ),
'counts' => self::count_outcomes( $rows ),
'covered_from' => $covered_from,
'next_to' => $next_to,
'logging' => $this->get_logging_state(),
);
}