auto-patch 638-dev-dev01-2024-05-14T20_44_36
This commit is contained in:
@@ -6,6 +6,7 @@
|
||||
*/
|
||||
|
||||
use Automattic\Jetpack\Constants;
|
||||
use Automattic\WooCommerce\Utilities\LoggingUtil;
|
||||
|
||||
if ( ! defined( 'ABSPATH' ) ) {
|
||||
exit; // Exit if accessed directly.
|
||||
@@ -251,13 +252,14 @@ class WC_Log_Handler_File extends WC_Log_Handler {
|
||||
* @return bool
|
||||
*/
|
||||
public function remove( $handle ) {
|
||||
$removed = false;
|
||||
$logs = $this->get_log_files();
|
||||
$handle = sanitize_title( $handle );
|
||||
$removed = false;
|
||||
$logs = $this->get_log_files();
|
||||
$log_directory = LoggingUtil::get_log_directory();
|
||||
$handle = sanitize_title( $handle );
|
||||
|
||||
if ( isset( $logs[ $handle ] ) && $logs[ $handle ] ) {
|
||||
$file = realpath( trailingslashit( WC_LOG_DIR ) . $logs[ $handle ] );
|
||||
if ( 0 === stripos( $file, realpath( trailingslashit( WC_LOG_DIR ) ) ) && is_file( $file ) && is_writable( $file ) ) { // phpcs:ignore WordPress.VIP.FileSystemWritesDisallow.file_ops_is_writable
|
||||
$file = realpath( trailingslashit( $log_directory ) . $logs[ $handle ] );
|
||||
if ( 0 === stripos( $file, realpath( trailingslashit( $log_directory ) ) ) && is_file( $file ) && is_writable( $file ) ) { // phpcs:ignore WordPress.VIP.FileSystemWritesDisallow.file_ops_is_writable
|
||||
$this->close( $file ); // Close first to be certain no processes keep it alive after it is unlinked.
|
||||
$removed = unlink( $file ); // phpcs:ignore WordPress.VIP.FileSystemWritesDisallow.file_ops_unlink
|
||||
}
|
||||
@@ -349,8 +351,10 @@ class WC_Log_Handler_File extends WC_Log_Handler {
|
||||
* @return bool|string The log file path or false if path cannot be determined.
|
||||
*/
|
||||
public static function get_log_file_path( $handle ) {
|
||||
$log_directory = LoggingUtil::get_log_directory();
|
||||
|
||||
if ( function_exists( 'wp_hash' ) ) {
|
||||
return trailingslashit( WC_LOG_DIR ) . self::get_log_file_name( $handle );
|
||||
return trailingslashit( $log_directory ) . self::get_log_file_name( $handle );
|
||||
} else {
|
||||
wc_doing_it_wrong( __METHOD__, __( 'This method should not be called before plugins_loaded.', 'woocommerce' ), '3.0' );
|
||||
return false;
|
||||
@@ -410,13 +414,14 @@ class WC_Log_Handler_File extends WC_Log_Handler {
|
||||
return;
|
||||
}
|
||||
|
||||
$log_files = self::get_log_files();
|
||||
$log_files = self::get_log_files();
|
||||
$log_directory = LoggingUtil::get_log_directory();
|
||||
|
||||
foreach ( $log_files as $log_file ) {
|
||||
$last_modified = filemtime( trailingslashit( WC_LOG_DIR ) . $log_file );
|
||||
$last_modified = filemtime( trailingslashit( $log_directory ) . $log_file );
|
||||
|
||||
if ( $last_modified < $timestamp ) {
|
||||
@unlink( trailingslashit( WC_LOG_DIR ) . $log_file ); // @codingStandardsIgnoreLine.
|
||||
@unlink( trailingslashit( $log_directory ) . $log_file ); // @codingStandardsIgnoreLine.
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -428,7 +433,9 @@ class WC_Log_Handler_File extends WC_Log_Handler {
|
||||
* @return array
|
||||
*/
|
||||
public static function get_log_files() {
|
||||
$files = @scandir( WC_LOG_DIR ); // @codingStandardsIgnoreLine.
|
||||
$log_directory = LoggingUtil::get_log_directory();
|
||||
|
||||
$files = @scandir( $log_directory ); // @codingStandardsIgnoreLine.
|
||||
$result = array();
|
||||
|
||||
if ( ! empty( $files ) ) {
|
||||
|
||||
Reference in New Issue
Block a user