mirror of
				https://github.com/yiisoft/yii2.git
				synced 2025-10-31 18:47:33 +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) | - 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) | - Bug #20140: Fix compatibility with PHP 8.4: calling `session_set_save_handler()` (Izumi-kun) | ||||||
| - New #20185: Add `BackedEnum` support to `AttributeTypecastBehavior` (briedis) | - 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 | 2.0.51 July 18, 2024 | ||||||
| -------------------- | -------------------- | ||||||
|  | |||||||
| @ -158,8 +158,14 @@ class FileCache extends Cache | |||||||
|             return @touch($cacheFile, $duration + time()); |             return @touch($cacheFile, $duration + time()); | ||||||
|         } |         } | ||||||
|  |  | ||||||
|         $error = error_get_last(); |         $message = "Unable to write cache file '{$cacheFile}'"; | ||||||
|         Yii::warning("Unable to write cache file '{$cacheFile}': {$error['message']}", __METHOD__); |  | ||||||
|  |         if ($error = error_get_last()) { | ||||||
|  |             $message .= ": {$error['message']}"; | ||||||
|  |         } | ||||||
|  |  | ||||||
|  |         Yii::warning($message, __METHOD__); | ||||||
|  |  | ||||||
|         return false; |         return false; | ||||||
|     } |     } | ||||||
|  |  | ||||||
| @ -265,21 +271,27 @@ 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__); |                             if ($error = error_get_last()) { | ||||||
|  |                                 $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__); |                         if ($error = error_get_last()) { | ||||||
|  |                             $message .= ": {$error['message']}"; | ||||||
|                         } |                         } | ||||||
|                     } |                     } | ||||||
|                 } |                 } | ||||||
|  |                 $message and Yii::warning($message, __METHOD__); | ||||||
|  |             } | ||||||
|             closedir($handle); |             closedir($handle); | ||||||
|         } |         } | ||||||
|     } |     } | ||||||
|  | |||||||
| @ -131,8 +131,11 @@ 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']}"); |             if ($error = error_get_last()) { | ||||||
|  |                 $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
	 Stefano D. Mtangoo
					Stefano D. Mtangoo