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 "Rename autonym for 'no' from 'norsk bokmål' to 'norsk'"
[lhc/web/wiklou.git]
/
includes
/
api
/
ApiDelete.php
diff --git
a/includes/api/ApiDelete.php
b/includes/api/ApiDelete.php
index
50c24ae
..
72bbe00
100644
(file)
--- a/
includes/api/ApiDelete.php
+++ b/
includes/api/ApiDelete.php
@@
-44,11
+44,13
@@
class ApiDelete extends ApiBase {
$params = $this->extractRequestParams();
$pageObj = $this->getTitleOrPageId( $params, 'fromdbmaster' );
$params = $this->extractRequestParams();
$pageObj = $this->getTitleOrPageId( $params, 'fromdbmaster' );
- if ( !$pageObj->exists() ) {
+ $titleObj = $pageObj->getTitle();
+ if ( !$pageObj->exists() &&
+ !( $titleObj->getNamespace() == NS_FILE && self::canDeleteFile( $pageObj->getFile() ) )
+ ) {
$this->dieWithError( 'apierror-missingtitle' );
}
$this->dieWithError( 'apierror-missingtitle' );
}
- $titleObj = $pageObj->getTitle();
$reason = $params['reason'];
$user = $this->getUser();
$reason = $params['reason'];
$user = $this->getUser();
@@
-128,6
+130,14
@@
class ApiDelete extends ApiBase {
return $page->doDeleteArticleReal( $reason, false, 0, true, $error, $user, $tags );
}
return $page->doDeleteArticleReal( $reason, false, 0, true, $error, $user, $tags );
}
+ /**
+ * @param File $file
+ * @return bool
+ */
+ protected static function canDeleteFile( File $file ) {
+ return $file->exists() && $file->isLocal() && !$file->getRedirected();
+ }
+
/**
* @param Page $page Object to work on
* @param User $user User doing the action
/**
* @param Page $page Object to work on
* @param User $user User doing the action
@@
-143,7
+153,7
@@
class ApiDelete extends ApiBase {
$title = $page->getTitle();
$file = $page->getFile();
$title = $page->getTitle();
$file = $page->getFile();
- if ( !
$file->exists() || !$file->isLocal() || $file->getRedirected(
) ) {
+ if ( !
self::canDeleteFile( $file
) ) {
return self::delete( $page, $user, $reason, $tags );
}
return self::delete( $page, $user, $reason, $tags );
}
@@
-218,6
+228,6
@@
class ApiDelete extends ApiBase {
}
public function getHelpUrls() {
}
public function getHelpUrls() {
- return 'https://www.mediawiki.org/wiki/API:Delete';
+ return 'https://www.mediawiki.org/wiki/
Special:MyLanguage/
API:Delete';
}
}
}
}