Use \SensitiveParameterValue as the replacement value in exception handling
authorTim Düsterhus <duesterhus@woltlab.com>
Fri, 24 Jun 2022 09:02:04 +0000 (11:02 +0200)
committerTim Düsterhus <duesterhus@woltlab.com>
Fri, 24 Jun 2022 09:04:37 +0000 (11:04 +0200)
Use the standard PHP 8.2 replacement value, instead of the `[redacted]` string
for consistency. This works as expected, because `SensitiveParameterValue` is
polyfilled.

wcfsetup/install/files/lib/core.functions.php

index ed81b6d393a23a65f9f44fb4e9239d01390ee502..8190bd7dd0bd1ffbbed9aae57b4e1624c552bd00 100644 (file)
@@ -736,8 +736,12 @@ EXPLANATION;
                                                        $isSensitive = true;
                                                }
 
-                                               if ($isSensitive && isset($item['args'][$i])) {
-                                                       $item['args'][$i] = '[redacted]';
+                                               if (
+                                                       $isSensitive
+                                                       && isset($item['args'][$i])
+                                                       && !($item['args'][$i] instanceof \SensitiveParameterValue)
+                                               ) {
+                                                       $item['args'][$i] = new \SensitiveParameterValue($item['args'][$i]);
                                                }
                                                $i++;
                                        }
@@ -748,8 +752,12 @@ EXPLANATION;
                                                || $item['class'] === 'PDO'
                                        ) {
                                                if ($item['function'] === '__construct') {
-                                                       $item['args'] = array_map(function () {
-                                                               return '[redacted]';
+                                                       $item['args'] = array_map(function ($value) {
+                                                               if (!($value instanceof \SensitiveParameterValue)) {
+                                                                       $value = new \SensitiveParameterValue($value);
+                                                               }
+
+                                                               return $value;
                                                        }, $item['args']);
                                                }
                                        }