Skip to content

Commit

Permalink
Merge pull request #1318 from sjinks/1.2.4
Browse files Browse the repository at this point in the history
[1.2.4] Fix #1314
  • Loading branch information
Phalcon committed Oct 1, 2013
2 parents e22c0de + f6483e4 commit bb0b31c
Show file tree
Hide file tree
Showing 4 changed files with 23 additions and 12 deletions.
7 changes: 5 additions & 2 deletions ext/mvc/model/manager.c
Original file line number Diff line number Diff line change
Expand Up @@ -789,7 +789,7 @@ PHP_METHOD(Phalcon_Mvc_Model_Manager, getWriteConnectionService){
PHP_METHOD(Phalcon_Mvc_Model_Manager, notifyEvent){

zval *event_name, *model, *status = NULL, *behaviors, *entity_name = NULL;
zval *models_behaviors, *behavior = NULL, *events_manager;
zval *models_behaviors, *behavior = NULL, *events_manager, *mgr;
zval *fire_event_name = NULL, *custom_events_manager;
HashTable *ah0;
HashPosition hp0;
Expand Down Expand Up @@ -863,12 +863,15 @@ PHP_METHOD(Phalcon_Mvc_Model_Manager, notifyEvent){
PHALCON_INIT_NVAR(entity_name);
phalcon_get_class(entity_name, model, 1 TSRMLS_CC);
if (phalcon_array_isset(custom_events_manager, entity_name)) {

PHALCON_OBS_VAR(mgr);
phalcon_array_fetch(&mgr, custom_events_manager, entity_name, PH_NOISY);

PHALCON_INIT_NVAR(fire_event_name);
PHALCON_CONCAT_SV(fire_event_name, "model:", event_name);

PHALCON_INIT_NVAR(status);
phalcon_call_method_p2(status, custom_events_manager, "fire", fire_event_name, model);
phalcon_call_method_p2(status, mgr, "fire", fire_event_name, model);
if (PHALCON_IS_FALSE(status)) {
RETURN_CCTOR(status);
}
Expand Down
12 changes: 2 additions & 10 deletions ext/validation/message/group.c
Original file line number Diff line number Diff line change
Expand Up @@ -67,21 +67,13 @@ PHALCON_INIT_CLASS(Phalcon_Validation_Message_Group){
*/
PHP_METHOD(Phalcon_Validation_Message_Group, __construct){

zval *messages = NULL;

PHALCON_MM_GROW();
zval *messages;

phalcon_fetch_params(1, 0, 1, &messages);

if (!messages) {
PHALCON_INIT_VAR(messages);
}

if (Z_TYPE_P(messages) == IS_ARRAY) {
if (messages && Z_TYPE_P(messages) == IS_ARRAY) {
phalcon_update_property_this(this_ptr, SL("_messages"), messages TSRMLS_CC);
}

PHALCON_MM_RESTORE();
}

/**
Expand Down
3 changes: 3 additions & 0 deletions unit-tests/ModelsTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -385,6 +385,9 @@ protected function _executeTestsNormal($di){
$persona->refresh();
$this->assertEquals($personaData, $persona->toArray());

// Issue 1314
$parts = new Parts2();
$parts->save();
}

protected function _executeTestsRenamed($di)
Expand Down
13 changes: 13 additions & 0 deletions unit-tests/models/Parts2.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
<?php

class Parts2 extends \Phalcon\Mvc\Model
{
public function initialize()
{
$eventsManager = new \Phalcon\Events\Manager();

$eventsManager->attach('model', function($event, $robot) { return true; });
$this->setEventsManager($eventsManager);
$this->setSource('parts');
}
}

0 comments on commit bb0b31c

Please sign in to comment.