filebackend: improve internal use of FileBackend constants
authorAaron Schulz <aschulz@wikimedia.org>
Fri, 30 Aug 2019 07:01:29 +0000 (00:01 -0700)
committerAaron Schulz <aschulz@wikimedia.org>
Wed, 4 Sep 2019 02:31:17 +0000 (19:31 -0700)
commit903f1810c8d1fafe27c10636b4c2fc982b89c48e
treecf89f4b3e342e453b8ea243a83615a77d34a4ad7
parent43cc14657dae8594eebbf2e7e33a5a3c50b2e9e4
filebackend: improve internal use of FileBackend constants

Add more result constants and split up FileBackend::UNKNOWN for
clarity. This follows up 5719815f3b, which added that constant.

Make internal FileBackendStore::doGet* methods distinguish I/O errors
from missing files; the return types of public FileBackend methods are
unchanged. Avoid process caching any mtime/size/sha1 values in the
case of I/O errors. Use error constants consistently for stat methods
when given invalid paths.

Also:
* Factor out FileBackendStore::processCacheAndPersistStatEntries() method
  to reduce significant code duplication.
* Consolidate duplicated isPathUsable() checks in FileOp subclasses to
  FileOp::precheck().
* Remove null process cache value check from FileBackend::getFileStat()
  as null values are never stored in the process cache to begin with.
* Reformat some oddly wrapped lines to look cleaner.

Change-Id: Id0e4b0da0bb2ed3184847b35142d587c7f3d953d
14 files changed:
includes/libs/filebackend/FSFileBackend.php
includes/libs/filebackend/FileBackend.php
includes/libs/filebackend/FileBackendMultiWrite.php
includes/libs/filebackend/FileBackendStore.php
includes/libs/filebackend/MemoryFileBackend.php
includes/libs/filebackend/SwiftFileBackend.php
includes/libs/filebackend/fileop/CopyFileOp.php
includes/libs/filebackend/fileop/CreateFileOp.php
includes/libs/filebackend/fileop/DeleteFileOp.php
includes/libs/filebackend/fileop/DescribeFileOp.php
includes/libs/filebackend/fileop/FileOp.php
includes/libs/filebackend/fileop/MoveFileOp.php
includes/libs/filebackend/fileop/StoreFileOp.php
tests/phpunit/includes/filebackend/FileBackendTest.php