Automattic\WooCommerce\Internal\Admin\Logging\FileV2
File::generate_file_id
Generate a public ID for a log file based on its properties.
The file ID is the basename of the file without the hash part. It allows us to identify a file without revealing its full name in the filesystem, so that it's difficult to access the file directly with an HTTP request.
Method of the class: File{}
No Hooks.
Returns
String.
Usage
$result = File::generate_file_id( $source, ?int $rotation, $created ): string;
- $source(string) (required)
- The source of the log entries contained in the file.
- ?int $rotation
- .
Default: null - $created(int)
- The date the file was created, as a Unix timestamp.
File::generate_file_id() File::generate file id code WC 10.3.3
public static function generate_file_id( string $source, ?int $rotation = null, int $created = 0 ): string {
$file_id = static::sanitize_source( $source );
if ( ! is_null( $rotation ) ) {
$file_id .= '.' . $rotation;
}
if ( $created > 0 ) {
$file_id .= '-' . gmdate( 'Y-m-d', $created );
}
return $file_id;
}