Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix misleading diagnostics on exception #1297

Merged
merged 2 commits into from Sep 26, 2013
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 3 additions & 4 deletions ext/kernel/fcall.c
Original file line number Diff line number Diff line change
Expand Up @@ -201,7 +201,7 @@ static int phalcon_call_func_vparams(zval *return_value, zval **return_value_ptr
efree(params);
}

if (status == FAILURE) {
if (status == FAILURE && !EG(exception)) {
php_error_docref(NULL TSRMLS_CC, E_ERROR, "Call to undefined function %s()", Z_STRVAL_P(func));
}
else if (EG(exception)) {
Expand Down Expand Up @@ -268,9 +268,8 @@ int phalcon_call_method_vparams(zval *return_value, zval **return_value_ptr, zva
efree(params);
}

if (status == FAILURE) {
if (status == FAILURE && !EG(exception)) {
php_error_docref(NULL TSRMLS_CC, E_ERROR, "Call to undefined method %s::%s()", ce->name, method_name);
status = FAILURE;
}
else if (EG(exception)) {
status = FAILURE;
Expand Down Expand Up @@ -336,7 +335,7 @@ static int phalcon_call_static_zval_str_func_vparams(zval *return_value, zval **
efree(params);
}

if (status == FAILURE) {
if (status == FAILURE && !EG(exception)) {
if (Z_TYPE_P(mixed_name) == IS_STRING) {
php_error_docref(NULL TSRMLS_CC, E_ERROR, "Call to undefined function %s::%s()", Z_STRVAL_P(mixed_name), method_name);
} else {
Expand Down
21 changes: 21 additions & 0 deletions ext/tests/issue-1297.phpt
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
--TEST--
Misleading diagnostocs on exception - https://github.com/phalcon/cphalcon/pull/1297
--SKIPIF--
<?php include('skipif.inc'); ?>
--FILE--
<?php
try {
$object = new stdClass();
$form = new \Phalcon\Forms\Form($object);
$form->add(new \Phalcon\Forms\Element\Text("title"));
echo $form->render('title');
}
catch (\Exception $e) {
echo $e->getMessage(), PHP_EOL;
}

echo "OK", PHP_EOL;
?>
--EXPECT--
A dependency injector container is required to obtain the "escaper" service
OK