• webmark487

    (@webmark487)


    Hello!

    We do get error messages on certain pages of our website.

    If I deactivate the plugin, the error messages are gone.

    Thx in advance and best regards

    Markus

    Warning: preg_match(): Compilation failed: quantifier does not follow a repeatable item at offset 1 in /home/.sites/838/site2533937/web/wp-includes/class-wp.php on line 238 Warning: preg_match(): Compilation failed: quantifier does not follow a repeatable item at offset 1 in /home/.sites/838/site2533937/web/wp-includes/class-wp.php on line 239 Warning: preg_match(): Compilation failed: quantifier does not follow a repeatable item at offset 1 in /home/.sites/838/site2533937/web/wp-includes/class-wp.php on line 238 Warning: preg_match(): Compilation failed: quantifier does not follow a repeatable item at offset 1 in /home/.sites/838/site2533937/web/wp-includes/class-wp.php on line 239 Warning: preg_match(): Compilation failed: quantifier does not follow a repeatable item at offset 1 in /home/.sites/838/site2533937/web/wp-includes/class-wp.php on line 238 Warning: preg_match(): Compilation failed: quantifier does not follow a repeatable item at offset 1 in /home/.sites/838/site2533937/web/wp-includes/class-wp.php on line 239 Warning: preg_match(): Compilation failed: quantifier does not follow a repeatable item at offset 1 in /home/.sites/838/site2533937/web/wp-includes/class-wp.php on line 238 Warning: preg_match(): Compilation failed: quantifier does not follow a repeatable item at offset 1 in /home/.sites/838/site2533937/web/wp-includes/class-wp.php on line 239 Warning: preg_match(): Compilation failed: quantifier does not follow a repeatable item at offset 1 in /home/.sites/838/site2533937/web/wp-includes/class-wp.php on line 238 Warning: preg_match(): Compilation failed: quantifier does not follow a repeatable item at offset 1 in /home/.sites/838/site2533937/web/wp-includes/class-wp.php on line 239 Warning: preg_match(): Compilation failed: quantifier does not follow a repeatable item at offset 1 in /home/.sites/838/site2533937/web/wp-includes/class-wp.php on line 238 Warning: preg_match(): Compilation failed: quantifier does not follow a repeatable item at offset 1 in /home/.sites/838/site2533937/web/wp-includes/class-wp.php on line 239 Warning: preg_match(): Compilation failed: quantifier does not follow a repeatable item at offset 1 in /home/.sites/838/site2533937/web/wp-includes/class-wp.php on line 238 Warning: preg_match(): Compilation failed: quantifier does not follow a repeatable item at offset 1 in /home/.sites/838/site2533937/web/wp-includes/class-wp.php on line 239

    The page I need help with: [log in to see the link]

Viewing 6 replies - 1 through 6 (of 6 total)
  • joneiseman

    (@joneiseman)

    To find out what is causing this warning add the following code snippet:

    // Temporary error handler to catch warnings and output a stack trace
    set_error_handler(function($errno, $errstr, $errfile, $errline) {
    // Only capture warnings, notices, etc., but not fatal errors
    if (!(error_reporting() & $errno)) {
    return false;
    }

    // This section logs the warning and includes the backtrace
    $log = "WARNING caught: $errstr in $errfile on line $errline\n";
    $log .= "Stack trace:\n";
    foreach (debug_backtrace() as $i => $item) {
    // Exclude the error handler itself from the backtrace
    if ($item['function'] === 'include' || $item['function'] === 'require') {
    continue;
    }

    $file = isset($item['file']) ? $item['file'] : '[internal]';
    $line = isset($item['line']) ? $item['line'] : '[internal]';
    $class = isset($item['class']) ? $item['class'] : '';
    $type = isset($item['type']) ? $item['type'] : '';
    $function = isset($item['function']) ? $item['function'] : '';

    $log .= "#$i $file($line): {$class}{$type}{$function}()\n";
    }

    error_log($log);

    // Let the standard PHP error handler continue, or return 'true' to stop further processing
    return false;
    }, E_WARNING;

    In wp-config.php make sure you have the following settings:

    define( 'WP_DEBUG', true );
    define( 'WP_DEBUG_DISPLAY', false );
    define( 'WP_DEBUG_LOG', true );

    The stack trace should be in the debug.log file.

    You can use the Code Snippets plugin to add the code snippet.

    Thread Starter webmark487

    (@webmark487)

    thx, i will try that

    btw, it seems like you forgot one closing bracket in the second line

    set_error_handler(function($errno, $errstr, $errfile, $errline)) {
    joneiseman

    (@joneiseman)

    It’s missing the a paren on the last line. The last line should have been this:

    }, E_WARNING);

    Here’s a better way to print the stack trace on PHP Warnings:

    /**
    * A simpler handler to log warnings with a stack trace.
    */
    set_error_handler(function($errno, $errstr, $errfile, $errline) {
    // Respect the @-operator and error_reporting() settings
    if (!(error_reporting() & $errno)) {
    return false;
    }

    // Get a clean, standard stack trace without manual looping.
    $trace = (new Exception)->getTraceAsString();

    // Format the log message
    $logMessage = "PHP Warning: $errstr in $errfile on line $errline\n";
    $logMessage .= "Stack trace:\n" . $trace . "\n\n";

    error_log($logMessage);

    // Let the standard PHP error handler continue
    return false;
    }, E_WARNING);
    Thread Starter webmark487

    (@webmark487)

    joneiseman

    (@joneiseman)

    Looks like this problem was reported before but there was no resolution: https://ww.wp.xz.cn/support/topic/issues-after-updating-to-version-6-4-3-compilation-failed/

    Do you know what you were doing when the warning is generated?

    Thread Starter webmark487

    (@webmark487)

    No special action that I did before the warning is generated.

    Saving the permalinks makes the warning go away for some short time, but unfortunately it comes back again.

    As there seems to be no solution, I disabled all warnings now with define( ‘WP_DEBUG_DISPLAY’, false ); in wp-config.php

Viewing 6 replies - 1 through 6 (of 6 total)

The topic ‘Warning “preg_match(): Compilation failed …”’ is closed to new replies.