From 3d97704f91f29ebb63d4111bf1d01feb4d89e65b Mon Sep 17 00:00:00 2001 From: Siebrand Mazeland Date: Sat, 18 Aug 2012 16:51:00 +0200 Subject: [PATCH] Replace some deprecated method calls. Change-Id: Id4beca7b6821139fcc319c5694917e68668835ee --- includes/FeedUtils.php | 2 +- includes/upload/UploadFromUrl.php | 7 ++++--- maintenance/importSiteScripts.php | 9 +++++++-- tests/jasmine/spec_makers/makeJqueryMsgSpec.php | 3 ++- tests/phpunit/includes/ArticleTablesTest.php | 4 ++-- thumb.php | 7 +++---- 6 files changed, 19 insertions(+), 13 deletions(-) diff --git a/includes/FeedUtils.php b/includes/FeedUtils.php index 1c5e777481..16eba66f87 100644 --- a/includes/FeedUtils.php +++ b/includes/FeedUtils.php @@ -85,7 +85,7 @@ class FeedUtils { $row->rc_last_oldid, $row->rc_this_oldid, $timestamp, ($row->rc_deleted & Revision::DELETED_COMMENT) - ? wfMsgHtml('rev-deleted-comment') + ? wfMessage('rev-deleted-comment')->escaped() : $row->rc_comment, $actiontext ); diff --git a/includes/upload/UploadFromUrl.php b/includes/upload/UploadFromUrl.php index c11d7192a4..fdd2b1ae0b 100644 --- a/includes/upload/UploadFromUrl.php +++ b/includes/upload/UploadFromUrl.php @@ -70,13 +70,14 @@ class UploadFromUrl extends UploadBase { if ( !count( $wgCopyUploadsDomains ) ) { return true; } - $parsedUrl = wfParseUrl( $url ); - if ( !$parsedUrl ) { + $uri = new Uri( $url ); + $parsedDomain = $uri->getHost(); + if ( $parsedDomain === null ) { return false; } $valid = false; foreach( $wgCopyUploadsDomains as $domain ) { - if ( $parsedUrl['host'] === $domain ) { + if ( $parsedDomain === $domain ) { $valid = true; break; } diff --git a/maintenance/importSiteScripts.php b/maintenance/importSiteScripts.php index 65ac65afd8..b4a1bacf7f 100644 --- a/maintenance/importSiteScripts.php +++ b/maintenance/importSiteScripts.php @@ -56,9 +56,12 @@ class ImportSiteScripts extends Maintenance { } $this->output( "Importing $page\n" ); - $url = wfAppendQuery( $baseUrl, array( + $uri = new Uri( $baseUrl ); + $uri->extendQuery( array( 'action' => 'raw', 'title' => "MediaWiki:{$page}" ) ); + $url = $uri->toString(); + $text = Http::get( $url ); $wikiPage = WikiPage::factory( $title ); @@ -79,7 +82,9 @@ class ImportSiteScripts extends Maintenance { $pages = array(); do { - $url = wfAppendQuery( $baseUrl, $data ); + $uri = new Uri( $baseUrl ); + $uri->extendQuery( $data ); + $url = $uri->toString(); $strResult = Http::get( $url ); //$result = FormatJson::decode( $strResult ); // Still broken $result = unserialize( $strResult ); diff --git a/tests/jasmine/spec_makers/makeJqueryMsgSpec.php b/tests/jasmine/spec_makers/makeJqueryMsgSpec.php index 1ac8dcba56..9d75be4ec6 100644 --- a/tests/jasmine/spec_makers/makeJqueryMsgSpec.php +++ b/tests/jasmine/spec_makers/makeJqueryMsgSpec.php @@ -57,10 +57,11 @@ class MakeLanguageSpec extends Maintenance { foreach ( self::$keyToTestArgs as $key => $testArgs ) { foreach ($testArgs as $args) { // get the raw template, without any transformations - $template = wfMsgGetKey( $key, /* useDb */ true, $languageCode, /* transform */ false ); + $template = wfMessage( $key )->inLanguage( $languageCode )->plain(); // get the magic-parsed version with args $wfMsgExtArgs = array_merge( array( $key, $wfMsgExtOptions ), $args ); + // @todo FIXME: Use Message class. $result = call_user_func_array( 'wfMsgExt', $wfMsgExtArgs ); // record the template, args, language, and expected result diff --git a/tests/phpunit/includes/ArticleTablesTest.php b/tests/phpunit/includes/ArticleTablesTest.php index 02571b55c9..17cee6e808 100644 --- a/tests/phpunit/includes/ArticleTablesTest.php +++ b/tests/phpunit/includes/ArticleTablesTest.php @@ -17,14 +17,14 @@ class ArticleTablesTest extends MediaWikiLangTestCase { $wgLang = Language::factory( 'fr' ); $status = $page->doEdit( '{{:{{int:history}}}}', 'Test code for bug 14404', 0, false, $user ); - $templates1 = $page->getUsedTemplates(); + $templates1 = $title->getTemplateLinksFrom(); $wgLang = Language::factory( 'de' ); $page->mPreparedEdit = false; // In order to force the rerendering of the same wikitext // We need an edit, a purge is not enough to regenerate the tables $status = $page->doEdit( '{{:{{int:history}}}}', 'Test code for bug 14404', EDIT_UPDATE, false, $user ); - $templates2 = $page->getUsedTemplates(); + $templates2 = $title->getTemplateLinksFrom(); $this->assertEquals( $templates1, $templates2 ); $this->assertEquals( $templates1[0]->getFullText(), 'Historial' ); diff --git a/thumb.php b/thumb.php index 58a8194d00..5fc4446248 100644 --- a/thumb.php +++ b/thumb.php @@ -71,10 +71,9 @@ function wfThumbHandle404() { } # Just get the URI path (REDIRECT_URL/REQUEST_URI is either a full URL or a path) if ( substr( $uriPath, 0, 1 ) !== '/' ) { - $bits = wfParseUrl( $uriPath ); - if ( $bits && isset( $bits['path'] ) ) { - $uriPath = $bits['path']; - } else { + $uri = new Uri( $uriPath ); + $uriPath = $uri->getPath(); + if ( $uriPath === null ) { wfThumbError( 404, 'The source file for the specified thumbnail does not exist.' ); return; } -- 2.20.1