Opened 11 months ago
Closed 6 months ago
#59650 closed task (blessed) (fixed)
Coding Standards fixes for WP 6.5
Reported by: | hellofromTonya | Owned by: | |
---|---|---|---|
Milestone: | 6.5 | Priority: | normal |
Severity: | normal | Version: | |
Component: | General | Keywords: | has-patch has-unit-tests |
Focuses: | coding-standards | Cc: |
Change History (26)
#1
@
11 months ago
- Summary changed from Coding Standards fixes for WP 6.4 to Coding Standards fixes for WP 6.5
This ticket was mentioned in PR #5517 on WordPress/wordpress-develop by @jrf.
11 months ago
#2
- Keywords has-patch added
This ticket was mentioned in PR #5518 on WordPress/wordpress-develop by @jrf.
11 months ago
#3
It is perfectly possible to write a commented regex with layout for readability by using the x
modifier.
As per the manual:
x (PCRE_EXTENDED)
If this modifier is set, whitespace data characters in the pattern are totally ignored except when escaped or inside a character class, and characters between an unescaped # outside a character class and the next newline character, inclusive, are also ignored. This is equivalent to Perl's /x modifier, and makes it possible to include commentary inside complicated patterns.
Note, however, that this applies only to data characters. Whitespace characters may never appear within special character sequences in a pattern, for example within the sequence (?( which introduces a conditional subpattern.
Ref: https://www.php.net/manual/en/reference.pcre.pattern.modifiers.php
This commit rewrites these two regexes to use the x
modifier and gets rid of the unnecessary phpcs:disable
comments.
The tests in the tests/phpunit/tests/db/dbDelta.php
file cover this change.
Trac ticket: https://core.trac.wordpress.org/ticket/59650
#4
@
11 months ago
I've opened two PRs on GitHub with patches for this ticket. Both rewrite a concatenated multi-line regex with comments to use the regex native "multi-line with comment" format.
This makes it more straight forward to update the regex, if needed, and gets rid of some unnecessary ignore annotations inline.
Both changes are already covered by pre-existing tests (and this has been verified by introducing a typo in the regex and seeing those tests fail - the typo has, of course been removed again after).
- https://github.com/WordPress/wordpress-develop/pull/5517
- https://github.com/WordPress/wordpress-develop/pull/5518
Note: the build failures are unrelated to these PRs, but related to the package.lock
file not having been updated for trunk
now being 6.5.
@SergeyBiryukov commented on PR #5517:
10 months ago
#7
Thanks for the PR! Merged in r57056.
10 months ago
#9
@SergeyBiryukov Looks like the commit message is a bit borked - it references the changes from PR #5518, not the changes from this PR ?
@SergeyBiryukov commented on PR #5517:
10 months ago
#11
@SergeyBiryukov Looks like the commit message is a bit borked - it references the changes from PR #5518, not the changes from this PR ?
Yeah, I mixed up the descriptions of the two PRs, sorry for that! Commit messages cannot be edited afterwards. At least the first sentence is accurate 🙂
@SergeyBiryukov commented on PR #5518:
10 months ago
#12
Thanks for the PR! Merged in r57061.
10 months ago
#13
Looks like the commit message is a bit borked - it references the changes from PR #5518, not the changes from this PR ?
Yeah, I mixed up the descriptions of the two PRs, sorry for that! Commit messages cannot be edited afterwards. At least the first sentence is accurate 🙂
@SergeyBiryukov It happen ;-)
This ticket was mentioned in PR #5652 on WordPress/wordpress-develop by @peterwilsoncc.
10 months ago
#15
- Keywords has-unit-tests added
It is perfectly possible to write a commented regex with layout for readability by using the
x
modifier.As per the manual:
Ref: https://www.php.net/manual/en/reference.pcre.pattern.modifiers.php
This commit rewrites this one regex to use the
x
modifier and gets rid of the unnecessaryphpcs:disable
comments.The tests in the
tests/phpunit/tests/kses.php
file cover this change.Trac ticket: https://core.trac.wordpress.org/ticket/59650