PleaseStand has uploaded a new change for review.
https://gerrit.wikimedia.org/r/163540
Change subject: Deprecate OutputPage::readOnlyPage()
......................................................................
Deprecate OutputPage::readOnlyPage()
Also, as this method is never called with an argument in any Gerrit-hosted
extension, shortened it to just `throw new ReadOnlyError;` on the assumption
that the removed portion was only left in for EditPage.
Change-Id: Icc2fc166b155eac548dfd5f3e67b0b1f92ef90d3
---
M RELEASE-NOTES-1.25
M includes/OutputPage.php
2 files changed, 12 insertions(+), 71 deletions(-)
git pull ssh://gerrit.wikimedia.org:29418/mediawiki/core
refs/changes/40/163540/1
diff --git a/RELEASE-NOTES-1.25 b/RELEASE-NOTES-1.25
index 22033cf..4f990e7 100644
--- a/RELEASE-NOTES-1.25
+++ b/RELEASE-NOTES-1.25
@@ -39,6 +39,8 @@
* Removed XmlDumpWriter::schemaVersion(). (deprecated since 1.20)
* Removed LogEventsList::getDisplayTitle(). (deprecated since 1.20)
* Removed Preferences::trySetUserEmail(). (deprecated since 1.20)
+* Deprecated OutputPage::readOnlyPage(). Also, it will now throw an MWException
+ if called with one or more arguments.
== Compatibility ==
diff --git a/includes/OutputPage.php b/includes/OutputPage.php
index 3321747..16cb544 100644
--- a/includes/OutputPage.php
+++ b/includes/OutputPage.php
@@ -2399,83 +2399,22 @@
}
/**
- * Display a page stating that the Wiki is in read-only mode,
- * and optionally show the source of the page that the user
- * was trying to edit. Should only be called (for this
- * purpose) after wfReadOnly() has returned true.
+ * Display a page stating that the Wiki is in read-only mode.
+ * Should only be called after wfReadOnly() has returned true.
*
- * For historical reasons, this function is _also_ used to
- * show the error message when a user tries to edit a page
- * they are not allowed to edit. (Unless it's because they're
- * blocked, then we show blockedPage() instead.) In this
- * case, the second parameter should be set to true and a list
- * of reasons supplied as the third parameter.
+ * Historically, this function was used to show the source of the page
that the user
+ * was trying to edit and _also_ permissions error messages. The
relevant code was
+ * moved into EditPage in 1.19 (r102024 / d83c2a431c2a) and removed
here in 1.25.
*
- * @todo Needs to be split into multiple functions.
- *
- * @param string $source Source code to show (or null).
- * @param bool $protected Is this a permissions error?
- * @param array $reasons List of reasons for this error, as returned by
- * Title::getUserPermissionsErrors().
- * @param string $action Action that was denied or null if unknown
+ * @deprecated since 1.25; throw the exception directly
* @throws ReadOnlyError
*/
- public function readOnlyPage( $source = null, $protected = false,
- array $reasons = array(), $action = null
- ) {
- $this->setRobotPolicy( 'noindex,nofollow' );
- $this->setArticleRelated( false );
-
- // If no reason is given, just supply a default "I can't let
you do
- // that, Dave" message. Should only occur if called by legacy
code.
- if ( $protected && empty( $reasons ) ) {
- $reasons[] = array( 'badaccess-group0' );
+ public function readOnlyPage() {
+ if ( func_num_args() > 0 ) {
+ throw new MWException( __METHOD__ . ' no longer accepts
arguments since 1.25.' );
}
- if ( !empty( $reasons ) ) {
- // Permissions error
- if ( $source ) {
- $this->setPageTitle( $this->msg(
'viewsource-title', $this->getTitle()->getPrefixedText() ) );
- $this->addBacklinkSubtitle( $this->getTitle() );
- } else {
- $this->setPageTitle( $this->msg( 'badaccess' )
);
- }
- $this->addWikiText(
$this->formatPermissionsErrorMessage( $reasons, $action ) );
- } else {
- // Wiki is read only
- throw new ReadOnlyError;
- }
-
- // Show source, if supplied
- if ( is_string( $source ) ) {
- $this->addWikiMsg( 'viewsourcetext' );
-
- $pageLang = $this->getTitle()->getPageLanguage();
- $params = array(
- 'id' => 'wpTextbox1',
- 'name' => 'wpTextbox1',
- 'cols' => $this->getUser()->getOption( 'cols' ),
- 'rows' => $this->getUser()->getOption( 'rows' ),
- 'readonly' => 'readonly',
- 'lang' => $pageLang->getHtmlCode(),
- 'dir' => $pageLang->getDir(),
- );
- $this->addHTML( Html::element( 'textarea', $params,
$source ) );
-
- // Show templates used by this article
- $templates = Linker::formatTemplates(
$this->getTitle()->getTemplateLinksFrom() );
- $this->addHTML( "<div class='templatesUsed'>
-$templates
-</div>
-" );
- }
-
- # If the title doesn't exist, it's fairly pointless to print a
return
- # link to it. After all, you just tried editing it and
couldn't, so
- # what's there to do there?
- if ( $this->getTitle()->exists() ) {
- $this->returnToMain( null, $this->getTitle() );
- }
+ throw new ReadOnlyError;
}
/**
--
To view, visit https://gerrit.wikimedia.org/r/163540
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings
Gerrit-MessageType: newchange
Gerrit-Change-Id: Icc2fc166b155eac548dfd5f3e67b0b1f92ef90d3
Gerrit-PatchSet: 1
Gerrit-Project: mediawiki/core
Gerrit-Branch: master
Gerrit-Owner: PleaseStand <[email protected]>
_______________________________________________
MediaWiki-commits mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits