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.

Provide support for non standard WordPress versions

See original GitHub issue

Bug Description

As raised by one user in the support forums PHP warnings can be found if using a non standard WordPress version number (ie. An integer, version 42),

In the users case their WordPress version was changed to 42 after applying an option within their Digital Ocean droplet, with other hosting providers also offering similar features.

The errors appear as below. They don’t impact Site Kit operations or functionality:

wp-content/plugins/google-site-kit/includes/Core/Assets/Assets.php:348
Google\S\C\A\Assets->Google\S\C\A\{closure}()
Unknown location
Google\S\C\A\Script_Data->Google\S\C\A\{closure}()
Unknown location
Google\S\C\A\Asset->before_print()
wp-content/plugins/google-site-kit/includes/Core/Assets/Assets.php:903
Google\S\C\A\Assets->run_before_print_callbacks()
wp-content/plugins/google-site-kit/includes/Core/Assets/Assets.php:912
Google\S\C\A\Assets->run_before_print_callbacks()
wp-content/plugins/google-site-kit/includes/Core/Assets/Assets.php:159
Google\S\C\A\Assets->Google\S\C\A\{closure}()
wp-includes/class-wp-hook.php:307
do_action('admin_print_scripts')
wp-admin/admin-header.php:146

Steps to reproduce

  1. Hide your WP version using a security plugin, custom function or hosting control panel
  2. Setup Site Kit
  3. Enable error reporting
  4. Check your error logs

Additional Context


Do not alter or remove anything below. The following sections will be managed by moderators only.

Acceptance criteria

  • Site Kit should not assume that the WordPress version has a major and minor segment. While this is commonly the case, version numbers like 5 are still valid version numbers. While this isn’t used by WordPress itself, there are some obscure plugins that change the WordPress version “for security reasons” to one without any . in it, which is currently causing a PHP notice.
  • Specifically, the Authentication::inline_js_base_data() method should be adjusted to account for this. If no . is present, it should simply assume 0 for the minor version instead of splitting the version string into major and minor bit.

Implementation Brief

  • Update the version which is split by periods in Authentication::inline_js_base_data to be unconditionally concatenated with a trailing .0 so that there are always at least two segments (assuming a non-empty version number)
    • This way, the $major and $minor versions remain accurate and 0 is used as a fallback in the case that the input $version is a single number/integer while preserving the real $version in the base data

Test Coverage

  • Add a test to AuthenticationTest to cover a standard case as well as a non-standard WP version by filtering bloginfo

QA Brief

  • Follow steps to reproduce and hide the WP version (a plugin like Sucuri can be used).
  • See that there’s no longer an error.

Changelog entry

  • Fix authentication issue with WordPress security plugins/other plugins that modify/obscure the WordPress version number.

Issue Analytics

  • State:closed
  • Created a year ago
  • Reactions:1
  • Comments:10

github_iconTop GitHub Comments

2reactions
aaemnnosttvcommented, Apr 25, 2022

@wpdarren For QA, I created a mini plugin to change the version to the integer 42. This shows the problem should be solved but I’ll include it here for others to verify as well. override-wp-version.0.1.zip

image

image

2reactions
jamesozziecommented, Apr 21, 2022

I’ll perform a check on this later today and let you know. There are a few ways to hide WP version numbers. Thanks @mohitwp and @wpdarren.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Version 5.9.1 – WordPress.org Forums
For step-by-step instructions on installing and updating WordPress: Updating WordPress.
Read more >
WordPress Core Automatic Upgrades and Deferrals
Managed WordPress code updates keep your site secure. Learn how our automatic upgrade works, how to defer, and how to manually upgrade.
Read more >
Post Formats – WordPress.com Support
View all themes that support post formats or visit the showcase and click Feature → Post Formats.
Read more >
Using the Classic Editor – WordPress.com Support
While the Classic Editor is still available, it is not recommended to use. You can use the block editor to create media-rich, mobile...
Read more >
Solve Problems With Plugins – WordPress.com Support
Plugins add extra features to your website not available by default in WordPress software. There are thousands of plugins developed mainly by other ......
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