Replies: 2 comments 5 replies
-
I agree. Let's try and find a better way |
Beta Was this translation helpful? Give feedback.
1 reply
-
As discussed in #672 we'd have to use a polyfill and add a php extension to the requirements. Some people object to that. I figured there would be some consensus on how to replace strtime when the release date for php9 was coming closer. |
Beta Was this translation helpful? Give feedback.
4 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
I've run into an issue with errors being suppressed by the
@
operator. Specifically this occurred relating to use ofstrftime
, which was deprecated in PHP 8.1. #672 reported this problem, which was "fixed" by silencing it in #811, and that code is still present in 5.0. There's a problem with using the@
operator like this – I use Smarty in a context where users can create their own templates, and I run them inside a test harness using a custom error handler to check they are correct before allowing them to be used. The problem here is that while the@
operator suppresses error output, it doesn't suppress the internal occurrence of the error, so the warning still occurs, it's just not reported by the default handler. Since I'm not using a default handler, I'm hit with the errors as if they had not been suppressed at all.As a workaround I'm now filtering deprecation warnings during this process, however, these errors only exist in Smarty's own code (like in #811) where I don't have control over it. Ideally I'd like these errors not to be happening in the first place. In other places I've used a BC polyfill to replace
strftime
with a userland implementation, which I feel is a far better way of solving the problem than using@
, though ultimately avoiding the deprecation altogether would better, if it's possible.Another factor is that while this operator suppresses the deprecation notice, it also suppresses any other errors that occur within the call, for example if an invalid format string is provided.
I think this silencing approach has been used elsewhere in Smarty to avoid deprecation notices, and I just don't think it's a great policy. It's also exactly the kind of thing that gets flagged by static analysis tools and code audits. Thoughts?
Beta Was this translation helpful? Give feedback.
All reactions