diff --git a/CHANGELOG b/CHANGELOG index 7fb6d250984..21b75422d16 100644 --- a/CHANGELOG +++ b/CHANGELOG @@ -129,6 +129,10 @@ - Phalcon\Events: - Added support for weak references (#663) - Bug fix in Phalcon\Events\manager::attach() (#1331, #1337) + - Phalcon\Flash: + - Phalcon\Flash\Session::getMessage('key') returns now an empty array if the key is not found (#908, #920) + - Phalcon\Flash\Session::getMessages() incorrectly removed all messages (#1575) + - Implemented Phalcon\Flash\Session::isset() (#1342) - Phalcon\Forms: - Phalcon\Forms\Element\* classes now implement Phalcon\Form\ElementInterface - Added support for HTML attributes to Phalcon\Forms\Form::label() (#1029) @@ -160,6 +164,7 @@ - Added Phalcon\Logger\Adapter\File::getPath() (#1495, #1508) - Phalcon\Logger optimizations (#1716) - Phalcon\Logger\Adapter::setLogLevel() is honored by transactions (#1716) + - Phalcon\Logger\Adapter::commit() now clears the queue (#1742) - Phalcon\Mvc: - Phalcon\Mvc\Application::handle() now checks whether the class exists before include()'ing its file (#812, #818) - Phalcon\Mvc\Model\Criteria::fromInput() now sets _modelName (#866, #873) @@ -200,10 +205,6 @@ - Fixed handling of numeric namespaces/modules/controllers/actions (#1688) - Added Phalcon\Mvc\View::exists() and Phalcon\Mvc\View(\Simple)::getRegisteredEngines() (#1707) - Volt: fixed bug in email_filed() (#1723) - - Phalcon\Flash: - - Phalcon\Flash\Session::getMessage('key') returns now an empty array if the key is not found (#908, #920) - - Phalcon\Flash\Session::getMessages() incorrectly removed all messages (#1575) - - Implemented Phalcon\Flash\Session::isset() (#1342) - Phalcon\Paginator: - Phalcon\Paginator\Adapter\Model returns correct results even when page number is incorrect (#1654) - Optimized Phalcon\Paginator\Adapter\QueryBuilder (#1632) diff --git a/ext/logger/adapter.c b/ext/logger/adapter.c index f10fc2a252f..ffe6e40623e 100644 --- a/ext/logger/adapter.c +++ b/ext/logger/adapter.c @@ -167,6 +167,15 @@ PHP_METHOD(Phalcon_Logger_Adapter, commit){ phalcon_call_method(time, *message, "gettime"); phalcon_call_method_p3_noret(this_ptr, "loginternal", message_str, type, time); } + + if (Z_REFCOUNT_P(queue) == 1 || Z_ISREF_P(queue)) { + zend_hash_clean(Z_ARRVAL_P(queue)); + } + else { + PHALCON_ALLOC_GHOST_ZVAL(queue); + array_init(queue); + phalcon_update_property_this(getThis(), SL("_queue"), queue TSRMLS_CC); + } } RETURN_THIS(); diff --git a/ext/tests/issue-1742.phpt b/ext/tests/issue-1742.phpt new file mode 100644 index 00000000000..2536c180ff4 --- /dev/null +++ b/ext/tests/issue-1742.phpt @@ -0,0 +1,27 @@ +--TEST-- +Phalcon\Logger\Adapter::commit() does not clear the queue - https://github.com/phalcon/cphalcon/issues/1742 +--SKIPIF-- + +--FILE-- +_queue); + } +} + +$logger = new MyStreamAdapter("php://stdout"); +$logger->begin(); +$logger->log('info', \Phalcon\Logger::INFO); +$logger->log('critical', \Phalcon\Logger::CRITICAL); +echo $logger->getQueueSize(), PHP_EOL; +$logger->commit(); +echo $logger->getQueueSize(), PHP_EOL; +?> +--EXPECTF-- +2 +[%s, %d %s %d %d:%d:%d %s][INFO] info +[%s, %d %s %d %d:%d:%d %s][CRITICAL] critical +0