summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authordaniel <daniel.kinzler@wikimedia.de>2012-10-08 17:26:11 +0200
committerdaniel <daniel.kinzler@wikimedia.de>2012-10-08 17:34:47 +0200
commitbb51a58e575b13eb8b6c496482f7066a7081f676 (patch)
treef1177d788ff58f1fc0a3c5a84aa29ad2a9e15970
parenta1387067295646435fcb4a01bc9b2ca3596498ac (diff)
Cleanup of Wikidata branch.origin/Wikidata
This cleans up several issues raised in comments to I3b2dad3a, mostly style and merge artifacts. Change-Id: I99f5e300a671db1353db151cd187ffd2e4478d03
-rw-r--r--RELEASE-NOTES-1.214
-rw-r--r--includes/Article.php27
-rw-r--r--includes/AutoLoader.php17
-rw-r--r--includes/DefaultSettings.php22
-rw-r--r--includes/Defines.php3
-rw-r--r--includes/DeprecatedGlobal.php2
-rw-r--r--includes/EditPage.php178
-rw-r--r--includes/GlobalFunctions.php79
-rw-r--r--includes/LinksUpdate.php2
-rw-r--r--includes/OutputPage.php2
-rw-r--r--includes/Revision.php10
-rw-r--r--includes/Timestamp.php2
-rw-r--r--includes/Title.php2
-rw-r--r--includes/Uri.php335
-rw-r--r--includes/WikiPage.php28
-rw-r--r--includes/actions/EditAction.php2
-rw-r--r--includes/api/ApiParse.php5
-rw-r--r--includes/api/ApiPurge.php1
-rw-r--r--includes/api/ApiQueryRevisions.php6
-rw-r--r--includes/cache/MessageCache.php6
-rw-r--r--includes/content/AbstractContent.php4
-rw-r--r--includes/content/Content.php14
-rw-r--r--includes/content/TextContent.php2
-rw-r--r--includes/content/WikitextContent.php2
-rw-r--r--includes/diff/DifferenceEngine.php2
-rw-r--r--includes/installer/Installer.php8
-rw-r--r--includes/installer/SqliteUpdater.php13
-rw-r--r--includes/upload/UploadFromUrl.php5
-rw-r--r--languages/messages/MessagesGa.php3
-rw-r--r--languages/messages/MessagesQqq.php3
-rw-r--r--maintenance/importSiteScripts.php9
-rw-r--r--maintenance/language/messages.inc9
-rw-r--r--tests/phpunit/MediaWikiTestCase.php4
-rw-r--r--tests/phpunit/includes/ContentHandlerTest.php21
-rw-r--r--tests/phpunit/includes/GlobalFunctions/GlobalTest.php2
-rw-r--r--tests/phpunit/includes/LinksUpdateTest.php1
-rw-r--r--tests/phpunit/includes/TimestampTest.php9
-rw-r--r--tests/phpunit/includes/UriTest.php164
-rw-r--r--tests/phpunit/includes/WikiPageTest.php33
-rw-r--r--tests/phpunit/includes/WikitextContentHandlerTest.php4
-rw-r--r--tests/phpunit/includes/WikitextContentTest.php15
-rw-r--r--tests/phpunit/includes/api/ApiEditPageTest.php16
-rw-r--r--tests/phpunit/includes/filerepo/FileBackendTest.php3
-rw-r--r--tests/phpunit/suite.xml4
-rw-r--r--thumb.php7
45 files changed, 306 insertions, 784 deletions
diff --git a/RELEASE-NOTES-1.21 b/RELEASE-NOTES-1.21
index e99487afe878..1964f813ccbd 100644
--- a/RELEASE-NOTES-1.21
+++ b/RELEASE-NOTES-1.21
@@ -57,7 +57,9 @@ The supported versions are:
== Upgrading ==
1.21 has several database changes since 1.20, and will not work without schema
-updates.
+updates. Note that due to changes to some very large tables like the revision
+table, the schema update may take quite long (minutes on a medium sized site,
+many hours on a large site).
If upgrading from before 1.11, and you are using a wiki as a commons
repository, make sure that it is updated as well. Otherwise, errors may arise
diff --git a/includes/Article.php b/includes/Article.php
index d16ee01a8da9..2180e88b4d7d 100644
--- a/includes/Article.php
+++ b/includes/Article.php
@@ -238,7 +238,7 @@ class Article extends Page {
* This function has side effects! Do not use this function if you
* only want the real revision text if any.
*
- * @deprecated in 1.21; use getContentObject() instead
+ * @deprecated in 1.21; use WikiPage::getContent() instead
*
* @return string Return the text of this revision
*/
@@ -262,11 +262,8 @@ class Article extends Page {
* @return Content Return the content of this revision
*
* @since 1.21
- *
- * @todo: FIXME: this should really be protected, all callers should be changed to use WikiPage::getContent() instead.
*/
- public function getContentObject() {
- global $wgUser;
+ protected function getContentObject() {
wfProfileIn( __METHOD__ );
if ( $this->mPage->getID() === 0 ) {
@@ -680,14 +677,12 @@ class Article extends Page {
$this->showCssOrJsPage();
$outputDone = true;
} elseif( !wfRunHooks( 'ArticleContentViewCustom',
- array( $this->fetchContentObject(), $this->getTitle(),
- $outputPage ) ) ) {
+ array( $this->fetchContentObject(), $this->getTitle(), $outputPage ) ) ) {
# Allow extensions do their own custom view for certain pages
$outputDone = true;
} elseif( !ContentHandler::runLegacyHooks( 'ArticleViewCustom',
- array( $this->fetchContentObject(), $this->getTitle(),
- $outputPage ) ) ) {
+ array( $this->fetchContentObject(), $this->getTitle(), $outputPage ) ) ) {
# Allow extensions do their own custom view for certain pages
$outputDone = true;
@@ -699,8 +694,7 @@ class Article extends Page {
# Viewing a redirect page (e.g. with parameter redirect=no)
$outputPage->addHTML( $this->viewRedirect( $rt ) );
# Parse just to get categories, displaytitle, etc.
- $this->mParserOutput = $content->getParserOutput( $this->getTitle(), $oldid,
- $parserOptions, false );
+ $this->mParserOutput = $content->getParserOutput( $this->getTitle(), $oldid, $parserOptions, false );
$outputPage->addParserOutputNoText( $this->mParserOutput );
$outputDone = true;
}
@@ -810,7 +804,7 @@ class Article extends Page {
$rev = $this->getRevisionFetched();
if ( !$rev ) {
- $this->getContext()->getOutput()->setPageTitle( wfMessage( 'errorpagetitle' )->text() );
+ $this->getContext()->getOutput()->setPageTitle( wfMessage( 'errorpagetitle' ) );
$this->getContext()->getOutput()->addWikiMsg( 'difference-missing-revision', $oldid, 1 );
return;
}
@@ -834,15 +828,16 @@ class Article extends Page {
*
* This is hooked by SyntaxHighlight_GeSHi to do syntax highlighting of these
* page views.
+ *
+ * @param bool $showCacheHint whether to show a message telling the user to clear the browser cache (default: true).
*/
protected function showCssOrJsPage( $showCacheHint = true ) {
- global $wgOut;
-
if ( $showCacheHint ) {
$dir = $this->getContext()->getLanguage()->getDir();
$lang = $this->getContext()->getLanguage()->getCode();
- $wgOut->wrapWikiMsg( "<div id='mw-clearyourcache' lang='$lang' dir='$dir' class='mw-content-$dir'>\n$1\n</div>",
+ $outputPage = $this->getContext()->getOutput();
+ $outputPage->wrapWikiMsg( "<div id='mw-clearyourcache' lang='$lang' dir='$dir' class='mw-content-$dir'>\n$1\n</div>",
'clearyourcache' );
}
@@ -1476,7 +1471,7 @@ class Article extends Page {
if ( !$reason ) {
try {
$reason = $this->generateReason( $hasHistory );
- } catch (MWException $e) {
+ } catch ( MWException $e ) {
# if a page is horribly broken, we still want to be able to delete it. so be lenient about errors here.
wfDebug("Error while building auto delete summary: $e");
$reason = '';
diff --git a/includes/AutoLoader.php b/includes/AutoLoader.php
index 59138239905b..7deeec073056 100644
--- a/includes/AutoLoader.php
+++ b/includes/AutoLoader.php
@@ -291,18 +291,18 @@ $wgAutoloadLocalClasses = array(
'ZipDirectoryReaderError' => 'includes/ZipDirectoryReader.php',
# content handler
- 'Content' => 'includes/content/Content.php',
'AbstractContent' => 'includes/content/AbstractContent.php',
'ContentHandler' => 'includes/content/ContentHandler.php',
- 'CssContent' => 'includes/content/CssContent.php',
- 'TextContentHandler' => 'includes/content/ContentHandler.php',
+ 'Content' => 'includes/content/Content.php',
'CssContentHandler' => 'includes/content/ContentHandler.php',
- 'JavaScriptContent' => 'includes/content/JavaScriptContent.php',
+ 'CssContent' => 'includes/content/CssContent.php',
'JavaScriptContentHandler' => 'includes/content/ContentHandler.php',
+ 'JavaScriptContent' => 'includes/content/JavaScriptContent.php',
'MessageContent' => 'includes/content/MessageContent.php',
+ 'TextContentHandler' => 'includes/content/ContentHandler.php',
'TextContent' => 'includes/content/TextContent.php',
- 'WikitextContent' => 'includes/content/WikitextContent.php',
'WikitextContentHandler' => 'includes/ContentHandler.php',
+ 'WikitextContent' => 'includes/content/WikitextContent.php',
# includes/actions
'CachedAction' => 'includes/actions/CachedAction.php',
@@ -1079,12 +1079,13 @@ $wgAutoloadLocalClasses = array(
'TestRecorder' => 'tests/testHelpers.inc',
# tests/phpunit
+ 'DummyContentHandlerForTesting' => 'tests/phpunit/includes/ContentHandlerTest.php',
+ 'DummyContentForTesting' => 'tests/phpunit/includes/ContentHandlerTest.php',
+ 'JavascriptContentTest' => 'tests/phpunit/includes/JavascriptContentTest.php',
'RevisionStorageTest' => 'tests/phpunit/includes/RevisionStorageTest.php',
'WikiPageTest' => 'tests/phpunit/includes/WikiPageTest.php',
'WikitextContentTest' => 'tests/phpunit/includes/WikitextContentTest.php',
- 'JavascriptContentTest' => 'tests/phpunit/includes/JavascriptContentTest.php',
- 'DummyContentHandlerForTesting' => 'tests/phpunit/includes/ContentHandlerTest.php',
- 'DummyContentForTesting' => 'tests/phpunit/includes/ContentHandlerTest.php',
+
# tests/phpunit/includes
'GenericArrayObjectTest' => 'tests/phpunit/includes/libs/GenericArrayObjectTest.php',
diff --git a/includes/DefaultSettings.php b/includes/DefaultSettings.php
index f1278734d3e6..31ec6c8b8f0f 100644
--- a/includes/DefaultSettings.php
+++ b/includes/DefaultSettings.php
@@ -740,7 +740,9 @@ $wgMediaHandlers = array(
/**
* Plugins for page content model handling.
- * Each entry in the array maps a model id to a class name
+ * Each entry in the array maps a model id to a class name.
+ *
+ * @since 1.21
*/
$wgContentHandlers = array(
CONTENT_MODEL_WIKITEXT => 'WikitextContentHandler', // the usual case
@@ -6237,6 +6239,8 @@ $wgDBtestpassword = '';
* Associative array mapping namespace IDs to the name of the content model pages in that namespace should have by
* default (use the CONTENT_MODEL_XXX constants). If no special content type is defined for a given namespace,
* pages in that namespace will use the CONTENT_MODEL_WIKITEXT (except for the special case of JS and CS pages).
+ *
+ * @since 1.21
*/
$wgNamespaceContentModels = array();
@@ -6245,16 +6249,24 @@ $wgNamespaceContentModels = array();
*
* * 'ignore': return null
* * 'fail': throw an MWException
- * * 'serializeContent': serializeContent to default format
+ * * 'serialize': serialize to default format
+ *
+ * @since 1.21
*/
$wgContentHandlerTextFallback = 'ignore';
/**
- * Compatibility switch for running ContentHandler code withoput a schema update.
* Set to false to disable use of the database fields introduced by the ContentHandler facility.
+ * This way, the ContentHandler facility can be used without any additional information in the database.
+ * A page's content model is then derived solely from the page's title. This however means that changing
+ * a page's default model (e.g. using $wgNamespaceContentModels) will break the page and/or make the content
+ * inaccessible. This also means that pages can not be moved to a title that would default to a different
+ * content model.
+ *
+ * Overall, with $wgContentHandlerUseDB = false, no database updates are needed, but content handling
+ * is less robust and less flexible.
*
- * @deprecated this is only here to allow code deployment without a database schema update on large sites.
- * get rid of it in the next version.
+ * @since 1.21
*/
$wgContentHandlerUseDB = true;
diff --git a/includes/Defines.php b/includes/Defines.php
index b5894936d172..1a25a6f1cf1c 100644
--- a/includes/Defines.php
+++ b/includes/Defines.php
@@ -277,7 +277,8 @@ define( 'PROTO_INTERNAL', 2 );
* These IDs will be exposed in the API and XML dumps.
*
* Extensions that define their own content model IDs should take
- * care to avoid conflicts. Using the extension name as a prefix is recommended.
+ * care to avoid conflicts. Using the extension name as a prefix is recommended,
+ * for example 'myextension-somecontent'.
*/
define( 'CONTENT_MODEL_WIKITEXT', 'wikitext' );
define( 'CONTENT_MODEL_JAVASCRIPT', 'javascript' );
diff --git a/includes/DeprecatedGlobal.php b/includes/DeprecatedGlobal.php
index d48bd0b0ca25..4d7b9689872b 100644
--- a/includes/DeprecatedGlobal.php
+++ b/includes/DeprecatedGlobal.php
@@ -27,7 +27,7 @@
*/
class DeprecatedGlobal extends StubObject {
- // The m's are to stay consistent with parent class.
+ // The m's are to stay consistent with parent class.
protected $mRealValue, $mVersion;
function __construct( $name, $realValue, $version = false ) {
diff --git a/includes/EditPage.php b/includes/EditPage.php
index a1a2686a5fc6..6f4691ba0200 100644
--- a/includes/EditPage.php
+++ b/includes/EditPage.php
@@ -219,7 +219,7 @@ class EditPage {
var $textbox1 = '', $textbox2 = '', $summary = '', $nosummary = false;
var $edittime = '', $section = '', $sectiontitle = '', $starttime = '';
var $oldid = 0, $editintro = '', $scrolltop = null, $bot = true;
- var $content_model = null, $content_format = null;
+ var $contentModel = null, $contentFormat = null;
# Placeholders for text injection by hooks (must be HTML)
# extensions should take care to _append_ to the present value
@@ -253,10 +253,10 @@ class EditPage {
$this->mArticle = $article;
$this->mTitle = $article->getTitle();
- $this->content_model = $this->mTitle->getContentModel();
+ $this->contentModel = $this->mTitle->getContentModel();
- $handler = ContentHandler::getForModelID( $this->content_model );
- $this->content_format = $handler->getDefaultFormat(); #NOTE: should be overridden by format of actual revision
+ $handler = ContentHandler::getForModelID( $this->contentModel );
+ $this->contentFormat = $handler->getDefaultFormat();
}
/**
@@ -410,14 +410,10 @@ class EditPage {
wfProfileOut( __METHOD__ );
return;
}
-
- if ( !$this->mTitle->getArticleID() ) {
+ if ( !$this->mTitle->getArticleID() )
wfRunHooks( 'EditFormPreloadText', array( &$this->textbox1, &$this->mTitle ) );
- }
- else {
+ else
wfRunHooks( 'EditFormInitialText', array( $this ) );
- }
-
}
$this->showEditForm();
@@ -609,10 +605,8 @@ class EditPage {
// modified by subclasses
wfProfileIn( get_class( $this ) . "::importContentFormData" );
$textbox1 = $this->importContentFormData( $request );
- if ( isset( $textbox1 ) ) {
+ if ( isset( $textbox1 ) )
$this->textbox1 = $textbox1;
- }
-
wfProfileOut( get_class( $this ) . "::importContentFormData" );
}
@@ -742,8 +736,8 @@ class EditPage {
$this->nosummary = $request->getBool( 'nosummary' );
$content_handler = ContentHandler::getForTitle( $this->mTitle );
- $this->content_model = $request->getText( 'model', $content_handler->getModelID() ); #may be overridden by revision
- $this->content_format = $request->getText( 'format', $content_handler->getDefaultFormat() ); #may be overridden by revision
+ $this->contentModel = $request->getText( 'model', $content_handler->getModelID() ); #may be overridden by revision
+ $this->contentFormat = $request->getText( 'format', $content_handler->getDefaultFormat() ); #may be overridden by revision
#TODO: check if the desired model is allowed in this namespace, and if a transition from the page's current model to the new model is allowed
#TODO: check if the desired content model supports the given content format!
@@ -812,7 +806,6 @@ class EditPage {
* @return mixed string on success, $def_text for invalid sections
* @private
* @deprecated since 1.21
- * @todo: deprecated, replace usage everywhere
*/
function getContent( $def_text = false ) {
wfDeprecated( __METHOD__, '1.21' );
@@ -829,7 +822,14 @@ class EditPage {
return $this->toEditText( $content );
}
- private function getContentObject( $def_content = null ) {
+ /**
+ * @param Content|false $def_content The default value to return
+ *
+ * @return mixed Content on success, $def_content for invalid sections
+ *
+ * @since 1.21
+ */
+ protected function getContentObject( $def_content = null ) {
global $wgOut, $wgRequest;
wfProfileIn( __METHOD__ );
@@ -948,8 +948,8 @@ class EditPage {
}
$revision = $this->mArticle->getRevisionFetched();
if ( $revision === null ) {
- if ( !$this->content_model ) $this->content_model = $this->getTitle()->getContentModel();
- $handler = ContentHandler::getForModelID( $this->content_model );
+ if ( !$this->contentModel ) $this->contentModel = $this->getTitle()->getContentModel();
+ $handler = ContentHandler::getForModelID( $this->contentModel );
return $handler->makeEmptyContent();
}
@@ -963,21 +963,21 @@ class EditPage {
* content object is returned instead of null.
*
* @since 1.21
- * @return string
+ * @return Content
*/
- private function getCurrentContent() {
+ protected function getCurrentContent() {
$rev = $this->mArticle->getRevision();
$content = $rev ? $rev->getContent( Revision::RAW ) : null;
if ( $content === false || $content === null ) {
- if ( !$this->content_model ) $this->content_model = $this->getTitle()->getContentModel();
- $handler = ContentHandler::getForModelID( $this->content_model );
+ if ( !$this->contentModel ) $this->contentModel = $this->getTitle()->getContentModel();
+ $handler = ContentHandler::getForModelID( $this->contentModel );
return $handler->makeEmptyContent();
} else {
# nasty side-effect, but needed for consistency
- $this->content_model = $rev->getContentModel();
- $this->content_format = $rev->getContentFormat();
+ $this->contentModel = $rev->getContentModel();
+ $this->contentFormat = $rev->getContentFormat();
return $content;
}
@@ -1019,7 +1019,7 @@ class EditPage {
*
* @deprecated since 1.21, use getPreloadedContent() instead
*/
- protected function getPreloadedText( $preload ) { #NOTE: B/C only, replace usage!
+ protected function getPreloadedText( $preload ) {
wfDeprecated( __METHOD__, "1.21" );
$content = $this->getPreloadedContent( $preload );
@@ -1038,7 +1038,7 @@ class EditPage {
*
* @since 1.21
*/
- protected function getPreloadedContent( $preload ) { #@todo: use this!
+ protected function getPreloadedContent( $preload ) {
global $wgUser;
if ( !empty( $this->mPreloadContent ) ) {
@@ -1053,7 +1053,7 @@ class EditPage {
$title = Title::newFromText( $preload );
# Check for existence to avoid getting MediaWiki:Noarticletext
- if ( $title === null || !$title->exists() || !$title->userCan( 'read', $wgUser ) ) {
+ if ( $title === null || !$title->exists() || !$title->userCan( 'read' ) ) {
return $handler->makeEmptyContent();
}
@@ -1061,7 +1061,7 @@ class EditPage {
if ( $page->isRedirect() ) {
$title = $page->getRedirectTarget();
# Same as before
- if ( $title === null || !$title->exists() || !$title->userCan( 'read', $wgUser ) ) {
+ if ( $title === null || !$title->exists() || !$title->userCan( 'read' ) ) {
return $handler->makeEmptyContent();
}
$page = WikiPage::factory( $title );
@@ -1218,7 +1218,7 @@ class EditPage {
# Construct Content object
$textbox_content = $this->toEditContent( $this->textbox1 );
} catch (MWContentSerializationException $ex) {
- $status->fatal( 'content-failed-to-parse', $this->content_model, $this->content_format, $ex->getMessage() );
+ $status->fatal( 'content-failed-to-parse', $this->contentModel, $this->contentFormat, $ex->getMessage() );
$status->value = self::AS_PARSE_ERROR;
wfProfileOut( __METHOD__ );
return $status;
@@ -1338,7 +1338,7 @@ class EditPage {
if ( $new ) {
// Late check for create permission, just in case *PARANOIA*
- if ( !$this->mTitle->userCan( 'create', $wgUser ) ) {
+ if ( !$this->mTitle->userCan( 'create' ) ) {
$status->fatal( 'nocreatetext' );
$status->value = self::AS_NO_CREATE_PERMISSION;
wfDebug( __METHOD__ . ": no create permission\n" );
@@ -1384,8 +1384,8 @@ class EditPage {
// passed.
if ( $this->summary === '' ) {
$cleanSectionTitle = $wgParser->stripSectionName( $this->sectiontitle );
- $this->summary = wfMessage( 'newsectionsummary' )
- ->rawParams( $cleanSectionTitle )->inContentLanguage()->text() ;
+ $this->summary = wfMessage( 'newsectionsummary', $cleanSectionTitle )
+ ->inContentLanguage()->text() ;
}
} elseif ( $this->summary !== '' ) {
// Insert the section title above the content.
@@ -1396,8 +1396,8 @@ class EditPage {
// Create a link to the new section from the edit summary.
$cleanSummary = $wgParser->stripSectionName( $this->summary );
- $this->summary = wfMessage( 'newsectionsummary' )
- ->rawParams( $cleanSummary )->inContentLanguage()->text();
+ $this->summary = wfMessage( 'newsectionsummary', $cleanSummary )
+ ->inContentLanguage()->text();
}
}
@@ -1426,7 +1426,8 @@ class EditPage {
$this->isConflict = false;
wfDebug( __METHOD__ . ": conflict suppressed; new section\n" );
}
- } elseif ( $this->section == '' && Revision::userWasLastToEdit( DB_MASTER, $this->mTitle->getArticleID(), $wgUser->getId(), $this->edittime ) ) {
+ } elseif ( $this->section == '' && Revision::userWasLastToEdit( DB_MASTER, $this->mTitle->getArticleID(),
+ $wgUser->getId(), $this->edittime ) ) {
# Suppress edit conflict with self, except for section edits where merging is required.
wfDebug( __METHOD__ . ": Suppressing edit conflict, same user.\n" );
$this->isConflict = false;
@@ -1447,8 +1448,7 @@ class EditPage {
wfDebug( __METHOD__ . ": conflict! getting section '{$this->section}' for time '{$this->edittime}'"
. " (article time '{$timestamp}')\n" );
- $content = $this->mArticle->replaceSectionContent( $this->section, $textbox_content,
- $sectionTitle, $this->edittime );
+ $content = $this->mArticle->replaceSectionContent( $this->section, $textbox_content, $sectionTitle, $this->edittime );
} else {
wfDebug( __METHOD__ . ": getting section '{$this->section}'\n" );
$content = $this->mArticle->replaceSectionContent( $this->section, $textbox_content, $sectionTitle );
@@ -1540,16 +1540,16 @@ class EditPage {
// passed.
if ( $this->summary === '' ) {
$cleanSectionTitle = $wgParser->stripSectionName( $this->sectiontitle );
- $this->summary = wfMessage( 'newsectionsummary' )
- ->rawParams( $cleanSectionTitle )->inContentLanguage()->text();
+ $this->summary = wfMessage( 'newsectionsummary', $cleanSectionTitle )
+ ->inContentLanguage()->text();
}
} elseif ( $this->summary !== '' ) {
$sectionanchor = $wgParser->guessLegacySectionNameFromWikiText( $this->summary );
# This is a new section, so create a link to the new section
# in the revision summary.
$cleanSummary = $wgParser->stripSectionName( $this->summary );
- $this->summary = wfMessage( 'newsectionsummary' )
- ->rawParams( $cleanSummary )->inContentLanguage()->text();
+ $this->summary = wfMessage( 'newsectionsummary', $cleanSummary )
+ ->inContentLanguage()->text();
}
} elseif ( $this->section != '' ) {
# Try to get a section anchor from the section source, redirect to edited section if header found
@@ -1590,11 +1590,11 @@ class EditPage {
( $bot ? EDIT_FORCE_BOT : 0 );
$doEditStatus = $this->mArticle->doEditContent( $content, $this->summary, $flags,
- false, null, $this->content_format );
+ false, null, $this->contentFormat );
if ( $doEditStatus->isOK() ) {
- $result['redirect'] = $content->isRedirect();
- $this->updateWatchlist();
+ $result['redirect'] = $content->isRedirect();
+ $this->commitWatch();
wfProfileOut( __METHOD__ );
return $status;
} else {
@@ -1615,27 +1615,19 @@ class EditPage {
}
/**
- * Register the change of watch status
+ * Commit the change of watch status
*/
- protected function updateWatchlist() {
+ protected function commitWatch() {
global $wgUser;
-
if ( $wgUser->isLoggedIn() && $this->watchthis != $wgUser->isWatched( $this->mTitle ) ) {
- $fname = __METHOD__;
- $title = $this->mTitle;
- $watch = $this->watchthis;
-
- // Do this in its own transaction to reduce contention...
$dbw = wfGetDB( DB_MASTER );
- $dbw->onTransactionIdle( function() use ( $dbw, $title, $watch, $wgUser, $fname ) {
- $dbw->begin( $fname );
- if ( $watch ) {
- WatchAction::doWatch( $title, $wgUser );
- } else {
- WatchAction::doUnwatch( $title, $wgUser );
- }
- $dbw->commit( $fname );
- } );
+ $dbw->begin( __METHOD__ );
+ if ( $this->watchthis ) {
+ WatchAction::doWatch( $this->mTitle, $wgUser );
+ } else {
+ WatchAction::doUnwatch( $this->mTitle, $wgUser );
+ }
+ $dbw->commit( __METHOD__ );
}
}
@@ -1670,7 +1662,7 @@ class EditPage {
* @parma $editText string
*
* @return bool
- * @since since 1.21
+ * @since since 1.WD
*/
private function mergeChangesIntoContent( &$editContent ){
wfProfileIn( __METHOD__ );
@@ -1769,7 +1761,7 @@ class EditPage {
$wgOut->addModules( 'mediawiki.action.edit' );
if ( $wgUser->getOption( 'uselivepreview', false ) ) {
- $wgOut->addModules( 'mediawiki.action.edit.preview' );
+ $wgOut->addModules( 'mediawiki.legacy.preview' );
}
// Bug #19334: textarea jumps when editing articles in IE8
$wgOut->addStyle( 'common/IE80Fixes.css', 'screen', 'IE 8' );
@@ -1917,7 +1909,7 @@ class EditPage {
. ContentHandler::getLocalizedName( $content->getModel() ) );
}
- return $content->serialize( $this->content_format );
+ return $content->serialize( $this->contentFormat );
}
/**
@@ -1935,7 +1927,7 @@ class EditPage {
*/
protected function toEditContent( $text ) {
$content = ContentHandler::makeContent( $text, $this->getTitle(),
- $this->content_model, $this->content_format );
+ $this->contentModel, $this->contentFormat );
if ( !$this->allowNonTextContent && !( $content instanceof TextContent ) ) {
throw new MWException( "This content model can not be edited as text: "
@@ -2059,8 +2051,8 @@ class EditPage {
$wgOut->addHTML( Html::hidden( 'oldid', $this->oldid ) );
- $wgOut->addHTML( Html::hidden( 'format', $this->content_format ) );
- $wgOut->addHTML( Html::hidden( 'model', $this->content_model ) );
+ $wgOut->addHTML( Html::hidden( 'format', $this->contentFormat ) );
+ $wgOut->addHTML( Html::hidden( 'model', $this->contentModel ) );
if ( $this->section == 'new' ) {
$this->showSummaryInput( true, $this->summary );
@@ -2111,7 +2103,7 @@ class EditPage {
$this->showConflict();
} catch ( MWContentSerializationException $ex ) {
// this can't really happen, but be nice if it does.
- $msg = wfMessage( 'content-failed-to-parse', $this->content_model, $this->content_format, $ex->getMessage() );
+ $msg = wfMessage( 'content-failed-to-parse', $this->contentModel, $this->contentFormat, $ex->getMessage() );
$wgOut->addWikiText( '<div class="error">' . $msg->text() . '</div>');
}
}
@@ -2219,7 +2211,7 @@ class EditPage {
if ( $revision ) {
// Let sysop know that this will make private content public if saved
- if ( !$revision->userCan( Revision::DELETED_TEXT, $wgUser ) ) {
+ if ( !$revision->userCan( Revision::DELETED_TEXT ) ) {
$wgOut->wrapWikiMsg( "<div class='mw-warning plainlinks'>\n$1\n</div>\n", 'rev-deleted-text-permission' );
} elseif ( $revision->isDeleted( Revision::DELETED_TEXT ) ) {
$wgOut->wrapWikiMsg( "<div class='mw-warning plainlinks'>\n$1\n</div>\n", 'rev-deleted-text-view' );
@@ -2253,13 +2245,10 @@ class EditPage {
$wgOut->wrapWikiMsg( "<div class='error' id='mw-userinvalidcssjstitle'>\n$1\n</div>", array( 'userinvalidcssjstitle', $this->mTitle->getSkinFromCssJsSubpage() ) );
}
if ( $this->formtype !== 'preview' ) {
- if ( $this->isCssSubpage ) {
+ if ( $this->isCssSubpage )
$wgOut->wrapWikiMsg( "<div id='mw-usercssyoucanpreview'>\n$1\n</div>", array( 'usercssyoucanpreview' ) );
- }
-
- if ( $this->isJsSubpage ) {
+ if ( $this->isJsSubpage )
$wgOut->wrapWikiMsg( "<div id='mw-userjsyoucanpreview'>\n$1\n</div>", array( 'userjsyoucanpreview' ) );
- }
}
}
}
@@ -2390,16 +2379,14 @@ class EditPage {
* @return String
*/
protected function getSummaryPreview( $isSubjectPreview, $summary = "" ) {
- if ( !$summary || ( !$this->preview && !$this->diff ) ) {
+ if ( !$summary || ( !$this->preview && !$this->diff ) )
return "";
- }
global $wgParser;
- if ( $isSubjectPreview ) {
+ if ( $isSubjectPreview )
$summary = wfMessage( 'newsectionsummary', $wgParser->stripSectionName( $summary ) )
->inContentLanguage()->text();
- }
$message = $isSubjectPreview ? 'subject-preview' : 'summary-preview';
@@ -2418,9 +2405,8 @@ class EditPage {
HTML
);
- if ( !$this->checkUnicodeCompliantBrowser() ) {
+ if ( !$this->checkUnicodeCompliantBrowser() )
$wgOut->addHTML( Html::hidden( 'safemode', '1' ) );
- }
}
protected function showFormAfterText() {
@@ -2530,15 +2516,13 @@ HTML
protected function displayPreviewArea( $previewOutput, $isOnTop = false ) {
global $wgOut;
$classes = array();
- if ( $isOnTop ) {
+ if ( $isOnTop )
$classes[] = 'ontop';
- }
$attribs = array( 'id' => 'wikiPreview', 'class' => implode( ' ', $classes ) );
- if ( $this->formtype != 'preview' ) {
+ if ( $this->formtype != 'preview' )
$attribs['style'] = 'display: none;';
- }
$wgOut->addHTML( Xml::openElement( 'div', $attribs ) );
@@ -2552,7 +2536,7 @@ HTML
try {
$this->showDiff();
} catch ( MWContentSerializationException $ex ) {
- $msg = wfMessage( 'content-failed-to-parse', $this->content_model, $this->content_format, $ex->getMessage() );
+ $msg = wfMessage( 'content-failed-to-parse', $this->contentModel, $this->contentFormat, $ex->getMessage() );
$wgOut->addWikiText( '<div class="error">' . $msg->text() . '</div>');
}
}
@@ -2605,8 +2589,8 @@ HTML
$textboxContent = $this->toEditContent( $this->textbox1 );
$newContent = $this->mArticle->replaceSectionContent(
- $this->section, $textboxContent,
- $this->summary, $this->edittime );
+ $this->section, $textboxContent,
+ $this->summary, $this->edittime );
ContentHandler::runLegacyHooks( 'EditPageGetDiffText', array( $this, &$newContent ) );
wfRunHooks( 'EditPageGetDiffContent', array( $this, &$newContent ) );
@@ -2740,10 +2724,10 @@ HTML
$content1 = $this->toEditContent( $this->textbox1 );
$content2 = $this->toEditContent( $this->textbox2 );
- $handler = ContentHandler::getForModelID( $this->content_model );
+ $handler = ContentHandler::getForModelID( $this->contentModel );
$de = $handler->createDifferenceEngine( $this->mArticle->getContext() );
$de->setContent( $content2, $content1 );
- $de->showDiff(
+ $de->showDiff(
wfMessage( 'yourtext' )->parse(),
wfMessage( 'storedversion' )->text()
);
@@ -2833,13 +2817,10 @@ HTML
);
// Quick paranoid permission checks...
if ( is_object( $data ) ) {
- if ( $data->log_deleted & LogPage::DELETED_USER ) {
+ if ( $data->log_deleted & LogPage::DELETED_USER )
$data->user_name = wfMessage( 'rev-deleted-user' )->escaped();
- }
-
- if ( $data->log_deleted & LogPage::DELETED_COMMENT ) {
+ if ( $data->log_deleted & LogPage::DELETED_COMMENT )
$data->log_comment = wfMessage( 'rev-deleted-comment' )->escaped();
- }
}
return $data;
}
@@ -2889,7 +2870,6 @@ HTML
$parserOptions = $this->mArticle->makeParserOptions( $this->mArticle->getContext() );
$parserOptions->setEditSection( false );
- $parserOptions->setTidy( true );
$parserOptions->setIsPreview( true );
$parserOptions->setIsSectionPreview( !is_null($this->section) && $this->section !== '' );
@@ -2929,7 +2909,7 @@ HTML
# If we're adding a comment, we need to show the
# summary as the headline
- if ( $this->section == "new" && $this->summary != "" ) {
+ if ( $this->section === "new" && $this->summary !== "" ) {
$content = $content->addSectionHeader( $this->summary );
}
@@ -2953,8 +2933,8 @@ HTML
$note .= "\n\n" . implode( "\n\n", $parserOutput->getWarnings() );
}
}
- } catch (MWContentSerializationException $ex) {
- $m = wfMessage('content-failed-to-parse', $this->content_model, $this->content_format, $ex->getMessage() );
+ } catch ( MWContentSerializationException $ex ) {
+ $m = wfMessage('content-failed-to-parse', $this->contentModel, $this->contentFormat, $ex->getMessage() );
$note .= "\n\n" . $m->parse();
$previewHTML = '';
}
diff --git a/includes/GlobalFunctions.php b/includes/GlobalFunctions.php
index 3184eb7e4213..3bbf62f0a035 100644
--- a/includes/GlobalFunctions.php
+++ b/includes/GlobalFunctions.php
@@ -391,7 +391,7 @@ function wfArrayToCgi( $array1, $array2 = null, $prefix = '' ) {
$cgi = '';
foreach ( $array1 as $key => $value ) {
- if ( $value !== false ) {
+ if ( !is_null($value) && $value !== false ) {
if ( $cgi != '' ) {
$cgi .= '&';
}
@@ -412,11 +412,8 @@ function wfArrayToCgi( $array1, $array2 = null, $prefix = '' ) {
} else {
if ( is_object( $value ) ) {
$value = $value->__toString();
- } elseif( !is_null( $value ) ) {
- $cgi .= urlencode( $key ) . '=' . urlencode( $value );
- } else {
- $cgi .= urlencode( $key );
}
+ $cgi .= urlencode( $key ) . '=' . urlencode( $value );
}
}
}
@@ -443,15 +440,14 @@ function wfCgiToArray( $query ) {
continue;
}
if ( strpos( $bit, '=' ) === false ) {
- // Pieces like &qwerty become 'qwerty' => null
- $key = urldecode( $bit );
- $value = null;
+ // Pieces like &qwerty become 'qwerty' => '' (at least this is what php does)
+ $key = $bit;
+ $value = '';
} else {
list( $key, $value ) = explode( '=', $bit );
- $key = urldecode( $key );
- $value = urldecode( $value );
}
-
+ $key = urldecode( $key );
+ $value = urldecode( $value );
if ( strpos( $key, '[' ) !== false ) {
$keys = array_reverse( explode( '[', $key ) );
$key = array_pop( $keys );
@@ -476,15 +472,23 @@ function wfCgiToArray( $query ) {
* Append a query string to an existing URL, which may or may not already
* have query string parameters already. If so, they will be combined.
*
- * @deprecated in 1.20. Use Uri class.
* @param $url String
* @param $query Mixed: string or associative array
* @return string
*/
function wfAppendQuery( $url, $query ) {
- $obj = new Uri( $url );
- $obj->extendQuery( $query );
- return $obj->toString();
+ if ( is_array( $query ) ) {
+ $query = wfArrayToCgi( $query );
+ }
+ if( $query != '' ) {
+ if( false === strpos( $url, '?' ) ) {
+ $url .= '?';
+ } else {
+ $url .= '&';
+ }
+ $url .= $query;
+ }
+ return $url;
}
/**
@@ -572,13 +576,49 @@ function wfExpandUrl( $url, $defaultProto = PROTO_CURRENT ) {
* @todo Need to integrate this into wfExpandUrl (bug 32168)
*
* @since 1.19
- * @deprecated
* @param $urlParts Array URL parts, as output from wfParseUrl
* @return string URL assembled from its component parts
*/
function wfAssembleUrl( $urlParts ) {
- $obj = new Uri( $urlParts );
- return $obj->toString();
+ $result = '';
+
+ if ( isset( $urlParts['delimiter'] ) ) {
+ if ( isset( $urlParts['scheme'] ) ) {
+ $result .= $urlParts['scheme'];
+ }
+
+ $result .= $urlParts['delimiter'];
+ }
+
+ if ( isset( $urlParts['host'] ) ) {
+ if ( isset( $urlParts['user'] ) ) {
+ $result .= $urlParts['user'];
+ if ( isset( $urlParts['pass'] ) ) {
+ $result .= ':' . $urlParts['pass'];
+ }
+ $result .= '@';
+ }
+
+ $result .= $urlParts['host'];
+
+ if ( isset( $urlParts['port'] ) ) {
+ $result .= ':' . $urlParts['port'];
+ }
+ }
+
+ if ( isset( $urlParts['path'] ) ) {
+ $result .= $urlParts['path'];
+ }
+
+ if ( isset( $urlParts['query'] ) ) {
+ $result .= '?' . $urlParts['query'];
+ }
+
+ if ( isset( $urlParts['fragment'] ) ) {
+ $result .= '#' . $urlParts['fragment'];
+ }
+
+ return $result;
}
/**
@@ -725,7 +765,6 @@ function wfUrlProtocolsWithoutProtRel() {
* 2) Handles protocols that don't use :// (e.g., mailto: and news: , as well as protocol-relative URLs) correctly
* 3) Adds a "delimiter" element to the array, either '://', ':' or '//' (see (2))
*
- * @deprecated
* @param $url String: a URL to parse
* @return Array: bits of the URL in an associative array, per PHP docs
*/
@@ -1025,7 +1064,6 @@ function wfLogDBError( $text ) {
} else {
$d = date_create( "now", $logDBErrorTimeZoneObject );
}
- $date = $d->format( 'D M j G:i:s T Y' );
$date = $d->format( 'D M j G:i:s T Y' );
@@ -2364,7 +2402,6 @@ define( 'TS_ISO_8601_BASIC', 9 );
/**
* Get a timestamp string in one of various formats
*
- * @deprecated
* @param $outputtype Mixed: A timestamp in one of the supported formats, the
* function will autodetect which format is supplied and act
* accordingly.
diff --git a/includes/LinksUpdate.php b/includes/LinksUpdate.php
index e2e860a15059..2b462608f1f5 100644
--- a/includes/LinksUpdate.php
+++ b/includes/LinksUpdate.php
@@ -830,7 +830,7 @@ class LinksDeletionUpdate extends SqlDataUpdate {
$this->mPage = $page;
- if ( !$page->getId() ) {
+ if ( !$page->exists() ) {
throw new MWException( "Page ID not known, perhaps the page doesn't exist?" );
}
}
diff --git a/includes/OutputPage.php b/includes/OutputPage.php
index a03282ab0230..88c3260816b3 100644
--- a/includes/OutputPage.php
+++ b/includes/OutputPage.php
@@ -1994,8 +1994,6 @@ class OutputPage extends ContextSource {
$this->sendCacheControl();
- wfRunHooks( 'AfterFinalPageOutput', array( &$this ) );
-
ob_end_flush();
wfProfileOut( __METHOD__ );
diff --git a/includes/Revision.php b/includes/Revision.php
index 51e41d4ceea6..2cd3ae83e352 100644
--- a/includes/Revision.php
+++ b/includes/Revision.php
@@ -156,7 +156,7 @@ class Revision implements IDBAccessObject {
'deleted' => $row->ar_deleted,
'len' => $row->ar_len,
'sha1' => isset( $row->ar_sha1 ) ? $row->ar_sha1 : null,
- 'content_model' => isset( $row->ar_content_model ) ? $row->ar_content_model : null,
+ 'content_model' => isset( $row->ar_content_model ) ? $row->ar_content_model : null,
'content_format' => isset( $row->ar_content_format ) ? $row->ar_content_format : null,
);
@@ -558,8 +558,8 @@ class Revision implements IDBAccessObject {
$this->mParentId = isset( $row['parent_id'] ) ? intval( $row['parent_id'] ) : null;
$this->mSha1 = isset( $row['sha1'] ) ? strval( $row['sha1'] ) : null;
- $this->mContentModel = isset( $row['content_model'] ) ? strval( $row['content_model'] ) : null;
- $this->mContentFormat = isset( $row['content_format'] ) ? strval( $row['content_format'] ) : null;
+ $this->mContentModel = isset( $row['content_model'] ) ? strval( $row['content_model'] ) : null;
+ $this->mContentFormat = isset( $row['content_format'] ) ? strval( $row['content_format'] ) : null;
// Enforce spacing trimming on supplied text
$this->mComment = isset( $row['comment'] ) ? trim( strval( $row['comment'] ) ) : null;
@@ -570,6 +570,10 @@ class Revision implements IDBAccessObject {
// if we have a Content object, override mText and mContentModel
if ( !empty( $row['content'] ) ) {
+ if ( !( $row['content'] instanceof Content ) ) {
+ throw new MWException( '`content` field must contain a Content object.' );
+ }
+
$handler = $this->getContentHandler();
$this->mContent = $row['content'];
diff --git a/includes/Timestamp.php b/includes/Timestamp.php
index a5844b67225d..56ce46c1ac3a 100644
--- a/includes/Timestamp.php
+++ b/includes/Timestamp.php
@@ -196,7 +196,7 @@ class MWTimestamp {
*
* @since 1.20
*
- * @return string Formatted timestamp
+ * @return Message Formatted timestamp
*/
public function getHumanTimestamp() {
$then = $this->getTimestamp( TS_UNIX );
diff --git a/includes/Title.php b/includes/Title.php
index 731fc141111b..1b3b89610be1 100644
--- a/includes/Title.php
+++ b/includes/Title.php
@@ -691,7 +691,7 @@ class Title {
/**
* Convenience method for checking a title's content model name
*
- * @param int $id
+ * @param String $id The content model ID (use the CONTENT_MODEL_XXX constants).
* @return Boolean true if $this->getContentModel() == $id
*/
public function hasContentModel( $id ) {
diff --git a/includes/Uri.php b/includes/Uri.php
deleted file mode 100644
index f6cf06f03f0d..000000000000
--- a/includes/Uri.php
+++ /dev/null
@@ -1,335 +0,0 @@
-<?php
-/**
- * Class for simple URI parsing and manipulation.
- * Intended to simplify things that were using wfParseUrl and
- * had to do manual concatenation for various needs.
- * Built to match our JS mw.Uri in naming patterns.
- * @file
- * @author Daniel Friesen
- * @since 1.20
- */
-
-class Uri {
-
- /**
- * The parsed components of the URI
- */
- protected $components;
-
- protected static $validComponents = array( 'scheme', 'delimiter', 'host', 'port', 'user', 'pass', 'path', 'query', 'fragment' );
- protected static $componentAliases = array( 'protocol' => 'scheme', 'password' => 'pass' );
-
- /**
- * parse_url() work-alike, but non-broken. Differences:
- *
- * 1) Does not raise warnings on bad URLs (just returns false)
- * 2) Handles protocols that don't use :// (e.g., mailto: and news: , as well as protocol-relative URLs) correctly
- * 3) Adds a "delimiter" element to the array, either '://', ':' or '//' (see (2))
- *
- * @param $url String: a URL to parse
- * @return Array: bits of the URL in an associative array, per PHP docs
- */
- protected static function parseUri( $url ) {
- global $wgUrlProtocols; // Allow all protocols defined in DefaultSettings/LocalSettings.php
-
- // Protocol-relative URLs are handled really badly by parse_url(). It's so bad that the easiest
- // way to handle them is to just prepend 'http:' and strip the protocol out later
- $wasRelative = substr( $url, 0, 2 ) == '//';
- if ( $wasRelative ) {
- $url = "http:$url";
- }
- wfSuppressWarnings();
- $bits = parse_url( $url );
- wfRestoreWarnings();
- // parse_url() returns an array without scheme for some invalid URLs, e.g.
- // parse_url("%0Ahttp://example.com") == array( 'host' => '%0Ahttp', 'path' => 'example.com' )
- if ( !$bits ||
- !isset( $bits['scheme'] ) && strpos( $url, "://" ) !== false ) {
- wfDebug( __METHOD__ . ": Invalid URL: $url" );
- return false;
- } else {
- $scheme = isset( $bits['scheme'] ) ? $bits['scheme'] : null;
- }
-
- // most of the protocols are followed by ://, but mailto: and sometimes news: not, check for it
- if ( in_array( $scheme . '://', $wgUrlProtocols ) ) {
- $bits['delimiter'] = '://';
- } elseif ( !is_null( $scheme ) && !in_array( $scheme . ':', $wgUrlProtocols ) ) {
- wfDebug( __METHOD__ . ": Invalid scheme in URL: $scheme" );
- return false;
- } elseif( !is_null( $scheme ) ) {
- if( !in_array( $scheme . ':', $wgUrlProtocols ) ) {
- // For URLs that don't have a scheme, but do have a user:password, parse_url
- // detects the user as the scheme.
- unset( $bits['scheme'] );
- $bits['user'] = $scheme;
- } else {
- $bits['delimiter'] = ':';
- // parse_url detects for news: and mailto: the host part of an url as path
- // We have to correct this wrong detection
- if ( isset( $bits['path'] ) ) {
- $bits['host'] = $bits['path'];
- $bits['path'] = '';
- }
- }
- }
-
- /* Provide an empty host for eg. file:/// urls (see bug 28627) */
- if ( !isset( $bits['host'] ) && $scheme == "file" ) {
- $bits['host'] = '';
-
- /* parse_url loses the third / for file:///c:/ urls (but not on variants) */
- if ( isset( $bits['path'] ) && substr( $bits['path'], 0, 1 ) !== '/' ) {
- $bits['path'] = '/' . $bits['path'];
- }
- }
-
- // If the URL was protocol-relative, fix scheme and delimiter
- if ( $wasRelative ) {
- $bits['scheme'] = '';
- $bits['delimiter'] = '//';
- }
- return $bits;
- }
-
- /**
- *
- * @param $uri mixed URI string or array
- */
- public function __construct( $uri ) {
- $this->components = array();
- $this->setUri( $uri );
- }
-
- /**
- * Set the Uri to the value of some other URI.
- *
- * @param $uri mixed URI string or array
- */
- public function setUri( $uri ) {
- if ( is_string( $uri ) ) {
- $parsed = self::parseUri( $uri );
- if( $parsed === false ) {
- return false;
- }
- $this->setComponents( $parsed );
- } elseif ( is_array( $uri ) ) {
- $this->setComponents( $uri );
- } elseif ( $uri instanceof Uri ) {
- $this->setComponents( $uri->getComponents() );
- } else {
- throw new MWException( __METHOD__ . ': $uri is not of a valid type.' );
- }
- }
-
- /**
- * Set the components of this array.
- * Will output warnings when invalid components or aliases are found.
- *
- * @param $components Array The components to set on this Uri.
- */
- public function setComponents( array $components ) {
- foreach ( $components as $name => $value ) {
- if ( isset( self::$componentAliases[$name] ) ) {
- $canonical = self::$componentAliases[$name];
- wfDebug( __METHOD__ . ": Converting alias $name to canonical $canonical." );
- $components[$canonical] = $value;
- unset( $components[$name] );
- } elseif ( !in_array( $name, self::$validComponents ) ) {
- throw new MWException( __METHOD__ . ": $name is not a valid component." );
- }
- }
-
- $this->components = $components;
- }
-
- /**
- * Return the components for this Uri
- * @return Array
- */
- public function getComponents() {
- return $this->components;
- }
-
- /**
- * Return the value of a specific component
- *
- * @param $name string The name of the component to return
- * @param string|null
- */
- public function getComponent( $name ) {
- if ( isset( self::$componentAliases[$name] ) ) {
- // Component is an alias. Get the actual name.
- $alias = $name;
- $name = self::$componentAliases[$name];
- wfDebug( __METHOD__ . ": Converting alias $alias to canonical $name." );
- }
-
- if( !in_array( $name, self::$validComponents ) ) {
- // Component is invalid
- throw new MWException( __METHOD__ . ": $name is not a valid component." );
- } elseif( !empty( $this->components[$name] ) ) {
- // Component is valid and has a value.
- return $this->components[$name];
- } else {
- // Component is empty
- return null;
- }
- }
-
- /**
- * Set a component for this Uri
- * @param $name string The name of the component to set
- * @param $value string|null The value to set
- */
- public function setComponent( $name, $value ) {
- if ( isset( self::$componentAliases[$name] ) ) {
- $alias = $name;
- $name = self::$componentAliases[$name];
- wfDebug( __METHOD__ . ": Converting alias $alias to canonical $name." );
- } elseif ( !in_array( $name, self::$validComponents ) ) {
- throw new MWException( __METHOD__ . ": $name is not a valid component." );
- }
- $this->components[$name] = $value;
- }
-
- public function getProtocol() { return $this->getComponent( 'scheme' ); }
- public function getUser() { return $this->getComponent( 'user' ); }
- public function getPassword() { return $this->getComponent( 'pass' ); }
- public function getHost() { return $this->getComponent( 'host' ); }
- public function getPort() { return $this->getComponent( 'port' ); }
- public function getPath() { return $this->getComponent( 'path' ); }
- public function getQueryString() { return $this->getComponent( 'query' ); }
- public function getFragment() { return $this->getComponent( 'fragment' ); }
-
- public function setProtocol( $scheme ) { $this->setComponent( 'scheme', $scheme ); }
- public function setUser( $user ) { $this->setComponent( 'user', $user ); }
- public function setPassword( $pass ) { $this->setComponent( 'pass', $pass ); }
- public function setHost( $host ) { $this->setComponent( 'host', $host ); }
- public function setPort( $port ) { $this->setComponent( 'port', $port ); }
- public function setPath( $path ) { $this->setComponent( 'path', $path ); }
- public function setFragment( $fragment ) { $this->setComponent( 'fragment', $fragment ); }
-
- /**
- * Gets the protocol-authority delimiter of a URI (:// or //).
- * @return string|null
- */
- public function getDelimiter() {
- $delimiter = $this->getComponent( 'delimiter' );
- if ( $delimiter ) {
- // A specific delimiter is set, so return it.
- return $delimiter;
- }
- if ( $this->getAuthority() && $this->getProtocol() ) {
- // If the URI has a protocol and a body (i.e., some sort of host, etc.)
- // the default delimiter is "://", e.g., "http://test.com".
- return '://';
- }
- return null;
- }
-
- /**
- * Gets query portion of a URI in array format.
- * @return string
- */
- public function getQuery() {
- return wfCgiToArray( $this->getQueryString() );
- }
-
- /**
- * Gets query portion of a URI.
- * @param string|array $query
- */
- public function setQuery( $query ) {
- if ( is_array( $query ) ) {
- $query = wfArrayToCGI( $query );
- }
- $this->setComponent( 'query', $query );
- }
-
- /**
- * Extend the query -- supply query parameters to override or add to ours
- * @param Array|string $parameters query parameters to override or add
- * @return Uri this URI object
- */
- public function extendQuery( $parameters ) {
- if ( !is_array( $parameters ) ) {
- $parameters = wfCgiToArray( $parameters );
- }
-
- $query = $this->getQuery();
- foreach( $parameters as $key => $value ) {
- $query[$key] = $value;
- }
-
- $this->setQuery( $query );
- return $this;
- }
-
- /**
- * Returns user and password portion of a URI.
- * @return string
- */
- public function getUserInfo() {
- $user = $this->getComponent( 'user' );
- $pass = $this->getComponent( 'pass' );
- return $pass ? "$user:$pass" : $user;
- }
-
- /**
- * Gets host and port portion of a URI.
- * @return string
- */
- public function getHostPort() {
- $host = $this->getComponent( 'host' );
- $port = $this->getComponent( 'port' );
- return $port ? "$host:$port" : $host;
- }
-
- /**
- * Returns the userInfo and host and port portion of the URI.
- * In most real-world URLs, this is simply the hostname, but it is more general.
- * @return string
- */
- public function getAuthority() {
- $userinfo = $this->getUserInfo();
- $hostinfo = $this->getHostPort();
- return $userinfo ? "$userinfo@$hostinfo" : $hostinfo;
- }
-
- /**
- * Returns everything after the authority section of the URI
- * @return String
- */
- public function getRelativePath() {
- $path = $this->getComponent( 'path' );
- $query = $this->getComponent( 'query' );
- $fragment = $this->getComponent( 'fragment' );
-
- $retval = $path;
- if( $query ) {
- $retval .= "?$query";
- }
- if( $fragment ) {
- $retval .= "#$fragment";
- }
- return $retval;
- }
-
- /**
- * Gets the entire URI string. May not be precisely the same as input due to order of query arguments.
- * @return String the URI string
- */
- public function toString() {
- return $this->getComponent( 'scheme' ) . $this->getDelimiter() . $this->getAuthority() . $this->getRelativePath();
- }
-
- /**
- * Gets the entire URI string. May not be precisely the same as input due to order of query arguments.
- * @return String the URI string
- */
- public function __toString() {
- return $this->toString();
- }
-
-}
diff --git a/includes/WikiPage.php b/includes/WikiPage.php
index 511f83a4f682..770c37a2a47a 100644
--- a/includes/WikiPage.php
+++ b/includes/WikiPage.php
@@ -1356,20 +1356,20 @@ class WikiPage extends Page implements IDBAccessObject {
return $ret;
}
- /**
- * Get the content that needs to be saved in order to undo all revisions
- * between $undo and $undoafter. Revisions must belong to the same page,
- * must exist and must not be deleted
- * @param $undo Revision
- * @param $undoafter Revision Must be an earlier revision than $undo
- * @return mixed string on success, false on failure
- * @since 1.21
- * Before we had the Content object, this was done in getUndoText
- */
- public function getUndoContent( Revision $undo, Revision $undoafter = null ) {
- $handler = $undo->getContentHandler();
- return $handler->getUndoContent( $this->getRevision(), $undo, $undoafter );
- }
+ /**
+ * Get the content that needs to be saved in order to undo all revisions
+ * between $undo and $undoafter. Revisions must belong to the same page,
+ * must exist and must not be deleted
+ * @param $undo Revision
+ * @param $undoafter Revision Must be an earlier revision than $undo
+ * @return mixed string on success, false on failure
+ * @since 1.21
+ * Before we had the Content object, this was done in getUndoText
+ */
+ public function getUndoContent( Revision $undo, Revision $undoafter = null ) {
+ $handler = $undo->getContentHandler();
+ return $handler->getUndoContent( $this->getRevision(), $undo, $undoafter );
+ }
/**
* Get the text that needs to be saved in order to undo all revisions
diff --git a/includes/actions/EditAction.php b/includes/actions/EditAction.php
index 1c97b26c50ea..08a33f4c0d9f 100644
--- a/includes/actions/EditAction.php
+++ b/includes/actions/EditAction.php
@@ -71,4 +71,4 @@ class SubmitAction extends EditAction {
parent::show();
}
-} \ No newline at end of file
+}
diff --git a/includes/api/ApiParse.php b/includes/api/ApiParse.php
index 2b3cd8d175da..312e43963d2b 100644
--- a/includes/api/ApiParse.php
+++ b/includes/api/ApiParse.php
@@ -355,8 +355,9 @@ class ApiParse extends ApiBase {
$this->content = $page->getContent( Revision::RAW ); //XXX: really raw?
if ( $this->section !== false ) {
- $this->content = $this->getSectionContent( $this->content, !is_null( $pageId )
- ? 'page id ' . $pageId : $page->getTitle()->getText() );
+ $this->content = $this->getSectionContent(
+ $this->content,
+ !is_null( $pageId ) ? 'page id ' . $pageId : $page->getTitle()->getText() );
// Not cached (save or load)
return $this->content->getParserOutput( $page->getTitle(), $popts );
diff --git a/includes/api/ApiPurge.php b/includes/api/ApiPurge.php
index 3cf32adc917d..dbfa89cbcf35 100644
--- a/includes/api/ApiPurge.php
+++ b/includes/api/ApiPurge.php
@@ -89,7 +89,6 @@ class ApiPurge extends ApiBase {
global $wgEnableParserCache;
$popts = $page->makeParserOptions( 'canonical' );
- $popts->setTidy( true );
# Parse content; note that HTML generation is only needed if we want to cache the result.
$content = $page->getContent( Revision::RAW );
diff --git a/includes/api/ApiQueryRevisions.php b/includes/api/ApiQueryRevisions.php
index 731fff9c12b2..5aff1e95fa0a 100644
--- a/includes/api/ApiQueryRevisions.php
+++ b/includes/api/ApiQueryRevisions.php
@@ -805,10 +805,10 @@ class ApiQueryRevisions extends ApiQueryBase {
return array_merge( parent::getPossibleErrors(), array(
array( 'nosuchrevid', 'diffto' ),
array( 'code' => 'revids', 'info' => 'The revids= parameter may not be used with the list options '
- . '(limit, startid, endid, dirNewer, start, end).' ),
+ . '(limit, startid, endid, dirNewer, start, end).' ),
array( 'code' => 'multpages', 'info' => 'titles, pageids or a generator was used to supply multiple pages, '
- . ' but the limit, startid, endid, dirNewer, user, excludeuser, '
- . 'start and end parameters may only be used on a single page.' ),
+ . ' but the limit, startid, endid, dirNewer, user, excludeuser, '
+ . 'start and end parameters may only be used on a single page.' ),
array( 'code' => 'diffto', 'info' => 'rvdiffto must be set to a non-negative number, "prev", "next" or "cur"' ),
array( 'code' => 'badparams', 'info' => 'start and startid cannot be used together' ),
array( 'code' => 'badparams', 'info' => 'end and endid cannot be used together' ),
diff --git a/includes/cache/MessageCache.php b/includes/cache/MessageCache.php
index 3ae26d0a1caf..af380506eaa2 100644
--- a/includes/cache/MessageCache.php
+++ b/includes/cache/MessageCache.php
@@ -776,12 +776,14 @@ class MessageCache {
wfDebugLog( 'MessageCache', __METHOD__ . ": failed to load message page text for {$title} ($code)" );
$message = null; // no negative caching
} else {
- #XXX: Is this the right way to turn a Content object into a message?
+ // XXX: Is this the right way to turn a Content object into a message?
+ // NOTE: $content is typically either WikitextContent, JavaScriptContent or CssContent.
+ // MessageContent is *not* used for storing messages, it's only used for wrapping them when needed.
$message = $content->getWikitextForTransclusion();
if ( $message === false || $message === null ) {
wfDebugLog( 'MessageCache', __METHOD__ . ": message content doesn't provide wikitext "
- . "(content model: #" . $content->getContentHandler() . ")" );
+ . "(content model: " . $content->getContentHandler() . ")" );
$message = false; // negative caching
} else {
diff --git a/includes/content/AbstractContent.php b/includes/content/AbstractContent.php
index 7511ec985797..860b4c38e666 100644
--- a/includes/content/AbstractContent.php
+++ b/includes/content/AbstractContent.php
@@ -86,7 +86,7 @@ abstract class AbstractContent implements Content {
*/
protected function checkFormat( $format ) {
if ( !$this->isSupportedFormat( $format ) ) {
- throw new MWException( "Format $format is not supported for content model " .
+ throw new MWException( "Format $format is not supported for content model " .
$this->getModel() );
}
}
@@ -102,7 +102,7 @@ abstract class AbstractContent implements Content {
* @see Content::isEmpty()
*/
public function isEmpty() {
- return $this->getSize() == 0;
+ return $this->getSize() === 0;
}
/**
diff --git a/includes/content/Content.php b/includes/content/Content.php
index a972e67f1c36..6cb9d8937277 100644
--- a/includes/content/Content.php
+++ b/includes/content/Content.php
@@ -54,7 +54,7 @@ interface Content {
* string, a nested array structure, an object, a binary blob...
* anything, really.
*
- * @NOTE: review all calls carefully, caller must be aware of content model!
+ * @NOTE: Caller must be aware of content model!
*/
public function getNativeData( );
@@ -171,7 +171,7 @@ interface Content {
*
* - Will return false if $that is null.
* - Will return true if $that === $this.
- * - Will return false if $that->getModelName() != $this->getModel().
+ * - Will return false if $that->getModel() != $this->getModel().
* - Will return false if $that->getNativeData() is not equal to $this->getNativeData(),
* where the meaning of "equal" depends on the actual data model.
*
@@ -198,7 +198,7 @@ interface Content {
* - $original->equals( $copy )
*
* If and only if the Content object is immutable, the copy() method can and
- * should return $this. That is, $copy === $original may be true, but only
+ * should return $this. That is, $copy === $original may be true, but only
* for immutable content objects.
*
* @since 1.21
@@ -219,7 +219,7 @@ interface Content {
* find out.
* @return boolean
*/
- public function isCountable( $hasLinks = null ) ;
+ public function isCountable( $hasLinks = null );
/**
@@ -312,7 +312,7 @@ interface Content {
*
* There is usually no need to override the default behaviour, subclasses that
* want to implement redirects should override getRedirectTarget().
- *
+ *
* @since 1.21
*
* @return Title
@@ -459,10 +459,8 @@ interface Content {
public function matchMagicWord( MagicWord $word );
# TODO: ImagePage and CategoryPage interfere with per-content action handlers
- # TODO: make sure WikiSearch extension still works
- # TODO: make sure ReplaceTemplates extension still works
# TODO: nice&sane integration of GeSHi syntax highlighting
- # [11:59] <vvv> Hooks are ugly; make CodeHighlighter interface and a
+ # [11:59] <vvv> Hooks are ugly; make CodeHighlighter interface and a
# config to set the class which handles syntax highlighting
# [12:00] <vvv> And default it to a DummyHighlighter
} \ No newline at end of file
diff --git a/includes/content/TextContent.php b/includes/content/TextContent.php
index 068b65e992f8..68e6c3913d93 100644
--- a/includes/content/TextContent.php
+++ b/includes/content/TextContent.php
@@ -57,7 +57,7 @@ abstract class TextContent extends AbstractContent {
return false;
}
- if ( $wgArticleCountMethod === 'any' ) {
+ if ( $wgArticleCountMethod === 'any' ) {
return true;
}
diff --git a/includes/content/WikitextContent.php b/includes/content/WikitextContent.php
index 95265209783f..b660fc092ddb 100644
--- a/includes/content/WikitextContent.php
+++ b/includes/content/WikitextContent.php
@@ -17,7 +17,7 @@ class WikitextContent extends TextContent {
$text = $this->getNativeData();
$sect = $wgParser->getSection( $text, $section, false );
- return new WikitextContent( $sect );
+ return new WikitextContent( $sect );
}
/**
diff --git a/includes/diff/DifferenceEngine.php b/includes/diff/DifferenceEngine.php
index 233e593417e6..18dcfe9e5ad2 100644
--- a/includes/diff/DifferenceEngine.php
+++ b/includes/diff/DifferenceEngine.php
@@ -713,7 +713,7 @@ class DifferenceEngine extends ContextSource {
function generateContentDiffBody( Content $old, Content $new ) {
if ( !( $old instanceof TextContent ) ) {
throw new MWException( "Diff not implemented for " . get_class( $old ) . "; "
- . "override generateContentDiffBody to fix this." );
+ . "override generateContentDiffBody to fix this." );
}
if ( !( $new instanceof TextContent ) ) {
diff --git a/includes/installer/Installer.php b/includes/installer/Installer.php
index 8140527839ca..c673f6fe9fdc 100644
--- a/includes/installer/Installer.php
+++ b/includes/installer/Installer.php
@@ -1600,10 +1600,10 @@ abstract class Installer {
);
$page->doEditContent( $content,
- '',
- EDIT_NEW,
- false,
- User::newFromName( 'MediaWiki default' ) );
+ '',
+ EDIT_NEW,
+ false,
+ User::newFromName( 'MediaWiki default' ) );
} catch (MWException $e) {
//using raw, because $wgShowExceptionDetails can not be set yet
$status->fatal( 'config-install-mainpage-failed', $e->getMessage() );
diff --git a/includes/installer/SqliteUpdater.php b/includes/installer/SqliteUpdater.php
index 1c2443157a06..e26aa78b6881 100644
--- a/includes/installer/SqliteUpdater.php
+++ b/includes/installer/SqliteUpdater.php
@@ -96,12 +96,13 @@ class SqliteUpdater extends DatabaseUpdater {
array( 'dropField', 'category', 'cat_hidden', 'patch-cat_hidden.sql' ),
// 1.21
- array( 'addField', 'revision', 'rev_content_format', 'patch-revision-rev_content_format.sql' ),
- array( 'addField', 'revision', 'rev_content_model', 'patch-revision-rev_content_model.sql' ),
- array( 'addField', 'archive', 'ar_content_format', 'patch-archive-ar_content_format.sql' ),
- array( 'addField', 'archive', 'ar_content_model', 'patch-archive-ar_content_model.sql' ),
- array( 'addField', 'page', 'page_content_model', 'patch-page-page_content_model.sql' ),
- array( 'dropField', 'site_stats', 'ss_admins', 'patch-drop-ss_admins.sql' ),
+ array( 'addField', 'revision', 'rev_content_format', 'patch-revision-rev_content_format.sql' ),
+ array( 'addField', 'revision', 'rev_content_model', 'patch-revision-rev_content_model.sql' ),
+ array( 'addField', 'archive', 'ar_content_format', 'patch-archive-ar_content_format.sql' ),
+ array( 'addField', 'archive', 'ar_content_model', 'patch-archive-ar_content_model.sql' ),
+ array( 'addField', 'page', 'page_content_model', 'patch-page-page_content_model.sql' ),
+
+ array( 'dropField', 'site_stats', 'ss_admins', 'patch-drop-ss_admins.sql' ),
array( 'dropField', 'recentchanges', 'rc_moved_to_title', 'patch-rc_moved.sql' ),
);
}
diff --git a/includes/upload/UploadFromUrl.php b/includes/upload/UploadFromUrl.php
index fa9ee6f45cfa..7f430c50ad94 100644
--- a/includes/upload/UploadFromUrl.php
+++ b/includes/upload/UploadFromUrl.php
@@ -72,9 +72,8 @@ class UploadFromUrl extends UploadBase {
if ( !count( $wgCopyUploadsDomains ) ) {
return true;
}
- $uri = new Uri( $url );
- $parsedDomain = $uri->getHost();
- if ( $parsedDomain === null ) {
+ $parsedUrl = wfParseUrl( $url );
+ if ( !$parsedUrl ) {
return false;
}
$valid = false;
diff --git a/languages/messages/MessagesGa.php b/languages/messages/MessagesGa.php
index b688fc1da5c2..cee9a1e28048 100644
--- a/languages/messages/MessagesGa.php
+++ b/languages/messages/MessagesGa.php
@@ -1771,9 +1771,6 @@ iarradh sábháil. Is dócha gur nasc chuig suíomh seachtrach ba chúis leis.',
'spamprotectionmatch' => 'Truicear ár scagaire dramhála ag an téacs seo a leanas: $1',
'spambot_username' => 'MediaWiki turscar glanadh',
-# Info page
-'pageinfo-subjectpage' => 'Leathanach',
-
# Skin names
'skinname-standard' => 'Clasaiceach',
'skinname-nostalgia' => 'Sean-nós',
diff --git a/languages/messages/MessagesQqq.php b/languages/messages/MessagesQqq.php
index 18cc47798420..734d5983a2ef 100644
--- a/languages/messages/MessagesQqq.php
+++ b/languages/messages/MessagesQqq.php
@@ -1060,7 +1060,8 @@ Please report at [[Support]] if you are unable to properly translate this messag
'moveddeleted-notice' => 'Shown on top of a deleted page in normal view modus ([http://translatewiki.net/wiki/Test example]).',
'edit-conflict' => "An 'Edit conflict' happens when more than one edit is being made to a page at the same time. This would usually be caused by separate individuals working on the same page. However, if the system is slow, several edits from one individual could back up and attempt to apply simultaneously - causing the conflict.",
'defaultmessagetext' => 'Caption above the default message text shown on the left-hand side of a diff displayed after clicking “Show changes” when creating a new page in the MediaWiki: namespace',
-'invalid-content-data' => 'Error message indicating that the page\'s content can not be saved because it is invalid. This may occurr for some non-text content types.',
+'content-failed-to-parse' => "Error message indicating that the page\'s content can not be saved because it is syntactically invalid. This may occurr for content types using serialization or a strict markup syntax.",
+'invalid-content-data' => 'Error message indicating that the page\'s content can not be saved because it is invalid. This may occurr for content types with internal consistency constraints.',
'content-not-allowed-here' => 'Error message indicating that the desired content model is not supported in given localtion.
* $1 is the human readable name of the content model
* $1 is the title of the page in question.',
diff --git a/maintenance/importSiteScripts.php b/maintenance/importSiteScripts.php
index e25ee2be64d1..fabc6dc6bb06 100644
--- a/maintenance/importSiteScripts.php
+++ b/maintenance/importSiteScripts.php
@@ -56,12 +56,9 @@ class ImportSiteScripts extends Maintenance {
}
$this->output( "Importing $page\n" );
- $uri = new Uri( $baseUrl );
- $uri->extendQuery( array(
+ $url = wfAppendQuery( $baseUrl, array(
'action' => 'raw',
'title' => "MediaWiki:{$page}" ) );
- $url = $uri->toString();
-
$text = Http::get( $url );
$wikiPage = WikiPage::factory( $title );
@@ -83,9 +80,7 @@ class ImportSiteScripts extends Maintenance {
$pages = array();
do {
- $uri = new Uri( $baseUrl );
- $uri->extendQuery( $data );
- $url = $uri->toString();
+ $url = wfAppendQuery( $baseUrl, $data );
$strResult = Http::get( $url );
//$result = FormatJson::decode( $strResult ); // Still broken
$result = unserialize( $strResult );
diff --git a/maintenance/language/messages.inc b/maintenance/language/messages.inc
index 4d2542f9dc29..86db0a571fe8 100644
--- a/maintenance/language/messages.inc
+++ b/maintenance/language/messages.inc
@@ -689,6 +689,15 @@ $wgMessageStructure = array(
'addsection-preload',
'addsection-editintro',
'defaultmessagetext',
+ 'content-failed-to-parse',
+ 'invalid-content-data',
+ 'content-not-allowed-here',
+ ),
+ 'contentmodel' => array(
+ 'content-model-wikitext',
+ 'content-model-text',
+ 'content-model-javascript',
+ 'content-model-css',
),
'parserwarnings' => array(
'expensive-parserfunction-warning',
diff --git a/tests/phpunit/MediaWikiTestCase.php b/tests/phpunit/MediaWikiTestCase.php
index 5285288229fd..8d78e50867cd 100644
--- a/tests/phpunit/MediaWikiTestCase.php
+++ b/tests/phpunit/MediaWikiTestCase.php
@@ -135,11 +135,11 @@ abstract class MediaWikiTestCase extends PHPUnit_Framework_TestCase {
foreach ( $this->restoreGlobals as $var ) {
$v = $GLOBALS[ $var ];
- if ( is_object( $v ) || is_array( $v ) ) {
+ if ( is_object( $v ) ) {
$v = clone $v;
}
- $this->savedGlobals[ $var ] = $v;
+ $this->savedGlobals[$var] = $v;
}
}
diff --git a/tests/phpunit/includes/ContentHandlerTest.php b/tests/phpunit/includes/ContentHandlerTest.php
index 4db4754b1053..797a3eedd812 100644
--- a/tests/phpunit/includes/ContentHandlerTest.php
+++ b/tests/phpunit/includes/ContentHandlerTest.php
@@ -321,8 +321,7 @@ class DummyContentForTesting extends AbstractContent {
* @return String a string representing the content in a way useful for building a full text search index.
* If no useful representation exists, this method returns an empty string.
*/
- public function getTextForSearchIndex()
- {
+ public function getTextForSearchIndex() {
return '';
}
@@ -330,8 +329,7 @@ class DummyContentForTesting extends AbstractContent {
* @return String the wikitext to include when another page includes this content, or false if the content is not
* includable in a wikitext page.
*/
- public function getWikitextForTransclusion()
- {
+ public function getWikitextForTransclusion() {
return false;
}
@@ -341,8 +339,7 @@ class DummyContentForTesting extends AbstractContent {
* @param int $maxlength maximum length of the summary text
* @return String the summary text
*/
- public function getTextForSummary( $maxlength = 250 )
- {
+ public function getTextForSummary( $maxlength = 250 ) {
return '';
}
@@ -363,8 +360,7 @@ class DummyContentForTesting extends AbstractContent {
*
* @return int
*/
- public function getSize()
- {
+ public function getSize() {
return strlen( $this->data );
}
@@ -382,8 +378,7 @@ class DummyContentForTesting extends AbstractContent {
*
* @return Content. A copy of this object
*/
- public function copy()
- {
+ public function copy() {
return $this;
}
@@ -395,8 +390,7 @@ class DummyContentForTesting extends AbstractContent {
* to avoid redundant parsing to find out.
* @return boolean
*/
- public function isCountable( $hasLinks = null )
- {
+ public function isCountable( $hasLinks = null ) {
return false;
}
@@ -410,8 +404,7 @@ class DummyContentForTesting extends AbstractContent {
*
* @return ParserOutput
*/
- public function getParserOutput( Title $title, $revId = null, ParserOptions $options = NULL, $generateHtml = true )
- {
+ public function getParserOutput( Title $title, $revId = null, ParserOptions $options = NULL, $generateHtml = true ) {
return new ParserOutput( $this->getNativeData() );
}
}
diff --git a/tests/phpunit/includes/GlobalFunctions/GlobalTest.php b/tests/phpunit/includes/GlobalFunctions/GlobalTest.php
index 129f271bf06a..9097d301f594 100644
--- a/tests/phpunit/includes/GlobalFunctions/GlobalTest.php
+++ b/tests/phpunit/includes/GlobalFunctions/GlobalTest.php
@@ -108,7 +108,7 @@ class GlobalTest extends MediaWikiTestCase {
array( array( 'foo' => 1 ), 'foo=1' ), // number test
array( array( 'foo' => true ), 'foo=1' ), // true test
array( array( 'foo' => false ), '' ), // false test
- array( array( 'foo' => null ), 'foo' ), // null test
+ array( array( 'foo' => null ), '' ), // null test
array( array( 'foo' => 'A&B=5+6@!"\'' ), 'foo=A%26B%3D5%2B6%40%21%22%27' ), // urlencoding test
array( array( 'foo' => 'bar', 'baz' => 'is', 'asdf' => 'qwerty' ), 'foo=bar&baz=is&asdf=qwerty' ), // multi-item test
array( array( 'foo' => array( 'bar' => 'baz' ) ), 'foo%5Bbar%5D=baz' ),
diff --git a/tests/phpunit/includes/LinksUpdateTest.php b/tests/phpunit/includes/LinksUpdateTest.php
index 5267e572327d..3d5f570458b0 100644
--- a/tests/phpunit/includes/LinksUpdateTest.php
+++ b/tests/phpunit/includes/LinksUpdateTest.php
@@ -151,6 +151,7 @@ class LinksUpdateTest extends MediaWikiTestCase {
protected function assertLinksUpdate( Title $title, ParserOutput $parserOutput, $table, $fields, $condition, array $expectedRows ) {
$update = new LinksUpdate( $title, $parserOutput );
+ //NOTE: make sure LinksUpdate does not generate warnings when called inside a transaction.
$update->beginTransaction();
$update->doUpdate();
$update->commitTransaction();
diff --git a/tests/phpunit/includes/TimestampTest.php b/tests/phpunit/includes/TimestampTest.php
index fd4ceb725775..2dd02e3cdc85 100644
--- a/tests/phpunit/includes/TimestampTest.php
+++ b/tests/phpunit/includes/TimestampTest.php
@@ -43,15 +43,8 @@ class TimestampTest extends MediaWikiTestCase {
* Test human readable timestamp format.
*/
function testHumanOutput() {
- global $wgLang;
-
- $wgLang = Language::factory( 'es' );
- $timestamp = new MWTimestamp( time() - 3600 );
- $this->assertEquals( "hace una hora", $timestamp->getHumanTimestamp()->toString() );
-
- $wgLang = Language::factory( 'en' );
$timestamp = new MWTimestamp( time() - 3600 );
- $this->assertEquals( "1 hour ago", $timestamp->getHumanTimestamp()->toString() );
+ $this->assertEquals( "1 hour ago", $timestamp->getHumanTimestamp()->inLanguage( 'en' )->text() );
}
/**
diff --git a/tests/phpunit/includes/UriTest.php b/tests/phpunit/includes/UriTest.php
deleted file mode 100644
index 3b78f470191e..000000000000
--- a/tests/phpunit/includes/UriTest.php
+++ /dev/null
@@ -1,164 +0,0 @@
-<?php
-
-class UriTest extends MediaWikiTestCase {
-
- function setUp() {
- AutoLoader::loadClass( 'Uri' );
- }
-
- function dataUris() {
- return array(
- array(
- 'http://example.com/',
- array(
- 'scheme' => 'http',
- 'delimiter' => '://',
- 'user' => null,
- 'pass' => null,
- 'host' => 'example.com',
- 'port' => null,
- 'path' => '/',
- 'query' => null,
- 'fragment' => null,
- ),
- ),
- array(
- '//mediawiki.org/wiki/Main_Page',
- array(
- 'scheme' => null,
- 'delimiter' => '//',
- 'user' => null,
- 'pass' => null,
- 'host' => 'mediawiki.org',
- 'port' => null,
- 'path' => '/wiki/Main_Page',
- 'query' => null,
- 'fragment' => null,
- ),
- ),
- array(
- 'http://user:pass@example.com/',
- array(
- 'scheme' => 'http',
- 'delimiter' => '://',
- 'user' => 'user',
- 'pass' => 'pass',
- 'host' => 'example.com',
- 'port' => null,
- 'path' => '/',
- 'query' => null,
- 'fragment' => null,
- ),
- ),
- array(
- '/?asdf=asdf',
- array(
- 'scheme' => null,
- 'delimiter' => null,
- 'user' => null,
- 'pass' => null,
- 'host' => null,
- 'port' => null,
- 'path' => '/',
- 'query' => 'asdf=asdf',
- 'fragment' => null,
- ),
- ),
- array(
- '?asdf=asdf#asdf',
- array(
- 'scheme' => null,
- 'delimiter' => null,
- 'user' => null,
- 'pass' => null,
- 'host' => null,
- 'port' => null,
- 'path' => null,
- 'query' => 'asdf=asdf',
- 'fragment' => 'asdf',
- ),
- )
- );
- }
-
- /**
- * Ensure that get* methods properly match the appropriate getComponent( key ) value
- * @dataProvider dataUris
- */
- function testGetters( $uri ) {
- $uri = new Uri( $uri );
- $getterMap = array(
- 'getProtocol' => 'scheme',
- 'getUser' => 'user',
- 'getPassword' => 'pass',
- 'getHost' => 'host',
- 'getPort' => 'port',
- 'getPath' => 'path',
- 'getQueryString' => 'query',
- 'getFragment' => 'fragment',
- );
- foreach ( $getterMap as $fn => $c ) {
- $this->assertSame( $uri->{$fn}(), $uri->getComponent( $c ), "\$uri->{$fn}(); matches \$uri->getComponent( '$c' );" );
- }
- }
-
- /**
- * Ensure that Uri has the proper components for our example uris
- * @dataProvider dataUris
- */
- function testComponents( $uri, $components ) {
- $uri = new Uri( $uri );
-
- $this->assertSame( $components['scheme'], $uri->getProtocol(), 'Correct scheme' );
- $this->assertSame( $components['delimiter'], $uri->getDelimiter(), 'Correct delimiter' );
- $this->assertSame( $components['user'], $uri->getUser(), 'Correct user' );
- $this->assertSame( $components['pass'], $uri->getPassword(), 'Correct pass' );
- $this->assertSame( $components['host'], $uri->getHost(), 'Correct host' );
- $this->assertSame( $components['port'], $uri->getPort(), 'Correct port' );
- $this->assertSame( $components['path'], $uri->getPath(), 'Correct path' );
- $this->assertSame( $components['query'], $uri->getQueryString(), 'Correct query' );
- $this->assertSame( $components['fragment'], $uri->getFragment(), 'Correct fragment' );
- }
-
- /**
- * Ensure that the aliases work for various components.
- */
- function testAliases() {
- $url = "//myuser@test.com";
- $uri = new Uri( $url );
-
- // Set the aliases.
- $uri->setComponent( 'protocol', 'https' );
- $uri->setComponent( 'password', 'mypass' );
-
- // Now try getting them.
- $this->assertSame( 'https', $uri->getComponent( 'protocol' ), 'Correct protocol (alias for scheme)' );
- $this->assertSame( 'mypass', $uri->getComponent( 'password' ), 'Correct password (alias for pass)' );
-
- // Finally check their actual names.
- $this->assertSame( 'https', $uri->getProtocol(), 'Alias for scheme works' );
- $this->assertSame( 'mypass', $uri->getPassword(), 'Alias for pass works' );
- }
-
- /**
- * Ensure that Uri's helper methods return the correct data
- */
- function testHelpers() {
- $uri = new Uri( 'http://a:b@example.com:8080/path?query=value' );
-
- $this->assertSame( 'a:b', $uri->getUserInfo(), 'Correct getUserInfo' );
- $this->assertSame( 'example.com:8080', $uri->getHostPort(), 'Correct getHostPort' );
- $this->assertSame( 'a:b@example.com:8080', $uri->getAuthority(), 'Correct getAuthority' );
- $this->assertSame( '/path?query=value', $uri->getRelativePath(), 'Correct getRelativePath' );
- $this->assertSame( 'http://a:b@example.com:8080/path?query=value', $uri->toString(), 'Correct toString' );
- }
-
- /**
- * Ensure that Uri's extend method properly overrides keys
- */
- function testExtend() {
- $uri = new Uri( 'http://example.org/?a=b&hello=world' );
- $uri->extendQuery( 'a=c&foo=bar' );
- $this->assertSame( 'a=c&hello=world&foo=bar', $uri->getQueryString() );
- }
-}
diff --git a/tests/phpunit/includes/WikiPageTest.php b/tests/phpunit/includes/WikiPageTest.php
index 23a4a011241e..1e34e5184697 100644
--- a/tests/phpunit/includes/WikiPageTest.php
+++ b/tests/phpunit/includes/WikiPageTest.php
@@ -12,22 +12,23 @@ class WikiPageTest extends MediaWikiLangTestCase {
function __construct( $name = null, array $data = array(), $dataName = '' ) {
parent::__construct( $name, $data, $dataName );
- $this->tablesUsed = array_merge ( $this->tablesUsed,
- array( 'page',
- 'revision',
- 'text',
+ $this->tablesUsed = array_merge (
+ $this->tablesUsed,
+ array( 'page',
+ 'revision',
+ 'text',
- 'recentchanges',
- 'logging',
+ 'recentchanges',
+ 'logging',
- 'page_props',
- 'pagelinks',
- 'categorylinks',
- 'langlinks',
- 'externallinks',
- 'imagelinks',
- 'templatelinks',
- 'iwlinks' ) );
+ 'page_props',
+ 'pagelinks',
+ 'categorylinks',
+ 'langlinks',
+ 'externallinks',
+ 'imagelinks',
+ 'templatelinks',
+ 'iwlinks' ) );
}
public function setUp() {
@@ -98,8 +99,8 @@ class WikiPageTest extends MediaWikiLangTestCase {
$page = $this->newPage( $title );
$content = ContentHandler::makeContent( "[[Lorem ipsum]] dolor sit amet, consetetur sadipscing elitr, sed diam "
- . " nonumy eirmod tempor invidunt ut labore et dolore magna aliquyam erat.",
- $title, CONTENT_MODEL_WIKITEXT );
+ . " nonumy eirmod tempor invidunt ut labore et dolore magna aliquyam erat.",
+ $title, CONTENT_MODEL_WIKITEXT );
$page->doEditContent( $content, "[[testing]] 1" );
diff --git a/tests/phpunit/includes/WikitextContentHandlerTest.php b/tests/phpunit/includes/WikitextContentHandlerTest.php
index a7615cfb4877..8aeb529e8e53 100644
--- a/tests/phpunit/includes/WikitextContentHandlerTest.php
+++ b/tests/phpunit/includes/WikitextContentHandlerTest.php
@@ -181,7 +181,7 @@ class WikitextContentHandlerTest extends MediaWikiTestCase {
}
/**
- * @todo Text case required database!
+ * @todo Text case requires database, should be done by a test class in the Database group
*/
/*
public function testGetAutoDeleteReason( Title $title, &$hasHistory ) {
@@ -189,7 +189,7 @@ class WikitextContentHandlerTest extends MediaWikiTestCase {
*/
/**
- * @todo Text case required database!
+ * @todo Text case requires database, should be done by a test class in the Database group
*/
/*
public function testGetUndoContent( Revision $current, Revision $undo, Revision $undoafter = null ) {
diff --git a/tests/phpunit/includes/WikitextContentTest.php b/tests/phpunit/includes/WikitextContentTest.php
index 8d69cf7610cc..dac80412cfa6 100644
--- a/tests/phpunit/includes/WikitextContentTest.php
+++ b/tests/phpunit/includes/WikitextContentTest.php
@@ -76,13 +76,13 @@ class WikitextContentTest extends MediaWikiTestCase {
// make updates accessible by class name
foreach ( $updates as $update ) {
$class = get_class( $update );
- $updates[ $class ] = $update;
+ $updates[$class] = $update;
}
foreach ( $expectedStuff as $class => $fieldValues ) {
$this->assertArrayHasKey( $class, $updates, "missing an update of type $class" );
- $update = $updates[ $class ];
+ $update = $updates[$class];
foreach ( $fieldValues as $field => $value ) {
$v = $update->$field; #if the field doesn't exist, just crash and burn
@@ -257,8 +257,11 @@ just a test"
$content = $this->newContent( $text );
$t = $content->getRedirectTarget( );
- if ( is_null( $expected ) ) $this->assertNull( $t, "text should not have generated a redirect target: $text" );
- else $this->assertEquals( $expected, $t->getPrefixedText() );
+ if ( is_null( $expected ) ) {
+ $this->assertNull( $t, "text should not have generated a redirect target: $text" );
+ } else {
+ $this->assertEquals( $expected, $t->getPrefixedText() );
+ }
}
/**
@@ -272,7 +275,7 @@ just a test"
/**
- * @todo: test needs database!
+ * @todo: test needs database! Should be done by a test class in the Database group.
*/
/*
public function getRedirectChain() {
@@ -282,7 +285,7 @@ just a test"
*/
/**
- * @todo: test needs database!
+ * @todo: test needs database! Should be done by a test class in the Database group.
*/
/*
public function getUltimateRedirectTarget() {
diff --git a/tests/phpunit/includes/api/ApiEditPageTest.php b/tests/phpunit/includes/api/ApiEditPageTest.php
index 3a60c6aa3058..8eca9a350e94 100644
--- a/tests/phpunit/includes/api/ApiEditPageTest.php
+++ b/tests/phpunit/includes/api/ApiEditPageTest.php
@@ -15,11 +15,11 @@ class ApiEditPageTest extends ApiTestCase {
parent::setup();
- $wgExtraNamespaces[ 12312 ] = 'Dummy';
- $wgExtraNamespaces[ 12313 ] = 'Dummy_talk';
+ $wgExtraNamespaces[12312] = 'Dummy';
+ $wgExtraNamespaces[12313] = 'Dummy_talk';
- $wgNamespaceContentModels[ 12312 ] = "testing";
- $wgContentHandlers[ "testing" ] = 'DummyContentHandlerForTesting';
+ $wgNamespaceContentModels[12312] = "testing";
+ $wgContentHandlers["testing"] = 'DummyContentHandlerForTesting';
MWNamespace::getCanonicalNamespaces( true ); # reset namespace cache
$wgContLang->resetNamespaces(); # reset namespace cache
@@ -30,11 +30,11 @@ class ApiEditPageTest extends ApiTestCase {
public function teardown() {
global $wgExtraNamespaces, $wgNamespaceContentModels, $wgContentHandlers, $wgContLang;
- unset( $wgExtraNamespaces[ 12312 ] );
- unset( $wgExtraNamespaces[ 12313 ] );
+ unset( $wgExtraNamespaces[12312] );
+ unset( $wgExtraNamespaces[12313] );
- unset( $wgNamespaceContentModels[ 12312 ] );
- unset( $wgContentHandlers[ "testing" ] );
+ unset( $wgNamespaceContentModels[12312] );
+ unset( $wgContentHandlers["testing"] );
MWNamespace::getCanonicalNamespaces( true ); # reset namespace cache
$wgContLang->resetNamespaces(); # reset namespace cache
diff --git a/tests/phpunit/includes/filerepo/FileBackendTest.php b/tests/phpunit/includes/filerepo/FileBackendTest.php
index 8bc6043037a3..cb54bb66b7e6 100644
--- a/tests/phpunit/includes/filerepo/FileBackendTest.php
+++ b/tests/phpunit/includes/filerepo/FileBackendTest.php
@@ -1,9 +1,6 @@
<?php
/**
- * @group medium
- * ^---- causes phpunit to use a higher timeout threshold
- *
* @group FileRepo
* @group FileBackend
* @group medium
diff --git a/tests/phpunit/suite.xml b/tests/phpunit/suite.xml
index f4ee50093b2c..f286fa118784 100644
--- a/tests/phpunit/suite.xml
+++ b/tests/phpunit/suite.xml
@@ -11,8 +11,8 @@
timeoutForSmallTests="2"
timeoutForMediumTests="10"
timeoutForLargeTests="60"
- strict="false"
- verbose="false">
+ strict="true"
+ verbose="true">
<testsuites>
<testsuite name="includes">
<directory>includes</directory>
diff --git a/thumb.php b/thumb.php
index b813ee370e6f..068ec01700d4 100644
--- a/thumb.php
+++ b/thumb.php
@@ -71,9 +71,10 @@ function wfThumbHandle404() {
}
# Just get the URI path (REDIRECT_URL/REQUEST_URI is either a full URL or a path)
if ( substr( $uriPath, 0, 1 ) !== '/' ) {
- $uri = new Uri( $uriPath );
- $uriPath = $uri->getPath();
- if ( $uriPath === null ) {
+ $bits = wfParseUrl( $uriPath );
+ if ( $bits && isset( $bits['path'] ) ) {
+ $uriPath = $bits['path'];
+ } else {
wfThumbError( 404, 'The source file for the specified thumbnail does not exist.' );
return;
}