Merge pull request #14553 from woocommerce/fix/14544

Check if is a resource before try set log rotate
This commit is contained in:
Claudio Sanches 2017-04-20 13:47:56 -03:00 committed by GitHub
commit 836b3a3162
1 changed files with 4 additions and 3 deletions

View File

@ -148,7 +148,8 @@ class WC_Log_Handler_File extends WC_Log_Handler {
}
}
if ( $this->handles[ $handle ] = @fopen( $file, $mode ) ) {
if ( $resource = @fopen( $file, $mode ) ) {
$this->handles[ $handle ] = $resource;
return true;
}
}
@ -163,7 +164,7 @@ class WC_Log_Handler_File extends WC_Log_Handler {
* @return bool True if $handle is open.
*/
protected function is_open( $handle ) {
return array_key_exists( $handle, $this->handles );
return array_key_exists( $handle, $this->handles ) && is_resource( $this->handles[ $handle ] );
}
/**
@ -175,7 +176,7 @@ class WC_Log_Handler_File extends WC_Log_Handler {
protected function close( $handle ) {
$result = false;
if ( $this->is_open( $handle ) && is_resource( $this->handles[ $handle ] ) ) {
if ( $this->is_open( $handle ) ) {
$result = fclose( $this->handles[ $handle ] );
unset( $this->handles[ $handle ] );
}