8000 [Debug] TypeError in ErrorHandler · Issue #20068 · symfony/symfony · GitHub
[go: up one dir, main page]

Skip to content

[Debug] TypeError in ErrorHandler #20068

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

Closed
gharlan opened this issue Sep 28, 2016 · 7 comments
Closed

[Debug] TypeError in ErrorHandler #20068

gharlan opened this issue Sep 28, 2016 · 7 comments

Comments

@gharlan
Copy link
Contributor
gharlan commented Sep 28, 2016

In a command class I'm using something like this:

        $imap = @imap_open('foo', 'bar', 'baz');

        if (!$imap) {
            throw new \RuntimeException(imap_last_error());
        }

When an imap error occurs, I get an uncaught TypeError:

Uncaught TypeError: Argument 5 passed to Symfony\Component\Debug\ErrorHandler::handleError() must be of the type array, null given in /Users/gharlan/workspace/symfony_demo/vendor/symfony/symfony/src/Symfony/Component/Debug/ErrorHandler.php:368

Symfony: current master
PHP: 7.0.11

It is reproducibly with symfony demo by adding the code above to ListUsersCommand::execute:

screenshot 2016-09-28 12 00 12

@fabpot
Copy link
Member
fabpot commented Sep 28, 2016

/cc @nicolas-grekas

@nicolas-grekas
Copy link
Member

I guess this should be reported on the imap extension also, because having Unknown as file, 0 for line, and null for context is plain broken.

@fabpot
Copy link
Member
fabpot commented Sep 28, 2016

If the imap extension does not behave correctly, we can indeed close this one as won't fix.

@nicolas-grekas
Copy link
Member
nicolas-grekas commented Sep 28, 2016

@gharlan please open a bug report on bugs.php.net, here is a plain php reproducer:

<?php

set_error_handler(function ($type, $message, $file, $line, $context) {
    if ($context) {
        $context = array_keys($context);
    }
    var_dump(compact('type', 'message', 'file', 'line', 'context'));
});

@imap_open('foo', 'bar', 'baz');

which displays:

array(5) {
  ["type"]=>
  int(2)
  ["message"]=>
  string(37) "imap_open(): Couldn't open stream foo"
  ["file"]=>
  string(35) "/.../test.php"
  ["line"]=>
  int(10)
  ["context"]=>
  array(7) {
    [0]=>
    string(4) "_GET"
    [1]=>
    string(5) "_POST"
    [2]=>
    string(7) "_COOKIE"
    [3]=>
    string(6) "_FILES"
    [4]=>
    string(4) "argv"
    [5]=>
    string(4) "argc"
    [6]=>
    string(7) "_SERVER"
  }
}
array(5) {
  ["type"]=>
  int(8)
  ["message"]=>
  string(59) "Unknown: Can't open mailbox foo: no such mailbox (errflg=2)"
  ["file"]=>
  string(7) "Unknown"
  ["line"]=>
  int(0)
  ["context"]=>
  NULL
}

which looks wrong

@wujku
Copy link
wujku commented Jan 25, 2017

Problem still exists.

@nicolas-grekas
Copy link
Member

See #21401

@stof
Copy link
Member
stof commented Jan 25, 2017

has the issue been reported to PHP ?

fabpot added a commit that referenced this issue Jan 25, 2017
This PR was merged into the 2.7 branch.

Discussion
----------

[Debug] Workaround "null" $context

| Q             | A
| ------------- | ---
| Branch?       | 2.7
| Bug fix?      | no
| New feature?  | no
| BC breaks?    | no
| Deprecations? | no
| Tests pass?   | yes
| Fixed tickets | -
| License       | MIT
| Doc PR        | -

As reported in #20068, the imap extension can call error handlers with $context = null.

Commits
-------

2555f31 [Debug] Workaround "null" $context
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

5 participants
0