From 5cbb90cf67db3d59f14e47f67895f68b3dea9df5 Mon Sep 17 00:00:00 2001 From: "James D. Forrester" Date: Mon, 24 Jun 2019 16:16:58 -0700 Subject: [PATCH] OutputPage::addScriptFile: Drop silencing invalid paths, deprecated in 1.24 Change-Id: Ia65c70366ab67324ef2a02f9b0e81a6fb7a081cb --- RELEASE-NOTES-1.34 | 4 ++++ includes/OutputPage.php | 7 ------ tests/phpunit/includes/OutputPageTest.php | 27 ----------------------- 3 files changed, 4 insertions(+), 34 deletions(-) diff --git a/RELEASE-NOTES-1.34 b/RELEASE-NOTES-1.34 index bba7df1455..d34b45959b 100644 --- a/RELEASE-NOTES-1.34 +++ b/RELEASE-NOTES-1.34 @@ -247,6 +247,10 @@ because of Phabricator reports. Use MediaWiki\Session\SessionManager instead. * The wfGetLBFactory global function, deprecated in 1.27, has been removed. Use MediaWikiServices::getInstance()->getDBLoadBalancerFactory(). +* The internal method OutputPage->addScriptFile() will no longer silently drop + calls that use an invalid path (i.e., something other than an absolute path, + protocol-relative URL, or full scheme URL), and will instead pass them to the + client where they will likely 404. This usage was deprecated in 1.24. * … === Deprecations in 1.34 === diff --git a/includes/OutputPage.php b/includes/OutputPage.php index 4ccb0d4274..e0ca258a9c 100644 --- a/includes/OutputPage.php +++ b/includes/OutputPage.php @@ -459,13 +459,6 @@ class OutputPage extends ContextSource { * @param string|null $unused Previously used to change the cache-busting query parameter */ public function addScriptFile( $file, $unused = null ) { - if ( substr( $file, 0, 1 ) !== '/' && !preg_match( '#^[a-z]*://#i', $file ) ) { - // This is not an absolute path, protocol-relative url, or full scheme url, - // presumed to be an old call intended to include a file from /w/skins/common, - // which doesn't exist anymore as of MediaWiki 1.24 per T71277. Ignore. - wfDeprecated( __METHOD__, '1.24' ); - return; - } $this->addScript( Html::linkedScript( $file, $this->getCSPNonce() ) ); } diff --git a/tests/phpunit/includes/OutputPageTest.php b/tests/phpunit/includes/OutputPageTest.php index 25de1a3523..243a90d741 100644 --- a/tests/phpunit/includes/OutputPageTest.php +++ b/tests/phpunit/includes/OutputPageTest.php @@ -298,33 +298,6 @@ class OutputPageTest extends MediaWikiTestCase { ); } - /** - * Test that addScriptFile() throws due to deprecation. - * - * @covers OutputPage::addScriptFile - */ - public function testAddDeprecatedScriptFileWarning() { - $this->setExpectedException( PHPUnit_Framework_Error_Deprecated::class, - 'Use of OutputPage::addScriptFile was deprecated in MediaWiki 1.24.' ); - - $op = $this->newInstance(); - $op->addScriptFile( 'ignored-script.js' ); - } - - /** - * Test the actual behavior of the method (in the case where it doesn't throw, e.g., in - * production). - * - * @covers OutputPage::addScriptFile - */ - public function testAddDeprecatedScriptFileNoOp() { - $this->hideDeprecated( 'OutputPage::addScriptFile' ); - $op = $this->newInstance(); - $op->addScriptFile( 'ignored-script.js' ); - - $this->assertNotContains( 'ignored-script.js', '' . $op->getBottomScripts() ); - } - /** * @covers OutputPage::addInlineScript */ -- 2.20.1