tracy icon indicating copy to clipboard operation
tracy copied to clipboard

improveException should suggest installing missing extensions

Open JanTvrdik opened this issue 9 years ago • 13 comments

For example Call to undefined function Nette\Mail\finfo_buffer, should be improved to

Call to undefined function Nette\Mail\finfo_buffer, you need to enable finfo extension in php.ini

We obviously can't have a large array with all possible php functions, but having a simple array mapping function prefix to extension name should work well enough for most use-cases.


@dg If you think this would be useful, you may tag this issue as easy pick to encourage contributions.

JanTvrdik avatar Sep 08 '16 12:09 JanTvrdik

+multibyte + disabled move_uploaded_file function etc.

adaamz avatar Sep 08 '16 12:09 adaamz

I guess everybody should run checker before start working. So this feature will be obsolete.

kravcik avatar Sep 08 '16 12:09 kravcik

@kravcik no, requirements checker solves different issue and does not help people who use Tracy without other Nette libraries

JanTvrdik avatar Sep 08 '16 13:09 JanTvrdik

IMHO the most confusing is namespace Nette\Mail\, it can be removed using \finfo_buffer or use function finfo_buffer. Or there can be check in code.

The problem only applies to extension fileinfo in nette/http and nette/mail and some of these extensions in Latte and utils. Some of them are checked in code, some checks can be added. I am :-1: to solve it in Tracy.

dg avatar Sep 08 '16 14:09 dg

The problem only applies to extension

I did not intended this feature for PHP extensions used by Nette but for all commonly missing PHP extensions such as json, curl, mbstring, openssl, ...

JanTvrdik avatar Sep 08 '16 14:09 JanTvrdik

As a general solution it probably makes sense.

BTW https://bugs.php.net/bug.php?id=73049

dg avatar Sep 08 '16 15:09 dg

Probably good idea in general, but the message should be more generic (i.e. not mention php.ini) and work not only with extension-related functions (i.e. new/removed core function like set_magic_quotes_runtime()).

BTW https://bugs.php.net/bug.php?id=73049

I believe the message is correct (although confusing), since the lookup is namespace-local first, then global. Same for constants. Maybe it could mention both variants in th message but either is partially correct.

Majkl578 avatar Sep 08 '16 15:09 Majkl578

not mention php.ini

Why not mention php.ini? Can you post an example of how such message should look like according to you?

work not only with extension-related functions

That seems out-of scope.

I believe the message is correct (although confusing)

Have you read the bug report? Because that's exatly what is states.

JanTvrdik avatar Sep 08 '16 15:09 JanTvrdik

Can you post an example of how such message should look like according to you?

Call to undefined function Nette\Mail\finfo_buffer or \finfo_buffer, ensure that finfo extension is enabled and loaded.

or maybe even like this to avoid namespace confusion: Call to undefined function finfo_buffer from namespace Nette\Mail, ensure that finfo extension is enabled and loaded.

Have you read the bug report? Because that's exatly what is states.

Yes and it does not. Quoting:

The better message should be "Call to undefined function json_encode()".

It drops the information about namespace entirely (so if you were using e.g. namespaced function like from GuzzleHttp or libsodium, you would have hard time to figuring that out, because function is not prefixed by extension name - situation depends on actual context / current namespace).

Majkl578 avatar Sep 08 '16 15:09 Majkl578

would have hard time to figuring that out

There is file name and line number.

dg avatar Sep 08 '16 15:09 dg

Call to undefined function Nette\Mail\finfo_buffer or \finfo_buffer, ensure that finfo extension is enabled and loaded.

But we can know for sure (extension_loaded) whether the extension is loaded. There is no need for the user to check whether the extension is loaded – we know it is not.

Yes and it does not. Quoting:

You have said „I believe the message is correct (although confusing)“ and @dg has said „the error message (…) is (…) confusing.“ and „both error messages are correct“

JanTvrdik avatar Sep 08 '16 15:09 JanTvrdik

For message Call to undefined function (namespace\)?(prefix)_.* when prefix is one of the listed prefixes and correspoding extension is not loaded, ideal message is Call to undefined function finfo_buffer, you need to enable finfo extension, i.e. without namespace. I am not sure about php.ini.

dg avatar Sep 08 '16 16:09 dg

@JanTvrdik Will you try to implement it?

dg avatar Apr 06 '18 12:04 dg