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

Fix misleading diagnostics on exception #1297

merged 2 commits into from Sep 26, 2013

Conversation

ghost
Copy link

@ghost ghost commented Sep 26, 2013

For example,

<?php
$object = new stdClass();
$object->title = 'Hello "world!"';

$form = new Phalcon\Forms\Form($object);
$form->add(new Phalcon\Forms\Element\Text("title"));
echo $form->render('title');

when run, it produces something like this:

Warning: Uncaught exception 'Phalcon\Tag\Exception' with message 'A dependency injector container is required to obtain the "escaper" service' in /home/vladimir/workspace/cphalcon/1190.php:8
Stack trace:
#0 [internal function]: Phalcon\Tag::getEscaperService()
#1 [internal function]: Phalcon\Tag::_inputField('text', Array)
#2 [internal function]: Phalcon\Tag::textField(Array)
#3 [internal function]: Phalcon\Forms\Element\Text->render(NULL)
#4 /home/vladimir/workspace/cphalcon/1190.php(8): Phalcon\Forms\Form->render('title')
#5 {main}
  thrown in /home/vladimir/workspace/cphalcon/1190.php on line 8

Fatal error: Phalcon\Tag::_inputField(): Call to undefined function self::getescaperservice() in /home/vladimir/workspace/cphalcon/1190.php on line 8

"Fatal error" message should not be there.

@ghost
Copy link
Author

ghost commented Sep 26, 2013

Test case:

--TEST--
Misleading diagnostocs on exception - https://github.com/phalcon/cphalcon/pull/1297
--SKIPIF--
--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

Result:

---- EXPECTED OUTPUT
A dependency injector container is required to obtain the "escaper" service
OK
---- ACTUAL OUTPUT
Warning: Uncaught exception 'Phalcon\Tag\Exception' with message 'A dependency injector container is required to obtain the "escaper" service' in /home/vladimir/workspace/cphalcon/ext/tests/issue-1297.php:6
Stack trace:
#0 [internal function]: Phalcon\Tag::getEscaperService()
#1 [internal function]: Phalcon\Tag::_inputField('text', Array)
#2 [internal function]: Phalcon\Tag::textField(Array)
#3 [internal function]: Phalcon\Forms\Element\Text->render(NULL)
#4 /home/vladimir/workspace/cphalcon/ext/tests/issue-1297.php(6): Phalcon\Forms\Form->render('title')
#5 {main}
  thrown in /home/vladimir/workspace/cphalcon/ext/tests/issue-1297.php on line 6

Fatal error: Phalcon\Tag::_inputField(): Call to undefined function self::getescaperservice() in /home/vladimir/workspace/cphalcon/ext/tests/issue-1297.php on line 6
---- FAILED

phalcon pushed a commit that referenced this pull request Sep 26, 2013
Fix misleading diagnostics on exception
@phalcon phalcon merged commit c33d65a into phalcon:1.3.0 Sep 26, 2013
@ghost ghost deleted the fcall-diag branch September 26, 2013 19:16
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants