Add workaround for HHVM issue 6206
authorMarius Hoch <hoo@online.de>
Fri, 19 May 2017 18:50:58 +0000 (20:50 +0200)
committerKrinkle <krinklemail@gmail.com>
Fri, 19 May 2017 19:02:50 +0000 (19:02 +0000)
Just use the actual global on HHVM, like we do on
Zend, but avoid hitting the warning.

This is a workaround for https://github.com/facebook/hhvm/issues/6206

Bug: T111641
Change-Id: I15ef0e90827c94a8b2609484b0dddcb78f04284c

tests/phpunit/MediaWikiTestCase.php

index bc9f97c..1114f2a 100644 (file)
@@ -1,5 +1,6 @@
 <?php
 
+use Closure;
 use MediaWiki\Logger\LegacySpi;
 use MediaWiki\Logger\LoggerFactory;
 use MediaWiki\Logger\MonologSpi;
@@ -737,6 +738,11 @@ abstract class MediaWikiTestCase extends PHPUnit_Framework_TestCase {
                                        $GLOBALS[$globalKey] instanceof FauxRequest
                                ) {
                                        $this->mwGlobals[$globalKey] = clone $GLOBALS[$globalKey];
+                               } elseif ( $GLOBALS[$globalKey] instanceof Closure ) {
+                                       // Serializing Closure only gives a warning on HHVM while
+                                       // it throws an Exception on Zend.
+                                       // Workaround for https://github.com/facebook/hhvm/issues/6206
+                                       $this->mwGlobals[$globalKey] = $GLOBALS[$globalKey];
                                } else {
                                        try {
                                                $this->mwGlobals[$globalKey] = unserialize( serialize( $GLOBALS[$globalKey] ) );