Skip to content

Conversation

@tbradsha
Copy link
Contributor

@tbradsha tbradsha commented Nov 21, 2025

Closes MONOREP-252

This addresses lots of warnings, deprecations, and fatals in the lessphp LESS library (https://github.com/leafo/lessphp). The library hasn't been updated in years, but it's been patched here and there to maintain compatibility.

In my edits I tried to respect the library's current style; it seems to not be linted anyway.

Proposed changes:

PHP Deprecated: Creation of dynamic property lessc::$env is deprecated in /wordpress/plugins/wpcomsh/8.1.0-alpha+rolling.1763722686.g3d7e3e4/jetpack_vendor/automattic/jetpack-mu-wpcom/src/features/custom-css/custom-css/preprocessors/lessc.inc.php on line 1892

The above (and a dozen other variants) are resolved by adding the #[\AllowDynamicProperties] attribute to the relevant classes. Were it not a copy/pasted library the better solution is to add them as properties, but this way allows us to reduce lines-of-code changes for easier comparison to the original.

PHP Deprecated: preg_match(): Passing null to parameter #4 ($flags) of type int is deprecated in /wordpress/plugins/wpcomsh/8.1.0-alpha+rolling.1763722686.g3d7e3e4/jetpack_vendor/automattic/jetpack-mu-wpcom/src/features/custom-css/custom-css/preprocessors/lessc.inc.php on line 3503
PHP Deprecated: preg_match(): Passing null to parameter #4 ($flags) of type int is deprecated in /wordpress/plugins/wpcomsh/8.1.0-alpha+rolling.1763722686.g3d7e3e4/jetpack_vendor/automattic/jetpack-mu-wpcom/src/features/custom-css/custom-css/preprocessors/lessc.inc.php on line 3534

For the above, the flags param expects an int, and null ultimately is treated as 0, so I updated them to use 0 explicitly.

PHP Warning: Trying to access array offset on false in /wordpress/plugins/wpcomsh/8.1.0-alpha+rolling.1763722686.g3d7e3e4/jetpack_vendor/automattic/jetpack-mu-wpcom/src/features/custom-css/custom-css/preprocessors/lessc.inc.php on line 665

For the above, we now make sure the key exists before trying to access its value.

PHP Fatal error: Uncaught TypeError: Unsupported operand types: string * float in /wordpress/plugins/wpcomsh/8.1.0-alpha+rolling.1763722686.g3d7e3e4/jetpack_vendor/automattic/jetpack-mu-wpcom/src/features/custom-css/custom-css/preprocessors/lessc.inc.php:1272

For the above, we cast the values to float. A non-numeric string would become 0, which then can be used in math operations.

Correction (h/t @anomiex): For the above, the keys were off by one, with $color[0] being a string that was used to determine how to process the remaining keys.

PHP Deprecated: Implicit conversion from float 22909.63671875 to int loses precision in /wordpress/plugins/wpcomsh/8.1.0-alpha+rolling.1763722686.g3d7e3e4/jetpack_vendor/automattic/jetpack-mu-wpcom/src/features/custom-css/custom-css/preprocessors/lessc.inc.php on line 1572

For the above, we cast the value to int so we can do modulo math.

Other information:

  • Have you written new tests for your changes, if applicable?
  • Have you checked the E2E test CI results, and verified that your changes do not break them?
  • Have you tested your changes on WordPress.com, if applicable (if so, you'll see a generated comment below with a script to run)?

Jetpack product discussion

Does this pull request change what data or activity we track or use?

Testing instructions:

  • Go to '..'

@tbradsha tbradsha requested a review from a team November 21, 2025 21:52
@tbradsha tbradsha self-assigned this Nov 21, 2025
@tbradsha tbradsha added [Status] Needs Review This PR is ready for review. [Type] Janitorial labels Nov 21, 2025
@github-actions
Copy link
Contributor

github-actions bot commented Nov 21, 2025

Are you an Automattician? Please test your changes on all WordPress.com environments to help mitigate accidental explosions.

  • To test on WoA, go to the Plugins menu on a WoA dev site. Click on the "Upload" button and follow the upgrade flow to be able to upload, install, and activate the Jetpack Beta plugin. Once the plugin is active, go to Jetpack > Jetpack Beta, select your plugin (WordPress.com Site Helper), and enable the fix/address_lessc_preprocessor_issues branch.
  • To test on Simple, run the following command on your sandbox:
bin/jetpack-downloader test jetpack-mu-wpcom-plugin fix/address_lessc_preprocessor_issues

Interested in more tips and information?

  • In your local development environment, use the jetpack rsync command to sync your changes to a WoA dev blog.
  • Read more about our development workflow here: PCYsg-eg0-p2
  • Figure out when your changes will be shipped to customers here: PCYsg-eg5-p2

@github-actions
Copy link
Contributor

Thank you for your PR!

When contributing to Jetpack, we have a few suggestions that can help us test and review your patch:

  • ✅ Include a description of your PR changes.
  • ✅ Add a "[Status]" label (In Progress, Needs Review, ...).
  • ✅ Add a "[Type]" label (Bug, Enhancement, Janitorial, Task).
  • ✅ Add testing instructions.
  • ✅ Specify whether this PR includes any changes to data or privacy.
  • ✅ Add changelog entries to affected projects

This comment will be updated as you work on your PR and make changes. If you think that some of those checks are not needed for your PR, please explain why you think so. Thanks for cooperation 🤖


Follow this PR Review Process:

  1. Ensure all required checks appearing at the bottom of this PR are passing.
  2. Make sure to test your changes on all platforms that it applies to. You're responsible for the quality of the code you ship.
  3. You can use GitHub's Reviewers functionality to request a review.
  4. When it's reviewed and merged, you will be pinged in Slack to deploy the changes to WordPress.com simple once the build is done.

If you have questions about anything, reach out in #jetpack-developers for guidance!

@jp-launch-control
Copy link

jp-launch-control bot commented Nov 21, 2025

Code Coverage Summary

This PR did not change code coverage!

That could be good or bad, depending on the situation. Everything covered before, and still is? Great! Nothing was covered before? Not so great. 🤷

Full summary · PHP report

Copy link
Contributor

@anomiex anomiex left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

One thing inline, otherwise it seems reasonable.

Co-authored-by: Brad Jorsch <[email protected]>
@tbradsha tbradsha requested a review from anomiex November 24, 2025 21:31
Copy link
Contributor

@anomiex anomiex left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks reasonable

@tbradsha tbradsha merged commit 4f81dbd into trunk Nov 24, 2025
66 checks passed
@tbradsha tbradsha deleted the fix/address_lessc_preprocessor_issues branch November 24, 2025 21:44
@github-actions github-actions bot removed the [Status] Needs Review This PR is ready for review. label Nov 24, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants