From c023c02b6cb93af684b999ffb8acb302b58e21d7 Mon Sep 17 00:00:00 2001 From: "Dylan K. Taylor" Date: Wed, 24 Nov 2021 23:57:55 +0000 Subject: [PATCH] MemoryManager: Removed obsolete workaround for $GLOBALS not being defined on threads this was long since fixed, and everyone has since been forced to upgrade to pthreads 4.0.0, which definitely has the fix. --- phpstan.neon.dist | 1 - src/pocketmine/MemoryManager.php | 44 +++++++++++------------- tests/phpstan/configs/pthreads-bugs.neon | 7 ---- 3 files changed, 21 insertions(+), 31 deletions(-) delete mode 100644 tests/phpstan/configs/pthreads-bugs.neon diff --git a/phpstan.neon.dist b/phpstan.neon.dist index 6b559cd86..8ad20ab63 100644 --- a/phpstan.neon.dist +++ b/phpstan.neon.dist @@ -4,7 +4,6 @@ includes: - tests/phpstan/configs/php-bugs.neon - tests/phpstan/configs/phpstan-bugs.neon - tests/phpstan/configs/phpunit-wiring-tests.neon - - tests/phpstan/configs/pthreads-bugs.neon - tests/phpstan/configs/runtime-type-checks.neon - tests/phpstan/configs/spl-fixed-array-sucks.neon - vendor/phpstan/phpstan-phpunit/extension.neon diff --git a/src/pocketmine/MemoryManager.php b/src/pocketmine/MemoryManager.php index ec31d9181..e7b56fb5f 100644 --- a/src/pocketmine/MemoryManager.php +++ b/src/pocketmine/MemoryManager.php @@ -353,35 +353,33 @@ class MemoryManager{ file_put_contents($outputFolder . "/staticProperties.js", json_encode($staticProperties, JSON_UNESCAPED_SLASHES | JSON_PRETTY_PRINT)); $logger->info("[Dump] Wrote $staticCount static properties"); - if(isset($GLOBALS)){ //This might be null if we're on a different thread - $globalVariables = []; - $globalCount = 0; + $globalVariables = []; + $globalCount = 0; - $ignoredGlobals = [ - 'GLOBALS' => true, - '_SERVER' => true, - '_REQUEST' => true, - '_POST' => true, - '_GET' => true, - '_FILES' => true, - '_ENV' => true, - '_COOKIE' => true, - '_SESSION' => true - ]; + $ignoredGlobals = [ + 'GLOBALS' => true, + '_SERVER' => true, + '_REQUEST' => true, + '_POST' => true, + '_GET' => true, + '_FILES' => true, + '_ENV' => true, + '_COOKIE' => true, + '_SESSION' => true + ]; - foreach($GLOBALS as $varName => $value){ - if(isset($ignoredGlobals[$varName])){ - continue; - } - - $globalCount++; - $globalVariables[$varName] = self::continueDump($value, $objects, $refCounts, 0, $maxNesting, $maxStringSize); + foreach($GLOBALS as $varName => $value){ + if(isset($ignoredGlobals[$varName])){ + continue; } - file_put_contents($outputFolder . "/globalVariables.js", json_encode($globalVariables, JSON_UNESCAPED_SLASHES | JSON_PRETTY_PRINT)); - $logger->info("[Dump] Wrote $globalCount global variables"); + $globalCount++; + $globalVariables[$varName] = self::continueDump($value, $objects, $refCounts, 0, $maxNesting, $maxStringSize); } + file_put_contents($outputFolder . "/globalVariables.js", json_encode($globalVariables, JSON_UNESCAPED_SLASHES | JSON_PRETTY_PRINT)); + $logger->info("[Dump] Wrote $globalCount global variables"); + $data = self::continueDump($startingObject, $objects, $refCounts, 0, $maxNesting, $maxStringSize); do{ diff --git a/tests/phpstan/configs/pthreads-bugs.neon b/tests/phpstan/configs/pthreads-bugs.neon deleted file mode 100644 index e9e5e535b..000000000 --- a/tests/phpstan/configs/pthreads-bugs.neon +++ /dev/null @@ -1,7 +0,0 @@ -parameters: - ignoreErrors: - - - message: "#^Variable \\$GLOBALS in isset\\(\\) always exists and is not nullable\\.$#" - count: 1 - path: ../../../src/pocketmine/MemoryManager.php -