mirror of
				https://github.com/yiisoft/yii2.git
				synced 2025-10-31 10:39:59 +08:00 
			
		
		
		
	Merge pull request #20294 from xcopy/xcopy-patch-1
Fix "Trying to access array offset on null" warning
This commit is contained in:
		| @ -21,6 +21,7 @@ Yii Framework 2 Change Log | ||||
| - Enh #20279: Add to the `\yii\web\Request` `csrfTokenSafeMethods` property to configure a custom safe HTTP methods list (olegbaturin) | ||||
| - Bug #20140: Fix compatibility with PHP 8.4: calling `session_set_save_handler()` (Izumi-kun) | ||||
| - New #20185: Add `BackedEnum` support to `AttributeTypecastBehavior` (briedis) | ||||
| - Bug #17365: Fix "Trying to access array offset on null" warning (xcopy) | ||||
|  | ||||
| 2.0.51 July 18, 2024 | ||||
| -------------------- | ||||
|  | ||||
| @ -158,8 +158,14 @@ class FileCache extends Cache | ||||
|             return @touch($cacheFile, $duration + time()); | ||||
|         } | ||||
|  | ||||
|         $error = error_get_last(); | ||||
|         Yii::warning("Unable to write cache file '{$cacheFile}': {$error['message']}", __METHOD__); | ||||
|         $message = "Unable to write cache file '{$cacheFile}'"; | ||||
|  | ||||
|         if ($error = error_get_last()) { | ||||
|             $message .= ": {$error['message']}"; | ||||
|         } | ||||
|  | ||||
|         Yii::warning($message, __METHOD__); | ||||
|  | ||||
|         return false; | ||||
|     } | ||||
|  | ||||
| @ -265,21 +271,27 @@ class FileCache extends Cache | ||||
|                     continue; | ||||
|                 } | ||||
|                 $fullPath = $path . DIRECTORY_SEPARATOR . $file; | ||||
|                 $message = null; | ||||
|                 if (is_dir($fullPath)) { | ||||
|                     $this->gcRecursive($fullPath, $expiredOnly); | ||||
|                     if (!$expiredOnly) { | ||||
|                         if (!@rmdir($fullPath)) { | ||||
|                             $error = error_get_last(); | ||||
|                             Yii::warning("Unable to remove directory '{$fullPath}': {$error['message']}", __METHOD__); | ||||
|                             $message = "Unable to remove directory '$fullPath'"; | ||||
|                             if ($error = error_get_last()) { | ||||
|                                 $message .= ": {$error['message']}"; | ||||
|                             } | ||||
|                         } | ||||
|                     } | ||||
|                 } elseif (!$expiredOnly || $expiredOnly && @filemtime($fullPath) < time()) { | ||||
|                     if (!@unlink($fullPath)) { | ||||
|                         $error = error_get_last(); | ||||
|                         Yii::warning("Unable to remove file '{$fullPath}': {$error['message']}", __METHOD__); | ||||
|                         $message = "Unable to remove file '$fullPath'"; | ||||
|                         if ($error = error_get_last()) { | ||||
|                             $message .= ": {$error['message']}"; | ||||
|                         } | ||||
|                     } | ||||
|                 } | ||||
|                 $message and Yii::warning($message, __METHOD__); | ||||
|             } | ||||
|             closedir($handle); | ||||
|         } | ||||
|     } | ||||
|  | ||||
| @ -131,8 +131,11 @@ class FileTarget extends Target | ||||
|         } | ||||
|         $writeResult = @fwrite($fp, $text); | ||||
|         if ($writeResult === false) { | ||||
|             $error = error_get_last(); | ||||
|             throw new LogRuntimeException("Unable to export log through file ({$this->logFile})!: {$error['message']}"); | ||||
|             $message = "Unable to export log through file ($this->logFile)!"; | ||||
|             if ($error = error_get_last()) { | ||||
|                 $message .= ": {$error['message']}"; | ||||
|             } | ||||
|             throw new LogRuntimeException($message); | ||||
|         } | ||||
|         $textSize = strlen($text); | ||||
|         if ($writeResult < $textSize) { | ||||
|  | ||||
		Reference in New Issue
	
	Block a user
	 Stefano D. Mtangoo
					Stefano D. Mtangoo