cakephp / elastic-search

Elastic search datasource for CakePHP
Other
88 stars 53 forks source link

Call to a member function log() on null - Logger instance not set in Cake\ElasticSearch\Datasource\Connection #94

Closed Antoniossss closed 8 years ago

Antoniossss commented 8 years ago

Datasource\Connection#_log method is overriding \Elastica\Client#_log without calling parent::_log. This is causing logger to be never set thus resulnting on NPE - logger is set in overriden implementation.

adding parent::_log call removes this error. I am not sure, but looks like one of those methods are surplus. Both of them will log the request (one via debug() and one via log()) but only parent implementation cares about checking if logger actually exists and creates it if needed.

On the other hand, overriding implementation is generating following warning on call $this->_logger->log($loggedQuery); Missing argument 2 for Elastica\Log::log(), called in Z:\...\vendor\cakephp\elastic-search\src\Datasource\Connection.php on line 201 and defined [ROOT\vendor\ruflin\elastica\lib\Elastica\Log.php, line 46]

but this must bue due to different logger implementations i guess. To stay with the cake nature, overriding implementation should handle logger creation if other parts of the system are not doing that alread (but it should be set it think, as this is a part of ConnectionInterface). Maybe bug in TypeRegistry then ?

markstory commented 8 years ago

Pull request up.