3

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.

Shir Gans
  • 1,976
  • 3
  • 23
  • 40
Zach Manning
  • 91
  • 1
  • 1
  • 5
  • Hi Zach, have you tried to change theme? something like WP default theme? – Shir Gans Sep 11 '19 at 04:58
  • Yes. The error still persists. – Zach Manning Sep 11 '19 at 14:59
  • What is the content of `$match`? I suspect a quantifier in it. – Toto Sep 12 '19 at 08:55
  • Can you try reinstall WordPress? It's sounds like a bad install or hosting issue. Nothing else left... – Shir Gans Sep 12 '19 at 13:08
  • @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. – Zach Manning Sep 14 '19 at 21:20
  • Just before the `preg_match`, do: `$temp = preg_quote($match)` and then use this new variable in the preg_match: `preg_match( "#^$temp#", ...`. – Toto Sep 15 '19 at 09:13

3 Answers3

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.

Zach Manning
  • 91
  • 1
  • 1
  • 5
  • THANK YOU! This was driving me insane. It would "fix" it if I disabled pretty permalinks, which obviously wasn't acceptable. This fixed it. – jphogan Sep 16 '20 at 15:45
  • I know what you mean! Took me a minute. Glad to be of some help to someone. – Zach Manning Oct 27 '20 at 23:50
  • 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. – metal_jacke1 Mar 30 '21 at 15:45
  • 1
    So, for me, first of all, this was for the "Events Manager" WordPress plugin (https://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". – Martin_W Jan 17 '22 at 03:17
2

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

Dharman
  • 30,962
  • 25
  • 85
  • 135
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.

WhiteEagle
  • 46
  • 3