Yaron Koren has uploaded a new change for review.
https://gerrit.wikimedia.org/r/264081
Change subject: Follow-up to 3a3c676 - re-added MW < 1.21 support for getting
raw text
......................................................................
Follow-up to 3a3c676 - re-added MW < 1.21 support for getting raw text
Change-Id: If41c3c78c7504435553455e63b936e78b82219b0
---
M includes/SF_AutoeditAPI.php
1 file changed, 22 insertions(+), 6 deletions(-)
git pull ssh://gerrit.wikimedia.org:29418/mediawiki/extensions/SemanticForms
refs/changes/81/264081/1
diff --git a/includes/SF_AutoeditAPI.php b/includes/SF_AutoeditAPI.php
index c9c78a8..8adfe80 100644
--- a/includes/SF_AutoeditAPI.php
+++ b/includes/SF_AutoeditAPI.php
@@ -307,10 +307,13 @@
$this->logMessage( 'Form ' . $this->mOptions['form'] .
' is a redirect. Finding target.', self::DEBUG );
- // FIXME: Title::newFromRedirectRecurse is deprecated
as of MW 1.21
- $formTitle = Title::newFromRedirectRecurse(
- WikiPage::factory( $formTitle )->getContent(
Revision::RAW )
- );
+ $formWikiPage = WikiPage::factory( $formTitle );
+ if ( method_exists( $formWikiPage, 'getContent' ) ) {
+ // MW 1.21+
+ $formTitle = $formWikiPage->getContent(
Revision::RAW )->getUltimateRedirectTarget();
+ } else {
+ $formTitle = Title::newFromRedirectRecurse(
$formWikiPage->getRawText() );
+ }
// if we exeeded $wgMaxRedirects or encountered an
invalid redirect target, give up
if ( $formTitle->isRedirect() ) {
@@ -763,6 +766,19 @@
}
/**
+ * Helper function, for backwards compatibility.
+ */
+ function getTextForPage( $title ) {
+ $wikiPage = WikiPage::factory( $title );
+ if ( method_exists( $wikiPage, 'getContent' ) ) {
+ // MW 1.21+
+ return $wikiPage->getContent( Revision::RAW
)->getNativeData();
+ } else {
+ return $wikiPage->getRawText();
+ }
+ }
+
+ /**
* Depending on the requested action this method will try to
store/preview
* the data in mOptions or retrieve the edit form.
*
@@ -799,7 +815,7 @@
'<noinclude>', // start
delimiter
'</noinclude>', // end delimiter
'', // replace by
- WikiPage::factory( $formTitle
)->getContent( Revision::RAW ) // subject
+ $this->getTextForPage(
$formTitle ) // subject
);
// signals that the form was submitted
@@ -848,7 +864,7 @@
if ( $preloadTitle !== null && $preloadTitle->exists()
) {
// the content of the page that was specified
to be used for preloading
- $preloadContent = WikiPage::factory(
$preloadTitle )->getContent( Revision::RAW );
+ $preloadContent = $this->getTextForPage(
$preloadTitle );
$pageExists = true;
--
To view, visit https://gerrit.wikimedia.org/r/264081
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings
Gerrit-MessageType: newchange
Gerrit-Change-Id: If41c3c78c7504435553455e63b936e78b82219b0
Gerrit-PatchSet: 1
Gerrit-Project: mediawiki/extensions/SemanticForms
Gerrit-Branch: master
Gerrit-Owner: Yaron Koren <[email protected]>
_______________________________________________
MediaWiki-commits mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits