aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorKunal Mehta <legoktm@member.fsf.org>2018-06-06 17:54:07 -0700
committerKunal Mehta <legoktm@member.fsf.org>2018-06-06 20:13:13 -0700
commit827cfb3351db57332e16db48bdfbcde6131c17cd (patch)
treee3e2bd3f739c5d213bc580eab157f9d17aec6beb
parent3b73014c55b75485366e25ea4b44f65a5f407bd3 (diff)
downloadmediawikicore-827cfb3351db57332e16db48bdfbcde6131c17cd.tar.gz
mediawikicore-827cfb3351db57332e16db48bdfbcde6131c17cd.zip
Fix UploadBase::checkXMLEncodingMissmatch() on PHP 7.1+
file_get_contents() started supporting a negative offset in 7.1+. But we really just want to start with 0. Also fix the order of arguments to assertSame() so that the expected value is first. Bug: T182366 Change-Id: I84c92652de5b51a43f6e2b58cd235d2889093453
-rw-r--r--RELEASE-NOTES-1.312
-rw-r--r--includes/upload/UploadBase.php2
-rw-r--r--tests/phpunit/includes/upload/UploadBaseTest.php2
3 files changed, 4 insertions, 2 deletions
diff --git a/RELEASE-NOTES-1.31 b/RELEASE-NOTES-1.31
index 49d53bd39846..c98f6633ef19 100644
--- a/RELEASE-NOTES-1.31
+++ b/RELEASE-NOTES-1.31
@@ -10,6 +10,7 @@ production.
* (T196092) Hide MySQL binary/utf-8 charset option in the installer.
* (T196185) Don't allow setting $wgDBmysql5 in the installer.
* (T196125) php-memcached 3.0 (provided with PHP 7.0) is now supported.
+* (T182366) UploadBase::checkXMLEncodingMissmatch() now works on PHP 7.1+
=== Changes since MediaWiki 1.31.0-rc.0 ===
* (T33223) Drop archive.ar_text and ar_flags.
@@ -166,6 +167,7 @@ production.
* (T2087, T10897, T87753, T174639) Whitespace created by category and language
links is now stripped rather than leaving blank lines in odd places.
* (T3780) Uploads with UTF-8 names now work on PHP7.1+ on Windows servers.
+* (T182366) UploadBase::checkXMLEncodingMissmatch() now works on PHP 7.1+
=== Action API changes in 1.31 ===
* (T185058) The 'name' value to tgprop for action=query&list=tags has been
diff --git a/includes/upload/UploadBase.php b/includes/upload/UploadBase.php
index 27c0ed773019..6a471ba573ed 100644
--- a/includes/upload/UploadBase.php
+++ b/includes/upload/UploadBase.php
@@ -1397,7 +1397,7 @@ abstract class UploadBase {
*/
public static function checkXMLEncodingMissmatch( $file ) {
global $wgSVGMetadataCutoff;
- $contents = file_get_contents( $file, false, null, -1, $wgSVGMetadataCutoff );
+ $contents = file_get_contents( $file, false, null, 0, $wgSVGMetadataCutoff );
$encodingRegex = '!encoding[ \t\n\r]*=[ \t\n\r]*[\'"](.*?)[\'"]!si';
if ( preg_match( "!<\?xml\b(.*?)\?>!si", $contents, $matches ) ) {
diff --git a/tests/phpunit/includes/upload/UploadBaseTest.php b/tests/phpunit/includes/upload/UploadBaseTest.php
index 3541091a68c3..a80262e932c0 100644
--- a/tests/phpunit/includes/upload/UploadBaseTest.php
+++ b/tests/phpunit/includes/upload/UploadBaseTest.php
@@ -562,7 +562,7 @@ class UploadBaseTest extends MediaWikiTestCase {
public function testCheckXMLEncodingMissmatch( $fileContents, $evil ) {
$filename = $this->getNewTempFile();
file_put_contents( $filename, $fileContents );
- $this->assertSame( UploadBase::checkXMLEncodingMissmatch( $filename ), $evil );
+ $this->assertSame( $evil, UploadBase::checkXMLEncodingMissmatch( $filename ) );
}
public function provideCheckXMLEncodingMissmatch() {