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

[CMSP-353] Add pantheon-wp-coding-standards #400

Merged
merged 44 commits into from
May 4, 2023

Conversation

jazzsequence
Copy link
Contributor

Adds our coding standards and fixes sniffs.

Also updates the circle lint workflow to use PHP 8

@jazzsequence jazzsequence requested review from a team as code owners April 18, 2023 20:31
@jazzsequence jazzsequence self-assigned this Apr 18, 2023
@pwtyler
Copy link
Member

pwtyler commented Apr 18, 2023

Interesting to note that behat fell down where phpunit did not. Is that a case we should cover with unit testing?

@jazzsequence jazzsequence changed the title Add pantheon-wp-coding-standards Add pantheon-wp-coding-standards [wip] Apr 19, 2023
@jazzsequence
Copy link
Contributor Author

Interesting to note that behat fell down where phpunit did not. Is that a case we should cover with unit testing?

@pwtyler I think there are legit issues that were introduced by some of the fixes for PHPCS sniffs. I'm trying to put stuff back the way it was to see if it can get through Behat and then be more intentional about what I'm changing. But I do think that if things are failing, probably unit tests should cover those unless they are legitimately not able to be covered by functional tests.

@jazzsequence jazzsequence force-pushed the add-pantheon-wp-coding-standards branch from 05de5ef to 1fc2b66 Compare April 19, 2023 16:08
@jazzsequence
Copy link
Contributor Author

Nevermind, it's the upstream tests that are failing, not the Behat tests running from the plugin. 🤦

@jazzsequence jazzsequence changed the title Add pantheon-wp-coding-standards [wip] Add pantheon-wp-coding-standards Apr 28, 2023
@pwtyler
Copy link
Member

pwtyler commented May 2, 2023

Will hold review until #406 is updated with same behat fixes and this PR is rebased.

@jazzsequence
Copy link
Contributor Author

jazzsequence commented May 3, 2023

@pwtyler This PR removes the upstream behat tests (although they're still loaded as a repository, we just aren't running them). I think while pantheon-systems/pantheon-wordpress-upstream-tests#62 is still WIP we can go ahead and merge this and move forward and re-add the upstream tests as those are fixed.

(actually those were removed in @jspellman814's update)

@jazzsequence jazzsequence merged commit 29a3ef8 into develop May 4, 2023
@jazzsequence jazzsequence deleted the add-pantheon-wp-coding-standards branch May 4, 2023 20:05
@jazzsequence jazzsequence changed the title Add pantheon-wp-coding-standards [CMSP-353] Add pantheon-wp-coding-standards May 4, 2023
jspellman814 pushed a commit that referenced this pull request May 8, 2023
* add our coding standards

* use php 8 for linting

* phpcbf fixes

* ignore tests for linting

* adjust and fix sniffs for object-cache.php drop-in

* check if all the server global values

* fix sniffs for WP CLI commands

* do a composer update before install for 7.4

* make the $cache property public

* fix composer update & install in both 7.4 tests

* set $cache_hits property to true

* set redis_calls property to public

* set is_redis_connected property to public

* revert wp_redis_ignore_global_groups const value

* make all the private and protected properties public

* use short arrays again

* remove parenthesis when we instantiate the class

* set object-cache back to what it was

* remove extra isset checks

* add the issets back to the database param

* add original object-cache file back

* use the version of the upstream tests that maybe have the issues fixed

* update the upstream tests

* Revert "add original object-cache file back"

This reverts commit 1fc2b66.

* restore cli.php and wp-redis.php back to what they were

* remove the upstream behat tests
these are failing because they're old and need to be updated. they have nothing to do with the plugin itself

* add some echos

* wordpress isn't actually getting installed
break the brackets

* one line, brackets and remove the &

* guess we can't do this on one line

* don't need that semicolon
i don't think

* okay fine, put it back the way it was

* enable redis before flushing cache

* enable redis on the entire site (not env) and add a wait command

* enable redis early
so we aren't potentially waiting for other things later

* don't need to wait

* don't need to enable because it's already enabled

* don't need an isset, we already know it's set

* use strip all tags instead of sanitize_text_field

* don't activate redis twice and flush cache after wp-redis is active

* re-add composer.lock

* re-add composer update for 7.4
jspellman814 pushed a commit that referenced this pull request May 9, 2023
* add our coding standards

* use php 8 for linting

* phpcbf fixes

* ignore tests for linting

* adjust and fix sniffs for object-cache.php drop-in

* check if all the server global values

* fix sniffs for WP CLI commands

* do a composer update before install for 7.4

* make the $cache property public

* fix composer update & install in both 7.4 tests

* set $cache_hits property to true

* set redis_calls property to public

* set is_redis_connected property to public

* revert wp_redis_ignore_global_groups const value

* make all the private and protected properties public

* use short arrays again

* remove parenthesis when we instantiate the class

* set object-cache back to what it was

* remove extra isset checks

* add the issets back to the database param

* add original object-cache file back

* use the version of the upstream tests that maybe have the issues fixed

* update the upstream tests

* Revert "add original object-cache file back"

This reverts commit 1fc2b66.

* restore cli.php and wp-redis.php back to what they were

* remove the upstream behat tests
these are failing because they're old and need to be updated. they have nothing to do with the plugin itself

* add some echos

* wordpress isn't actually getting installed
break the brackets

* one line, brackets and remove the &

* guess we can't do this on one line

* don't need that semicolon
i don't think

* okay fine, put it back the way it was

* enable redis before flushing cache

* enable redis on the entire site (not env) and add a wait command

* enable redis early
so we aren't potentially waiting for other things later

* don't need to wait

* don't need to enable because it's already enabled

* don't need an isset, we already know it's set

* use strip all tags instead of sanitize_text_field

* don't activate redis twice and flush cache after wp-redis is active

* re-add composer.lock

* re-add composer update for 7.4
$redis_server = [
'host' => wp_strip_all_tags( $_SERVER['CACHE_HOST'] ),
'port' => isset( $_SERVER['CACHE_PORT'] ) ? wp_strip_all_tags( $_SERVER['CACHE_PORT'] ) : 0,
'auth' => isset( $_SERVER['CACHE_PASSWORD'] ) ? wp_strip_all_tags( $_SERVER['CACHE_PASSWORD'] ) : '',
Copy link
Contributor

Choose a reason for hiding this comment

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

@jazzsequence FYI, just noting that this line is incorrect and the default value should have been null as I had indicated in my PR to fixed this. Also, the default port should not be 0 as that is completely invalid for Redis and should be 6379.

#360

Copy link
Contributor

Choose a reason for hiding this comment

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

@jazzsequence noting also that changes should have fixed the issues called out in #359 but in fact broke our patch which we will now have to redo.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

These have been updated in #428. Thanks for digging this up.

'host' => sanitize_text_field( $_SERVER['CACHE_HOST'] ),
'port' => sanitize_text_field( $_SERVER['CACHE_PORT'] ),
'auth' => sanitize_text_field( $_SERVER['CACHE_PASSWORD'] ),
'database' => sanitize_text_field( $_SERVER['CACHE_DB'] ),
Copy link
Contributor

Choose a reason for hiding this comment

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

@jazzsequence this was also incorrectly changed to no longer be providing a default value.

Copy link
Contributor Author

@jazzsequence jazzsequence Jun 5, 2023

Choose a reason for hiding this comment

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

The CACHE_DB value is checked on line 41 -- which checks if ALL of these values are set. If any of them are not set, it uses the default values on lines 49-53

wp-redis/wp-redis.php

Lines 49 to 53 in 1541959

$redis_server = [
'host' => '127.0.0.1',
'port' => 6379,
'database' => 0,
];

timnolte added a commit to timnolte/wp-redis that referenced this pull request Jun 5, 2023
* Fixes pantheon-systems#359
* Falls back on port 6379 if the CACHE_PORT is not configured.
* Doesn't require a CACHE_PASSWORD to be set when it isn't used, or can't be.
* Improves code quality by reducing Redis default port & databasei duplicate values to a share variables.
* Fixes invalid code changes made in PR [pantheon-systems#400 ](pantheon-systems#400) to the core plugin connectivity testing that prevent connectivty checks if the port/password/database aren't explicitly defined.
jazzsequence added a commit that referenced this pull request Jun 5, 2023
* fix: Fixes assumption that CACHE_PORT & CACHE_PASSWORD are Set.

* Fixes #359
* Falls back on port 6379 if the CACHE_PORT is not configured.
* Doesn't require a CACHE_PASSWORD to be set when it isn't used, or can't be.
* Improves code quality by reducing Redis default port & databasei duplicate values to a share variables.
* Fixes invalid code changes made in PR [#400 ](#400) to the core plugin connectivity testing that prevent connectivty checks if the port/password/database aren't explicitly defined.

* update changelog

---------

Co-authored-by: Chris Reynolds <chris@jazzsequence.com>
jazzsequence added a commit that referenced this pull request Jun 26, 2023
* fix: Fixes assumption that CACHE_PORT & CACHE_PASSWORD are Set.

* Fixes #359
* Falls back on port 6379 if the CACHE_PORT is not configured.
* Doesn't require a CACHE_PASSWORD to be set when it isn't used, or can't be.
* Improves code quality by reducing Redis default port & databasei duplicate values to a share variables.
* Fixes invalid code changes made in PR [#400 ](#400) to the core plugin connectivity testing that prevent connectivty checks if the port/password/database aren't explicitly defined.

* update changelog

---------

Co-authored-by: Chris Reynolds <chris@jazzsequence.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants