@@ -37,34 +37,36 @@ public function handle(): int
3737 RawPage::query ()
3838 ->select (['id ' , 'html ' ])
3939 ->orderBy ('id ' )
40- ->chunkById ($ chunk , function ($ chunkRows ) use (&$ processed , &$ skipped , $ dryRun , $ force ) {
41- foreach ($ chunkRows as $ rp ) {
42- $ raw = $ rp ->getAttributes ()['html ' ] ?? '' ;
40+ ->chunkById ($ chunk , function ($ chunkRows ) use (&$ processed , &$ skipped , $ dryRun , $ force ): void {
41+ foreach ($ chunkRows as $ chunkRow ) {
42+ $ raw = $ chunkRow ->getAttributes ()['html ' ] ?? '' ;
4343 // Skip already gzip data unless --force is specified
4444 if (! $ force && is_string ($ raw ) && HtmlCompression::isGzip ($ raw )) {
4545 $ skipped ++;
46+
4647 continue ;
4748 }
4849
4950 if ($ dryRun ) {
5051 $ processed ++;
52+
5153 continue ;
5254 }
5355
5456 // Reassign to trigger cast compression
5557 // For already compressed data with --force, decode first then re-encode
5658 if ($ force && is_string ($ raw ) && HtmlCompression::isGzip ($ raw )) {
57- $ rp ->html = HtmlCompression::decode ($ raw );
59+ $ chunkRow ->html = HtmlCompression::decode ($ raw );
5860 } else {
59- $ rp ->html = $ rp ->html ;
6061 }
61- $ rp ->saveQuietly ();
62+
63+ $ chunkRow ->saveQuietly ();
6264 $ processed ++;
6365 }
6466 });
6567
6668 $ logger ->info ('Finish backfill: compress raw_pages.html ' , ['processed ' => $ processed , 'skipped ' => $ skipped , 'dry ' => $ dryRun , 'force ' => $ force ]);
67- $ this ->info (" processed= { $ processed } skipped= { $ skipped } dryRun= " . ($ dryRun ? 'yes ' : 'no ' ) . ' force= ' . ($ force ? 'yes ' : 'no ' ));
69+ $ this ->info (sprintf ( ' processed=%d skipped=%d dryRun= ' , $ processed , $ skipped ). ($ dryRun ? 'yes ' : 'no ' ). ' force= ' . ($ force ? 'yes ' : 'no ' ));
6870
6971 return self ::SUCCESS ;
7072 } catch (\Throwable $ throwable ) {
0 commit comments