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

Adding ignoreStrictCheck option for call_user_func_array, if throwing exception #1236

Closed
wants to merge 2 commits into from

Conversation

TamasBarta
Copy link
Contributor

I experienced the issue when using FuelPHP's ORM with EAV containers. When I tried to reference a property that was not defined I expected to get null, but instead the whole application stopped because an exception was thrown in the ORM, that no such function is present.

I couldn't find other possible exception that could be thrown when this function is called, so I assumed it's safe to take the ignoreStrictCheck into consideration here.

… exception

Signed-off-by: Barta Tamás <barta.tamas.d@gmail.com>
// to call is not supported. If ignoreStrictCheck is true, we should return null.
try {
$ret = call_user_func_array(array($object, $method), $arguments);
} catch (Exception $e) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Here, you basically catch all exception for all methods, which of course is not possible.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I expected a similar response, but I had no other idea for a clean solution. I was going to write about alternate methods of solving this problem, but then I looked up BadMethodCallException, and it looks like a built-in PHP exception (since 5.1.0). I thought since, that it would be a FuelPHP dependency to use that. Would it be OK to simply replace Exception with BadMethodCallException?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I added a new commit reflecting to your complaint. Please take a look if you find it possible to merge. Thanks!

@sagikazarmark
Copy link

Any update on this?

@fabpot
Copy link
Contributor

fabpot commented Nov 23, 2013

@TamasBarta Can you add some unit tests?

@fabpot
Copy link
Contributor

fabpot commented Dec 3, 2013

closing in favor of #1286

@fabpot fabpot closed this Dec 3, 2013
fabpot added a commit that referenced this pull request Dec 3, 2013
…y, if throwing exception (fabpot)

This PR was merged into the master branch.

Discussion
----------

Adding ignoreStrictCheck option for call_user_func_array, if throwing exception

Same as #1236 with added unit tests and C extension support (to come).

"I experienced the issue when using FuelPHP's ORM with EAV containers. When I tried to reference a property that was not defined I expected to get null, but instead the whole application stopped because an exception was thrown in the ORM, that no such function is present.

I couldn't find other possible exception that could be thrown when this function is called, so I assumed it's safe to take the ignoreStrictCheck into consideration here."

Commits
-------

1abf5d9 [ext] Mirroring PHP change for call_user_func_array, see #1286
9ab290b added tests for exceptions thrown in __call()
c711d37 Adding ignoreStrictCheck option for call_user_func_array, if throwing exception
@TamasBarta
Copy link
Contributor Author

Awesome news! Thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

Successfully merging this pull request may close these issues.

3 participants