mirror of
				https://github.com/yiisoft/yii2.git
				synced 2025-11-04 14:46:19 +08:00 
			
		
		
		
	Append additional (error) message only if error_get_last() returns non-null value #20294
				
					
				
			This commit is contained in:
		@ -159,10 +159,7 @@ class FileCache extends Cache
 | 
				
			|||||||
        }
 | 
					        }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        $message = "Unable to write cache file '{$cacheFile}'";
 | 
					        $message = "Unable to write cache file '{$cacheFile}'";
 | 
				
			||||||
 | 
					        ($error = error_get_last()) and $message .= ": {$error['message']}";
 | 
				
			||||||
        if ($error = error_get_last()) {
 | 
					 | 
				
			||||||
            $message .= ": {$error['message']}";
 | 
					 | 
				
			||||||
        }
 | 
					 | 
				
			||||||
 | 
					
 | 
				
			||||||
        Yii::warning($message, __METHOD__);
 | 
					        Yii::warning($message, __METHOD__);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
@ -271,20 +268,22 @@ class FileCache extends Cache
 | 
				
			|||||||
                    continue;
 | 
					                    continue;
 | 
				
			||||||
                }
 | 
					                }
 | 
				
			||||||
                $fullPath = $path . DIRECTORY_SEPARATOR . $file;
 | 
					                $fullPath = $path . DIRECTORY_SEPARATOR . $file;
 | 
				
			||||||
 | 
					                $message = null;
 | 
				
			||||||
                if (is_dir($fullPath)) {
 | 
					                if (is_dir($fullPath)) {
 | 
				
			||||||
                    $this->gcRecursive($fullPath, $expiredOnly);
 | 
					                    $this->gcRecursive($fullPath, $expiredOnly);
 | 
				
			||||||
                    if (!$expiredOnly) {
 | 
					                    if (!$expiredOnly) {
 | 
				
			||||||
                        if (!@rmdir($fullPath)) {
 | 
					                        if (!@rmdir($fullPath)) {
 | 
				
			||||||
                            $error = error_get_last();
 | 
					                            $message = "Unable to remove directory '$fullPath'";
 | 
				
			||||||
                            Yii::warning("Unable to remove directory '{$fullPath}': {$error['message']}", __METHOD__);
 | 
					                            ($error = error_get_last()) and $message .= ": {$error['message']}";
 | 
				
			||||||
                        }
 | 
					                        }
 | 
				
			||||||
                    }
 | 
					                    }
 | 
				
			||||||
                } elseif (!$expiredOnly || $expiredOnly && @filemtime($fullPath) < time()) {
 | 
					                } elseif (!$expiredOnly || $expiredOnly && @filemtime($fullPath) < time()) {
 | 
				
			||||||
                    if (!@unlink($fullPath)) {
 | 
					                    if (!@unlink($fullPath)) {
 | 
				
			||||||
                        $error = error_get_last();
 | 
					                        $message = "Unable to remove file '$fullPath'";
 | 
				
			||||||
                        Yii::warning("Unable to remove file '{$fullPath}': {$error['message']}", __METHOD__);
 | 
					                        ($error = error_get_last()) and $message .= ": {$error['message']}";
 | 
				
			||||||
                    }
 | 
					                    }
 | 
				
			||||||
                }
 | 
					                }
 | 
				
			||||||
 | 
					                $message and Yii::warning($message, __METHOD__);
 | 
				
			||||||
            }
 | 
					            }
 | 
				
			||||||
            closedir($handle);
 | 
					            closedir($handle);
 | 
				
			||||||
        }
 | 
					        }
 | 
				
			||||||
 | 
				
			|||||||
@ -131,8 +131,9 @@ class FileTarget extends Target
 | 
				
			|||||||
        }
 | 
					        }
 | 
				
			||||||
        $writeResult = @fwrite($fp, $text);
 | 
					        $writeResult = @fwrite($fp, $text);
 | 
				
			||||||
        if ($writeResult === false) {
 | 
					        if ($writeResult === false) {
 | 
				
			||||||
            $error = error_get_last();
 | 
					            $message = "Unable to export log through file ($this->logFile)!";
 | 
				
			||||||
            throw new LogRuntimeException("Unable to export log through file ({$this->logFile})!: {$error['message']}");
 | 
					            ($error = error_get_last()) and $message .= ": {$error['message']}";
 | 
				
			||||||
 | 
					            throw new LogRuntimeException($message);
 | 
				
			||||||
        }
 | 
					        }
 | 
				
			||||||
        $textSize = strlen($text);
 | 
					        $textSize = strlen($text);
 | 
				
			||||||
        if ($writeResult < $textSize) {
 | 
					        if ($writeResult < $textSize) {
 | 
				
			||||||
 | 
				
			|||||||
		Reference in New Issue
	
	Block a user