Skip to content

Commit 419c392

Browse files
committed
Rename crawl_cache table to crawled_files
1 parent ad13c3e commit 419c392

File tree

12 files changed

+66
-65
lines changed

12 files changed

+66
-65
lines changed

src/CLI.php

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -822,36 +822,36 @@ public function process_queue(): void {
822822
}
823823

824824
/**
825-
* Crawl Cache
825+
* Crawled Files
826826
*
827827
* <list>
828828
*
829-
* List all URLs in the CrawlCache
829+
* List all crawled files
830830
*
831831
* <count>
832832
*
833-
* Show total number of URLs in CrawlCache
833+
* Show total number of crawled files
834834
*
835835
* <delete>
836836
*
837-
* Empty all URLs from CrawlCache
837+
* Delete all crawled files
838838
*
839839
* @param string[] $args Arguments after command
840840
* @param string[] $assoc_args Parameters after command
841841
*/
842-
public function crawl_cache( array $args, array $assoc_args ): void {
842+
public function crawled_files( array $args, array $assoc_args ): void {
843843
$action = isset( $args[0] ) ? $args[0] : null;
844844

845845
if ( $action === 'list' ) {
846-
$urls = CrawlCache::getHashes();
846+
$urls = CrawledFiles::getHashes();
847847

848848
foreach ( $urls as $url ) {
849849
WP_CLI::line( $url );
850850
}
851851
}
852852

853853
if ( $action === 'count' ) {
854-
$urls = CrawlCache::getHashes();
854+
$urls = CrawledFiles::getHashes();
855855

856856
WP_CLI::line( (string) count( $urls ) );
857857
}
@@ -861,19 +861,19 @@ public function crawl_cache( array $args, array $assoc_args ): void {
861861
if ( ! isset( $assoc_args['force'] ) ) {
862862
$this->multilinePrint(
863863
"no --force given. Please type 'yes' to confirm
864-
deletion of Crawl Cache"
864+
deletion of crawled files"
865865
);
866866

867867
$userval = trim( (string) fgets( STDIN ) );
868868

869869
if ( $userval !== 'yes' ) {
870-
WP_CLI::error( 'Failed to delete Crawl Cache' );
870+
WP_CLI::error( 'Failed to delete crawled files' );
871871
}
872872
}
873873

874-
CrawlCache::truncate();
874+
CrawledFiles::truncate();
875875

876-
WP_CLI::success( 'Deleted Crawl Cache' );
876+
WP_CLI::success( 'Deleted crawled files' );
877877
}
878878
}
879879

@@ -979,7 +979,7 @@ public function processed_site( array $args, array $assoc_args ): void {
979979
*
980980
* Delete all generated Static Site files from server
981981
*
982-
* -- also deletes the CrawlCache
982+
* -- also deletes the crawled files
983983
*
984984
* @param string[] $args Arguments after command
985985
* @param string[] $assoc_args Parameters after command

src/Controller.php

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -105,7 +105,7 @@ public static function activateForSingleSite(): void {
105105
// prepare DB tables
106106
WsLog::createTable();
107107
CoreOptions::init();
108-
CrawlCache::createTable();
108+
CrawledFiles::createTable();
109109
DetectedFiles::createTable();
110110
DeployCache::createTable();
111111
JobQueue::createTable();
@@ -234,11 +234,11 @@ public static function registerOptionsPage(): void {
234234

235235
add_submenu_page(
236236
'',
237-
'WP2Static Crawl Cache',
238-
'Crawl Cache',
237+
'WP2Static Crawled Files',
238+
'Crawled Files',
239239
'manage_options',
240-
'wp2static-crawl-cache',
241-
[ ViewRenderer::class, 'renderCrawlCache' ]
240+
'wp2static-crawled-files',
241+
[ ViewRenderer::class, 'renderCrawledFiles' ]
242242
);
243243

244244
add_submenu_page(
@@ -337,7 +337,7 @@ public static function wp2staticDeleteAllCaches(): void {
337337

338338
public static function deleteAllCaches(): void {
339339
DetectedFiles::truncate();
340-
CrawlCache::truncate();
340+
CrawledFiles::truncate();
341341
StaticSite::delete();
342342
ProcessedSite::delete();
343343
DeployCache::truncate();
@@ -386,19 +386,19 @@ public static function wp2staticDeployCacheShow(): void {
386386
exit;
387387
}
388388

389-
public static function wp2staticCrawlCacheDelete(): void {
389+
public static function wp2staticCrawledFilesDelete(): void {
390390
check_admin_referer( 'wp2static-caches-page' );
391391

392-
CrawlCache::truncate();
392+
CrawledFiles::truncate();
393393

394394
wp_safe_redirect( admin_url( 'admin.php?page=wp2static-caches' ) );
395395
exit;
396396
}
397397

398-
public static function wp2staticCrawlCacheShow(): void {
398+
public static function wp2staticCrawledFilesShow(): void {
399399
check_admin_referer( 'wp2static-caches-page' );
400400

401-
wp_safe_redirect( admin_url( 'admin.php?page=wp2static-crawl-cache' ) );
401+
wp_safe_redirect( admin_url( 'admin.php?page=wp2static-crawled-files' ) );
402402
exit;
403403
}
404404

@@ -764,7 +764,7 @@ public static function invalidateSingleURLCache(
764764
$permalink
765765
);
766766

767-
CrawlCache::rmUrl( $url );
767+
CrawledFiles::rmUrl( $url );
768768
}
769769

770770
public static function emailDeployNotification(): void {
Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
namespace WP2Static;
44

5-
class CrawlCache {
5+
class CrawledFiles {
66

77
public static function createTable(): void {
88
global $wpdb;
@@ -56,7 +56,7 @@ public static function createTable(): void {
5656
}
5757

5858
/**
59-
* Get all Crawl Cache path hashes
59+
* Get all crawled file path hashes
6060
*
6161
* @return string[]
6262
*/
@@ -72,7 +72,7 @@ public static function getHashes(): array {
7272
}
7373

7474
public static function getTableName(): string {
75-
return Controller::getTableName( 'crawl_cache' );
75+
return Controller::getTableName( 'crawled_files' );
7676
}
7777

7878
/**
@@ -127,7 +127,7 @@ public static function addPathsIter( \Iterator $paths ): \Iterator {
127127
$result = $wpdb->query( $wpdb->prepare( $sql, ...$values ) );
128128

129129
if ( false === $result ) {
130-
WsLog::w( 'Error inserting into crawl cache: ' . $wpdb->last_error );
130+
WsLog::w( 'Error inserting into crawled files: ' . $wpdb->last_error );
131131
}
132132

133133
foreach ( $paths as $path ) {
@@ -184,7 +184,7 @@ public static function getPathsIter(): \Iterator {
184184
}
185185

186186
/**
187-
* Remove 404 URLs from the detected files, crawl cache, and
187+
* Remove 404 URLs from the detected files, crawled files, and
188188
* files written to disk.
189189
*/
190190
public static function remove404s( \Iterator $paths ): \Iterator {
@@ -298,7 +298,7 @@ public static function getUrl( string $path, string $content_hash ): string {
298298
}
299299

300300
/**
301-
* Get all paths in CrawlCache
301+
* Get all crawled files
302302
*
303303
* @return object[] {
304304
* All crawlable paths
@@ -358,26 +358,26 @@ public static function rmUrlsById( array $ids ): void {
358358
}
359359

360360
/**
361-
* Clear CrawlCache via truncation
361+
* Clear crawled files via truncation
362362
*/
363363
public static function truncate(): void {
364-
WsLog::l( 'Deleting CrawlCache' );
364+
WsLog::l( 'Deleting crawled files' );
365365

366366
global $wpdb;
367367

368368
$table_name = self::getTableName();
369369

370370
$wpdb->query( "TRUNCATE TABLE $table_name" );
371371

372-
$totalcrawl_cache = self::getTotal();
372+
$total_crawled_files = self::getTotal();
373373

374-
if ( $totalcrawl_cache > 0 ) {
375-
WsLog::l( 'Failed to truncate CrawlCache: try deleting instead' );
374+
if ( $total_crawled_files > 0 ) {
375+
WsLog::l( 'Failed to truncate crawled files: try deleting instead' );
376376
}
377377
}
378378

379379
/**
380-
* Count URLs in Crawl Cache
380+
* Count crawled files
381381
*/
382382
public static function getTotal(): int {
383383
global $wpdb;

src/Crawler.php

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -106,9 +106,9 @@ public static function wp2staticCrawl( string $crawler_slug ): void {
106106
$detected = DetectedFiles::getPathsIter();
107107
$last_now = $wpdb->get_var( 'SELECT NOW()' );
108108
$crawled = $crawler->crawlIter( $detected );
109-
$crawled = CrawlCache::remove404s( $crawled );
110-
$crawled = CrawlCache::writeFilesIter( $crawled );
111-
$crawled = CrawlCache::addPathsIter( $crawled );
109+
$crawled = CrawledFiles::remove404s( $crawled );
110+
$crawled = CrawledFiles::writeFilesIter( $crawled );
111+
$crawled = CrawledFiles::addPathsIter( $crawled );
112112
$crawled = $url_discovery->discoverURLs( $crawled );
113113
foreach ( $crawled as $_ ) {
114114
// Intentionally empty to consume the iterator
@@ -120,8 +120,8 @@ public static function wp2staticCrawl( string $crawler_slug ): void {
120120
$detected = DetectedFiles::getPathsIter( $last_now );
121121
$last_now = $wpdb->get_var( 'SELECT NOW()' );
122122
$crawled = $crawler->crawlIter( $detected );
123-
$crawled = CrawlCache::writeFilesIter( $crawled );
124-
$crawled = CrawlCache::addPathsIter( $crawled );
123+
$crawled = CrawledFiles::writeFilesIter( $crawled );
124+
$crawled = CrawledFiles::addPathsIter( $crawled );
125125
$crawled = $url_discovery->discoverURLs( $crawled );
126126
$has_new = false;
127127
foreach ( $crawled as $_ ) {

src/DirectDeployer.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -79,9 +79,9 @@ public function deployComplete(): void {
7979
public function deployPaths( \Iterator $paths, bool $remove_404s = true ): void {
8080
$crawled = $this->crawler->crawlIter( $paths );
8181
if ( $remove_404s ) {
82-
$crawled = CrawlCache::remove404s( $crawled );
82+
$crawled = CrawledFiles::remove404s( $crawled );
8383
}
84-
$crawled = CrawlCache::addPathsIter( $crawled );
84+
$crawled = CrawledFiles::addPathsIter( $crawled );
8585
$crawled = $this->url_discovery->discoverURLs( $crawled );
8686

8787
$processed = $this->processor->processIter( $crawled );

src/PostProcessor.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,7 @@ public function processStaticSite(
5454
return;
5555
}
5656

57-
$crawled = CrawlCache::getPathsIter();
57+
$crawled = CrawledFiles::getPathsIter();
5858
$processed = $this->processIter( $crawled );
5959

6060
foreach ( $processed as $path ) {

src/StaticSite.php

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -51,8 +51,9 @@ public static function delete(): void {
5151
if ( is_dir( self::getPath() ) ) {
5252
FilesHelper::deleteDirWithFiles( self::getPath() );
5353

54-
// CrawlCache not useful without StaticSite files
55-
CrawlCache::truncate();
54+
// The crawled file data is not useful without
55+
// StaticSite files.
56+
CrawledFiles::truncate();
5657
}
5758
}
5859

src/ViewRenderer.php

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -100,7 +100,7 @@ function ( $url ) use ( $search_term ) {
100100
require_once WP2STATIC_PATH . 'views/detected-files-page.php';
101101
}
102102

103-
public static function renderCrawlCache(): void {
103+
public static function renderCrawledFiles(): void {
104104
if ( ! is_admin() ) {
105105
http_response_code( 403 );
106106
die( 'Forbidden' );
@@ -113,10 +113,10 @@ public static function renderCrawlCache(): void {
113113
$url_id = filter_input( INPUT_GET, 'id' );
114114

115115
if ( $action === 'remove' && is_array( $url_id ) ) {
116-
CrawlCache::rmUrlsById( $url_id );
116+
CrawledFiles::rmUrlsById( $url_id );
117117
}
118118

119-
$urls = CrawlCache::getURLs();
119+
$urls = CrawledFiles::getURLs();
120120
// Apply search
121121
$search_term = strval( filter_input( INPUT_GET, 's' ) );
122122
if ( $search_term !== '' ) {
@@ -139,7 +139,7 @@ function ( $url ) use ( $search_term ) {
139139
'paginatorTotalRecords' => $paginator->totalRecords(),
140140
];
141141

142-
require_once WP2STATIC_PATH . 'views/crawl-cache-page.php';
142+
require_once WP2STATIC_PATH . 'views/crawled-files-page.php';
143143
}
144144

145145
public static function renderPostProcessedSitePaths(): void {
@@ -355,7 +355,7 @@ public static function renderCachesPage(): void {
355355
}
356356

357357
$view['DetectedFilesTotal'] = DetectedFiles::getTotal();
358-
$view['crawlCacheTotalURLs'] = CrawlCache::getTotal();
358+
$view['crawledFilesTotal'] = CrawledFiles::getTotal();
359359
$view['deployCacheTotalPaths'] = DeployCache::getTotal();
360360
$view['uploads_path'] = SiteInfo::getPath( 'uploads' );
361361
$view['nonce_action'] = 'wp2static-caches-page';

src/WordPressAdmin.php

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,7 @@ public static function registerHooks( string $bootstrap_file ): void {
5757

5858
add_filter(
5959
Controller::getHookName( 'list_redirects' ),
60-
[ CrawlCache::class, 'wp2static_list_redirects' ]
60+
[ CrawledFiles::class, 'wp2static_list_redirects' ]
6161
);
6262

6363
add_filter(
@@ -185,15 +185,15 @@ public static function registerHooks( string $bootstrap_file ): void {
185185
);
186186

187187
add_action(
188-
'admin_post_wp2static_crawl_cache_delete',
189-
[ Controller::class, 'wp2staticCrawlCacheDelete' ],
188+
'admin_post_wp2static_crawled_files_delete',
189+
[ Controller::class, 'wp2staticCrawledFilesDelete' ],
190190
10,
191191
0
192192
);
193193

194194
add_action(
195-
'admin_post_wp2static_crawl_cache_show',
196-
[ Controller::class, 'wp2staticCrawlCacheShow' ],
195+
'admin_post_wp2static_crawled_files_show',
196+
[ Controller::class, 'wp2staticCrawledFilesShow' ],
197197
10,
198198
0
199199
);

uninstall.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111

1212
$tables_to_drop = [
1313
'core_options',
14-
'crawl_cache',
14+
'crawled_files',
1515
'deploy_cache',
1616
'detected_files',
1717
'jobs',

0 commit comments

Comments
 (0)