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

[BUG] \Phalcon\Debug Array to string conversion #1103

Closed
beermeat opened this issue Aug 17, 2013 · 9 comments
Closed

[BUG] \Phalcon\Debug Array to string conversion #1103

beermeat opened this issue Aug 17, 2013 · 9 comments

Comments

@beermeat
Copy link

public function indexAction()
{
    throw new \Exception('sss');
}

make request:
/?var[]=1&var[]=2

and get the error (notice) "Array to string conversion"

@dreamsxin
Copy link
Contributor

Could you please post the code that reproduces the bug?

@ovr
Copy link
Contributor

ovr commented Aug 20, 2013

@dreamsxin
Code

<?php
ini_set('display_errors', 1);
error_reporting(-1);
(new \Phalcon\Debug)->listen();
throw new Exception('fdsfsdf');

Screenshot http://gyazo.com/b6a5c3c618b28e4cc5bda59565ed8e9d
See Request Tab i think maybe use var_dump() for varibles or encode to json if is n`t string
url http://host/?var[]=1&var[]=2

@dreamsxin
Copy link
Contributor

You are right.
I try fix it.

                        if (Z_TYPE_P(value) == IS_ARRAY) {
                                PHALCON_INIT_VAR(joined_value);
                                phalcon_fast_join_str(joined_value, SL(", "), value TSRMLS_CC);
                                PHALCON_SCONCAT_SVSVS(html, "<tr><td class=\"key\">", key_request, "</td><td>Array(", joined_value, ")</td></tr>");
                        } else {
                                PHALCON_SCONCAT_SVSVS(html, "<tr><td class=\"key\">", key_request, "</td><td>", value, "</td></tr>");
                        }

@ghost
Copy link

ghost commented Aug 20, 2013

@dreamsxin Please try

http://host/?var[1][]=1&var[1][]=2

and see if it works

@ovr
Copy link
Contributor

ovr commented Aug 20, 2013

@dreamsxin @sjinks Maybe the best way convert to json in value td if isnt string?

@dreamsxin
Copy link
Contributor

When using recursion. I decided to use zend_print_zval_r output to buffer.

                        if (Z_TYPE_P(value) == IS_ARRAY) {
                                PHALCON_INIT_NVAR(joined_value);
                                phalcon_ob_start(TSRMLS_C);
                                zend_print_zval_r(value, 0);
                                phalcon_ob_get_contents(joined_value TSRMLS_CC);
                                phalcon_ob_end_clean(TSRMLS_C);
                                PHALCON_SCONCAT_SVSVS(html, "<tr><td class=\"key\">", key_request, "</td><td>", joined_value, "</td></tr>");
                        } else {
                                PHALCON_SCONCAT_SVSVS(html, "<tr><td class=\"key\">", key_request, "</td><td>", value, "</td></tr>");
                        }

@beermeat
Copy link
Author

maybe it would be better to use an existing method _getVarDump?

@dreamsxin
Copy link
Contributor

@tema87 you are right.

phalcon pushed a commit that referenced this issue Aug 20, 2013
@phalcon
Copy link
Collaborator

phalcon commented Aug 23, 2013

This is fixed in 1.3.0

@phalcon phalcon closed this as completed Aug 23, 2013
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

No branches or pull requests

3 participants