Fatal error: 'break' not in the 'loop' or 'switch' context in

Fatal error: 'break' not in the 'loop' or 'switch' context in

  1. Blog
  2. 15 November 2026
  3. 3 min read

Stefan Bogdanescu

Founder & Senior Architect

The Logic Error Behind the "break" Fatal Crash

When you import a WordPress database into a fresh environment, expecting your blog to launch instantly, you are often greeted by a cryptic PHP fatal error. In this specific case, the stack trace points to /wp-content/plugins/types/embedded/common/toolset-forms/lib/adodb-time.inc.php on line 1012. The error message is blunt: Fatal error: 'break' not in the 'loop' or 'switch' context.

Looking at the source code provided, the culprit is immediately obvious to anyone who has read a bit of PHP. Between lines 1010 and 1013, we see two identical ternary expressions returning a formatted timezone string, followed immediately by a break; statement outside of any control structure.

function adodb_tz_offset($gmt,$isphp5)
{
    $zhrs = abs($gmt)/3600;
    $hrs = floor($zhrs);
    if ($isphp5) 
        return sprintf('%s%02d%02d',($gmt<=0)?'+':'-',floor($zhrs),($zhrs-$hrs)*60); 
    else
        return sprintf('%s%02d%02d',($gmt<0)?'+':'-',floor($zhrs),($zhrs-$hrs)*60); 
    break; // Line 1012: This never executes
}

This is a classic syntactic logic error. The break keyword is designed to exit loops (for, while) or switch statements. Since this function contains neither, the PHP interpreter throws a fatal error the moment it attempts to parse the function body. Crucially, the line of code preceding the break actually returns a value. Because a return statement completes the execution flow of a function, the code on subsequent lines is unreachable. The break at line 1012 will never be reached during runtime in this specific context, but its mere presence in the source file prevents the PHP engine from executing the function at all.

This situation typically arises when copying plugins between environments or upgrading dependencies without checking for known issues in third-party libraries. The code block shown is part of the adodb-time library, which is often bundled with older versions of Toolset Forms (types). If you are running an older version of WordPress or a legacy installation of Toolset, this file might still be present in your wp-content/plugins/types/embedded/common/toolset-forms/lib/ directory.

Resolution Strategy

The fix is straightforward: remove the erroneous line. Since the function already returns a value in both branches of its if/else statement, the logic is complete before it hits the break. Deleting that single line restores functionality.

You can resolve this via FTP or your hosting file manager:

  1. Navigate to /wp-content/plugins/types/embedded/common/toolset-forms/lib/.
  2. Open adodb-time.inc.php.
  3. Locate line 1012 (or the line immediately following the last return statement).
  4. Delete the break; line and the trailing semicolon if they exist on that line.

Alternatively, you can use a command-line one-liner if you have SSH access:

sed -i 's/.*break;$//' /home/kbuzz/webapps/kb_blog/wp-content/plugins/types/embedded/common/toolset-forms/lib/adodb-time.inc.php

However, manual verification is safer to ensure no other stray statements exist in that file.

Why This Happens

Errors like this often stem from legacy code migration or copy-paste mistakes where a developer intended to break out of a loop but forgot the surrounding control structure before saving the file. In the context of third-party plugins, these errors persist until the plugin maintainer releases an update. If you are using Toolset Forms, checking your WordPress dashboard for available updates is the primary way to get rid of this file permanently. The maintainers may have realized the redundancy and removed the break in a newer patch version.

It is also worth noting that if this error appears after a database import, it confirms that your plugin files are intact but potentially outdated or incompatible with your current PHP version. While the logic inside the function doesn't change based on the $isphp5 flag (both branches return a string), the presence of the break makes the entire function uncallable regardless of PHP version.

By cleaning up this specific snippet, you restore the ability for Toolset Forms to handle timezone offsets correctly, allowing your embedded forms and date-time pickers to function as intended. Always keep an eye on plugin dependencies; sometimes the most critical bug is hiding in a tiny, seemingly irrelevant line of code at the end of a file.

Our network