-
Notifications
You must be signed in to change notification settings - Fork 447
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
Web: fix deprecated php stuff #2971
Conversation
The `ereg` function is deprecated since 5.3 and was removed in 7.0. Using `break;` outside a loop was working unintentionally before 7.0 but now throws a compile error. Using s call-time pass-by-reference throws an error since 5.4. The `&` is only needed in the function declaration not when calling the function.
Also, in translation.inc could change |
This PR is focused on deprecated PHP stuff not simplifying the existing code. Adding unrelated changes is the equivalent to the "Feature Creep" Antipattern. |
those lines produced a warning under php 7 |
@@ -326,7 +326,7 @@ function show_next($iter, $view) { | |||
// | |||
show_refresh_finished(); | |||
$refresh->update('count=count+1'); | |||
break; | |||
return; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I have no full picture of what PHP's quirky use of break
outside a loop was doing in different contexts, nor do I know what it was meant to do in this context. AFAIK, break
outside a loop exits a script: what does that say about using it in a function like this? Yes, it could mean return
but I don't know.
Bottom line: this should be reviewed by David who knows the intended semantic of this code.
Otherwise I'm fine with the changes.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@davidpanderson Can you recall why you put a break
here? I don't have the means to test this part.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
That break
would have behaved the same as return
in this case (no PHPun intended). Both calls to show_next()
are made inside of case
statements and are immediately followed by a break
, so if execution was reaching that drifter of a break
inside the function, and this was not generating a fatal runtime error about break
being called out of scope, it would just cause execution to break out of the parent switch
in the calling routine (which it was going to do immediately, anyway, upon return). No need to hold up this PR, in my opinion.
I'm with David on this one, if it's really a warning (although I'd consider this an optimization). |
Which exact warning does PHP throw in this case? Assigning to var and returning later looks like a very common pattern. |
I didn't reproduce the case David posted but it was not listed in Scrutinizer as an Issue. I nevertheless changed it as I was fixing the other issues Scrutiniter showed in this file. I didn't check other files. |
Per Oliver:
|
I already explained why the |
b7cc9ca
to
83af843
Compare
This is ready for review again. As a side note I'm currently fiddling with the Scrutinizer config to hide all the unrelated issues and then plan on having a look at what remains. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm approving all changes but the one I commented on earlier. That still needs to be approved by @davidpanderson .
This is some basic stuff. Could someone please merge this? |
Description of the Change
ereg
function is deprecated since 5.3 and was removed in 7.0.break;
outside a loop was working unintentionally before 7.0 but now throws a compile error.&
is only needed in the function declaration not when calling the function.Fixes #2102
Release Notes
N/A