Skip to content

Commit 29463c8

Browse files
committed
Show hashes and deployed datetimes on deploy cache
1 parent 2f88a28 commit 29463c8

3 files changed

Lines changed: 41 additions & 5 deletions

File tree

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@
1212
deploy.
1313
- Fix location in crawler redirect debug message.
1414
- Add more debug messages to crawler.
15+
- Show data hashes and deployed at datetimes on deploy cache pages.
1516

1617
## 9.8.0 (2026-01-07)
1718

src/DeployCache.php

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -230,4 +230,29 @@ public static function getPaths(
230230
),
231231
);
232232
}
233+
234+
/**
235+
* Get all cached rows
236+
*
237+
* @return object[] All cached paths
238+
*/
239+
public static function getRows(
240+
string $ns,
241+
): array {
242+
global $wpdb;
243+
244+
$table_name = self::getTableName();
245+
246+
// phpcs:ignore WordPress.DB.DirectDatabaseQuery
247+
return $wpdb->get_results(
248+
$wpdb->prepare(
249+
'SELECT path,data_hash,deployed_at'
250+
. ' FROM %i'
251+
. ' WHERE namespace = %s'
252+
. ' ORDER BY path,namespace,id',
253+
$table_name,
254+
$ns,
255+
),
256+
);
257+
}
233258
}

src/ViewRenderer.php

Lines changed: 15 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -278,9 +278,12 @@ public static function renderDeployCache(): void {
278278
FILTER_SANITIZE_URL,
279279
)
280280
);
281-
$paths = $deploy_namespace !== ''
282-
? DeployCache::getPaths( $deploy_namespace )
283-
: DeployCache::getPaths();
281+
282+
if ( $deploy_namespace === '' ) {
283+
$deploy_namespace = DeployCache::DEFAULT_NAMESPACE;
284+
}
285+
286+
$paths = DeployCache::getRows( $deploy_namespace );
284287

285288
// Apply search
286289
$search_term = strval( filter_input( INPUT_GET, 's', FILTER_SANITIZE_URL ) );
@@ -292,8 +295,13 @@ public static function renderDeployCache(): void {
292295
}
293296

294297
$records = array_map(
295-
fn( string $path ): array => [
296-
$path,
298+
fn( object $row ): array => [
299+
$row->path,
300+
$row->data_hash,
301+
$row->deployed_at
302+
. ' ('
303+
. human_time_diff( Utils::wpDateTime( $row->deployed_at )->getTimestamp() )
304+
. ' ago)',
297305
],
298306
$paths,
299307
);
@@ -305,6 +313,8 @@ public static function renderDeployCache(): void {
305313
$view = [
306314
'colHeadings' => [
307315
'Deployed Files',
316+
'Data Hash',
317+
'Deployed At',
308318
],
309319
'emptyMessage' => 'There are no deployed files.',
310320
'paginatorFirstPage' => $paginator->firstPage(),

0 commit comments

Comments
 (0)