Skip to content

[BUG] \Phalcon\Mvc\Model set property to model on relation #1296

Closed
@ovr

Description

@ovr

Hi all
i think this bug on https://github.com/phalcon/cphalcon/blob/master/ext/mvc/model.c#L6192
On User Model i have relation Notify like

$this->hasOne('id', 'User\Model\User\Notify', 'user_id', array(
    'foreignKey' => true,
    'alias' => 'Notify'
));

test code

$notify = \User\Model\User\Notify::findFirst(1);
var_dump($notify->toArray());
$notify->adviseToRead = 0; 
var_dump($notify->toArray());

var_dump($user->Notify->toArray());     
$user->Notify->adviseToRead = 0; 
var_dump($user->Notify->toArray());

output

array(14) {
  ["user_id"]=>
  string(1) "1"
  ["message"]=>
  string(1) "1"
  ["commented"]=>
  string(1) "1"
  ["favorite_author"]=>
  string(1) "1"
  ["favorite_product"]=>
  string(1) "1"
  ["my_favorite_author_add_product"]=>
  string(1) "1"
  ["myproduct_add_to_editors_choice"]=>
  string(1) "1"
  ["tarif_expire"]=>
  string(1) "1"
  ["myblog_commented"]=>
  string(1) "1"
  ["mycomment_commented"]=>
  string(1) "1"
  ["news"]=>
  string(1) "1"
  ["feed_report"]=>
  string(1) "1"
  ["adviseToRead"]=>
  string(1) "1"
  ["selectionOfProducts"]=>
  string(1) "1"
}
array(14) {
  ["user_id"]=>
  string(1) "1"
  ["message"]=>
  string(1) "1"
  ["commented"]=>
  string(1) "1"
  ["favorite_author"]=>
  string(1) "1"
  ["favorite_product"]=>
  string(1) "1"
  ["my_favorite_author_add_product"]=>
  string(1) "1"
  ["myproduct_add_to_editors_choice"]=>
  string(1) "1"
  ["tarif_expire"]=>
  string(1) "1"
  ["myblog_commented"]=>
  string(1) "1"
  ["mycomment_commented"]=>
  string(1) "1"
  ["news"]=>
  string(1) "1"
  ["feed_report"]=>
  string(1) "1"
  ["adviseToRead"]=>
  int(0)
  ["selectionOfProducts"]=>
  string(1) "1"
}
array(14) {
  ["user_id"]=>
  string(1) "1"
  ["message"]=>
  string(1) "1"
  ["commented"]=>
  string(1) "1"
  ["favorite_author"]=>
  string(1) "1"
  ["favorite_product"]=>
  string(1) "1"
  ["my_favorite_author_add_product"]=>
  string(1) "1"
  ["myproduct_add_to_editors_choice"]=>
  string(1) "1"
  ["tarif_expire"]=>
  string(1) "1"
  ["myblog_commented"]=>
  string(1) "1"
  ["mycomment_commented"]=>
  string(1) "1"
  ["news"]=>
  string(1) "1"
  ["feed_report"]=>
  string(1) "1"
  ["adviseToRead"]=>
  string(1) "1"
  ["selectionOfProducts"]=>
  string(1) "1"
}
array(14) {
  ["user_id"]=>
  string(1) "1"
  ["message"]=>
  string(1) "1"
  ["commented"]=>
  string(1) "1"
  ["favorite_author"]=>
  string(1) "1"
  ["favorite_product"]=>
  string(1) "1"
  ["my_favorite_author_add_product"]=>
  string(1) "1"
  ["myproduct_add_to_editors_choice"]=>
  string(1) "1"
  ["tarif_expire"]=>
  string(1) "1"
  ["myblog_commented"]=>
  string(1) "1"
  ["mycomment_commented"]=>
  string(1) "1"
  ["news"]=>
  string(1) "1"
  ["feed_report"]=>
  string(1) "1"
  ["adviseToRead"]=>
  string(1) "1"
  ["selectionOfProducts"]=>
  string(1) "1"
}

Want to back this issue? Post a bounty on it! We accept bounties via Bountysource.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions