MyBB Community Forums

Full Version: system emailed a warning after upgrade to 1821
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
Quote:Your copy of MyBB running on Ho-Lee-Fooks (https://ho-lee-fooks.com/forum) has experienced an error. Details of the error include:
---
Type: 2
File: inc/datahandlers/warnings.php (Line no. 595)
Message
"continue" targeting switch is equivalent to "break". Did you mean to use "continue 2"?


I have received 3 of these today at approximately 11a, 2p and 3p server time. I have not seen evidence of php errors in my browser. Could this be generated by another user and system sends errors to me?

Suggestions welcome. Thanks. Meanwhile, I will go see what line 595 says.

I am answering my own question. This appears to be a coding error.
Switch statements are usually ended with break.
If or while loops are usually ended with continue which passes control to the top of the loop.
Or so suggests w3resource.

Here is the code block. I think the programmer meant continue; instead of continue 2;

I am not a programmer. Looking for feedback.

Quote:591 switch($i)
592 {
593 case 1: // Ban
594 // we'll have to resort to letting the admin/mod remove the ban manually, since there's an issue if stacked bans are in force...
595 continue 2;
596 case 2: // Revoke posting
597 $current_expiry_field = 'suspensiontime';
598 $current_inforce_field = 'suspendposting';
599 break;
600 case 3:
601 $current_expiry_field = 'moderationtime';
602 $current_inforce_field = 'moderateposts';
603 break;
604 }

Something's wrong here.
DB field shows timestamp correctly for warnings issued in April 2017.
Displaying the Warning Log in ModCP shows a number of warnings were issued today less than an hour ago. Not sure if that's server time or my local time.

Devs?

I compared theĀ inc/datahandlers/warnings.php files.
There is no difference between version 1819 and 1821 except for the line 595.
The new version says 'continue 2;'
The old version says 'continue;'

I solved the error message email by reverting to the older file.

Incorrect dates in the warning log still exists.
See attached screen shot.

[attachment=42208]
continue; and break; are largely interchangeable. There's no reason why that should throw a warning.

I'd turn off warnings.
Which version of MyBB do you use?
(2019-09-23, 01:51 PM)noyle Wrote: [ -> ]Which version of MyBB do you use?

Updated to 1.8.21 from 1.8.19

editing line 595 from 'continue 2;' to 'continue;' still generates errors that are emailed to me.
I have changed that line to 'break;'
We'll see if that solves the emailed errors.
(2019-09-22, 11:06 PM)HLFadmin Wrote: [ -> ]Something's wrong here.
DB field shows timestamp correctly for warnings issued in April 2017.
Displaying the Warning Log in ModCP shows a number of warnings were issued today less than an hour ago. Not sure if that's server time or my local time.

This problem is caused by Absolute - Relative Time-Format plugin 1.10.
Relative time, like "30 minutes ago", is a personal preference. There should be a choice baked in, not by plugin.
And I think relative time the stupidest thing. I'll have to find another solution.
Upgrade is successful from 1.8.19 to 1.8.21

Turning off emailed warnings is not the best solution since I'd prefer to receive notifications if something did go wrong.

Argument 2 is passed because the switch is inside a loop. "continue 2;" generates an error message. While "continue" and "break" are considered equivalent in a switch statement, break is identified as preferred, so I changed the statement to "break 2;" and the errors have stopped while preserving the control structure.

The absolute-relative time plugin was updated after the author suggested a change in the coding. Thank you doylecc.