r108488 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r108487‎ | r108488 | r108489 >
Date:02:18, 10 January 2012
Author:aaron
Status:ok (Comments)
Tags:
Comment:
r108353: Distinguish null/false in FileBackend::fileExists(). This is intended for things that might really care.
Modified paths:
  • /trunk/phase3/includes/filerepo/backend/FileBackend.php (modified) (history)

Diff [purge]

Index: trunk/phase3/includes/filerepo/backend/FileBackend.php
@@ -405,16 +405,17 @@
406406
407407 /**
408408 * Get quick information about a file at a storage path in the backend.
409 - * The result is an associative array that includes:
410 - * mtime : the last-modified timestamp (TS_MW) or false
411 - * size : the file size (bytes) or false
 409+ * If the file does not exist, then this returns false.
 410+ * Otherwise, the result is an associative array that includes:
 411+ * mtime : the last-modified timestamp (TS_MW)
 412+ * size : the file size (bytes)
412413 *
413414 * $params include:
414415 * src : source storage path
415416 * latest : use the latest available data
416417 *
417418 * @param $params Array
418 - * @return Array|false Returns false on failure
 419+ * @return Array|false|null Returns null on failure
419420 */
420421 abstract public function getFileStat( array $params );
421422
@@ -867,7 +868,11 @@
868869 * @see FileBackendBase::fileExists()
869870 */
870871 final public function fileExists( array $params ) {
871 - return (bool)$this->getFileStat( $params );
 872+ $stat = $this->getFileStat( $params );
 873+ if ( $stat === null ) {
 874+ return null; // failure
 875+ }
 876+ return (bool)$stat;
872877 }
873878
874879 /**

Past revisions this follows-up on

RevisionCommit summaryAuthorDate
r108353In FileBackend:...aaron08:40, 8 January 2012

Comments

#Comment by Hashar (talk | contribs)   09:41, 10 January 2012

doGetFileStat() does not see to return null. So is that really needed? :-)

#Comment by Hashar (talk | contribs)   09:11, 12 January 2012

Of course my english is crappy. The above question was:


doGetFileStat() does not seems to return null. So is that really needed? :-)

#Comment by Aaron Schulz (talk | contribs)   17:02, 12 January 2012

Swift does, and I may change FS to do so as well.

Status & tagging log