Skip to content

The CssSelector throws a warning for unsupported selectors #11947

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
stof opened this issue Sep 18, 2014 · 7 comments
Closed

The CssSelector throws a warning for unsupported selectors #11947

stof opened this issue Sep 18, 2014 · 7 comments

Comments

@stof
Copy link
Member

stof commented Sep 18, 2014

When a CSS selector contains an unsupported selector (:active for instance), the component will throw an exception. However, it will also throw a warning because of the behavior of array_map when an exception is thrown in its callback: http://3v4l.org/rDT3R

This is annoying, especially when trying to catch the exception to ignore the unsupported selector.

@stof
Copy link
Member Author

stof commented Oct 7, 2014

OK, this is even worse than I thought: the warning triggered by array_map when an exception happens inside it seems to disappear magically when an error handler tries to catch it: http://3v4l.org/OR5ba. This looks very confusing

@nicolas-grekas
Copy link
Member

That's interesting indeed :) This is a PHP bug, array_map has no reason to trigger a warning.
This is a won't fix IMHO: I can't think of any viable workaround...

@xabbuh
Copy link
Member

xabbuh commented Oct 7, 2014

Is replacing calls to array_map() inside the component with a custom implementation an option?

@stof
Copy link
Member Author

stof commented Oct 7, 2014

well, the easy workaround would be to use a foreach loop rather than array_map in the Translator, where throwing an exception inside the callback is something expected sometimes.

Anyway, this is too bad for functional programming in PHP if array_map is broken...

@nicolas-grekas
Copy link
Member

The only side effect of the warning is a line in the php log file, with no userland side effect (as any custom error handler is not called). This is bad, but not a blocker...

@stof
Copy link
Member Author

stof commented Oct 7, 2014

Well, I find it a bit annoying, as it is filling my output when running the testsuite of my project at work. The warning does not end up in the log files, but in the output in such case (well, probably STDERR, but it does not make a difference on Travis as they get mixed together)

@stof
Copy link
Member Author

stof commented Oct 7, 2014

For reference, this was reported to PHP 3 years ago: https://bugs.php.net/bug.php?id=55416

fabpot added a commit that referenced this issue Oct 9, 2014
…n (xabbuh)

This PR was merged into the 2.3 branch.

Discussion
----------

[CssSelector] don't raise warnings when exception is thrown

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

`array_map()` raises a warning when an exception is thrown inside the
callback (see https://bugs.php.net/bug.php?id=55416). To avoid these
warnings, `selectorToXPath()` is applied inside the loop.

Commits
-------

38e9623 don't raise warnings when exception is thrown
@fabpot fabpot closed this as completed Oct 9, 2014
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

4 participants