* Fixed type check in StreamFile::prepareForStream() for 404s
authorAaron Schulz <aaron@users.mediawiki.org>
Tue, 17 Jan 2012 05:34:01 +0000 (05:34 +0000)
committerAaron Schulz <aaron@users.mediawiki.org>
Tue, 17 Jan 2012 05:34:01 +0000 (05:34 +0000)
* Code comment tweaks and fixes

includes/StreamFile.php
includes/filerepo/backend/FileBackend.php
includes/filerepo/backend/FileOp.php

index 89c862e..dc70712 100644 (file)
@@ -41,17 +41,17 @@ class StreamFile {
         * (c) sends Content-Length header based on HTTP_IF_MODIFIED_SINCE check
         *
         * @param $path string Storage path or file system path
-        * @param $info Array File stat info with 'mtime' and 'size' fields
+        * @param $info Array|false File stat info with 'mtime' and 'size' fields
         * @param $headers Array Additional headers to send
         * @param $sendErrors bool Send error messages if errors occur (like 404)
         * @return int|false READY_STREAM, NOT_MODIFIED, or false on failure
         */
        public static function prepareForStream(
-               $path, array $info, $headers = array(), $sendErrors = true
+               $path, $info, $headers = array(), $sendErrors = true
        ) {
                global $wgLanguageCode;
 
-               if ( !$info ) {
+               if ( !is_array( $info ) ) {
                        if ( $sendErrors ) {
                                header( 'HTTP/1.0 404 Not Found' );
                                header( 'Cache-Control: no-cache' );
index 71ce4bb..ded152b 100644 (file)
@@ -75,7 +75,6 @@ abstract class FileBackendBase {
 
        /**
         * Get the unique backend name.
-        * 
         * We may have multiple different backends of the same type.
         * For example, we can have two Swift backends using different proxies.
         * 
@@ -288,8 +287,9 @@ abstract class FileBackendBase {
        abstract public function concatenate( array $params );
 
        /**
-        * Prepare a storage path for usage. This will create containers
-        * that don't yet exist or, on FS backends, create parent directories.
+        * Prepare a storage directory for usage.
+        * This will create any required containers and parent directories.
+        * Backends using key/value stores only need to create the container.
         * 
         * $params include:
         *     dir : storage directory
@@ -312,8 +312,8 @@ abstract class FileBackendBase {
        /**
         * Take measures to block web access to a storage directory and
         * the container it belongs to. FS backends might add .htaccess
-        * files whereas backends like Swift this might restrict container
-        * access to backend user that represents end-users in web request.
+        * files whereas key/value store backends might restrict container
+        * access to the auth user that represents end-users in web request.
         * This is not guaranteed to actually do anything.
         * 
         * $params include:
@@ -341,8 +341,9 @@ abstract class FileBackendBase {
        abstract protected function doSecure( array $params );
 
        /**
-        * Clean up an empty storage directory.
-        * On FS backends, the directory will be deleted. Others may do nothing.
+        * Delete a storage directory if it is empty.
+        * Backends using key/value stores may do nothing unless the directory
+        * is that of an empty container, in which case it should be deleted.
         * 
         * $params include:
         *     dir : storage directory
index 8152cfe..cd20097 100644 (file)
@@ -382,7 +382,7 @@ class StoreFileOp extends FileOp {
 
 /**
  * Create a file in the backend with the given content.
- * Parameters similar to FileBackend::create(), which include:
+ * Parameters similar to FileBackend::createInternal(), which include:
  *     content       : a string of raw file contents
  *     dst           : destination storage path
  *     overwriteDest : do nothing and pass if an identical file exists at destination
@@ -426,7 +426,7 @@ class CreateFileOp extends FileOp {
 
 /**
  * Copy a file from one storage path to another in the backend.
- * Parameters similar to FileBackend::copy(), which include:
+ * Parameters similar to FileBackend::copyInternal(), which include:
  *     src           : source storage path
  *     dst           : destination storage path
  *     overwriteDest : do nothing and pass if an identical file exists at destination
@@ -478,7 +478,7 @@ class CopyFileOp extends FileOp {
 
 /**
  * Move a file from one storage path to another in the backend.
- * Parameters similar to FileBackend::move(), which include:
+ * Parameters similar to FileBackend::moveInternal(), which include:
  *     src           : source storage path
  *     dst           : destination storage path
  *     overwriteDest : do nothing and pass if an identical file exists at destination
@@ -539,7 +539,7 @@ class MoveFileOp extends FileOp {
 
 /**
  * Delete a file at the storage path.
- * Parameters similar to FileBackend::delete(), which include:
+ * Parameters similar to FileBackend::deleteInternal(), which include:
  *     src                 : source storage path
  *     ignoreMissingSource : don't return an error if the file does not exist
  */