aboutsummaryrefslogtreecommitdiffstats
path: root/includes/libs/filebackend/FileBackend.php
diff options
context:
space:
mode:
authorAryeh Gregor <ayg@aryeh.name>2019-10-30 13:30:38 +0200
committerAryeh Gregor <ayg@aryeh.name>2019-10-30 13:32:29 +0200
commit77cceb644a76a515ae8b74ca5a830ae62d7880e2 (patch)
tree655a51f2821949dc0f0d99610816a292de567458 /includes/libs/filebackend/FileBackend.php
parent7fae3dc0e019f5daa7a40b0c1ce8b8fb558bd1fd (diff)
downloadmediawikicore-77cceb644a76a515ae8b74ca5a830ae62d7880e2.tar.gz
mediawikicore-77cceb644a76a515ae8b74ca5a830ae62d7880e2.zip
100% unit test coverage for FileBackend
Bug: T234227 Change-Id: I2bfd975e9af78f4ee792d024ad7c1dd06902a284
Diffstat (limited to 'includes/libs/filebackend/FileBackend.php')
-rw-r--r--includes/libs/filebackend/FileBackend.php11
1 files changed, 10 insertions, 1 deletions
diff --git a/includes/libs/filebackend/FileBackend.php b/includes/libs/filebackend/FileBackend.php
index eb2fcaa9dc7d..02f42185132b 100644
--- a/includes/libs/filebackend/FileBackend.php
+++ b/includes/libs/filebackend/FileBackend.php
@@ -211,7 +211,6 @@ abstract class FileBackend implements LoggerAwareInterface {
: 50;
$this->obResetFunc = $config['obResetFunc'] ?? [ $this, 'resetOutputBuffer' ];
$this->streamMimeFunc = $config['streamMimeFunc'] ?? null;
- $this->statusWrapper = $config['statusWrapper'] ?? null;
$this->profiler = $config['profiler'] ?? null;
if ( !is_callable( $this->profiler ) ) {
@@ -1571,6 +1570,9 @@ abstract class FileBackend implements LoggerAwareInterface {
* @return string|null Parent storage path or null on failure
*/
final public static function parentStoragePath( $storagePath ) {
+ // XXX dirname() depends on platform and locale! If nothing enforces that the storage path
+ // doesn't contain characters like '\', behavior can vary by platform. We should use
+ // explode() instead.
$storagePath = dirname( $storagePath );
list( , , $rel ) = self::splitStoragePath( $storagePath );
@@ -1585,6 +1587,8 @@ abstract class FileBackend implements LoggerAwareInterface {
* @return string
*/
final public static function extensionFromPath( $path, $case = 'lowercase' ) {
+ // This will treat a string starting with . as not having an extension, but store paths have
+ // to start with 'mwstore://', so "garbage in, garbage out".
$i = strrpos( $path, '.' );
$ext = $i ? substr( $path, $i + 1 ) : '';
@@ -1701,7 +1705,12 @@ abstract class FileBackend implements LoggerAwareInterface {
return $this->profiler ? ( $this->profiler )( $section ) : null;
}
+ /**
+ * @codeCoverageIgnore Let's not reset output buffering during tests
+ */
protected function resetOutputBuffer() {
+ // XXX According to documentation, ob_get_status() always returns a non-empty array and this
+ // condition will always be true
while ( ob_get_status() ) {
if ( !ob_end_clean() ) {
// Could not remove output buffer handler; abort now