WC_Log_Handler_File::increment_log_infix
Increment a log file suffix.
Method of the class: WC_Log_Handler_File{}
No Hooks.
Returns
true|false. True if increment was successful, otherwise false.
Usage
// protected - for code of main (parent) or child class $result = $this->increment_log_infix( $handle, $number );
- $handle(string) (required)
- Log handle.
- $number(null|int)
- Log suffix number to be incremented.
Default:null
WC_Log_Handler_File::increment_log_infix() WC Log Handler File::increment log infix code WC 10.8.1
protected function increment_log_infix( $handle, $number = null ) {
if ( null === $number ) {
$suffix = '';
$next_suffix = '.0';
} else {
$suffix = '.' . $number;
$next_suffix = '.' . ( $number + 1 );
}
$rename_from = self::get_log_file_path( "{$handle}{$suffix}" );
$rename_to = self::get_log_file_path( "{$handle}{$next_suffix}" );
if ( $this->is_open( $rename_from ) ) {
$this->close( $rename_from );
}
if ( is_writable( $rename_from ) ) { // phpcs:ignore WordPress.VIP.FileSystemWritesDisallow.file_ops_is_writable
return rename( $rename_from, $rename_to ); // phpcs:ignore WordPress.VIP.FileSystemWritesDisallow.file_ops_rename
} else {
return false;
}
}