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

Release 1.4.0 #409

Merged
merged 6 commits into from
May 9, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion .circleci/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ jobs:
lint:
working_directory: ~/pantheon-systems/wp-redis
docker:
- image: quay.io/pantheon-public/build-tools-ci:8.x-php8.2
- image: quay.io/pantheon-public/build-tools-ci:8.x-php8.0
steps:
- checkout
- restore_cache:
Expand Down Expand Up @@ -96,6 +96,7 @@ jobs:
- restore_cache:
keys:
- test-phpunit-74-dependencies-{{ checksum "composer.json" }}
- run: composer update
- run: composer install -n --prefer-dist
- save_cache:
key: test-phpunit-74-dependencies-{{ checksum "composer.json" }}
Expand Down Expand Up @@ -136,6 +137,7 @@ jobs:
- restore_cache:
keys:
- test-phpunit-74-dependencies-{{ checksum "composer.json" }}
- run: composer update
- run: composer install -n --prefer-dist
- save_cache:
key: test-phpunit-74-dependencies-{{ checksum "composer.json" }}
Expand Down
37 changes: 27 additions & 10 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,13 @@ Pull requests and issues are welcome!

## Workflow

The `develop` branch is the development branch which means it contains the next version to be released. `master` contains the corresponding stable development version. Always work on the `develop` branch and open up PRs against `develop`.
Development and releases are structured around two branches, `develop` and `master`. The `develop` branch is the default branch for the repository, and is the source and destination for feature branches.

We prefer to squash commits (i.e. avoid merge PRs) from a feature branch into `develop` when merging, and to include the PR # in the commit message. PRs to `develop` should also include any relevent updates to the changelog in readme.txt. For example, if a feature constitutes a minor or major version bump, that version update should be discussed and made as part of approving and merging the feature into `develop`.

`develop` should be stable and usable, though possibly a few commits ahead of the public release on wp.org.

The `master` branch matches the latest stable release deployed to [wp.org](wp.org).

## Testing

Expand All @@ -25,13 +31,24 @@ Behat requires a Pantheon site with Redis enabled. Once you've created the site,

## Release Process

1. Starting from `develop`, cut a release branch named `release_X.Y.Z` containing your changes.
1. Update plugin version in `README.md`, `readme.txt`, and `wp-redis.php`.
1. Update the Changelog with the latest changes.
1. Create a PR against the `master` branch.
1. After all tests pass and you have received approval from a CODEOWNER (including resolving any merge conflicts), merge the PR into `master`.
1. Pull `master` locally, create a new tag, and push up.
1. From `develop`, checkout a new branch `release_X.Y.Z`.
1. Make a release commit:
* Drop the `-dev` from the version number in `README.md`, `readme.txt`, and `wp-redis.php`.
* Update the "Latest" heading in the changelog to the new version number with the date
* Commit these changes with the message `Release X.Y.Z`
* Push the release branch up.
1. Open a Pull Request to merge `release_X.Y.Z` into `master`. Your PR should consist of all commits to `develop` since the last release, and one commit to update the version number. The PR name should also be `Release X.Y.Z`.
1. After all tests pass and you have received approval from a [CODEOWNER](./CODEOWNERS), merge the PR into `master`. "Rebase and merge" is preferred in this case. _Never_ squash to `master`.
1. Pull `master` locally, create a new tag (based on version number from previous steps), and push up. The tag should _only_ be the version number. It _should not_ be prefixed `v` (i.e. `X.Y.Z`, not `vX.Y.X`).
1. Confirm that the necessary assets are present in the newly created tag, and test on a WP install if desired.
1. Create a [new release](https://github.com/pantheon-systems/wp-redis/releases/new) using the tag created in the previous steps, naming the release with the new version number, and targeting the tag created in the previous step. Paste the release changelog from the `Changelog` section of the `README` into the body of the release and include a link to the closed issues if applicable.
1. Wait for the [_Release wp-redis plugin to wp.org_ action](https://github.com/pantheon-systems/wp-redis/actions/workflows/wordpress-plugin-deploy.yml) to finish deploying to the WordPress.org repository. If all goes well, users with SVN commit access for that plugin will receive an emailed diff of changes.
1. Check WordPress.org: Ensure that the changes are live on https://wordpress.org/plugins/wp-redis/. This may take a few minutes.
1. Create a [new release](https://github.com/pantheon-systems/wp-redis/releases/new) using the tag created in the previous steps, naming the release with the new version number, and targeting the tag created in the previous step. Paste the release changelog from the `Changelog` section of [the readme](readme.txt) into the body of the release, including the links to the closed issues if applicable.
1. Wait for the [_Release wp-redis plugin to wp.org_ action](https://github.com/pantheon-systems/wp-redis/actions/workflows/wordpress-plugin-deploy.yml) to finish deploying to the WordPress.org plugin repository. If all goes well, users with SVN commit access for that plugin will receive an emailed diff of changes.
1. Check WordPress.org: Ensure that the changes are live on [the plugin repository](https://wordpress.org/plugins/wp-redis/). This may take a few minutes.
1. Following the release, prepare the next dev version with the following steps:
* `git checkout develop`
* `git rebase master`
* Update the version number in all locations, incrementing the version by one patch version, and add the `-dev` flag (e.g. after releasing `1.2.3`, the new verison will be `1.2.4-dev`)
* Add a new `** Latest **` heading to the changelog
* `git add -A .`
* `git commit -m "Prepare X.Y.X-dev"`
* `git push origin develop`
18 changes: 14 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
**Tags:** cache, plugin, redis
**Requires at least:** 3.0.1
**Tested up to:** 6.2
**Stable tag:** 1.3.5
**Stable tag:** 1.4.0
**License:** GPLv2 or later
**License URI:** http://www.gnu.org/licenses/gpl-2.0.html

Expand Down Expand Up @@ -103,14 +103,20 @@ This declaration means use of `wp_cache_set( 'foo', 'bar', 'bad-actor' );` and `
There's a known issue with WordPress `alloptions` cache design. Specifically, a race condition between two requests can cause the object cache to have stale values. If you think you might be impacted by this, [review this GitHub issue](https://github.com/pantheon-systems/wp-redis/issues/221) for links to more context, including a workaround.

## Changelog ##

### 1.4.0 (May 9, 2023) ###
* Add support for `flush_runtime` and `flush_group` functions [[#405](https://github.com/pantheon-systems/wp-redis/pull/405)]
* Add `pantheon-wp-coding-standards` [[#400](https://github.com/pantheon-systems/wp-redis/pull/400)]
* Update CONTRIBUTING.MD [[#406](https://github.com/pantheon-systems/wp-redis/pull/406)]
* Update Composer dependencies [[#401](https://github.com/pantheon-systems/wp-redis/pull/394)]

### 1.3.5 (April 6, 2023) ###
* Bump tested up to version to 6.2
* Update Composer dependencies [[#394](https://github.com/pantheon-systems/wp-redis/pull/394)]

### 1.3.4 (March 7, 2023) ###
* Set `missing_redis_message` if Redis service is not connected [[#391](https://github.com/pantheon-systems/wp-redis/pull/391)]


### 1.3.3 (February 28, 2023) ###
* Add PHP 8.2 support [[#388](https://github.com/pantheon-systems/wp-redis/pull/388)]
* Remove Grunt, add valid license to Composer file [[#387](https://github.com/pantheon-systems/wp-redis/pull/387)]
Expand All @@ -122,8 +128,7 @@ There's a known issue with WordPress `alloptions` cache design. Specifically, a
### 1.3.1 (December 2, 2022) ###
* Declare `wp_cache_supports` function and support features. [[#378](https://github.com/pantheon-systems/wp-redis/pull/378)]
* Make dependabot target `develop` branch for PRs. [[#376](https://github.com/pantheon-systems/wp-redis/pull/376)]

Declare `wp_cache_supports` function and support features. [[#378](https://github.com/pantheon-systems/wp-redis/pull/378)]
* Declare `wp_cache_supports` function and support features. [[#378](https://github.com/pantheon-systems/wp-redis/pull/378)]

### 1.3.0 (November 29, 2022) ###
* Added CONTRIBUTING.MD and GitHub action to automate deployments to wp.org. [[#368](https://github.com/pantheon-systems/wp-redis/pull/368)]
Expand Down Expand Up @@ -225,3 +230,8 @@ Declare `wp_cache_supports` function and support features. [[#378](https://githu

### 0.1 ###
* Initial commit of working code for the benefit of all.

## Upgrade Notice ##

### 1.4.0 (May 9, 2023) ###
WP Redis 1.4.0 adds support for the `flush_runtime` and `flush_group` functions. If you've copied `object-cache.php` and made your own changes, be sure to copy these additions over as well.
9 changes: 0 additions & 9 deletions behat.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,15 +7,6 @@ default:
contexts:
- Behat\MinkExtension\Context\MinkContext
- PantheonSystems\PantheonWordPressUpstreamTests\Behat\AdminLogIn
core:
filters:
tags: "~@upstreamonly"
paths:
- vendor/pantheon-systems/pantheon-wordpress-upstream-tests/features
contexts:
- Behat\MinkExtension\Context\MinkContext
- PantheonSystems\PantheonWordPressUpstreamTests\Behat\AdminLogIn
- PantheonSystems\PantheonWordPressUpstreamTests\Behat\ResponseHeader
extensions:
Behat\MinkExtension:
# base_url set by ENV
Expand Down
10 changes: 8 additions & 2 deletions bin/behat-prepare.sh
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,9 @@ set -ex
terminus env:create $TERMINUS_SITE.dev $TERMINUS_ENV
terminus env:wipe $SITE_ENV --yes

# Enable Redis
terminus redis:enable $TERMINUS_SITE

###
# Get all necessary environment details.
###
Expand Down Expand Up @@ -83,11 +86,14 @@ terminus build:workflow:wait $TERMINUS_SITE.$TERMINUS_ENV
###
# Set up WordPress, theme, and plugins for the test run
###
echo "Installing WordPress..."
# Silence output so as not to show the password.
{
terminus wp $SITE_ENV -- core install --title=$TERMINUS_ENV-$TERMINUS_SITE --url=$PANTHEON_SITE_URL --admin_user=$WORDPRESS_ADMIN_USERNAME [email protected] --admin_password=$WORDPRESS_ADMIN_PASSWORD
terminus wp $SITE_ENV -- core install --title=$TERMINUS_ENV-$TERMINUS_SITE --url=$PANTHEON_SITE_URL --admin_user=$WORDPRESS_ADMIN_USERNAME [email protected] --admin_password=$WORDPRESS_ADMIN_PASSWORD
} &> /dev/null
terminus wp $SITE_ENV -- cache flush

echo "Flush cache and setup environment..."
terminus wp $SITE_ENV -- plugin activate wp-redis classic-editor
terminus wp $SITE_ENV -- cache flush
terminus wp $SITE_ENV -- theme activate twentyseventeen
terminus wp $SITE_ENV -- rewrite structure '/%year%/%monthnum%/%day%/%postname%/'
62 changes: 33 additions & 29 deletions cli.php
Original file line number Diff line number Diff line change
@@ -1,7 +1,10 @@
<?php
/**
* Various WP Redis CLI utility commands.
*/

/**
* Various WP Redis utility commands.
* Main WP Redis CLI command class.
*/
class WP_Redis_CLI_Command {

Expand All @@ -12,31 +15,32 @@ public function cli() {
global $redis_server;

if ( empty( $redis_server ) ) {
# Attempt to automatically load Pantheon's Redis config from the env.
if ( isset( $_SERVER['CACHE_HOST'] ) ) {
$redis_server = array(
'host' => $_SERVER['CACHE_HOST'],
'port' => $_SERVER['CACHE_PORT'],
'auth' => $_SERVER['CACHE_PASSWORD'],
'database' => isset( $_SERVER['CACHE_DB'] ) ? $_SERVER['CACHE_DB'] : 0,
);
// Attempt to automatically load Pantheon's Redis config from the env.
if ( isset( $_SERVER['CACHE_HOST'] ) && isset( $_SERVER['CACHE_PORT'] ) && isset( $_SERVER['CACHE_PASSWORD'] ) && isset( $_SERVER['CACHE_DB'] ) ) {
$redis_server = [
'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'] ),
];
} else {
$redis_server = array(
'host' => '127.0.0.1',
'port' => 6379,
'auth' => '',
$redis_server = [
'host' => '127.0.0.1',
'port' => 6379,
'auth' => '',
'database' => 0,
);
];
}
}

if ( ! isset( $redis_server['database'] ) ) {
$redis_server['database'] = 0;
}

$cmd = WP_CLI\Utils\esc_cmd( 'redis-cli -h %s -p %s -a %s -n %s', $redis_server['host'], $redis_server['port'], $redis_server['auth'], $redis_server['database'] );
$process = WP_CLI\Utils\proc_open_compat( $cmd, array( STDIN, STDOUT, STDERR ), $pipes );
$r = proc_close( $process );
$pipes = null;
$cmd = WP_CLI\Utils\esc_cmd( 'redis-cli -h %s -p %s -a %s -n %s', $redis_server['host'], $redis_server['port'], $redis_server['auth'], $redis_server['database'] );
$process = WP_CLI\Utils\proc_open_compat( $cmd, [ STDIN, STDOUT, STDERR ], $pipes );
$r = proc_close( $process );
exit( (int) $r );
}

Expand All @@ -56,11 +60,11 @@ public function cli() {
public function debug( $_, $assoc_args ) {
global $wp_object_cache;
$this->load_wordpress_with_template();
$data = array(
$data = [
'cache_hits' => $wp_object_cache->cache_hits,
'cache_misses' => $wp_object_cache->cache_misses,
'redis_calls' => $wp_object_cache->redis_calls,
);
];
WP_CLI::print_value( $data, $assoc_args );
}

Expand Down Expand Up @@ -134,14 +138,14 @@ public function enable() {
* Success: Redis stats reset.
*/
public function info( $_, $assoc_args ) {
global $wp_object_cache, $redis_server;
global $wp_object_cache;

if ( ! defined( 'WP_REDIS_OBJECT_CACHE' ) || ! WP_REDIS_OBJECT_CACHE ) {
WP_CLI::error( 'WP Redis object-cache.php file is missing from the wp-content/ directory.' );
}

if ( $wp_object_cache->is_redis_connected && WP_CLI\Utils\get_flag_value( $assoc_args, 'reset' ) ) {
// Redis::resetStat() isn't functional, see https://github.com/phpredis/phpredis/issues/928
// Redis::resetStat() isn't functional, see https://github.com/phpredis/phpredis/issues/928.
if ( $wp_object_cache->redis->eval( "return redis.call('CONFIG','RESETSTAT')" ) ) {
WP_CLI::success( 'Redis stats reset.' );
} else {
Expand All @@ -168,7 +172,7 @@ private function load_wordpress_with_template() {
// Set up the main WordPress query.
wp();

$interpreted = array();
$interpreted = [];
foreach ( $wp_query as $key => $value ) {
if ( 0 === stripos( $key, 'is_' ) && $value ) {
$interpreted[] = $key;
Expand All @@ -188,15 +192,15 @@ function( $template ) {
999
);

// Template is normally loaded in global scope, so we need to replicate
// Template is normally loaded in global scope, so we need to replicate.
foreach ( $GLOBALS as $key => $value ) {
// phpcs:ignore PHPCompatibility.Variables.ForbiddenGlobalVariableVariable.NonBareVariableFound
global $$key;
}

// Load the theme template.
ob_start();
require_once( ABSPATH . WPINC . '/template-loader.php' );
require_once ABSPATH . WPINC . '/template-loader.php';
ob_get_clean();
}

Expand All @@ -206,7 +210,7 @@ function( $template ) {
* @see http://stackoverflow.com/questions/2637945/getting-relative-path-from-absolute-path-in-php
*/
private static function get_relative_path( $from, $to ) {
// some compatibility fixes for Windows paths
// some compatibility fixes for Windows paths.
$from = is_dir( $from ) ? rtrim( $from, '\/' ) . '/' : $from;
$to = is_dir( $to ) ? rtrim( $to, '\/' ) . '/' : $to;
$from = str_replace( '\\', '/', $from );
Expand All @@ -217,15 +221,15 @@ private static function get_relative_path( $from, $to ) {
$rel_path = $to;

foreach ( $from as $depth => $dir ) {
// find first non-matching dir
// find first non-matching dir.
if ( $dir === $to[ $depth ] ) {
// ignore this directory
// ignore this directory.
array_shift( $rel_path );
} else {
// get number of remaining dirs to $from
// get number of remaining dirs to $from.
$remaining = count( $from ) - $depth;
if ( $remaining > 1 ) {
// add traversals up to first matching dir
// add traversals up to first matching dir.
$pad_length = ( count( $rel_path ) + $remaining - 1 ) * -1;
$rel_path = array_pad( $rel_path, $pad_length, '..' );
break;
Expand Down
4 changes: 1 addition & 3 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -12,11 +12,9 @@
"behat/behat": "^3.1",
"behat/mink-extension": "^2.2",
"behat/mink-goutte-driver": "^1.2",
"pantheon-systems/pantheon-wp-coding-standards": "^1.0",
"pantheon-systems/pantheon-wordpress-upstream-tests": "dev-master",
"wp-coding-standards/wpcs": "dev-develop as 2.3.1",
"dealerdirect/phpcodesniffer-composer-installer": "^1.0.0",
"phpunit/phpunit": "^9",
"phpcompatibility/php-compatibility": "^9.3",
"yoast/phpunit-polyfills": "^1.0"
},
"scripts": {
Expand Down
Loading