diff vendor/symfony/http-kernel/Debug/FileLinkFormatter.php @ 14:1fec387a4317

Update Drupal core to 8.5.2 via Composer
author Chris Cannam
date Mon, 23 Apr 2018 09:46:53 +0100
parents 4c8ae668cc8c
children 129ea1e6d783
line wrap: on
line diff
--- a/vendor/symfony/http-kernel/Debug/FileLinkFormatter.php	Mon Apr 23 09:33:26 2018 +0100
+++ b/vendor/symfony/http-kernel/Debug/FileLinkFormatter.php	Mon Apr 23 09:46:53 2018 +0100
@@ -13,6 +13,8 @@
 
 use Symfony\Component\HttpFoundation\Request;
 use Symfony\Component\HttpFoundation\RequestStack;
+use Symfony\Component\Routing\Exception\ExceptionInterface;
+use Symfony\Component\Routing\Generator\UrlGeneratorInterface;
 
 /**
  * Formats debug file links.
@@ -26,6 +28,9 @@
     private $baseDir;
     private $urlFormat;
 
+    /**
+     * @param string|\Closure $urlFormat the URL format, or a closure that returns it on-demand
+     */
     public function __construct($fileLinkFormat = null, RequestStack $requestStack = null, $baseDir = null, $urlFormat = null)
     {
         $fileLinkFormat = $fileLinkFormat ?: ini_get('xdebug.file_link_format') ?: get_cfg_var('xdebug.file_link_format');
@@ -63,7 +68,23 @@
 
     public function unserialize($serialized)
     {
-        $this->fileLinkFormat = unserialize($serialized);
+        if (\PHP_VERSION_ID >= 70000) {
+            $this->fileLinkFormat = unserialize($serialized, array('allowed_classes' => false));
+        } else {
+            $this->fileLinkFormat = unserialize($serialized);
+        }
+    }
+
+    /**
+     * @internal
+     */
+    public static function generateUrlFormat(UrlGeneratorInterface $router, $routeName, $queryString)
+    {
+        try {
+            return $router->generate($routeName).$queryString;
+        } catch (ExceptionInterface $e) {
+            return null;
+        }
     }
 
     private function getFileLinkFormat()
@@ -74,6 +95,10 @@
         if ($this->requestStack && $this->baseDir && $this->urlFormat) {
             $request = $this->requestStack->getMasterRequest();
             if ($request instanceof Request) {
+                if ($this->urlFormat instanceof \Closure && !$this->urlFormat = \call_user_func($this->urlFormat)) {
+                    return;
+                }
+
                 return array(
                     $request->getSchemeAndHttpHost().$request->getBaseUrl().$this->urlFormat,
                     $this->baseDir.DIRECTORY_SEPARATOR, '',