Prevent Magento throwing an exception for a PHP deprecation warning

Deprecation exists to allow developers to slowly fix their code over time, while the original code will still work
perfectly fine. For some reason Magento wants to throw an exception for a simple deprecation warning - causing
unnecessary errors in production environments.

This patch will check if an error is a deprecation warning, log the warning, and proceed as normal. If the store is in
`developer` mode, it will behave the same as core Magento and throw an exception.

--- a/vendor/magento/framework/App/Bootstrap.php
+++ b/vendor/magento/framework/App/Bootstrap.php
@@ -384,7 +384,8 @@ class Bootstrap
      */
     private function initErrorHandler()
     {
-        $handler = new ErrorHandler();
+        $bootstrap = $this;
+        $handler = new ErrorHandler(function () use ($bootstrap) { return $bootstrap->isDeveloperMode(); });
         set_error_handler([$handler, 'handler']);
     }

--- a/vendor/magento/framework/App/ErrorHandler.php
+++ b/vendor/magento/framework/App/ErrorHandler.php
@@ -34,6 +34,21 @@ class ErrorHandler
         E_USER_DEPRECATED => 'User Deprecated Functionality',
     ];

+    private $isDeveloperModeProxy = null;
+
+    public function __construct(callable $isDeveloperModeProxy = null) {
+        $this->isDeveloperModeProxy = $isDeveloperModeProxy;
+    }
+
+    private function isDeveloperMode(): bool
+    {
+        try {
+            return $this->isDeveloperModeProxy !== null && ($this->isDeveloperModeProxy)();
+        } catch (\Throwable $exception) {
+            return false;
+        }
+    }
+
     /**
      * Custom error handler
      *
@@ -58,6 +73,12 @@ class ErrorHandler

         $msg = isset($this->errorPhrases[$errorNo]) ? $this->errorPhrases[$errorNo] : "Unknown error ({$errorNo})";
         $msg .= ": {$errorStr} in {$errorFile} on line {$errorLine}";
+
+        if (!$this->isDeveloperMode() && in_array($errorNo, [E_DEPRECATED, E_USER_DEPRECATED])) {
+            error_log($msg);
+            return false;
+        }
+
         // phpcs:ignore Magento2.Exceptions.DirectThrow
         throw new \Exception($msg);
     }
