MongoCollection: Call to a member function notifyEvent() on array in ...
cottton opened this issue · 1 comments
cottton commented
Call to a member function notifyEvent() on array in /var/www/html/vendor/phalcon/incubator/Library/Phalcon/Mvc/MongoCollection.php:449
https://github.com/phalcon/incubator/blob/3.0.x/Library/Phalcon/Mvc/MongoCollection.php#L449
- Phalcon Framework version: 3.1.2
- Phalcon Incubator version: 3.0.x
- PHP Version: 7.1.30
Seems like with cphalcon 3.1.2 no di and no models manager gets set.
Test script:
var_dump(PHP_VERSION); // string(6) "7.1.30"
var_dump(Phalcon\Version::get()); // string(5) "3.1.2"
// "phalcon/incubator": "3.0.x",
class User extends Phalcon\Mvc\MongoCollection
{
public function getSource()
{
return 'user';
}
}
$model = new User();
$model->foo = 1;
$model->create();
/** @var User $model */
$model = User::findFirst();
echo var_export($model->toArray(), true) . PHP_EOL;
// array(
// '_id' => MongoDB\BSON\ObjectId::__set_state(array(
// 'oid' => '5d31e528f328bb00bc38a402',
// )),
// '_dependencyInjector' => array(), <---------- oO?
// '_modelsManager' => array(), <---------- oO?
// '_source' => null,
// '_operationMade' => 1,
// '_dirtyState' => 1,
// '_connection' => array(),
// '_errorMessages' => array(),
// '_skipped' => false,
// 'foo' => 1,
// )
echo get_class(\Phalcon\Di::getDefault()->get('modelsManager')) . PHP_EOL; // Phalcon\Mvc\Model\Manager
// delete collection
$model->delete(); // Call to a member function notifyEvent() on array in /var/www/html/vendor/phalcon/incubator/Library/Phalcon/Mvc/MongoCollection.php:449
Seems related: #760
Could not find out where the _modelsManager was originally set.
Any idea how to tmp-fix that?
Jeckerson commented
Try to use phalcon/incubator-mongodb@v2.0.0