Provide support for non standard WordPress versions
See original GitHub issueBug 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
- Hide your WP version using a security plugin, custom function or hosting control panel
- Setup Site Kit
- Enable error reporting
- Check your error logs
Additional Context
- Site Kit 1.70.0
- Support topic SH info - No obvious cause
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
5are 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 assume0for 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_datato be unconditionally concatenated with a trailing.0so that there are always at least two segments (assuming a non-empty version number)- This way, the
$majorand$minorversions remain accurate and0is used as a fallback in the case that the input$versionis a single number/integer while preserving the real$versionin the base data
- This way, the
Test Coverage
- Add a test to
AuthenticationTestto cover a standard case as well as a non-standard WP version by filteringbloginfo
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:
- Created a year ago
- Reactions:1
- Comments:10
Top 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 >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found

@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.zipI’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.