Skip to content

Commit

Permalink
Merge pull request #1420 from sjinks/issue-1413
Browse files Browse the repository at this point in the history
[1.3.0] Fix #1413
  • Loading branch information
Phalcon committed Oct 23, 2013
2 parents 64ed378 + 05417fe commit b941ca0
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 2 deletions.
18 changes: 16 additions & 2 deletions ext/forms/element.c
Original file line number Diff line number Diff line change
Expand Up @@ -809,8 +809,22 @@ PHP_METHOD(Phalcon_Forms_Element, clear){
PHP_METHOD(Phalcon_Forms_Element, __toString) {

if (FAILURE == phalcon_call_method_params(return_value, return_value_ptr, this_ptr, SL("render"), zend_inline_hash_func(SS("render")) TSRMLS_CC, 0)) {
if (EG(exception) && return_value_ptr) {
ALLOC_INIT_ZVAL(*return_value_ptr);
if (EG(exception)) {
zval *e = EG(exception);
zval *m = zend_read_property(Z_OBJCE_P(e), e, SL("message"), 1 TSRMLS_CC);

Z_ADDREF_P(m);
if (Z_TYPE_P(m) != IS_STRING) {
convert_to_string_ex(&m);
}

if (return_value_ptr) {
ALLOC_INIT_ZVAL(*return_value_ptr);
}

zend_clear_exception(TSRMLS_C);
zend_error(E_ERROR, "%s", Z_STRVAL_P(m));
zval_ptr_dtor(&m);
}
}
}
11 changes: 11 additions & 0 deletions ext/tests/issue-1413.phpt
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
--TEST--
Phalcon\Forms\Element::toString() throws exceptions - https://github.com/phalcon/cphalcon/issues/1413
--SKIPIF--
<?php include('skipif.inc'); ?>
--FILE--
<?php
$e = new \Phalcon\Forms\Element\Text('name', array('value' => '&&&'));
echo $e, PHP_EOL;
?>
--EXPECTF--
Fatal error: A dependency injector container is required to obtain the "escaper" service in %s on line %d

0 comments on commit b941ca0

Please sign in to comment.