Skip to content

Commit

Permalink
Further attempts to fix HHVM issues (11)
Browse files Browse the repository at this point in the history
  • Loading branch information
antecedent committed Oct 9, 2015
1 parent 29a4be8 commit 908a233
Show file tree
Hide file tree
Showing 6 changed files with 4 additions and 54 deletions.
7 changes: 1 addition & 6 deletions Patchwork.php
Original file line number Diff line number Diff line change
Expand Up @@ -71,15 +71,10 @@ function blacklist($path)
Preprocessor\exclude($path);
}

function deployQueue()
{
Interceptor\State::$queueDeployedManually = true;
Interceptor\deployQueue();
}

if (Utils\runningOnHHVM()) {
# no preprocessor needed on HHVM;
# just let Patchwork become a wrapper for fb_intercept()
spl_autoload_register('Patchwork\Interceptor\deployQueue');
register_shutdown_function('Patchwork\undoAll');
return;
}
Expand Down
18 changes: 0 additions & 18 deletions src/Interceptor.php
Original file line number Diff line number Diff line change
Expand Up @@ -134,7 +134,6 @@ function patchMethod($function, $patch, PatchHandle $handle = null)

function unpatchAll()
{
checkForMissedDeployments();
foreach (State::$patches as $class => $patchesByClass) {
foreach ($patchesByClass as $method => $patches) {
foreach ($patches as $patch) {
Expand Down Expand Up @@ -237,25 +236,9 @@ function getHHVMExpirationHandler($function)
if ($empty) {
fb_intercept($function, null);
}
checkForMissedDeployments();
};
}

function checkForMissedDeployments()
{
if (State::$queueDeployedManually) {
return;
}
foreach (State::$queuedPatches as $queuedPatch) {
list($target) = $queuedPatch;
list($class) = Utils\interpretCallback($target);
if (class_exists($class, false)) {
$message = 'Please invoke Patchwork\deployQueue() from your autoloader to make %s redefinable';
trigger_error(sprintf($message, Utils\callbackToString($target)), E_USER_WARNING);
}
}
}

function getPatchesFor($class, $method)
{
if (!isset(State::$patches[$class][$method])) {
Expand All @@ -268,7 +251,6 @@ class State
{
static $patches = array();
static $queuedPatches = array();
static $queueDeployedManually = false;
static $preprocessedFiles = array();
static $patchStack = array();
}
2 changes: 1 addition & 1 deletion src/Stack.php
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ function topArgsOverride()
throw new Exceptions\StackEmpty;
}
list($offset, $calledClass, $argsOverride) = end(State::$items);
return $argsOverride;
return $argsOverride;
}

function all()
Expand Down
27 changes: 0 additions & 27 deletions tests/hhvm-manual-queue-deployment.phpt

This file was deleted.

2 changes: 2 additions & 0 deletions tests/includes/InheritanceWithAssertions.php
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,8 @@ function getBar()
}
}

Patchwork\Interceptor\deployQueue();

$foo = new FooObject;
$bar = new BarObject;
$baz = new BazObject;
Expand Down
2 changes: 0 additions & 2 deletions tests/inheritance-delayed-redefinition.phpt
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,6 @@ Patchwork\replace("BarObject::getBar", function() {

require __DIR__ . "/includes/InheritanceWithAssertions.php";

Patchwork\undoAll();

?>
===DONE===

Expand Down

0 comments on commit 908a233

Please sign in to comment.