dépôts
/
lhc
/
web
/
wiklou.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
Merge "Don't check namespace in SpecialWantedtemplates"
[lhc/web/wiklou.git]
/
includes
/
filerepo
/
file
/
ArchivedFile.php
diff --git
a/includes/filerepo/file/ArchivedFile.php
b/includes/filerepo/file/ArchivedFile.php
index
a71acde
..
1aec446
100644
(file)
--- a/
includes/filerepo/file/ArchivedFile.php
+++ b/
includes/filerepo/file/ArchivedFile.php
@@
-100,8
+100,9
@@
class ArchivedFile {
* @param Title $title
* @param int $id
* @param string $key
* @param Title $title
* @param int $id
* @param string $key
+ * @param string $sha1
*/
*/
- function __construct( $title, $id = 0, $key = '' ) {
+ function __construct( $title, $id = 0, $key = ''
, $sha1 = ''
) {
$this->id = -1;
$this->title = false;
$this->name = false;
$this->id = -1;
$this->title = false;
$this->name = false;
@@
-136,7
+137,11
@@
class ArchivedFile {
$this->key = $key;
}
$this->key = $key;
}
- if ( !$id && !$key && !( $title instanceof Title ) ) {
+ if ( $sha1 ) {
+ $this->sha1 = $sha1;
+ }
+
+ if ( !$id && !$key && !( $title instanceof Title ) && !$sha1 ) {
throw new MWException( "No specifications provided to ArchivedFile constructor." );
}
}
throw new MWException( "No specifications provided to ArchivedFile constructor." );
}
}
@@
-162,6
+167,9
@@
class ArchivedFile {
if ( $this->title ) {
$conds['fa_name'] = $this->title->getDBkey();
}
if ( $this->title ) {
$conds['fa_name'] = $this->title->getDBkey();
}
+ if ( $this->sha1 ) {
+ $conds['fa_sha1'] = $this->sha1;
+ }
if ( !count( $conds ) ) {
throw new MWException( "No specific information for retrieving archived file" );
if ( !count( $conds ) ) {
throw new MWException( "No specific information for retrieving archived file" );
@@
-264,6
+272,9
@@
class ArchivedFile {
// old row, populate from key
$this->sha1 = LocalRepo::getHashFromKey( $this->key );
}
// old row, populate from key
$this->sha1 = LocalRepo::getHashFromKey( $this->key );
}
+ if ( !$this->title ) {
+ $this->title = Title::makeTitleSafe( NS_FILE, $row->fa_name );
+ }
}
/**
}
/**
@@
-272,6
+283,9
@@
class ArchivedFile {
* @return Title
*/
public function getTitle() {
* @return Title
*/
public function getTitle() {
+ if ( !$this->title ) {
+ $this->load();
+ }
return $this->title;
}
return $this->title;
}
@@
-407,6
+421,7
@@
class ArchivedFile {
/**
* Returns the number of pages of a multipage document, or false for
* documents which aren't multipage documents
/**
* Returns the number of pages of a multipage document, or false for
* documents which aren't multipage documents
+ * @return bool|int
*/
function pageCount() {
if ( !isset( $this->pageCount ) ) {
*/
function pageCount() {
if ( !isset( $this->pageCount ) ) {
@@
-470,7
+485,7
@@
class ArchivedFile {
if ( $type == 'text' ) {
return $this->user_text;
} elseif ( $type == 'id' ) {
if ( $type == 'text' ) {
return $this->user_text;
} elseif ( $type == 'id' ) {
- return $this->user;
+ return
(int)
$this->user;
}
throw new MWException( "Unknown type '$type'." );
}
throw new MWException( "Unknown type '$type'." );
@@
-571,6
+586,7
@@
class ArchivedFile {
public function userCan( $field, User $user = null ) {
$this->load();
public function userCan( $field, User $user = null ) {
$this->load();
- return Revision::userCanBitfield( $this->deleted, $field, $user );
+ $title = $this->getTitle();
+ return Revision::userCanBitfield( $this->deleted, $field, $user, $title ?: null );
}
}
}
}