Skip to content

Commit

Permalink
Fixed remove() not removing service #14396
Browse files Browse the repository at this point in the history
  • Loading branch information
ruudboon authored and sergeyklay committed Sep 24, 2019
1 parent 3988af0 commit cbdb9c4
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 2 deletions.
1 change: 1 addition & 0 deletions CHANGELOG-4.0.md
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@
- Fixed `Phalcon/Db/Dialect/Mysql` Fixed missing schema in constraint for create table [#14378](https://github.com/phalcon/cphalcon/issues/14378)
- Fixed `Phalcon\Mvc\Model::hasChanged()` and `getChangedFields()` returning false values when `castOnHydrate` option is on. [#14376](https://github.com/phalcon/cphalcon/issues/14376)
- Fixed `Phalcon\Mvc\Model::create()` Using write connection to prevent replica lag [#14256](https://github.com/phalcon/cphalcon/issues/14256)
- Fixed `Phalcon\Di::remove()` Fixed remove() not removing service [#14396](https://github.com/phalcon/cphalcon/issues/14396)

## Removed
- Removed `Phalcon\Plugin` - duplicate of `Phalcon\DI\Injectable` [#14359](https://github.com/phalcon/cphalcon/issues/14359)
Expand Down
11 changes: 9 additions & 2 deletions phalcon/Di.zep
Original file line number Diff line number Diff line change
Expand Up @@ -512,8 +512,15 @@ class Di implements DiInterface
*/
public function remove(string! name) -> void
{
unset this->services[name];
unset this->sharedInstances[name];
var services;
let services = this->services;
unset services[name];
let this->services = services;

var sharedInstances;
let sharedInstances = this->sharedInstances;
unset sharedInstances[name];
let this->sharedInstances = sharedInstances;
}

/**
Expand Down
7 changes: 7 additions & 0 deletions tests/unit/Di/GetServicesCest.php
Original file line number Diff line number Diff line change
Expand Up @@ -35,5 +35,12 @@ public function diGetServices(UnitTester $I)
$di->set('escaper', Escaper::class);

$I->assertCount(1, $di->getServices());

$di->remove('escaper');
$I->assertFalse($di->has('escaper'));
$I->assertEquals([], $di->getServices());
$I->assertEmpty($di->getServices());
$I->assertTrue(is_array($di->getServices()));
$I->assertCount(0, $di->getServices());
}
}

0 comments on commit cbdb9c4

Please sign in to comment.