From 9cb6d1bf13c65c2b69fcbdf449ce1058ef03d96f Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Rub=C3=A9n=20Calvo?= <rubencm@gmail.com>
Date: Sat, 17 Feb 2018 19:15:54 +0100
Subject: [PATCH 1/3] [ticket/15553] Add method to get direct link

PHPBB3-15553
---
 .../storage/adapter/adapter_interface.php     |  7 ++++++
 phpBB/phpbb/storage/adapter/local.php         | 22 +++++++++++++++----
 phpBB/phpbb/storage/storage.php               | 10 +++++++++
 3 files changed, 35 insertions(+), 4 deletions(-)

diff --git a/phpBB/phpbb/storage/adapter/adapter_interface.php b/phpBB/phpbb/storage/adapter/adapter_interface.php
index afc78a7f83..39ef789717 100644
--- a/phpBB/phpbb/storage/adapter/adapter_interface.php
+++ b/phpBB/phpbb/storage/adapter/adapter_interface.php
@@ -85,4 +85,11 @@ interface adapter_interface
 	 * 													When the file cannot be copied
 	 */
 	public function copy($path_orig, $path_dest);
+
+	/**
+	 * Get direct link.
+	 *
+	 * @param string	$path	The file
+	 */
+	public function get_link($path);
 }
diff --git a/phpBB/phpbb/storage/adapter/local.php b/phpBB/phpbb/storage/adapter/local.php
index 1ef2516f4f..7056d573bc 100644
--- a/phpBB/phpbb/storage/adapter/local.php
+++ b/phpBB/phpbb/storage/adapter/local.php
@@ -57,6 +57,11 @@ class local implements adapter_interface, stream_interface
 	 */
 	protected $root_path;
 
+	/**
+	 * @var string path
+	 */
+	protected $path;
+
 	/**
 	 * Constructor
 	 */
@@ -73,12 +78,13 @@ class local implements adapter_interface, stream_interface
 	 */
 	public function configure($options)
 	{
-		$this->root_path = $this->phpbb_root_path . $options['path'];
-
-		if (substr($this->root_path, -1, 1) !== DIRECTORY_SEPARATOR)
+		if (substr($options['path'], -1, 1) !== DIRECTORY_SEPARATOR)
 		{
-			$this->root_path = $this->root_path . DIRECTORY_SEPARATOR;
+			$options['path'] = $options['path'] . DIRECTORY_SEPARATOR;
 		}
+
+		$this->path = $options['path'];
+		$this->root_path = $this->phpbb_root_path . $options['path'];
 	}
 
 	/**
@@ -331,4 +337,12 @@ class local implements adapter_interface, stream_interface
 	{
 		return $this->image_dimensions($path);
 	}
+
+	/**
+	 * {@inheritdoc}
+	 */
+	public function get_link($path)
+	{
+		return generate_board_url() . $this->root_path . $path;
+	}
 }
diff --git a/phpBB/phpbb/storage/storage.php b/phpBB/phpbb/storage/storage.php
index bc089117d4..aa596da62e 100644
--- a/phpBB/phpbb/storage/storage.php
+++ b/phpBB/phpbb/storage/storage.php
@@ -216,4 +216,14 @@ class storage
 	{
 		return new file_info($this->adapter, $path);
 	}
+
+	/**
+	 * Get direct link
+	 *
+	 * @param string	$path	The file
+	 */
+	public function get_link($path)
+	{
+		return $this->get_adapter()->get_link($path);
+	}
 }

From 0dda99ead625a80395f5721394a4e87944d0f015 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Rub=C3=A9n=20Calvo?= <rubencm@gmail.com>
Date: Sun, 18 Feb 2018 12:09:55 +0100
Subject: [PATCH 2/3] [ticket/15553] Fix path

PHPBB3-15553
---
 phpBB/phpbb/storage/adapter/local.php | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/phpBB/phpbb/storage/adapter/local.php b/phpBB/phpbb/storage/adapter/local.php
index 7056d573bc..16ddebad91 100644
--- a/phpBB/phpbb/storage/adapter/local.php
+++ b/phpBB/phpbb/storage/adapter/local.php
@@ -343,6 +343,6 @@ class local implements adapter_interface, stream_interface
 	 */
 	public function get_link($path)
 	{
-		return generate_board_url() . $this->root_path . $path;
+		return generate_board_url() . $this->path . $path;
 	}
 }

From f95cb27643623b2914c3f3958481f2a7131d3630 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Rub=C3=A9n=20Calvo?= <rubencm@gmail.com>
Date: Wed, 30 May 2018 22:34:54 +0200
Subject: [PATCH 3/3] [ticket/15553] Add return annotation to get_link

PHPBB3-15553
---
 phpBB/phpbb/storage/adapter/adapter_interface.php | 3 +++
 phpBB/phpbb/storage/storage.php                   | 3 +++
 2 files changed, 6 insertions(+)

diff --git a/phpBB/phpbb/storage/adapter/adapter_interface.php b/phpBB/phpbb/storage/adapter/adapter_interface.php
index 39ef789717..d57c2ba587 100644
--- a/phpBB/phpbb/storage/adapter/adapter_interface.php
+++ b/phpBB/phpbb/storage/adapter/adapter_interface.php
@@ -90,6 +90,9 @@ interface adapter_interface
 	 * Get direct link.
 	 *
 	 * @param string	$path	The file
+	 *
+	 * @return string	Returns link.
+	 *
 	 */
 	public function get_link($path);
 }
diff --git a/phpBB/phpbb/storage/storage.php b/phpBB/phpbb/storage/storage.php
index aa596da62e..862b039c6a 100644
--- a/phpBB/phpbb/storage/storage.php
+++ b/phpBB/phpbb/storage/storage.php
@@ -221,6 +221,9 @@ class storage
 	 * Get direct link
 	 *
 	 * @param string	$path	The file
+	 *
+	 * @return string	Returns link.
+	 *
 	 */
 	public function get_link($path)
 	{