From 0751c2e7a5644f851039de6fe248bb50841f5b13 Mon Sep 17 00:00:00 2001 From: Vincent Petry Date: Thu, 8 Sep 2016 12:11:53 +0200 Subject: [PATCH] Only use realpath for real directories (#26058) In some cross-local-storage use cases, the Local storage is instantiated with "/" as data directory. In such cases, calling realpath() would cause PHP warnings when open_basedir is set. This fix bypasses the realpath() call when dealing with a root storage. --- lib/private/Files/Storage/Local.php | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/lib/private/Files/Storage/Local.php b/lib/private/Files/Storage/Local.php index 683fd1c3e377..0424072e12ea 100644 --- a/lib/private/Files/Storage/Local.php +++ b/lib/private/Files/Storage/Local.php @@ -53,7 +53,12 @@ public function __construct($arguments) { throw new \InvalidArgumentException('No data directory set for local storage'); } $this->datadir = $arguments['datadir']; - $this->realDataDir = rtrim(realpath($this->datadir), '/') . '/'; + // some crazy code uses a local storage on root... + if ($this->datadir === '/') { + $this->realDataDir = $this->datadir; + } else { + $this->realDataDir = rtrim(realpath($this->datadir), '/') . '/'; + } if (substr($this->datadir, -1) !== '/') { $this->datadir .= '/'; }