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

Error Handling -> E_USER_WARNING instead of E_USER_NOTICE #2961

Open
rubas opened this issue Apr 3, 2024 · 1 comment
Open

Error Handling -> E_USER_WARNING instead of E_USER_NOTICE #2961

rubas opened this issue Apr 3, 2024 · 1 comment
Milestone

Comments

@rubas
Copy link
Contributor

rubas commented Apr 3, 2024


The function deprecated is trigger_error with the error level of E_USER_NOTICE.

I argue this should be at least a E_USER_WARNING, if not even an E_USER_ERROR.
Similar arguments can be made for the other trigger_error in the same file.

Reason

We just found a bug from the Timber v2 migration, that could been easily caught, if the correct error level was used.

👉🏻 Code: term.posts(1, 'post_type')

[ Timber ] Passing post_type_or_class is deprecated since Timber version 2.0.0! Use Pass post_type as part of the $query argument. For specifying class, use Class Maps: https://timber.github.io/docs/v2/guides/class-maps/ instead.


I strongly suggest, to increase the error level for important messages like this to at least WARNING, if not even ERROR.

NOTICE is something, that is normally not displayed and not even logged because of the noise level.

Which means there is good chance this issue will not be noticed and you end up with another annoying bug, that is probably not easy to spot as the above code just ignores the post_type and returns a post.

As always, I'm happy to provide a PR.

Error Definition

https://www.php.net/manual/en/errorfunc.constants.php

  • NOTICE Run-time notices. Indicate that the script encountered something that could indicate an error, but could also happen in the normal course of running a script.

  • WARNING: Run-time warnings (non-fatal errors). Execution of the script is not halted.

  • ERROR: Fatal run-time errors. These indicate errors that can not be recovered from, such as a memory allocation problem. Execution of the script is halted.

@Levdbas
Copy link
Member

Levdbas commented May 8, 2024

Hi @rubas ,

I've discussed this with @gchtr and we will probably take a bigger dive in the whole error handling in version 2.2.
See #2210 and #2487

@Levdbas Levdbas modified the milestones: 2.2.0, 2.3.0 May 8, 2024
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

2 participants