Skip to content

Commit

Permalink
Merge pull request #1400 from sjinks/issue-1399
Browse files Browse the repository at this point in the history
[1.3.0] Fix #1399
  • Loading branch information
Phalcon committed Oct 19, 2013
2 parents 2bc80a1 + d516dd0 commit 9fa4480
Show file tree
Hide file tree
Showing 2 changed files with 31 additions and 19 deletions.
21 changes: 21 additions & 0 deletions ext/tests/issue-1399.phpt
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
--TEST--
Missing argument 1 for MyEntity::readAttribute() - https://github.com/phalcon/cphalcon/issues/1399
--SKIPIF--
<?php include('skipif.inc'); ?>
--FILE--
<?php

class MyEntity
{
public function readAttribute($attr)
{
return "aaa";
}
}

$validation = new \Phalcon\Validation();
$validation->add('email', new \Phalcon\Validation\Validator\Email());
$validation->bind(new MyEntity(), array());
$validation->validate();
?>
--EXPECT--
29 changes: 10 additions & 19 deletions ext/validation.c
Original file line number Diff line number Diff line change
Expand Up @@ -158,12 +158,8 @@ PHP_METHOD(Phalcon_Validation, validate){
}

phalcon_update_property_this(this_ptr, SL("_messages"), messages TSRMLS_CC);
if (Z_TYPE_P(data) == IS_ARRAY) {
if (Z_TYPE_P(data) == IS_ARRAY || Z_TYPE_P(data) == IS_OBJECT) {
phalcon_update_property_this(this_ptr, SL("_data"), data TSRMLS_CC);
} else {
if (Z_TYPE_P(data) == IS_OBJECT) {
phalcon_update_property_this(this_ptr, SL("_data"), data TSRMLS_CC);
}
}

PHALCON_INIT_VAR(cancel_on_fail);
Expand Down Expand Up @@ -351,8 +347,8 @@ PHP_METHOD(Phalcon_Validation, appendMessage){
* Assigns the data to an entity
* The entity is used to obtain the validation values
*
* @param string $entity
* @param string $data
* @param object $entity
* @param object|array $data
* @return Phalcon\Validation
*/
PHP_METHOD(Phalcon_Validation, bind){
Expand Down Expand Up @@ -407,18 +403,14 @@ PHP_METHOD(Phalcon_Validation, getValue){
if (phalcon_method_exists(entity, method TSRMLS_CC) == SUCCESS) {
PHALCON_INIT_VAR(value);
phalcon_call_method_zval(value, entity, method);
} else if (phalcon_method_exists_ex(entity, SS("readattribute") TSRMLS_CC) == SUCCESS) {
PHALCON_INIT_VAR(value);
phalcon_call_method_p1(value, entity, "readattribute", attribute);
} else if (phalcon_isset_property_zval(entity, attribute TSRMLS_CC)) {
PHALCON_OBS_VAR(value);
phalcon_read_property_zval(&value, entity, attribute, PH_NOISY_CC);
} else {
if (phalcon_method_exists_ex(entity, SS("readattribute") TSRMLS_CC) == SUCCESS) {
PHALCON_INIT_NVAR(value);
phalcon_call_method(value, entity, "readattribute");
} else {
if (phalcon_isset_property_zval(entity, attribute TSRMLS_CC)) {
PHALCON_OBS_NVAR(value);
phalcon_read_property_zval(&value, entity, attribute, PH_NOISY_CC);
} else {
PHALCON_INIT_NVAR(value);
}
}
PHALCON_INIT_VAR(value);
}

RETURN_CCTOR(value);
Expand Down Expand Up @@ -511,4 +503,3 @@ PHP_METHOD(Phalcon_Validation, getValue){

RETURN_MM_NULL();
}

0 comments on commit 9fa4480

Please sign in to comment.