question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Wordpress 5.5 breaks discoverability

See original GitHub issue

Ran into this after upgrading one of our wordpress sites to 5.5. This new version of wordpress adds a number of new API routes, including this one: /wp/v2/plugins/(?P<plugin>[^.\\/]+(?:\\/[^.\\/]+)?).

Currently, something in that regular expression is not playing nicely with the discoverability code, because whenever I point wpapi at our wordpress 5.5 site, I get the following error:

SyntaxError: Invalid regular expression: /^[^.\/]+(?:\/[^.\/]+$/: Unterminated group
    at new RegExp (<anonymous>)
    at reduceRouteComponents (./node_modules/wpapi/lib/route-tree.js:86:3)
    at Array.reduce (<anonymous>)
    at reduceRouteTree (./node_modules/wpapi/lib/route-tree.js:185:18)
    at Object.keys.reduce (./node_modules/wpapi/lib/util/object-reduce.js:25:20)
    at Array.reduce (<anonymous>)
    at module.exports (./node_modules/wpapi/lib/util/object-reduce.js:24:3)
    at buildRouteTree (./node_modules/wpapi/lib/route-tree.js:203:9)
    at WPAPI.bootstrap (./node_modules/wpapi/wpapi.js:349:23)
    at new WPAPI (./node_modules/wpapi/wpapi.js:88:4)

Was able to reproduce it with this test:

const wpapi = require('wpapi');

async function test() {
  await wpapi.discover('https://example-wordpress-55-site.com');
}

test().catch(console.error);

I added some logging in that reduceRouteComponents and confirmed that it’s the plugins url that’s messing things up.

Because discoverability is breaking, it falls back to assuming default routes, meaning none of our custom post types are currently usable via this package 😕

I’ll do my best to investigate further and open a PR, but wanted to open this issue in case anyone else runs into the same problem.

Issue Analytics

  • State:closed
  • Created 3 years ago
  • Reactions:15
  • Comments:11

github_iconTop GitHub Comments

2reactions
kevinwhoffmancommented, May 11, 2021

@kadamwhite Thanks very much for the release. I successfully tested the following using wpapi 1.2.2 and WordPress 5.7.1:

WPAPI.discover(location.origin).then((response) => console.log(response));
2reactions
kadamwhitecommented, May 10, 2021

wpapi version 1.2.2 has been released, which includes @socrates77’ change. Thank you for reporting this, and I am sorry to you all that I was lax in accepting and releasing this. I did adjust the RE slightly while rebasing that change into the v1 branch, so @kevinwhoffman @riddla @NielsdeBlaauw et al, if you still encounter this behavior after updating to v1.2.2, please @ me here with details.

Read more comments on GitHub >

github_iconTop Results From Across the Web

WordPress 5.5 Breaking Websites: How to Fix - iThemes
If you have a broken website after updating to WordPress 5.5, don't panic. In this post, we'll cover why WordPress 5.5 is breaking...
Read more >
What's New in WordPress 5.5 - Deep Dive Into an Epic Release
WordPress 5.5 is the latest WordPress release and brings tons of changes to ... in any negative consequences for the site's discoverability.
Read more >
Why WordPress 5.5 is Breaking Sites - Search Engine Journal
Two issues related to WordPress 5.5 are possibly affecting thousands of websites. This is how to fix them.
Read more >
WordPress 5.5 sitemap feature
It may not result in negative consequences for “discoverability” but it could have negative consequences for people who have spent time crafting how...
Read more >
Why WordPress 5.5 Breaking sites | Causes and Fixes
WordPress 5.5 update is breaking Sites due to outdated themes and plugins codes. Here are 2 methods to fix WordPress 5.5 breaking sites...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found