1771584599.M272322P2019549.r24,S=195624,W=198228ŒžXΤ‘1771585033.M32303P2022441.r24,S=497321,W=504108ž Τ‘1771585148.M442300P2023109.r24,S=667070,W=675880ŽžπΤ‘1771585346.M368348P2024433.r24,S=332619,W=337142ž@Τ‘1771586648.M801191P2032505.r24,S=3101,W=3160‘žˆΤ‘1771586714.M696554P2032878.r24,S=185567,W=189018”žΨΤ‘1771603288.M766082P2140168.r24,S=84201,W=85837›ž Τ‘1771617638.M47916P2222665.r24,S=43355,W=44113̞hΤ‘1771832676.M650290P137895.r24,S=17370,W=17691՞°Τ‘1771841132.M207069P1375777.r24,S=31536,W=32167מψΤ‘1771845610.M880350P1568666.r24,S=57850,W=58826ΰž@Τ‘1771856782.M453640P1682814.r24,S=27889,W=28412ιžˆΤ‘1771863455.M757522P1736223.r24,S=336961,W=341510ωžΨΤ‘1771906261.M642535P2121851.r24,S=44522,W=45249Ÿ Τ‘1771918740.M306720P2854594.r24,S=72830,W=73824ŸhΤ‘1771921178.M963882P3275126.r24,S=67312,W=68463Ÿ°Τ‘1771923374.M233866P3634806.r24,S=28835,W=29326ŸψΤ‘1771923933.M349763P3714116.r24,S=68022,W=69288 Ÿ@Τ‘1771925212.M329855P3854893.r24,S=55087,W=56031 ŸˆΤ‘1771925641.M386395P3913727.r24,S=125747,W=127430 ŸΨΤ‘1771926469.M7704P4051038.r24,S=70992,W=72220Ÿ Τ‘1771929226.M276144P145708.r24,S=117167,W=119286ŸhΤ‘1771929505.M985169P147827.r24,S=85640,W=87124Ÿ°Τ‘1771929540.M809758P147990.r24,S=27879,W=28403ŸψΤ‘1771929938.M725080P150907.r24,S=2941,W=30003Ÿ@Τ‘1772005782.M588192P1904698.r24,S=42299,W=42880GŸˆΤ‘1772036484.M847854P3021298.r24,S=71283,W=72622XŸΠΤ‘1772051702.M157408P3108214.r24,S=35700,W=36334YŸΤ‘1772051752.M958496P3108481.r24,S=29281,W=29773ZŸ`Τ‘1772052444.M869525P3112082.r24,S=18637,W=18998]Ÿ¨Τ‘1772054701.M287257P3130200.r24,S=12112,W=12365oŸπΤ‘1772095765.M19481P1128789.r24,S=11533,W=11707pŸ8Τ‘1772096377.M604898P1228225.r24,S=46300,W=47143tŸ€Τ‘1772103898.M620087P1575729.r24,S=24777,W=25127ŸΘΤ‘1772114256.M475223P1657962.r24,S=2898,W=2953€ŸΤ‘1772114556.M778082P1660737.r24,S=13425,W=13702‚ŸXΤ‘1772115035.M590085P1664193.r24,S=3563978,W=3612863ƒŸ¨Τ‘1772115055.M769874P1664342.r24,S=2914,W=2972†ŸπΤ‘1772118346.M351617P1692359.r24,S=146209,W=149150˜Ÿ@Τ‘1772184230.M633415P4004200.r24,S=2903,W=2960™ŸˆΤ‘1772184993.M860153P4095138.r24,S=135950,W=138053šŸΨΤ‘1772186595.M735675P95372.r24,S=101455,W=103216›Ÿ Τ‘1772187883.M377527P143595.r24,S=3004,W=3064ŸŸhΤ‘1772192398.M871219P180002.r24,S=62493,W=63516£Ÿ°Τ‘1772199588.M605110P235113.r24,S=37987,W=38598ͺŸψΤ‘1772212609.M252939P320420.r24,S=87262,W=88705ן@Τ‘1772397050.M612880P1424663.r24,S=36753,W=37496ηŸˆΤ‘1772438289.M933331P2589687.r24,S=436329,W=442507τŸΨΤ‘1772447444.M916586P3848894.r24,S=22801,W=23264φŸ Τ‘1772449242.M309080P3932206.r24,S=2924,W=2982χŸhΤ‘1772449294.M940413P3932671.r24,S=4685,W=4775ψŸ°Τ‘1772449500.M473307P3934202.r24,S=19881,W=20302ωŸψΤ‘1772449649.M277751P3935190.r24,S=48132,W=48973ϋŸ@Τ‘1772450446.M121P3941335.r24,S=2859,W=2914όŸˆΤ‘1772450684.M966369P3943291.r24,S=16230,W=16591ύŸΠΤ‘1772450847.M583630P3945115.r24,S=21782,W=22074 '/path-to/home1/wp-content/cache/wp-rocket/example.com/home1/deleted-page', * '/path-to/home1/wp-content/cache/wp-rocket/example.com/home1/very-dead-page', * ], * ], * [ * 'home_url' => 'http://example.com/home1', * 'home_path' => '/path-to/home1/wp-content/cache/wp-rocket/example.com-Greg-594d03f6ae698691165999/home1', * 'logged_in' => true, * 'files' => [ * '/path-to/home1/wp-content/cache/wp-rocket/example.com-Greg-594d03f6ae698691165999/home1/how-to-prank-your-coworkers', * '/path-to/home1/wp-content/cache/wp-rocket/example.com-Greg-594d03f6ae698691165999/home1/best-source-of-gifs', * ], * ], * ] * @param array $args { * @type string $url The home url. * @type int $lifespan Files lifespan in seconds. * @type int $file_age_limit Timestamp of the maximum age files must have. This is basically `time() - $lifespan`. * } */ do_action( 'rocket_after_automatic_cache_purge_dir', $url_deleted, $args ); } $args = [ 'lifespan' => $lifespan, 'file_age_limit' => $file_age_limit, ]; /** * Fires after cache directories are purged. * * @since 3.4 * * @param array $deleted { * An array of arrays, described like: { * @type string $home_url The home URL. * @type string $home_path Path to home. * @type bool $logged_in True if the home path corresponds to a logged in user’s folder. * @type array $files A list of paths of files that have been deleted. * } * Ex: * [ * [ * 'home_url' => 'http://example.com/home1', * 'home_path' => '/path-to/home1/wp-content/cache/wp-rocket/example.com/home1', * 'logged_in' => false, * 'files' => [ * '/path-to/home1/wp-content/cache/wp-rocket/example.com/home1/deleted-page', * '/path-to/home1/wp-content/cache/wp-rocket/example.com/home1/very-dead-page', * ], * ], * [ * 'home_url' => 'http://example.com/home1', * 'home_path' => '/path-to/home1/wp-content/cache/wp-rocket/example.com-Greg-594d03f6ae698691165999/home1', * 'logged_in' => true, * 'files' => [ * '/path-to/home1/wp-content/cache/wp-rocket/example.com-Greg-594d03f6ae698691165999/home1/how-to-prank-your-coworkers', * '/path-to/home1/wp-content/cache/wp-rocket/example.com-Greg-594d03f6ae698691165999/home1/best-source-of-gifs', * ], * ], * [ * 'home_url' => 'http://example.com/home4', * 'home_path' => '/path-to/home4/wp-content/cache/wp-rocket/example.com-Greg-71edg8d6af865569979569/home4', * 'logged_in' => true, * 'files' => [ * '/path-to/home4/wp-content/cache/wp-rocket/example.com-Greg-71edg8d6af865569979569/home4/easter-eggs-in-code-your-best-opportunities', * ], * ], * ] * } * @param array $args { * @type int $lifespan Files lifespan in seconds. * @type int $file_age_limit Timestamp of the maximum age files must have. This is basically `time() - $lifespan`. * } */ do_action( 'rocket_after_automatic_cache_purge', $deleted, $args ); } /** ----------------------------------------------------------------------------------------- */ /** TOOLS =================================================================================== */ /** ----------------------------------------------------------------------------------------- */ /** * Get all cache files for the provided URL * * @since 3.4 * * @param array $file An array of the parsed URL parts. * @return array|\CallbackFilterIterator */ private function get_cache_files_in_dir( $file ) { // Grab cache folders. $host_pattern = '@^' . preg_quote( $file['host'], '@' ) . '@'; $sub_dir = rtrim( $file['path'], '/' ); try { $iterator = new \DirectoryIterator( $this->cache_path ); } catch ( \Exception $e ) { return []; } return new \CallbackFilterIterator( $iterator, function ( $current ) use ( $host_pattern, $sub_dir ) { if ( ! $current->isDir() || $current->isDot() ) { // We look for folders only, and don't want '.' nor '..'. return false; } if ( ! preg_match( $host_pattern, $current->getFilename() ) ) { // Not the right host. return false; } if ( '' !== $sub_dir && ! $this->filesystem->exists( $current->getPathname() . $sub_dir ) ) { // Not the right path. return false; } return true; } ); } /** * Purge a folder from old files. * * @since 3.4 * * @param string $dir_path Path to the folder to purge. * @param int $file_age_limit Timestamp of the maximum age files must have. * @return array A list of files that have been deleted. */ private function purge_dir( $dir_path, $file_age_limit ) { $deleted = []; try { $iterator = new \DirectoryIterator( $dir_path ); } catch ( \Exception $e ) { return []; } foreach ( $iterator as $item ) { if ( $item->isDot() ) { continue; } if ( $item->isDir() ) { /** * A folder, let’s see what’s in there. * Maybe there’s a dinosaur fossil or a hidden treasure. */ $dir_deleted = $this->purge_dir( $item->getPathname(), $file_age_limit ); $deleted = array_merge( $deleted, $dir_deleted ); } elseif ( $item->isFile() && $item->getMTime() < $file_age_limit ) { $file_path = $item->getPathname(); /** * The file is older than our limit. * This will also delete the file if `$item->getMTime()` fails. */ if ( ! $this->filesystem->delete( $file_path ) ) { continue; } /** * A page can have multiple cache files: * index(-mobile)(-https)(-dynamic-cookie-key){0,*}.html(_gzip). */ $dir_path = dirname( $file_path ); if ( ! in_array( $dir_path, $deleted, true ) ) { $deleted[] = $dir_path; } } } if ( $this->is_dir_empty( $dir_path ) ) { // If the folder is empty, remove it. $this->filesystem->delete( $dir_path ); } return $deleted; } /** * Tell if a folder is empty. * * @since 3.4 * * @param string $dir_path Path to the folder to purge. * @return bool True if empty. False if it contains files. */ private function is_dir_empty( $dir_path ) { try { $iterator = new \DirectoryIterator( $dir_path ); } catch ( \Exception $e ) { return true; } foreach ( $iterator as $item ) { if ( $item->isDot() ) { continue; } return false; } return true; } /** * Update lifespan option to convert old minutes to hours. * * @since 3.8 * * @param int $old_lifespan Old value in minutes. * @param string $old_lifespan_unit Old value of unit. * * @return void */ public function update_lifespan_value( $old_lifespan, $old_lifespan_unit ) { if ( 'MINUTE_IN_SECONDS' !== $old_lifespan_unit ) { return; } $options = get_option( 'wp_rocket_settings', [] ); if ( $old_lifespan > 0 && $old_lifespan < 60 ) { $old_lifespan = 60; } $options['purge_cron_unit'] = 'HOUR_IN_SECONDS'; $options['purge_cron_interval'] = round( $old_lifespan / 60 ); update_option( 'wp_rocket_settings', $options ); } }