Automattic\WooCommerce\Internal\TransientFiles
TransientFilesEngine::file_has_expired()
Verify if a file has expired, given its full physical file path.
Given a file name returned by 'create_transient_file', the procedure to check if it has expired is as follows:
- Use 'get_transient_file_path' to obtain the full file path.
- If the above returns null, the file doesn't exist anymore (likely it expired and was deleted by the cleanup process).
- Otherwise, use 'file_has_expired' passing the obtained full file path.
Method of the class: TransientFilesEngine{}
No Hooks.
Return
true|false
. True if the file has expired, false otherwise.
Usage
$TransientFilesEngine = new TransientFilesEngine(); $TransientFilesEngine->file_has_expired( $file_path ): bool;
- $file_path(string) (required)
- The full file path to check.
TransientFilesEngine::file_has_expired() TransientFilesEngine::file has expired code WC 9.3.3
public function file_has_expired( string $file_path ): bool { $dirname = dirname( $file_path ); $expiration_date = basename( $dirname ); $expiration_date_object = new DateTime( $expiration_date, TimeUtil::get_utc_date_time_zone() ); $today_date_object = new DateTime( $this->legacy_proxy->call_function( 'gmdate', 'Y-m-d' ), TimeUtil::get_utc_date_time_zone() ); return $expiration_date_object < $today_date_object; }