Warning: preg_match(): Compilation failed: quantifier does not follow a repeatable item at offset 1 in wp-includes/class-wp.php on line 222
Asked Answered
G

5

6

Any pages with page type posts, order type posts, or posts show this error. This is only visible on a hosted environment. I cannot replicate the errors locally

I have done the following in this order:

  1. deactivated all plugins
  2. went to settings->permalinks and resaved the %postname% option
  3. verified that error is still present with no plugins and permalinks reset.
  4. Updated all plugins and themes.
  5. Verified error is still present.
  6. Followed the same procedure locally, and was not able to replicate this problem.

from class-wp.php:

foreach ( (array) $rewrite as $match => $query ) {
    // If the requested file is the anchor of the match, prepend it to the path info.
    if ( ! empty( $requested_file ) && strpos( $match, $requested_file ) === 0 && $requested_file != $requested_path ) {
        $request_match = $requested_file . '/' . $requested_path;
    }

    if ( preg_match( "#^$match#", $request_match, $matches ) ||
        preg_match( "#^$match#", urldecode( $request_match ), $matches ) ) {

        if ( $wp_rewrite->use_verbose_page_rules && preg_match( '/pagename=\$matches\[([0-9]+)\]/', $query, $varmatch ) ) {
            // This is a verbose page match, let's check to be sure about it.
            $page = get_page_by_path( $matches[ $varmatch[1] ] );
            if ( ! $page ) {
                continue;
            }

            $post_status_obj = get_post_status_object( $page->post_status );
            if ( ! $post_status_obj->public && ! $post_status_obj->protected
                && ! $post_status_obj->private && $post_status_obj->exclude_from_search ) {
                continue;
            }
        }

        // Got a match.
        $this->matched_rule = $match;
        break;
    }
}

I have scoured the interweb for an answer on this, but I have come up with nothing. Let the WordPress Junkies speak please.

Gabriel answered 11/9, 2019 at 1:42 Comment(6)
Hi Zach, have you tried to change theme? something like WP default theme?Supersonics
Yes. The error still persists.Gabriel
What is the content of $match? I suspect a quantifier in it.Taiwan
Can you try reinstall WordPress? It's sounds like a bad install or hosting issue. Nothing else left...Supersonics
@toto I am not sure what it represents, that said... It has to be something to do with links on the page referencing content. (e.g. orders, pages, posts, etc...). I am not sure what the purpose of matching urls is as I would have programmed things differently to avoid such a weird use case. I really don't want to migrate again lol... If I have to I will, but it's just a stakeholder approval site. The dashboard errors aren't showing on the front end. Just any time it has to iterate over multiple page links/edit options.Gabriel
Just before the preg_match, do: $temp = preg_quote($match) and then use this new variable in the preg_match: preg_match( "#^$temp#", ....Taiwan
G
6

Thank you for your help everyone. This ended up being a conflict with a plugin called The Events Calendar. If you create a page with the name Events, and change The Events Calendar default page of "events" to something else this error occurs. Since it's a third party app, I am just going to look for something else to suit my needs. By removing the folder completely from the plugins directory, the error is cleared.

Gabriel answered 26/9, 2019 at 13:16 Comment(4)
THANK YOU! This was driving me insane. It would "fix" it if I disabled pretty permalinks, which obviously wasn't acceptable. This fixed it.Deltadeltaic
I know what you mean! Took me a minute. Glad to be of some help to someone.Gabriel
After a solid hour of searching for a resolution, this fixed my issue. You have to have a page for your events. I believe this bug was fixed with a later version.Magnesia
So, for me, first of all, this was for the "Events Manager" WordPress plugin (wordpress.org/plugins/events-manager). The issue arose because the "Events page" was set to a non-existent page (one that had been deleted) -- menu: "Events... Settings... Pages tab... Event List/Archive section... Events page dropdown".Slesvig
L
4

Change the Permalink Settings

In your WordPress site, under settings -> If Permalink setting is Post Name try changing it to Custom Structure and vice versa. This helped me in fixing this error.

enter image description here

Liberalize answered 23/2, 2021 at 16:16 Comment(0)
A
1

I had the same error on alle pages, except the homepage. When I changed Permalinks from "Postname" to "Simple" (pageid) error was gone. When I switched back, error was back too. Finally I tried to add a slash to the end of the base URL in Settings -> General -> "WordPress address (URL)" & "Siteaddress (URL)". After saving settings the slash was gone (because it is not valid to have it) but the problem was solved too.

Andra answered 27/9, 2021 at 19:5 Comment(0)
M
0

Deactivating Events Calendar plugins got rid of the errors. The error occurred after I deleted a page named "events".

Mallee answered 17/10, 2023 at 11:20 Comment(1)
Your answer could be improved with additional supporting information. Please edit to add further details, such as citations or documentation, so that others can confirm that your answer is correct. You can find more information on how to write good answers in the help center.Ionian
A
0

Personally, I found the best way to solve this was simply hiding the warning - since it doesn't affect the site's performance. There are cases where %postname% permalink is important e.g. on blogs.

To hide the error, simply add these lines on your wpconfig file:

define('WP_DEBUG', false);<br>
ini_set('display_errors','Off');<br>
ini_set('error_reporting', E_ALL );<br>
define('WP_DEBUG', false);<br>
define('WP_DEBUG_DISPLAY', false);<br>
Admeasurement answered 26/9, 2024 at 22:1 Comment(0)

© 2022 - 2025 — McMap. All rights reserved.