Close file if it's already open before clear

This commit is contained in:
Mike Jolley 2016-04-19 16:31:36 +01:00
parent 9f5967cb87
commit f47a1de108
1 changed files with 6 additions and 1 deletions

View File

@ -74,7 +74,7 @@ class WC_Logger {
if ( $this->open( $handle ) && is_resource( $this->_handles[ $handle ] ) ) {
$time = date_i18n( 'm-d-Y @ H:i:s -' ); // Grab Time
$result = fwrite( $this->_handles[ $handle ], $time . " " . $message . "\n" );
$result = @fwrite( $this->_handles[ $handle ], $time . " " . $message . "\n" );
}
do_action( 'woocommerce_log_add', $handle, $message );
@ -92,6 +92,11 @@ class WC_Logger {
public function clear( $handle ) {
$result = false;
// Close the file if it's already open.
if ( is_resource( $this->_handles[ $handle ] ) ) {
@fclose( $handle );
}
/**
* $this->open( $handle, 'w' ) == Open the file for writing only. Place the file pointer at the beginning of the file,
* and truncate the file to zero length.