wp/wp-includes/sodium_compat/src/Core/Util.php
changeset 18 be944660c56a
parent 9 177826044cd9
child 19 3d72ae0968f4
--- a/wp/wp-includes/sodium_compat/src/Core/Util.php	Tue Dec 15 15:52:01 2020 +0100
+++ b/wp/wp-includes/sodium_compat/src/Core/Util.php	Wed Sep 21 18:19:35 2022 +0200
@@ -287,6 +287,22 @@
     }
 
     /**
+     * Catch hash_update() failures and throw instead of silently proceding
+     *
+     * @param HashContext|resource &$hs
+     * @param string $data
+     * @return void
+     * @throws SodiumException
+     * @psalm-suppress PossiblyInvalidArgument
+     */
+    protected static function hash_update(&$hs, $data)
+    {
+        if (!hash_update($hs, $data)) {
+            throw new SodiumException('hash_update() failed');
+        }
+    }
+
+    /**
      * Convert a hexadecimal string into a binary string without cache-timing
      * leaks
      *
@@ -903,6 +919,9 @@
      *
      * @internal You should not use this directly from another application
      *
+     * Note: MB_OVERLOAD_STRING === 2, but we don't reference the constant
+     * (for nuisance-free PHP 8 support)
+     *
      * @return bool
      */
     protected static function isMbStringOverride()
@@ -911,8 +930,10 @@
 
         if ($mbstring === null) {
             $mbstring = extension_loaded('mbstring')
+                && defined('MB_OVERLOAD_STRING')
                 &&
-            ((int) (ini_get('mbstring.func_overload')) & MB_OVERLOAD_STRING);
+            ((int) (ini_get('mbstring.func_overload')) & 2);
+            // MB_OVERLOAD_STRING === 2
         }
         /** @var bool $mbstring */