Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Revert phpcs testVersion back to PHP 5.6 #52384

Merged
merged 1 commit into from
Jul 6, 2023

Conversation

hellofromtonya
Copy link
Contributor

@hellofromtonya hellofromtonya commented Jul 6, 2023

Part of #52344

What?

Reverts the PHP version back to 5.6 for WPCS CI job.

I've changed my mind and now believe WPCS should continue checking PHP compatibility at 5.6.

See:

Why?

Gutenberg needs to continue supporting PHP 5.6. Reverting the WPCS CI, i.e. the Unit Tests / PHP coding standards (pull_request) job, is part of the tooling that helps check PHP compatibility for all code changes.

Why does Gutenberg need to supporting PHP 5.6? Because it supports the latest 2 WordPress major versions, which as of today is WP 6.1 and 6.2. Both of these WP versions support PHP 5.6. Thus, so must Gutenberg.

For example, let's say a contributor declares a function return type. Function return type declarations are valid in PHP 7.0, but not compatible with PHP 5.6.

How?

This PR reverts the phpcs testValue change back to 5.6-.

Testing Instructions

The CI Unit Tests / PHP coding standards (pull_request) job in this PR should pass ✅

Testing it locally involves several steps. The following sections provide set up and testing instructions.

Step 1: Set up

Sample code change

Change a function to declare a return type. For example, change wp_fonts() to

function wp_fonts(): WP_Fonts {

Run PHPCS

You'll use the following command to run phpcs in your favorite command line tool:

composer run lint -- ./lib/experimental/fonts-api/fonts-api.php

Run Gutenberg on PHP 5.6

With wp-env running on Docker, you can add a .wp-env.override.json file locally and define the phpVersion as `"5.6".

Step 2: Before applying the change in this PR:

  1. Run the lint above. Notice WPCS passes.
> phpcs --standard=phpcs.xml.dist './lib/experimental/fonts-api/fonts-api.php'
. 1 / 1 (100%)

Time: 123ms; Memory: 14MB
  1. Now run Gutenberg on PHP 5.6. A fatal error should happen.
Parse error: syntax error, unexpected ':', expecting '{' in /var/www/html/wp-content/plugins/gutenberg/lib/experimental/fonts-api/fonts-api.php on line 20

Step 3: Apply this PR's change and then:

  1. Run the lint above. WPCS should now fail.
> phpcs --standard=phpcs.xml.dist './lib/experimental/fonts-api/fonts-api.php'
E 1 / 1 (100%)

FILE: /Volumes/DevSSD/Dev/wordpress-develop/src/wp-content/plugins/gutenberg/lib/experimental/fonts-api/fonts-api.php
-----------------------------------------------------------------------------------------------------------------------------------------------------------
FOUND 1 ERROR AFFECTING 1 LINE
-----------------------------------------------------------------------------------------------------------------------------------------------------------
 20 | ERROR | Class name return type is not present in PHP version 5.6 or earlier
    |       | (PHPCompatibility.FunctionDeclarations.NewReturnTypeDeclarations.class_nameFound)
-----------------------------------------------------------------------------------------------------------------------------------------------------------

Time: 125ms; Memory: 16MB
  1. Run Gutenberg on PHP 5.6. No fatal error should happen.

@github-actions
Copy link

github-actions bot commented Jul 6, 2023

Flaky tests detected in 830b86e.
Some tests passed with failed attempts. The failures may not be related to this commit but are still reported for visibility. See the documentation for more information.

🔍 Workflow run URL: https://github.com/WordPress/gutenberg/actions/runs/5477528738
📝 Reported issues:

@hellofromtonya hellofromtonya marked this pull request as ready for review July 6, 2023 16:27
@hellofromtonya hellofromtonya self-assigned this Jul 6, 2023
@hellofromtonya hellofromtonya added [Type] Build Tooling Issues or PRs related to build tooling [Type] Automated Testing Testing infrastructure changes impacting the execution of end-to-end (E2E) and/or unit tests. labels Jul 6, 2023
Copy link
Contributor

@anton-vlasenko anton-vlasenko left a comment

Choose a reason for hiding this comment

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

This PR reverts one of the changes that were introduced in #52345, so I consider it to be safe.
Reverting coding standards checks back to PHP 5.6 makes sense to me (please see the reasoning in the PR's description); therefore, I approve this PR.

@anton-vlasenko
Copy link
Contributor

anton-vlasenko commented Jul 6, 2023

I believe this PR should also be backported to the wp/6.3 branch (once it's merged into trunk), along with the original pull request: #52345 (comment)

@anton-vlasenko anton-vlasenko added the Backport to WP 6.7 Beta/RC Pull request that needs to be backported to the WordPress major release that's currently in beta label Jul 6, 2023
@hellofromtonya hellofromtonya merged commit f4c1046 into trunk Jul 6, 2023
@hellofromtonya hellofromtonya deleted the fix/reenable-php56-phpcs branch July 6, 2023 17:32
@github-actions github-actions bot added this to the Gutenberg 16.3 milestone Jul 6, 2023
@hellofromtonya hellofromtonya added Backport to Gutenberg RC Pull request that needs to be backported to a Gutenberg release candidate (RC) and removed Backport to WP 6.7 Beta/RC Pull request that needs to be backported to the WordPress major release that's currently in beta labels Jul 6, 2023
@hellofromtonya
Copy link
Contributor Author

Thank you @anton-vlasenko. I switched the label to backport this change to the Gutenberg RC branch, vs going into WP Core.

@hellofromtonya hellofromtonya added the Backport to WP 6.7 Beta/RC Pull request that needs to be backported to the WordPress major release that's currently in beta label Jul 6, 2023
@hellofromtonya
Copy link
Contributor Author

Whoopsie, I see after reading @Mamaduka's comment on the other PR. Looks like this is needed on both the RC release/16.2 and wp/6.3 branches.

@Mamaduka
Copy link
Member

Mamaduka commented Jul 6, 2023

If the original PR hasn’t been backported yet then there’s no need to backport revert commit.

@hellofromtonya
Copy link
Contributor Author

If the original PR hasn’t been backported yet then there’s no need to backport revert commit.

This commit is a partial revert of the original PR. The original PR also includes removing the 2 PHP 5.6 unit test on WordPress trunk CI job. Therefore, both need to be backported.

tellthemachines pushed a commit that referenced this pull request Jul 7, 2023
Reverts phpcs PHP compatibility version back to 5.6.
@tellthemachines
Copy link
Contributor

I just cherry-picked this PR to the update/first-pre-beta-4 branch to get it included in the next release: 9dc955e

@tellthemachines tellthemachines removed the Backport to WP 6.7 Beta/RC Pull request that needs to be backported to the WordPress major release that's currently in beta label Jul 7, 2023
tellthemachines added a commit that referenced this pull request Jul 7, 2023
* add hint to show template part move (#52395)

* Page Content Focus: Ignore page content within a Query Loop block (#52351)

* Block Editor: Pass context and className props to editor.BlockEdit filter

* Page Content Focus: Ignore content blocks that are within a Query Loop

* Patterns: stop endless snackbars appearing (#52012)

* Patterns: Distinguish between theme patterns and template parts in category list (#52382)

* Allow opt out of auto-creation of Navigation fallback (#52319)

* Update welcome guide copy (#52282)

* Patterns: Update pattern copy (#52340)

* Post Title: The changes should be reflected when previewing a post (#52369)

* Update fixed block toolbar (#52123)

* update the icons for expanding and collapsing the fixed block toolbar

* hide the tools selector item in document tools for fixed toolbar preference

* reveal undo, redo and list view buttons

* tweaks for show icon labels and hide zoom out for top toolbar option

* improve the responsiveness of the fixed block toolbar

* remove the overflow rule - bad experiment

* update top toolbar test with the new label for buttons

* update the toolbar tests to account for moving the collapse button

* Drop PHP 5.6 CI jobs (#52345)

* Remove PHP 5.6 PHPUnit CI job
* Raise version in phpcs / WPCS

* Patterns: Add handling of sync status to the wp-admin patterns list page (#52346)

* Exit template focus when opening the W menu (#52235)

* wrap buttons (#52249)

* Update the behavior of the cached undo/redo stack (#51644)

Co-authored-by: Ella van Durpe <ella@vandurpe.com>

* Adjust top position (#52248)

* Patterns: add a hint about the rename of reusable blocks to menu and inserter  (#51771)

Co-authored-by: Saxon Fletcher <saxonafletcher@gmail.com>

* Site Editor: update headings hierarchy in the 'Manage all' screens (#52271)

* This commit:
- updates heading levels on the template and template part pages
- passes a `level` prop to Header from Page

* update h2 size

* Rolling back custom sizes

* Rolling back unnecessary classNames
There was a rogue space in trunk. Let's let it live

* Check randomizer experiment is enabled before rendering button (#52306)

* Hide parent selector when parent is 'disabled' or 'contentOnly' (#52264)

* Fix incorrect aria-describedby attributes for theme patterns (#52263)

* Patterns: rename sync_status and move to top level field on rest return instead of a meta field (#52146)

* Fix default block dimensions visibility (#52256)

* core/heading

* core/details

* core/list

* core/table

* core/video

* core/verse

* core/social-links

* core/site-title

* core/site-tagline

* core/site-logo

* core/post-time-to-read

* core/gallery

* core/code

* core/categories

* core/audio

* core/archives

* Patterns: Display all custom template part areas in sidebar nav (#52355)

* Revert phpcs back to PHP 5.6 (#52384)

Reverts phpcs PHP compatibility version back to 5.6.

* Check if experiment enabled fr this time (#52315)

* Navigation: Remove one preloaded endpoint (#52115)

* default to showing status (#52226)

* Command palette: rename (#52153)

* Revise use of “command menu” to “command palette”.

Dropping "global" where it was used as well.

* Find “command center” and replace with “command palette”

* Image block and behaviors: Fix some warnings (#52109)

* Fix first warning

* Fix second warning - dividing a NaN

* Turn off DFM for style book and style editing (#52117)

* Add confirmation step when deleting a Template (#52236)

* [Command Palette]: Remove suggestion for deleting templates/parts (#52168)

* Update stepper styling in Home template details panel (#51972)

* Update stepper styling

* Remove !important

* [Edit Post]: Add toggle fullscreen mode and list view commands (#52184)

* Style Book: Show tabs and make blocks clickable when entering edit mode from the Styles menu (#52222)

* Style Book: Show tabs and make blocks clickable when entering edit mode from the Styles menu

* Move lines

* !important (#52025)

* Navigation in Site View: Readd the edit button (#52111)

* Fix UnitControl crashing on regex control characters.

Units are now escaped using `escapeRegExp` before concatenating them into a regular expression.

Fixes #52211.
---------

Co-authored-by: Mitchell Austin <mr.fye@oneandthesame.net>

* Patterns: rename wp_block sync_status postmeta to wp_pattern_sync_status (#52232)

---------

Co-authored-by: Kai Hao <kai@kaihao.dev>

* Site Editor Frame: Ignore Spotlight in view mode (#52262)

* Guide: Place focus on the guide's container instead of its first tabbable (#52300)

* Guide: Place focus on the guide's container instead of its first tabbable

* Update CHANGELOG

* Post editor: Require confirmation before removing Footnotes (#52277)

* Post editor: Require confirmation before removing Footnotes

Context: #52176

* BlockRemovalWarningModal: Limit width to 40rem

* Explain that footnotes are preserved. Add warning to Site Editor

* Fix react-dropdown-menu version to avoid breaking change from one of … (#52356)

* Fix react-dropdown-menu version to avoid breaking change from one if its dependencies.

* Changelog update

* move changelog entry to the right place

* Update package-lock

---------

Co-authored-by: Saxon Fletcher <saxonafletcher@gmail.com>
Co-authored-by: Robert Anderson <robert@noisysocks.com>
Co-authored-by: Glen Davies <glendaviesnz@users.noreply.github.com>
Co-authored-by: James Koster <james@jameskoster.co.uk>
Co-authored-by: Dave Smith <getdavemail@gmail.com>
Co-authored-by: George Mamadashvili <georgemamadashvili@gmail.com>
Co-authored-by: Andrei Draganescu <me@andreidraganescu.info>
Co-authored-by: Tonya Mork <tonya.mork@automattic.com>
Co-authored-by: Riad Benguella <benguella@gmail.com>
Co-authored-by: Ella van Durpe <ella@vandurpe.com>
Co-authored-by: Ramon <ramonjd@users.noreply.github.com>
Co-authored-by: Kai Hao <kevin830726@gmail.com>
Co-authored-by: Rich Tabor <hi@richtabor.com>
Co-authored-by: Aaron Robertshaw <60436221+aaronrobertshaw@users.noreply.github.com>
Co-authored-by: Ben Dwyer <ben@scruffian.com>
Co-authored-by: Mitchell Austin <mr.fye@oneandthesame.net>
Co-authored-by: Carlos Bravo <37012961+c4rl0sbr4v0@users.noreply.github.com>
Co-authored-by: Nik Tsekouras <ntsekouras@outlook.com>
Co-authored-by: Aki Hamano <54422211+t-hamano@users.noreply.github.com>
Co-authored-by: Timothy Jacobs <timothy@ironbounddesigns.com>
Co-authored-by: Kai Hao <kai@kaihao.dev>
Co-authored-by: Miguel Fonseca <150562+mcsf@users.noreply.github.com>
fullofcaffeine pushed a commit that referenced this pull request Jul 11, 2023
Reverts phpcs PHP compatibility version back to 5.6.
@ockham
Copy link
Contributor

ockham commented Jul 12, 2023

@fullofcaffeine cherry-picked this to the release/16.2 branch in e110b21.

@ockham ockham removed the Backport to Gutenberg RC Pull request that needs to be backported to a Gutenberg release candidate (RC) label Jul 12, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
[Type] Automated Testing Testing infrastructure changes impacting the execution of end-to-end (E2E) and/or unit tests. [Type] Build Tooling Issues or PRs related to build tooling
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants