From 1e2ce444d596547377ff18db4b97c681365bb46a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ionu=C8=9B=20Staicu?= Date: Mon, 24 Apr 2023 19:20:41 +0300 Subject: [PATCH 01/11] typo in var caused undefined notice (#582) --- views/options/action.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/views/options/action.php b/views/options/action.php index 1f065a68..d8e9c06b 100644 --- a/views/options/action.php +++ b/views/options/action.php @@ -58,7 +58,7 @@ $upload_dir = wp_upload_dir(); $base_dir = $upload_dir['basedir']; $base_dir = str_replace( ABSPATH, '/', $base_dir ); - $dir = $basedir . '/solr-for-wordpress-on-pantheon/'; + $dir = $base_dir . '/solr-for-wordpress-on-pantheon/'; } ?> To use a custom schema.xml, upload it to the From 6af57a394f6b77002d166f15fd4d9f86eceb3d88 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Mon, 8 May 2023 16:05:32 -0600 Subject: [PATCH 02/11] Bump grunt-contrib-cssmin from 4.0.0 to 5.0.0 (#583) Bumps [grunt-contrib-cssmin](https://github.com/gruntjs/grunt-contrib-cssmin) from 4.0.0 to 5.0.0. - [Release notes](https://github.com/gruntjs/grunt-contrib-cssmin/releases) - [Changelog](https://github.com/gruntjs/grunt-contrib-cssmin/blob/main/CHANGELOG) - [Commits](https://github.com/gruntjs/grunt-contrib-cssmin/compare/v4.0.0...v5.0.0) --- updated-dependencies: - dependency-name: grunt-contrib-cssmin dependency-type: direct:development update-type: version-update:semver-major ... Signed-off-by: dependabot[bot] Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> --- package-lock.json | 24 ++++++++++++------------ package.json | 2 +- 2 files changed, 13 insertions(+), 13 deletions(-) diff --git a/package-lock.json b/package-lock.json index f0776f33..9420f17c 100644 --- a/package-lock.json +++ b/package-lock.json @@ -10,7 +10,7 @@ "devDependencies": { "grunt": "^1.6.1", "grunt-autoprefixer": "~3.0.4", - "grunt-contrib-cssmin": "^4.0.0", + "grunt-contrib-cssmin": "^5.0.0", "grunt-contrib-jshint": "^3.2.0", "grunt-contrib-uglify": "~5.2.2", "grunt-contrib-watch": "^1.1.0", @@ -1346,17 +1346,17 @@ } }, "node_modules/grunt-contrib-cssmin": { - "version": "4.0.0", - "resolved": "https://registry.npmjs.org/grunt-contrib-cssmin/-/grunt-contrib-cssmin-4.0.0.tgz", - "integrity": "sha512-jXU+Zlk8Q8XztOGNGpjYlD/BDQ0n95IHKrQKtFR7Gd8hZrzgqiG1Ra7cGYc8h2DD9vkSFGNlweb9Q00rBxOK2w==", + "version": "5.0.0", + "resolved": "https://registry.npmjs.org/grunt-contrib-cssmin/-/grunt-contrib-cssmin-5.0.0.tgz", + "integrity": "sha512-SNp4H4+85mm2xaHYi83FBHuOXylpi5vcwgtNoYCZBbkgeXQXoeTAKa59VODRb0woTDBvxouP91Ff5PzCkikg6g==", "dev": true, "dependencies": { - "chalk": "^4.1.0", - "clean-css": "^5.0.1", + "chalk": "^4.1.2", + "clean-css": "^5.3.2", "maxmin": "^3.0.0" }, "engines": { - "node": ">=10.0" + "node": ">=14.0" } }, "node_modules/grunt-contrib-cssmin/node_modules/ansi-styles": { @@ -5374,13 +5374,13 @@ } }, "grunt-contrib-cssmin": { - "version": "4.0.0", - "resolved": "https://registry.npmjs.org/grunt-contrib-cssmin/-/grunt-contrib-cssmin-4.0.0.tgz", - "integrity": "sha512-jXU+Zlk8Q8XztOGNGpjYlD/BDQ0n95IHKrQKtFR7Gd8hZrzgqiG1Ra7cGYc8h2DD9vkSFGNlweb9Q00rBxOK2w==", + "version": "5.0.0", + "resolved": "https://registry.npmjs.org/grunt-contrib-cssmin/-/grunt-contrib-cssmin-5.0.0.tgz", + "integrity": "sha512-SNp4H4+85mm2xaHYi83FBHuOXylpi5vcwgtNoYCZBbkgeXQXoeTAKa59VODRb0woTDBvxouP91Ff5PzCkikg6g==", "dev": true, "requires": { - "chalk": "^4.1.0", - "clean-css": "^5.0.1", + "chalk": "^4.1.2", + "clean-css": "^5.3.2", "maxmin": "^3.0.0" }, "dependencies": { diff --git a/package.json b/package.json index 7b76e68b..d9d74d4b 100644 --- a/package.json +++ b/package.json @@ -15,7 +15,7 @@ "devDependencies": { "grunt": "^1.6.1", "grunt-autoprefixer": "~3.0.4", - "grunt-contrib-cssmin": "^4.0.0", + "grunt-contrib-cssmin": "^5.0.0", "grunt-contrib-jshint": "^3.2.0", "grunt-contrib-uglify": "~5.2.2", "grunt-contrib-watch": "^1.1.0", From f59847d8016623f4e17a4901aa9531b352ba0662 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Wed, 24 May 2023 16:11:23 -0600 Subject: [PATCH 03/11] Bump node-sass from 8.0.0 to 9.0.0 (#584) --- package-lock.json | 16 ++++++++-------- package.json | 2 +- 2 files changed, 9 insertions(+), 9 deletions(-) diff --git a/package-lock.json b/package-lock.json index 9420f17c..5239eb2c 100644 --- a/package-lock.json +++ b/package-lock.json @@ -16,7 +16,7 @@ "grunt-contrib-watch": "^1.1.0", "grunt-sass": "~3.1.0", "grunt-wp-readme-to-markdown": "~2.1.0", - "node-sass": "^8.0.0" + "node-sass": "^9.0.0" } }, "node_modules/@babel/code-frame": { @@ -2864,9 +2864,9 @@ } }, "node_modules/node-sass": { - "version": "8.0.0", - "resolved": "https://registry.npmjs.org/node-sass/-/node-sass-8.0.0.tgz", - "integrity": "sha512-jPzqCF2/e6JXw6r3VxfIqYc8tKQdkj5Z/BDATYyG6FL6b/LuYBNFGFVhus0mthcWifHm/JzBpKAd+3eXsWeK/A==", + "version": "9.0.0", + "resolved": "https://registry.npmjs.org/node-sass/-/node-sass-9.0.0.tgz", + "integrity": "sha512-yltEuuLrfH6M7Pq2gAj5B6Zm7m+gdZoG66wTqG6mIZV/zijq3M2OO2HswtT6oBspPyFhHDcaxWpsBm0fRNDHPg==", "dev": true, "hasInstallScript": true, "dependencies": { @@ -2889,7 +2889,7 @@ "node-sass": "bin/node-sass" }, "engines": { - "node": ">=14" + "node": ">=16" } }, "node_modules/node-sass/node_modules/ansi-styles": { @@ -6550,9 +6550,9 @@ } }, "node-sass": { - "version": "8.0.0", - "resolved": "https://registry.npmjs.org/node-sass/-/node-sass-8.0.0.tgz", - "integrity": "sha512-jPzqCF2/e6JXw6r3VxfIqYc8tKQdkj5Z/BDATYyG6FL6b/LuYBNFGFVhus0mthcWifHm/JzBpKAd+3eXsWeK/A==", + "version": "9.0.0", + "resolved": "https://registry.npmjs.org/node-sass/-/node-sass-9.0.0.tgz", + "integrity": "sha512-yltEuuLrfH6M7Pq2gAj5B6Zm7m+gdZoG66wTqG6mIZV/zijq3M2OO2HswtT6oBspPyFhHDcaxWpsBm0fRNDHPg==", "dev": true, "requires": { "async-foreach": "^0.1.3", diff --git a/package.json b/package.json index d9d74d4b..8c343a06 100644 --- a/package.json +++ b/package.json @@ -21,6 +21,6 @@ "grunt-contrib-watch": "^1.1.0", "grunt-sass": "~3.1.0", "grunt-wp-readme-to-markdown": "~2.1.0", - "node-sass": "^8.0.0" + "node-sass": "^9.0.0" } } From f04c9f8f6d70bb458ae9958edf435ddc2ac85bc0 Mon Sep 17 00:00:00 2001 From: John Spellman Date: Thu, 1 Jun 2023 11:48:53 -0600 Subject: [PATCH 04/11] Update CONTRIBUTING.md (#585) * update contributing.md * clarify where the changelogs are --- CHANGELOG.md | 16 +++++++++------- CONTRIBUTING.md | 38 ++++++++++++++++++++++++++++---------- README.md | 2 +- readme.txt | 7 ++++++- solr-power.php | 4 ++-- 5 files changed, 46 insertions(+), 21 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 12f8ab95..0fa93e82 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,27 +1,29 @@ ## Changelog ## -## 2.4.5 (April 9, 2023) ## +### Latest ### +* Updates CONTRIBUTING.md [[#585](https://github.com/pantheon-systems/solr-power/pull/585)] +* Fixes typo in var which caused undefined notice [[#582](https://github.com/pantheon-systems/solr-power/pull/582)] +* Update Composer dependencies [[#576](https://github.com/pantheon-systems/solr-power/pull/576)] [[#574](https://github.com/pantheon-systems/solr-power/pull/583)] [[#573](https://github.com/pantheon-systems/solr-power/pull/584)] + +### 2.4.5 (April 9, 2023) ### * Fixes missing vendor/ directory in previous release [[#580](https://github.com/pantheon-systems/solr-power/pull/580)] -## 2.4.4 (April 7, 2023) ## +### 2.4.4 (April 7, 2023) ### * Update Composer dependencies [[#576](https://github.com/pantheon-systems/solr-power/pull/576)] [[#574](https://github.com/pantheon-systems/solr-power/pull/574)] [[#573](https://github.com/pantheon-systems/solr-power/pull/573)] * Fix failing tests [[#577](https://github.com/pantheon-systems/solr-power/pull/577)] * Update tested up to version -## 2.4.3 (January 19, 2022) ## * Include schema.xml in release distribution [[#568](https://github.com/pantheon-systems/solr-power/pull/568)] -## 2.4.2 (December 2, 2022) ## +### 2.4.2 (December 2, 2022) ### * Re-add changelog heading to readme.txt [[#564](https://github.com/pantheon-systems/solr-power/pull/564)] -## 2.4.1 (December 1, 2022) ## +### 2.4.1 (December 1, 2022) ### * Fixes the WordPress `readme.txt` [[#562](https://github.com/pantheon-systems/solr-power/pull/562/)] -## 2.4.0 (November 30, 2022) ## * Adds Github Actions for building tag and deploying to wp.org. Add CONTRIBUTING.md. [[#551](https://github.com/pantheon-systems/solr-power/issues/551)] * Added SOLRPOWER_DISABLE_AUTOCOMMIT to disable autocommitting of posts, moved CHANGELOG to it's own file, added `$post->score` value to parsed search results [[#559](https://github.com/pantheon-systems/solr-power/pull/559)] -## 2.3.3 (September 28, 2022) ## * Fixes issue where options could not be saved [[#541](https://github.com/pantheon-systems/solr-power/issues/541)] * Enforces network activation requirement for WordPress multisite [[#538](https://github.com/pantheon-systems/solr-power/issues/538)] diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index 5f043971..5dc66cdf 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -4,7 +4,13 @@ Since 2.3.3 the default branch is `main`. Please make sure you are working again ## Workflow -The `develop` branch is the development branch which means it contains the next version to be released. `main` 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 `main`. 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 `main` branch matches the latest stable release deployed to [wp.org](wp.org). ## Testing @@ -23,12 +29,24 @@ Note that dependencies are installed via Composer and the `vendor` directory is ## Release Process -1. Starting from `develop`, cut a release branch named `release_X.Y.Z` containing your changes. -1. Update plugin version in `package.json`, `README.md`, `readme.txt`, and `solr-power.php`. -1. Update the Changelog with the latest changes. -1. Create a PR against the `main` branch. -1. After all tests pass and you have received approval from a CODEOWNER (including resolving any merge conflicts), merge the PR into `main`. -1. [Check the _Build and Tag_ action](https://github.com/pantheon-systems/solr-power/actions/workflows/build-tag.yml): a new tag named with the version number should've been created. It should contain all the built assets. -1. Create a [new release](https://github.com/pantheon-systems/solr-power/releases/new), naming the release with the new version number, and targeting the tag created in the previous step. Paste the release changelog from `CHANGELOG.md` into the body of the release and include a link to the closed issues if applicable. -1. Wait for the [_Release solr-power plugin to wp.org_ action](https://github.com/pantheon-systems/solr-power/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/solr-power/. This may take a few minutes. \ No newline at end of file +1. From `develop`, checkout a new branch `release_X.Y.Z`. +1. Make a release commit: + * Drop the `-dev` from the version number in `package.json`, `README.md`, `readme.txt`, and `solr-power.php`. + * Update the "Latest" heading in the changelog (both `CHANGELOG.md` and in `readme.txt`) 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 `main`. 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 `main`. "Rebase and merge" is preferred in this case. _Never_ squash to `main`. +1. Pull `main` 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/solr-power/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 solr-power plugin to wp.org_ action](https://github.com/pantheon-systems/solr-power/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/solr-power/). This may take a few minutes. +1. Following the release, prepare the next dev version with the following steps: + * `git checkout develop` + * `git rebase main` + * 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` \ No newline at end of file diff --git a/README.md b/README.md index 6236f5b5..df8d0755 100644 --- a/README.md +++ b/README.md @@ -4,7 +4,7 @@ **Requires at least:** 4.6 **Requires PHP:** 7.1 **Tested up to:** 6.2 -**Stable tag:** 2.4.5 +**Stable tag:** 2.4.6-dev **License:** GPLv2 or later **License URI:** http://www.gnu.org/licenses/gpl-2.0.html diff --git a/readme.txt b/readme.txt index 003fc65e..973c12a8 100644 --- a/readme.txt +++ b/readme.txt @@ -4,7 +4,7 @@ Tags: search Requires at least: 4.6 Requires PHP: 7.1 Tested up to: 6.2 -Stable tag: 2.4.5 +Stable tag: 2.4.6-dev License: GPLv2 or later License URI: http://www.gnu.org/licenses/gpl-2.0.html @@ -228,6 +228,11 @@ To force-commit data when this variable is defined outside of a normal cron run, == Changelog == += Latest = +* Updates CONTRIBUTING.md [[#585](https://github.com/pantheon-systems/solr-power/pull/585)] +* Fixes typo in var which caused undefined notice [[#582](https://github.com/pantheon-systems/solr-power/pull/582)] +* Update Composer dependencies [[#576](https://github.com/pantheon-systems/solr-power/pull/576)] [[#574](https://github.com/pantheon-systems/solr-power/pull/583)] [[#573](https://github.com/pantheon-systems/solr-power/pull/584)] + = 2.4.5 (April 9, 2023) = * Fixes missing vendor/ directory in previous release [[#580](https://github.com/pantheon-systems/solr-power/pull/580)] diff --git a/solr-power.php b/solr-power.php index 7d6025ec..d4ecc18f 100644 --- a/solr-power.php +++ b/solr-power.php @@ -2,7 +2,7 @@ /** * Plugin Name: Solr Power * Description: Allows WordPress sites to index and search content with ApacheSolr. - * Version: 2.4.5 + * Version: 2.4.6-dev * Author: Pantheon * Author URI: http://pantheon.io * Text Domain: solr-for-wordpress-on-pantheon @@ -10,7 +10,7 @@ * @package Solr_Power **/ -define( 'SOLR_POWER_VERSION', '2.4.5' ); +define( 'SOLR_POWER_VERSION', '2.4.6-dev' ); /** * Copyright (c) 2011-2022 Pantheon, Matt Weber, Solr Power contributors From 7dbf193090822fb1d5ad0bb6a1069b76765e6ac8 Mon Sep 17 00:00:00 2001 From: Kevin Porras Date: Wed, 7 Jun 2023 07:05:35 -0600 Subject: [PATCH 05/11] Merge pull request #586 from pantheon-systems/dependabot/composer/develop/yoast/phpunit-polyfills-2.0.0 Bump yoast/phpunit-polyfills from 1.0.5 to 2.0.0 --- composer.json | 2 +- composer.lock | 28 ++++++++++++++-------------- 2 files changed, 15 insertions(+), 15 deletions(-) diff --git a/composer.json b/composer.json index e02ffca8..ab25beba 100644 --- a/composer.json +++ b/composer.json @@ -32,7 +32,7 @@ "dealerdirect/phpcodesniffer-composer-installer": "^1.0.0", "phpunit/phpunit": "^6 || ^7", "phpcompatibility/php-compatibility": "^9.3", - "yoast/phpunit-polyfills": "^1.0" + "yoast/phpunit-polyfills": "^2.0" }, "scripts": { "lint": [ diff --git a/composer.lock b/composer.lock index a4a02633..4c7bb0a5 100644 --- a/composer.lock +++ b/composer.lock @@ -4,7 +4,7 @@ "Read more about it at https://getcomposer.org/doc/01-basic-usage.md#installing-dependencies", "This file is @generated automatically" ], - "content-hash": "9cf1c995b853a8d73bc305dd4c177385", + "content-hash": "9971da5872d73092e02191e0753f5a2d", "packages": [ { "name": "solarium/solarium", @@ -2311,16 +2311,16 @@ }, { "name": "sebastian/diff", - "version": "3.0.3", + "version": "3.0.4", "source": { "type": "git", "url": "https://github.com/sebastianbergmann/diff.git", - "reference": "14f72dd46eaf2f2293cbe79c93cc0bc43161a211" + "reference": "6296a0c086dd0117c1b78b059374d7fcbe7545ae" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/sebastianbergmann/diff/zipball/14f72dd46eaf2f2293cbe79c93cc0bc43161a211", - "reference": "14f72dd46eaf2f2293cbe79c93cc0bc43161a211", + "url": "https://api.github.com/repos/sebastianbergmann/diff/zipball/6296a0c086dd0117c1b78b059374d7fcbe7545ae", + "reference": "6296a0c086dd0117c1b78b059374d7fcbe7545ae", "shasum": "" }, "require": { @@ -2365,7 +2365,7 @@ ], "support": { "issues": "https://github.com/sebastianbergmann/diff/issues", - "source": "https://github.com/sebastianbergmann/diff/tree/3.0.3" + "source": "https://github.com/sebastianbergmann/diff/tree/3.0.4" }, "funding": [ { @@ -2373,7 +2373,7 @@ "type": "github" } ], - "time": "2020-11-30T07:59:04+00:00" + "time": "2023-05-07T05:30:20+00:00" }, { "name": "sebastian/environment", @@ -4192,21 +4192,21 @@ }, { "name": "yoast/phpunit-polyfills", - "version": "1.0.5", + "version": "2.0.0", "source": { "type": "git", "url": "https://github.com/Yoast/PHPUnit-Polyfills.git", - "reference": "3b59adeef77fb1c03ff5381dbb9d68b0aaff3171" + "reference": "c758753e8f9dac251fed396a73c8305af3f17922" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/Yoast/PHPUnit-Polyfills/zipball/3b59adeef77fb1c03ff5381dbb9d68b0aaff3171", - "reference": "3b59adeef77fb1c03ff5381dbb9d68b0aaff3171", + "url": "https://api.github.com/repos/Yoast/PHPUnit-Polyfills/zipball/c758753e8f9dac251fed396a73c8305af3f17922", + "reference": "c758753e8f9dac251fed396a73c8305af3f17922", "shasum": "" }, "require": { - "php": ">=5.4", - "phpunit/phpunit": "^4.8.36 || ^5.7.21 || ^6.0 || ^7.0 || ^8.0 || ^9.0" + "php": ">=5.6", + "phpunit/phpunit": "^5.7.21 || ^6.0 || ^7.0 || ^8.0 || ^9.0 || ^10.0" }, "require-dev": { "yoast/yoastcs": "^2.3.0" @@ -4248,7 +4248,7 @@ "issues": "https://github.com/Yoast/PHPUnit-Polyfills/issues", "source": "https://github.com/Yoast/PHPUnit-Polyfills" }, - "time": "2023-03-30T23:39:05+00:00" + "time": "2023-06-06T20:28:24+00:00" } ], "aliases": [], From dce2fc69e199f519a58d49bb6f999a0bf0a0a051 Mon Sep 17 00:00:00 2001 From: Chris Reynolds Date: Fri, 30 Jun 2023 15:36:27 -0600 Subject: [PATCH 06/11] [CMSP-480] mVDP Readme update (#589) * add mvdp note to readmes * update changelog & add link to PR * re-dd whitespace --- CHANGELOG.md | 1 + README.md | 4 ++++ readme.txt | 5 +++++ 3 files changed, 10 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 0fa93e82..5344f7c1 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -4,6 +4,7 @@ * Updates CONTRIBUTING.md [[#585](https://github.com/pantheon-systems/solr-power/pull/585)] * Fixes typo in var which caused undefined notice [[#582](https://github.com/pantheon-systems/solr-power/pull/582)] * Update Composer dependencies [[#576](https://github.com/pantheon-systems/solr-power/pull/576)] [[#574](https://github.com/pantheon-systems/solr-power/pull/583)] [[#573](https://github.com/pantheon-systems/solr-power/pull/584)] +* Updates security policy [[#589](https://github.com/pantheon-systems/solr-power/pull/589)] ### 2.4.5 (April 9, 2023) ### * Fixes missing vendor/ directory in previous release [[#580](https://github.com/pantheon-systems/solr-power/pull/580)] diff --git a/README.md b/README.md index df8d0755..e5202da4 100644 --- a/README.md +++ b/README.md @@ -218,3 +218,7 @@ To force-commit data when this variable is defined outside of a normal cron run, ```bash wp solr commit ``` + +## Security Policy +### Reporting Security Bugs +Please report security bugs found in the Solr Power plugin's source code through the [Patchstack Vulnerability Disclosure Program](https://patchstack.com/database/vdp/solr-power). The Patchstack team will assist you with verification, CVE assignment, and notify the developers of this plugin. diff --git a/readme.txt b/readme.txt index 973c12a8..d3becd07 100644 --- a/readme.txt +++ b/readme.txt @@ -226,12 +226,17 @@ To force-commit data when this variable is defined outside of a normal cron run, wp solr commit +== Frequently Asked Questions == += Where do I report security bugs found in this plugin? = +Please report security bugs found in the source code of the Solr Power plugin through the [Patchstack Vulnerability Disclosure Program](https://patchstack.com/database/vdp/solr-power). The Patchstack team will assist you with verification, CVE assignment, and notify the developers of this plugin. + == Changelog == = Latest = * Updates CONTRIBUTING.md [[#585](https://github.com/pantheon-systems/solr-power/pull/585)] * Fixes typo in var which caused undefined notice [[#582](https://github.com/pantheon-systems/solr-power/pull/582)] * Update Composer dependencies [[#576](https://github.com/pantheon-systems/solr-power/pull/576)] [[#574](https://github.com/pantheon-systems/solr-power/pull/583)] [[#573](https://github.com/pantheon-systems/solr-power/pull/584)] +* Updates security policy [[#589](https://github.com/pantheon-systems/solr-power/pull/589)] = 2.4.5 (April 9, 2023) = * Fixes missing vendor/ directory in previous release [[#580](https://github.com/pantheon-systems/solr-power/pull/580)] From ef02320426995d65b4f7ae098d4479a999152100 Mon Sep 17 00:00:00 2001 From: Chris Reynolds Date: Mon, 3 Jul 2023 08:51:40 -0600 Subject: [PATCH 07/11] Add WP.org validator (#590) * add the wp.org validator * update changelog * use wp_safe_redirect in favor of wp_redirect * use '' instead of null null is deprecated * wporg linting fixes * escape other things on the same line * ignore both rules * move wp_kses_post outside the apply_filters * sanitize the unsanitized thing * ignore both rules * one more --- .github/workflows/wporg-validator.yml | 13 ++++++ CHANGELOG.md | 1 + includes/class-solrpower-batch-index.php | 4 +- includes/class-solrpower-facet-widget.php | 10 ++--- includes/class-solrpower-options.php | 2 +- includes/class-solrpower-sync.php | 4 +- includes/class-solrpower.php | 12 +++--- includes/legacy-functions.php | 8 ++-- readme.txt | 1 + template/s4w_search.php | 48 +++++++++++------------ template/s4wp_search.php | 48 +++++++++++------------ templates/solr-search-results.php | 4 +- 12 files changed, 85 insertions(+), 70 deletions(-) create mode 100644 .github/workflows/wporg-validator.yml diff --git a/.github/workflows/wporg-validator.yml b/.github/workflows/wporg-validator.yml new file mode 100644 index 00000000..e1dd30f5 --- /dev/null +++ b/.github/workflows/wporg-validator.yml @@ -0,0 +1,13 @@ +# On push, run the action-wporg-validator workflow. +name: WP.org Validator +on: [push] +jobs: + wporg-validation: + runs-on: ubuntu-latest + steps: + - name: Checkout + uses: actions/checkout@v3 + - name: WP.org Validator + uses: pantheon-systems/action-wporg-validator@1.0.0 + with: + type: plugin diff --git a/CHANGELOG.md b/CHANGELOG.md index 5344f7c1..4847e565 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -4,6 +4,7 @@ * Updates CONTRIBUTING.md [[#585](https://github.com/pantheon-systems/solr-power/pull/585)] * Fixes typo in var which caused undefined notice [[#582](https://github.com/pantheon-systems/solr-power/pull/582)] * Update Composer dependencies [[#576](https://github.com/pantheon-systems/solr-power/pull/576)] [[#574](https://github.com/pantheon-systems/solr-power/pull/583)] [[#573](https://github.com/pantheon-systems/solr-power/pull/584)] +* Adds WP.org Validation GitHub action [[#590](https://github.com/pantheon-systems/solr-power/pull/590)] * Updates security policy [[#589](https://github.com/pantheon-systems/solr-power/pull/589)] ### 2.4.5 (April 9, 2023) ### diff --git a/includes/class-solrpower-batch-index.php b/includes/class-solrpower-batch-index.php index df612bd3..9337ec3a 100644 --- a/includes/class-solrpower-batch-index.php +++ b/includes/class-solrpower-batch-index.php @@ -104,7 +104,7 @@ public function __construct( $query_args = array() ) { $this->query_args = $clean_query_args; // Cache the 'paged' value for resuming. delete_option( $this->batch_cache_key ); - add_option( $this->batch_cache_key, $this->query_args['paged'], null, false ); + add_option( $this->batch_cache_key, $this->query_args['paged'], '', false ); $query = new WP_Query( $clean_query_args ); $this->post_ids = $query->posts; $found_posts = $query->found_posts; @@ -206,7 +206,7 @@ public function fetch_next_posts() { public function increment_page() { $this->query_args['paged']++; delete_option( $this->batch_cache_key ); - add_option( $this->batch_cache_key, $this->query_args['paged'], null, false ); + add_option( $this->batch_cache_key, $this->query_args['paged'], '', false ); } /** diff --git a/includes/class-solrpower-facet-widget.php b/includes/class-solrpower-facet-widget.php index 94b80d40..993ffe7f 100644 --- a/includes/class-solrpower-facet-widget.php +++ b/includes/class-solrpower-facet-widget.php @@ -36,9 +36,9 @@ public function __construct() { */ public function widget( $args, $instance ) { $this->dummy_query(); - echo $args['before_widget']; + echo wp_kses_post( $args['before_widget'] ); if ( ! empty( $instance['title'] ) ) { - echo $args['before_title'] . $instance['title'] . $args['after_title']; + echo wp_kses_post( $args['before_title'] . $instance['title'] . $args['after_title'] ); } $this->facets = filter_input( INPUT_GET, 'facet', FILTER_SANITIZE_FULL_SPECIAL_CHARS, FILTER_REQUIRE_ARRAY ); echo '
'; @@ -47,7 +47,7 @@ public function widget( $args, $instance ) { $this->fetch_facets(); echo ''; echo '
'; - echo $args['after_widget']; + echo wp_kses_post( $args['after_widget'] ); } /** @@ -190,7 +190,7 @@ function fetch_facets( $echo = true ) { } // End foreach(). if ( $echo ) { - echo $output; + echo $output; // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped,WordPressDotOrg.sniffs.OutputEscaping.UnescapedOutputParameter } else { return $output; } @@ -236,7 +236,7 @@ public function render_searchbox() { * * @param string $html the search box html. */ - echo apply_filters( 'solr_facet_searchbox', $html ); + echo wp_kses_post( apply_filters( 'solr_facet_searchbox', $html ) ); } /** diff --git a/includes/class-solrpower-options.php b/includes/class-solrpower-options.php index f9f3760a..e49d1688 100644 --- a/includes/class-solrpower-options.php +++ b/includes/class-solrpower-options.php @@ -106,7 +106,7 @@ public function action_wpmuadminedit() { update_site_option( $option, $value ); } $goback = add_query_arg( 'settings-updated', 'true', wp_get_referer() ); - wp_redirect( $goback ); + wp_safe_redirect( $goback ); exit; } diff --git a/includes/class-solrpower-sync.php b/includes/class-solrpower-sync.php index 0fbcabcc..184d62c6 100644 --- a/includes/class-solrpower-sync.php +++ b/includes/class-solrpower-sync.php @@ -651,7 +651,7 @@ function load_all_posts( $prev, $post_type = 'post', $limit = 5, $echo = true ) $end = true; $results = sprintf( '{"type": "' . $post_type . '", "last": "%s", "end": true, "percent": "%.2f"}', $last, 100 ); if ( $echo ) { - echo $results; + echo $results; // phpcs:ignore WordPressDotOrg.sniffs.OutputEscaping.UnescapedOutputParameter,WordPress.Security.EscapeOutput.OutputNotEscaped } die(); } @@ -685,7 +685,7 @@ function load_all_posts( $prev, $post_type = 'post', $limit = 5, $echo = true ) $results = sprintf( '{"type\": "' . $post_type . '", "last": "%s", "end": false, "percent": "%.2f"}', $last, $percent ); } if ( $echo ) { - echo $results; + echo $results; // phpcs:ignore WordPressDotOrg.sniffs.OutputEscaping.UnescapedOutputParameter,WordPress.Security.EscapeOutput.OutputNotEscaped return; } diff --git a/includes/class-solrpower.php b/includes/class-solrpower.php index a2777770..a9b400ca 100644 --- a/includes/class-solrpower.php +++ b/includes/class-solrpower.php @@ -72,15 +72,15 @@ public function activate( $networkwide ) { $schema_message = SolrPower_Api::get_instance()->submit_schema(); if ( strpos( $schema_message, 'Error' ) ) { // Translators: 1 The error message, 2: The SOLR_PATH constant. - $message = wp_kses( __( 'Submitting the schema failed with the message: %1$s

%2$s', 'solr-for-wordpress-on-pantheon' ), [ 'br' => [] ] ); - wp_die( sprintf( $message, esc_html( $schema_message ), $solr_path ) ); + $message = __( 'Submitting the schema failed with the message: %1$s

%2$s', 'solr-for-wordpress-on-pantheon' ); + wp_die( sprintf( wp_kses( $message, [ 'br' => [] ] ), esc_html( $schema_message ), esc_textarea( $solr_path ) ) ); } } if ( is_multisite() && ! $networkwide ) { // Translators: 1: The URL to the network admin plugins page. - $message = wp_kses_post( __( 'You are attempting to activate the plugin on a multisite as a single-site plugin. For WordPress multisites, you need to activate network-wide. Go to your your Network Admin Plugins page and click the Network Activate link there.', 'solr-for-wordpress-on-pantheon' ) ); - wp_die( sprintf( $message, get_admin_url( 1, 'network/plugins.php' ) ) ); + $message = __( 'You are attempting to activate the plugin on a multisite as a single-site plugin. For WordPress multisites, you need to activate network-wide. Go to your your Network Admin Plugins page and click the Network Activate link there.', 'solr-for-wordpress-on-pantheon' ); + wp_die( sprintf( wp_kses_post( $message ), esc_url_raw( get_admin_url( 1, 'network/plugins.php' ) ) ) ); } SolrPower_Options::get_instance()->initalize_options(); @@ -210,9 +210,9 @@ public function template_redirect() { } // If there is a template file then we use it. - if ( file_exists( TEMPLATEPATH . '/s4wp_search.php' ) ) { + if ( file_exists( get_template_directory() . '/s4wp_search.php' ) ) { // use theme file. - include_once( TEMPLATEPATH . '/s4wp_search.php' ); + include_once( get_template_directory() . '/s4wp_search.php' ); } elseif ( file_exists( dirname( __FILE__ ) . '/template/s4wp_search.php' ) ) { // use plugin supplied file. add_action( 'wp_head', array( $this, 'default_head' ) ); diff --git a/includes/legacy-functions.php b/includes/legacy-functions.php index f2bf2c3e..1e39aa72 100644 --- a/includes/legacy-functions.php +++ b/includes/legacy-functions.php @@ -39,7 +39,7 @@ function s4wp_search_form() { } $form = ''; - printf( $form, filter_input( INPUT_GET, 'ssearch', FILTER_SANITIZE_FULL_SPECIAL_CHARS ), $sortval, $orderval, $serverval ); + printf( $form, filter_input( INPUT_GET, 'ssearch', FILTER_SANITIZE_FULL_SPECIAL_CHARS ), $sortval, $orderval, $serverval ); // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped } /** @@ -319,16 +319,16 @@ function s4wp_print_facet_items( $items, $pre = '
    ', $post = '
', $before if ( ! $items ) { return; } - printf( "%s\n", $pre ); + printf( "%s\n", wp_kses_post( $pre ) ); foreach ( $items as $item ) { - printf( "%s%s (%s)%s\n", $before, $item['link'], $item['name'], $item['count'], $after ); + printf( "%s%s (%s)%s\n", wp_kses_post( $before ), esc_url_raw( $item['link'] ), esc_textarea( $item['name'] ), esc_textarea( $item['count'] ), wp_kses_post( $after ) ); $item_items = isset( $item['items'] ) ? true : false; if ( $item_items ) { s4wp_print_facet_items( $item['items'], $nestedpre, $nestedpost, $nestedbefore, $nestedafter, $nestedpre, $nestedpost, $nestedbefore, $nestedafter ); } } - printf( "%s\n", $post ); + printf( "%s\n", wp_kses_post( $post ) ); } /** diff --git a/readme.txt b/readme.txt index d3becd07..85e739a6 100644 --- a/readme.txt +++ b/readme.txt @@ -236,6 +236,7 @@ Please report security bugs found in the source code of the Solr Power plugin th * Updates CONTRIBUTING.md [[#585](https://github.com/pantheon-systems/solr-power/pull/585)] * Fixes typo in var which caused undefined notice [[#582](https://github.com/pantheon-systems/solr-power/pull/582)] * Update Composer dependencies [[#576](https://github.com/pantheon-systems/solr-power/pull/576)] [[#574](https://github.com/pantheon-systems/solr-power/pull/583)] [[#573](https://github.com/pantheon-systems/solr-power/pull/584)] +* Adds WP.org Validation GitHub action [[#590](https://github.com/pantheon-systems/solr-power/pull/590)] * Updates security policy [[#589](https://github.com/pantheon-systems/solr-power/pull/589)] = 2.4.5 (April 9, 2023) = diff --git a/template/s4w_search.php b/template/s4w_search.php index 366d6c16..de813da9 100644 --- a/template/s4w_search.php +++ b/template/s4w_search.php @@ -23,7 +23,7 @@ @@ -52,9 +52,9 @@ %s hits", $results['firstresult'], $results['hits'] ); + printf( "Displaying result %s of %s hits", $results['firstresult'], $results['hits'] ); // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped } else { - printf( "Displaying results %s-%s of %s hits", $results['firstresult'], $results['lastresult'], $results['hits'] ); + printf( "Displaying results %s-%s of %s hits", $results['firstresult'], $results['lastresult'], $results['hits'] ); // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped } } ?> @@ -62,11 +62,11 @@ @@ -87,29 +87,29 @@ printf( "
    \n" ); foreach ( $results['results'] as $result ) { - printf( "
  1. \n", $result['permalink'] ); - printf( "

    %s

    \n", $result['permalink'], $result['title'] ); + printf( "
  2. \n", esc_url_raw( $result['permalink'] ) ); + printf( "

    %s

    \n", esc_url_raw( $result['permalink'] ), esc_textarea( $result['title'] ) ); echo '

    '; foreach ( explode( '...', $result['teaser'] ) as $this_result ) { if ( ! empty( $this_result ) ) { - echo '...' . $this_result . '...

    '; + echo '...' . $this_result . '...

    '; // phpcs:ignore WordPressDotOrg.sniffs.OutputEscaping.UnescapedOutputParameter,WordPress.Security.EscapeOutput.OutputNotEscaped } } if ( $result['numcomments'] > 0 ) { - printf( "(comment match)", $result['comment_link'] ); + printf( "(comment match)", esc_url_raw( $result['comment_link'] ) ); } echo "

    \n"; printf( "\n", - $result['authorlink'], - $result['author'], - get_the_category_list( ', ', '', $result['id'] ), - gmdate( 'm/d/Y', strtotime( $result['date'] ) ), - $result['comment_link'], - $result['numcomments'] + esc_url_raw( $result['authorlink'] ), + esc_textarea( $result['author'] ), + wp_kses_post( get_the_category_list( ', ', '', $result['id'] ) ), + esc_textarea( gmdate( 'm/d/Y', strtotime( $result['date'] ) ) ), + esc_url_raw( $result['comment_link'] ), + esc_textarea( $result['numcomments'] ) ); printf( "
  3. \n" ); } @@ -146,15 +146,15 @@ } if ( '' !== $prev ) { - printf( 'Previous', $prev ); + printf( 'Previous', esc_url_raw( $prev ) ); } foreach ( $itemlinks as $itemlink ) { - echo $itemlink; + echo wp_kses_post( $itemlink ); } if ( '' !== $next ) { - printf( 'Next', $next ); + printf( 'Next', esc_url_raw( $next ) ); } printf( "\n" ); @@ -173,7 +173,7 @@ %sx', $selectedfacet['removelink'], $selectedfacet['name'] ); + printf( '
  4. %sx
  5. ', esc_url_raw( $selectedfacet['removelink'] ), esc_textarea( $selectedfacet['name'] ) ); } } ?> @@ -185,7 +185,7 @@ foreach ( $results['facets'] as $facet ) { // don't display facets with only 1 value. if ( isset( $facet['items'] ) and sizeof( $facet['items'] ) > 1 ) { - printf( "
  6. \n

    %s

    \n", $facet['name'] ); + printf( "
  7. \n

    %s

    \n", wp_kses_post( $facet['name'] ) ); s4wp_print_facet_items( $facet['items'], '
      ', '
    ', '
  8. ', '
  9. ', '
    1. ', '
  10. ', '
  11. ', '
  12. ' ); printf( "\n" ); } diff --git a/template/s4wp_search.php b/template/s4wp_search.php index 366d6c16..ee514185 100644 --- a/template/s4wp_search.php +++ b/template/s4wp_search.php @@ -23,7 +23,7 @@ @@ -52,9 +52,9 @@ %s hits", $results['firstresult'], $results['hits'] ); + printf( "Displaying result %s of %s hits", $results['firstresult'], $results['hits'] ); // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped } else { - printf( "Displaying results %s-%s of %s hits", $results['firstresult'], $results['lastresult'], $results['hits'] ); + printf( "Displaying results %s-%s of %s hits", $results['firstresult'], $results['lastresult'], $results['hits'] ); // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped } } ?> @@ -62,11 +62,11 @@ @@ -87,29 +87,29 @@ printf( "
      \n" ); foreach ( $results['results'] as $result ) { - printf( "
    1. \n", $result['permalink'] ); - printf( "

      %s

      \n", $result['permalink'], $result['title'] ); + printf( "
    2. \n", esc_url_raw( $result['permalink'] ) ); + printf( "

      %s

      \n", esc_url_raw( $result['permalink'] ), wp_kses_post( $result['title'] ) ); echo '

      '; foreach ( explode( '...', $result['teaser'] ) as $this_result ) { if ( ! empty( $this_result ) ) { - echo '...' . $this_result . '...

      '; + echo '...' . $this_result . '...

      '; // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped,WordPressDotOrg.sniffs.OutputEscaping.UnescapedOutputParameter } } if ( $result['numcomments'] > 0 ) { - printf( "(comment match)", $result['comment_link'] ); + printf( "(comment match)", esc_url_raw( $result['comment_link'] ) ); } echo "

      \n"; printf( "\n", - $result['authorlink'], - $result['author'], - get_the_category_list( ', ', '', $result['id'] ), - gmdate( 'm/d/Y', strtotime( $result['date'] ) ), - $result['comment_link'], - $result['numcomments'] + esc_url_raw( $result['authorlink'] ), + esc_textarea( $result['author'] ), + wp_kses_post( get_the_category_list( ', ', '', $result['id'] ) ), + esc_textarea( gmdate( 'm/d/Y', strtotime( $result['date'] ) ) ), + esc_url_raw( $result['comment_link'] ), + esc_textarea( $result['numcomments'] ) ); printf( "
    3. \n" ); } @@ -146,15 +146,15 @@ } if ( '' !== $prev ) { - printf( 'Previous', $prev ); + printf( 'Previous', esc_url_raw( $prev ) ); } foreach ( $itemlinks as $itemlink ) { - echo $itemlink; + echo wp_kses_post( $itemlink ); } if ( '' !== $next ) { - printf( 'Next', $next ); + printf( 'Next', esc_url_raw( $next ) ); } printf( "\n" ); @@ -173,7 +173,7 @@ %sx', $selectedfacet['removelink'], $selectedfacet['name'] ); + printf( '
    4. %sx
    5. ', $selectedfacet['removelink'], $selectedfacet['name'] ); // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped } } ?> @@ -185,7 +185,7 @@ foreach ( $results['facets'] as $facet ) { // don't display facets with only 1 value. if ( isset( $facet['items'] ) and sizeof( $facet['items'] ) > 1 ) { - printf( "
    6. \n

      %s

      \n", $facet['name'] ); + printf( "
    7. \n

      %s

      \n", esc_textarea( $facet['name'] ) ); s4wp_print_facet_items( $facet['items'], '
        ', '
      ', '
    8. ', '
    9. ', '
      1. ', '
    10. ', '
    11. ', '
    12. ' ); printf( "\n" ); } diff --git a/templates/solr-search-results.php b/templates/solr-search-results.php index 6832b78c..131a6ef6 100644 --- a/templates/solr-search-results.php +++ b/templates/solr-search-results.php @@ -25,7 +25,7 @@ if ( in_array( 'category', get_object_taxonomies( get_post_type() ) ) ) : ?> str_replace( $big, '%#%', get_pagenum_link( $big, false ) ), 'format' => '?paged=%#%', From 54d521322e4071904ac27f54bf219a4649f0f0e8 Mon Sep 17 00:00:00 2001 From: Phil Tyler Date: Wed, 12 Jul 2023 10:17:39 -0700 Subject: [PATCH 08/11] Revert "Add WP.org validator" (#592) This reverts commit ef02320426995d65b4f7ae098d4479a999152100. --- .github/workflows/wporg-validator.yml | 13 ------ CHANGELOG.md | 1 - includes/class-solrpower-batch-index.php | 4 +- includes/class-solrpower-facet-widget.php | 10 ++--- includes/class-solrpower-options.php | 2 +- includes/class-solrpower-sync.php | 4 +- includes/class-solrpower.php | 12 +++--- includes/legacy-functions.php | 8 ++-- readme.txt | 1 - template/s4w_search.php | 48 +++++++++++------------ template/s4wp_search.php | 48 +++++++++++------------ templates/solr-search-results.php | 4 +- 12 files changed, 70 insertions(+), 85 deletions(-) delete mode 100644 .github/workflows/wporg-validator.yml diff --git a/.github/workflows/wporg-validator.yml b/.github/workflows/wporg-validator.yml deleted file mode 100644 index e1dd30f5..00000000 --- a/.github/workflows/wporg-validator.yml +++ /dev/null @@ -1,13 +0,0 @@ -# On push, run the action-wporg-validator workflow. -name: WP.org Validator -on: [push] -jobs: - wporg-validation: - runs-on: ubuntu-latest - steps: - - name: Checkout - uses: actions/checkout@v3 - - name: WP.org Validator - uses: pantheon-systems/action-wporg-validator@1.0.0 - with: - type: plugin diff --git a/CHANGELOG.md b/CHANGELOG.md index 4847e565..5344f7c1 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -4,7 +4,6 @@ * Updates CONTRIBUTING.md [[#585](https://github.com/pantheon-systems/solr-power/pull/585)] * Fixes typo in var which caused undefined notice [[#582](https://github.com/pantheon-systems/solr-power/pull/582)] * Update Composer dependencies [[#576](https://github.com/pantheon-systems/solr-power/pull/576)] [[#574](https://github.com/pantheon-systems/solr-power/pull/583)] [[#573](https://github.com/pantheon-systems/solr-power/pull/584)] -* Adds WP.org Validation GitHub action [[#590](https://github.com/pantheon-systems/solr-power/pull/590)] * Updates security policy [[#589](https://github.com/pantheon-systems/solr-power/pull/589)] ### 2.4.5 (April 9, 2023) ### diff --git a/includes/class-solrpower-batch-index.php b/includes/class-solrpower-batch-index.php index 9337ec3a..df612bd3 100644 --- a/includes/class-solrpower-batch-index.php +++ b/includes/class-solrpower-batch-index.php @@ -104,7 +104,7 @@ public function __construct( $query_args = array() ) { $this->query_args = $clean_query_args; // Cache the 'paged' value for resuming. delete_option( $this->batch_cache_key ); - add_option( $this->batch_cache_key, $this->query_args['paged'], '', false ); + add_option( $this->batch_cache_key, $this->query_args['paged'], null, false ); $query = new WP_Query( $clean_query_args ); $this->post_ids = $query->posts; $found_posts = $query->found_posts; @@ -206,7 +206,7 @@ public function fetch_next_posts() { public function increment_page() { $this->query_args['paged']++; delete_option( $this->batch_cache_key ); - add_option( $this->batch_cache_key, $this->query_args['paged'], '', false ); + add_option( $this->batch_cache_key, $this->query_args['paged'], null, false ); } /** diff --git a/includes/class-solrpower-facet-widget.php b/includes/class-solrpower-facet-widget.php index 993ffe7f..94b80d40 100644 --- a/includes/class-solrpower-facet-widget.php +++ b/includes/class-solrpower-facet-widget.php @@ -36,9 +36,9 @@ public function __construct() { */ public function widget( $args, $instance ) { $this->dummy_query(); - echo wp_kses_post( $args['before_widget'] ); + echo $args['before_widget']; if ( ! empty( $instance['title'] ) ) { - echo wp_kses_post( $args['before_title'] . $instance['title'] . $args['after_title'] ); + echo $args['before_title'] . $instance['title'] . $args['after_title']; } $this->facets = filter_input( INPUT_GET, 'facet', FILTER_SANITIZE_FULL_SPECIAL_CHARS, FILTER_REQUIRE_ARRAY ); echo '
      '; @@ -47,7 +47,7 @@ public function widget( $args, $instance ) { $this->fetch_facets(); echo ''; echo '
      '; - echo wp_kses_post( $args['after_widget'] ); + echo $args['after_widget']; } /** @@ -190,7 +190,7 @@ function fetch_facets( $echo = true ) { } // End foreach(). if ( $echo ) { - echo $output; // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped,WordPressDotOrg.sniffs.OutputEscaping.UnescapedOutputParameter + echo $output; } else { return $output; } @@ -236,7 +236,7 @@ public function render_searchbox() { * * @param string $html the search box html. */ - echo wp_kses_post( apply_filters( 'solr_facet_searchbox', $html ) ); + echo apply_filters( 'solr_facet_searchbox', $html ); } /** diff --git a/includes/class-solrpower-options.php b/includes/class-solrpower-options.php index e49d1688..f9f3760a 100644 --- a/includes/class-solrpower-options.php +++ b/includes/class-solrpower-options.php @@ -106,7 +106,7 @@ public function action_wpmuadminedit() { update_site_option( $option, $value ); } $goback = add_query_arg( 'settings-updated', 'true', wp_get_referer() ); - wp_safe_redirect( $goback ); + wp_redirect( $goback ); exit; } diff --git a/includes/class-solrpower-sync.php b/includes/class-solrpower-sync.php index 184d62c6..0fbcabcc 100644 --- a/includes/class-solrpower-sync.php +++ b/includes/class-solrpower-sync.php @@ -651,7 +651,7 @@ function load_all_posts( $prev, $post_type = 'post', $limit = 5, $echo = true ) $end = true; $results = sprintf( '{"type": "' . $post_type . '", "last": "%s", "end": true, "percent": "%.2f"}', $last, 100 ); if ( $echo ) { - echo $results; // phpcs:ignore WordPressDotOrg.sniffs.OutputEscaping.UnescapedOutputParameter,WordPress.Security.EscapeOutput.OutputNotEscaped + echo $results; } die(); } @@ -685,7 +685,7 @@ function load_all_posts( $prev, $post_type = 'post', $limit = 5, $echo = true ) $results = sprintf( '{"type\": "' . $post_type . '", "last": "%s", "end": false, "percent": "%.2f"}', $last, $percent ); } if ( $echo ) { - echo $results; // phpcs:ignore WordPressDotOrg.sniffs.OutputEscaping.UnescapedOutputParameter,WordPress.Security.EscapeOutput.OutputNotEscaped + echo $results; return; } diff --git a/includes/class-solrpower.php b/includes/class-solrpower.php index a9b400ca..a2777770 100644 --- a/includes/class-solrpower.php +++ b/includes/class-solrpower.php @@ -72,15 +72,15 @@ public function activate( $networkwide ) { $schema_message = SolrPower_Api::get_instance()->submit_schema(); if ( strpos( $schema_message, 'Error' ) ) { // Translators: 1 The error message, 2: The SOLR_PATH constant. - $message = __( 'Submitting the schema failed with the message: %1$s

      %2$s', 'solr-for-wordpress-on-pantheon' ); - wp_die( sprintf( wp_kses( $message, [ 'br' => [] ] ), esc_html( $schema_message ), esc_textarea( $solr_path ) ) ); + $message = wp_kses( __( 'Submitting the schema failed with the message: %1$s

      %2$s', 'solr-for-wordpress-on-pantheon' ), [ 'br' => [] ] ); + wp_die( sprintf( $message, esc_html( $schema_message ), $solr_path ) ); } } if ( is_multisite() && ! $networkwide ) { // Translators: 1: The URL to the network admin plugins page. - $message = __( 'You are attempting to activate the plugin on a multisite as a single-site plugin. For WordPress multisites, you need to activate network-wide. Go to your your Network Admin Plugins page and click the Network Activate link there.', 'solr-for-wordpress-on-pantheon' ); - wp_die( sprintf( wp_kses_post( $message ), esc_url_raw( get_admin_url( 1, 'network/plugins.php' ) ) ) ); + $message = wp_kses_post( __( 'You are attempting to activate the plugin on a multisite as a single-site plugin. For WordPress multisites, you need to activate network-wide. Go to your your Network Admin Plugins page and click the Network Activate link there.', 'solr-for-wordpress-on-pantheon' ) ); + wp_die( sprintf( $message, get_admin_url( 1, 'network/plugins.php' ) ) ); } SolrPower_Options::get_instance()->initalize_options(); @@ -210,9 +210,9 @@ public function template_redirect() { } // If there is a template file then we use it. - if ( file_exists( get_template_directory() . '/s4wp_search.php' ) ) { + if ( file_exists( TEMPLATEPATH . '/s4wp_search.php' ) ) { // use theme file. - include_once( get_template_directory() . '/s4wp_search.php' ); + include_once( TEMPLATEPATH . '/s4wp_search.php' ); } elseif ( file_exists( dirname( __FILE__ ) . '/template/s4wp_search.php' ) ) { // use plugin supplied file. add_action( 'wp_head', array( $this, 'default_head' ) ); diff --git a/includes/legacy-functions.php b/includes/legacy-functions.php index 1e39aa72..f2bf2c3e 100644 --- a/includes/legacy-functions.php +++ b/includes/legacy-functions.php @@ -39,7 +39,7 @@ function s4wp_search_form() { } $form = ''; - printf( $form, filter_input( INPUT_GET, 'ssearch', FILTER_SANITIZE_FULL_SPECIAL_CHARS ), $sortval, $orderval, $serverval ); // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped + printf( $form, filter_input( INPUT_GET, 'ssearch', FILTER_SANITIZE_FULL_SPECIAL_CHARS ), $sortval, $orderval, $serverval ); } /** @@ -319,16 +319,16 @@ function s4wp_print_facet_items( $items, $pre = '
        ', $post = '
      ', $before if ( ! $items ) { return; } - printf( "%s\n", wp_kses_post( $pre ) ); + printf( "%s\n", $pre ); foreach ( $items as $item ) { - printf( "%s%s (%s)%s\n", wp_kses_post( $before ), esc_url_raw( $item['link'] ), esc_textarea( $item['name'] ), esc_textarea( $item['count'] ), wp_kses_post( $after ) ); + printf( "%s%s (%s)%s\n", $before, $item['link'], $item['name'], $item['count'], $after ); $item_items = isset( $item['items'] ) ? true : false; if ( $item_items ) { s4wp_print_facet_items( $item['items'], $nestedpre, $nestedpost, $nestedbefore, $nestedafter, $nestedpre, $nestedpost, $nestedbefore, $nestedafter ); } } - printf( "%s\n", wp_kses_post( $post ) ); + printf( "%s\n", $post ); } /** diff --git a/readme.txt b/readme.txt index 85e739a6..d3becd07 100644 --- a/readme.txt +++ b/readme.txt @@ -236,7 +236,6 @@ Please report security bugs found in the source code of the Solr Power plugin th * Updates CONTRIBUTING.md [[#585](https://github.com/pantheon-systems/solr-power/pull/585)] * Fixes typo in var which caused undefined notice [[#582](https://github.com/pantheon-systems/solr-power/pull/582)] * Update Composer dependencies [[#576](https://github.com/pantheon-systems/solr-power/pull/576)] [[#574](https://github.com/pantheon-systems/solr-power/pull/583)] [[#573](https://github.com/pantheon-systems/solr-power/pull/584)] -* Adds WP.org Validation GitHub action [[#590](https://github.com/pantheon-systems/solr-power/pull/590)] * Updates security policy [[#589](https://github.com/pantheon-systems/solr-power/pull/589)] = 2.4.5 (April 9, 2023) = diff --git a/template/s4w_search.php b/template/s4w_search.php index de813da9..366d6c16 100644 --- a/template/s4w_search.php +++ b/template/s4w_search.php @@ -23,7 +23,7 @@ @@ -52,9 +52,9 @@ %s hits", $results['firstresult'], $results['hits'] ); // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped + printf( "Displaying result %s of %s hits", $results['firstresult'], $results['hits'] ); } else { - printf( "Displaying results %s-%s of %s hits", $results['firstresult'], $results['lastresult'], $results['hits'] ); // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped + printf( "Displaying results %s-%s of %s hits", $results['firstresult'], $results['lastresult'], $results['hits'] ); } } ?> @@ -62,11 +62,11 @@ @@ -87,29 +87,29 @@ printf( "
        \n" ); foreach ( $results['results'] as $result ) { - printf( "
      1. \n", esc_url_raw( $result['permalink'] ) ); - printf( "

        %s

        \n", esc_url_raw( $result['permalink'] ), esc_textarea( $result['title'] ) ); + printf( "
      2. \n", $result['permalink'] ); + printf( "

        %s

        \n", $result['permalink'], $result['title'] ); echo '

        '; foreach ( explode( '...', $result['teaser'] ) as $this_result ) { if ( ! empty( $this_result ) ) { - echo '...' . $this_result . '...

        '; // phpcs:ignore WordPressDotOrg.sniffs.OutputEscaping.UnescapedOutputParameter,WordPress.Security.EscapeOutput.OutputNotEscaped + echo '...' . $this_result . '...

        '; } } if ( $result['numcomments'] > 0 ) { - printf( "(comment match)", esc_url_raw( $result['comment_link'] ) ); + printf( "(comment match)", $result['comment_link'] ); } echo "

        \n"; printf( "\n", - esc_url_raw( $result['authorlink'] ), - esc_textarea( $result['author'] ), - wp_kses_post( get_the_category_list( ', ', '', $result['id'] ) ), - esc_textarea( gmdate( 'm/d/Y', strtotime( $result['date'] ) ) ), - esc_url_raw( $result['comment_link'] ), - esc_textarea( $result['numcomments'] ) + $result['authorlink'], + $result['author'], + get_the_category_list( ', ', '', $result['id'] ), + gmdate( 'm/d/Y', strtotime( $result['date'] ) ), + $result['comment_link'], + $result['numcomments'] ); printf( "
      3. \n" ); } @@ -146,15 +146,15 @@ } if ( '' !== $prev ) { - printf( 'Previous', esc_url_raw( $prev ) ); + printf( 'Previous', $prev ); } foreach ( $itemlinks as $itemlink ) { - echo wp_kses_post( $itemlink ); + echo $itemlink; } if ( '' !== $next ) { - printf( 'Next', esc_url_raw( $next ) ); + printf( 'Next', $next ); } printf( "\n" ); @@ -173,7 +173,7 @@ %sx', esc_url_raw( $selectedfacet['removelink'] ), esc_textarea( $selectedfacet['name'] ) ); + printf( '
      4. %sx
      5. ', $selectedfacet['removelink'], $selectedfacet['name'] ); } } ?> @@ -185,7 +185,7 @@ foreach ( $results['facets'] as $facet ) { // don't display facets with only 1 value. if ( isset( $facet['items'] ) and sizeof( $facet['items'] ) > 1 ) { - printf( "
      6. \n

        %s

        \n", wp_kses_post( $facet['name'] ) ); + printf( "
      7. \n

        %s

        \n", $facet['name'] ); s4wp_print_facet_items( $facet['items'], '
          ', '
        ', '
      8. ', '
      9. ', '
        1. ', '
      10. ', '
      11. ', '
      12. ' ); printf( "\n" ); } diff --git a/template/s4wp_search.php b/template/s4wp_search.php index ee514185..366d6c16 100644 --- a/template/s4wp_search.php +++ b/template/s4wp_search.php @@ -23,7 +23,7 @@ @@ -52,9 +52,9 @@ %s hits", $results['firstresult'], $results['hits'] ); // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped + printf( "Displaying result %s of %s hits", $results['firstresult'], $results['hits'] ); } else { - printf( "Displaying results %s-%s of %s hits", $results['firstresult'], $results['lastresult'], $results['hits'] ); // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped + printf( "Displaying results %s-%s of %s hits", $results['firstresult'], $results['lastresult'], $results['hits'] ); } } ?> @@ -62,11 +62,11 @@ @@ -87,29 +87,29 @@ printf( "
          \n" ); foreach ( $results['results'] as $result ) { - printf( "
        1. \n", esc_url_raw( $result['permalink'] ) ); - printf( "

          %s

          \n", esc_url_raw( $result['permalink'] ), wp_kses_post( $result['title'] ) ); + printf( "
        2. \n", $result['permalink'] ); + printf( "

          %s

          \n", $result['permalink'], $result['title'] ); echo '

          '; foreach ( explode( '...', $result['teaser'] ) as $this_result ) { if ( ! empty( $this_result ) ) { - echo '...' . $this_result . '...

          '; // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped,WordPressDotOrg.sniffs.OutputEscaping.UnescapedOutputParameter + echo '...' . $this_result . '...

          '; } } if ( $result['numcomments'] > 0 ) { - printf( "(comment match)", esc_url_raw( $result['comment_link'] ) ); + printf( "(comment match)", $result['comment_link'] ); } echo "

          \n"; printf( "\n", - esc_url_raw( $result['authorlink'] ), - esc_textarea( $result['author'] ), - wp_kses_post( get_the_category_list( ', ', '', $result['id'] ) ), - esc_textarea( gmdate( 'm/d/Y', strtotime( $result['date'] ) ) ), - esc_url_raw( $result['comment_link'] ), - esc_textarea( $result['numcomments'] ) + $result['authorlink'], + $result['author'], + get_the_category_list( ', ', '', $result['id'] ), + gmdate( 'm/d/Y', strtotime( $result['date'] ) ), + $result['comment_link'], + $result['numcomments'] ); printf( "
        3. \n" ); } @@ -146,15 +146,15 @@ } if ( '' !== $prev ) { - printf( 'Previous', esc_url_raw( $prev ) ); + printf( 'Previous', $prev ); } foreach ( $itemlinks as $itemlink ) { - echo wp_kses_post( $itemlink ); + echo $itemlink; } if ( '' !== $next ) { - printf( 'Next', esc_url_raw( $next ) ); + printf( 'Next', $next ); } printf( "\n" ); @@ -173,7 +173,7 @@ %sx', $selectedfacet['removelink'], $selectedfacet['name'] ); // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped + printf( '
        4. %sx
        5. ', $selectedfacet['removelink'], $selectedfacet['name'] ); } } ?> @@ -185,7 +185,7 @@ foreach ( $results['facets'] as $facet ) { // don't display facets with only 1 value. if ( isset( $facet['items'] ) and sizeof( $facet['items'] ) > 1 ) { - printf( "
        6. \n

          %s

          \n", esc_textarea( $facet['name'] ) ); + printf( "
        7. \n

          %s

          \n", $facet['name'] ); s4wp_print_facet_items( $facet['items'], '
            ', '
          ', '
        8. ', '
        9. ', '
          1. ', '
        10. ', '
        11. ', '
        12. ' ); printf( "\n" ); } diff --git a/templates/solr-search-results.php b/templates/solr-search-results.php index 131a6ef6..6832b78c 100644 --- a/templates/solr-search-results.php +++ b/templates/solr-search-results.php @@ -25,7 +25,7 @@ if ( in_array( 'category', get_object_taxonomies( get_post_type() ) ) ) : ?> str_replace( $big, '%#%', get_pagenum_link( $big, false ) ), 'format' => '?paged=%#%', From 9bcc12450fe701480bc21ae3657949fbafdb95a5 Mon Sep 17 00:00:00 2001 From: Phil Tyler Date: Wed, 12 Jul 2023 11:13:58 -0700 Subject: [PATCH 09/11] [BUGS-6482] Disable Auto-commit by default (#591) --- .github/workflows/lint-test.yml | 8 +------ .gitignore | 3 ++- CHANGELOG.md | 1 + README.md | 17 ++++++++------ bin/phpunit-test.sh | 10 +++++++++ composer.json | 14 +++++++++--- includes/class-solrpower-sync.php | 17 +++++++++++--- package-lock.json | 4 ++-- package.json | 2 +- phpunit.xml.dist | 5 +++++ readme.txt | 25 ++++++++++++++------- solr-power.php | 4 ++-- tests/phpunit/class-solr-test-base.php | 5 +++++ tests/phpunit/test-shouldcommit.php | 31 ++++++++++++++++++++++++++ 14 files changed, 112 insertions(+), 34 deletions(-) create mode 100644 bin/phpunit-test.sh create mode 100644 tests/phpunit/test-shouldcommit.php diff --git a/.github/workflows/lint-test.yml b/.github/workflows/lint-test.yml index e7394646..44d48ff4 100644 --- a/.github/workflows/lint-test.yml +++ b/.github/workflows/lint-test.yml @@ -70,14 +70,8 @@ jobs: - name: Install dependencies run: composer install - - name: "Run Tests" - run: | - bash bin/install-wp-tests.sh wordpress_test root root 127.0.0.1 latest - composer phpunit - rm -rf $WP_TESTS_DIR $WP_CORE_DIR - bash bin/install-wp-tests.sh wordpress_test root root 127.0.0.1 nightly true - WP_MULTISITE=1 composer phpunit + run: bash bin/phpunit-test.sh test-behat: needs: test-phpunit diff --git a/.gitignore b/.gitignore index 352b9c26..8dea055f 100644 --- a/.gitignore +++ b/.gitignore @@ -6,4 +6,5 @@ vendor/ assets/css/*.css assets/css/*.css.map assets/js/*.js -composer.lock \ No newline at end of file +composer.lock +.envrc \ No newline at end of file diff --git a/CHANGELOG.md b/CHANGELOG.md index 5344f7c1..d3621bf2 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -5,6 +5,7 @@ * Fixes typo in var which caused undefined notice [[#582](https://github.com/pantheon-systems/solr-power/pull/582)] * Update Composer dependencies [[#576](https://github.com/pantheon-systems/solr-power/pull/576)] [[#574](https://github.com/pantheon-systems/solr-power/pull/583)] [[#573](https://github.com/pantheon-systems/solr-power/pull/584)] * Updates security policy [[#589](https://github.com/pantheon-systems/solr-power/pull/589)] +* Disable auto-commit by default. [[#591](https://github.com/pantheon-systems/solr-power/pull/591)] ### 2.4.5 (April 9, 2023) ### * Fixes missing vendor/ directory in previous release [[#580](https://github.com/pantheon-systems/solr-power/pull/580)] diff --git a/README.md b/README.md index e5202da4..99701982 100644 --- a/README.md +++ b/README.md @@ -4,7 +4,7 @@ **Requires at least:** 4.6 **Requires PHP:** 7.1 **Tested up to:** 6.2 -**Stable tag:** 2.4.6-dev +**Stable tag:** 2.5.0-dev **License:** GPLv2 or later **License URI:** http://www.gnu.org/licenses/gpl-2.0.html @@ -204,16 +204,19 @@ Add the following to your `functions.php` file. ## Explicit Commit vs Autocommit ## -Once solr has sent the data to the solr server, solr must COMMIT the data to the index and adjust the index and -relevancy ratings accordingly before that data can appear in search results. By default, Solr Search for WordPress does this when it sends every post. It may be necessary on occasion to disable this behavior (e.g. when importing a lot of posts via CSV). To do this, you need add the following code to your index.php in the root of your site install: +Once solr has sent the data to the solr server, solr must COMMIT the data to the index and adjust the index and relevancy ratings accordingly before that data can appear in search results. + +By default, Solr Search for WordPress has auto-commit disabled. The index is committed when the uncommitted item is two minutes old, or the cron runs. By default, the cron runs on the Pantheon platform every hour. + +When autocommit is enabled, Solr Search for WordPress commits data when it sends every post. When running on Pantheon, we recommend leaving autocommit disabled to aid overall site performance. + +To enable autocommit, add the following to `wp-config.php` or an mu-plugin. ```php -define( 'SOLRPOWER_DISABLE_AUTOCOMMIT', true ); +define( 'SOLRPOWER_DISABLE_AUTOCOMMIT', false ); ``` -When this variable is defined, Solr Search for WordPress will not commit the index until the uncommitted item is two minutes old or the cron runs. By default, the cron runs on the Pantheon platform every hour. - -To force-commit data when this variable is defined outside of a normal cron run, from the command line, you can run the command below or simply force a cron-run. +To force-commit data outside of a normal cron run, from the command line, you can run the command below or simply force a cron-run. ```bash wp solr commit diff --git a/bin/phpunit-test.sh b/bin/phpunit-test.sh new file mode 100644 index 00000000..5bc51480 --- /dev/null +++ b/bin/phpunit-test.sh @@ -0,0 +1,10 @@ +#!/bin/bash +set -e + +DIRNAME=$(dirname "$0") +bash "${DIRNAME}/install-wp-tests.sh" wordpress_test root root 127.0.0.1 latest +composer test +rm -rf $WP_TESTS_DIR $WP_CORE_DIR + +bash "${DIRNAME}/install-wp-tests.sh" wordpress_test root root 127.0.0.1 latest true +WP_MULTISITE=1 composer test diff --git a/composer.json b/composer.json index ab25beba..e5a72cea 100644 --- a/composer.json +++ b/composer.json @@ -10,7 +10,7 @@ } ], "support": { - "issues": "https://github.com/pantheon-systems/solr-power/issues" + "issues": "https://github.com/pantheon-systems/solr-power/issues" }, "minimum-stability": "dev", "prefer-stable": true, @@ -45,11 +45,19 @@ "phpcs": "vendor/bin/phpcs", "phpcbf": "vendor/bin/phpcbf", "phpunit": "vendor/bin/phpunit", - "test": "@phpunit" + "phpunit-shouldcommit": [ + "vendor/bin/phpunit --group should-commit --filter testShouldNotCommitWhenConstNull", + "vendor/bin/phpunit --group should-commit --filter testShouldNotCommitWhenConstTrue", + "vendor/bin/phpunit --group should-commit --filter testShouldCommitWhenConstFalse" + ], + "test": [ + "@phpunit-shouldcommit", + "@phpunit" + ] }, "autoload": { "classmap": [ "includes" ] } -} +} \ No newline at end of file diff --git a/includes/class-solrpower-sync.php b/includes/class-solrpower-sync.php index 0fbcabcc..2a927751 100644 --- a/includes/class-solrpower-sync.php +++ b/includes/class-solrpower-sync.php @@ -734,16 +734,27 @@ function copy_config_to_all_blogs() { * when the plugin posts data to Solr, but your Solr instance will need * to have a cron job enabled that does a hard commit on a regular basis. * - * To disable commiting to Solr, add the following to your wp-config.php + * + * To enable commiting to Solr, add the following to your wp-config.php * * - * define( 'SOLRPOWER_DISABLE_AUTOCOMMIT', true ); + * define( 'SOLRPOWER_DISABLE_AUTOCOMMIT', false ); * * + * As of 2.5.0, the default behavior is to not auto-commit. + * Yes, this function could be more concise, but the double-negative logic + * can be confusing so making the logic as explicit as possible. + * * @see https://cwiki.apache.org/confluence/display/solr/UpdateXmlMessages#UpdateXmlMessages-%22commit%22and%22optimize%22 * @return bool Whether to commit immediately when writing site data to Solr. */ function should_commit() { - return ! ( defined( 'SOLRPOWER_DISABLE_AUTOCOMMIT' ) && SOLRPOWER_DISABLE_AUTOCOMMIT ); + // Auto-commit is explicitly enabled by not disabling it 🤮. + if ( defined( 'SOLRPOWER_DISABLE_AUTOCOMMIT' ) && ! SOLRPOWER_DISABLE_AUTOCOMMIT ) { + return true; + } + + // Do not autocommit, as cron will take care of it. + return false; } } diff --git a/package-lock.json b/package-lock.json index 5239eb2c..f9a0f6fd 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,12 +1,12 @@ { "name": "solr-power", - "version": "2.4.5", + "version": "2.5.0-dev", "lockfileVersion": 2, "requires": true, "packages": { "": { "name": "solr-power", - "version": "2.4.5", + "version": "2.5.0-dev", "devDependencies": { "grunt": "^1.6.1", "grunt-autoprefixer": "~3.0.4", diff --git a/package.json b/package.json index 8c343a06..02be736b 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "solr-power", - "version": "2.4.5", + "version": "2.5.0-dev", "repository": { "type": "git", "url": "https://github.com/pantheon-systems/solr-power.git" diff --git a/phpunit.xml.dist b/phpunit.xml.dist index 4084d58a..f58f12e9 100644 --- a/phpunit.xml.dist +++ b/phpunit.xml.dist @@ -11,4 +11,9 @@ ./tests/phpunit/ + + + should-commit + + diff --git a/readme.txt b/readme.txt index d3becd07..87b3cc9a 100644 --- a/readme.txt +++ b/readme.txt @@ -4,7 +4,7 @@ Tags: search Requires at least: 4.6 Requires PHP: 7.1 Tested up to: 6.2 -Stable tag: 2.4.6-dev +Stable tag: 2.5.0-dev License: GPLv2 or later License URI: http://www.gnu.org/licenses/gpl-2.0.html @@ -78,8 +78,8 @@ For further documentation, such as available filters and working with the `SolrP You may notice there are two sets of tests running, on two different services: -* Travis CI runs the [PHPUnit](https://phpunit.de/) test suite against a Solr instance. -* Circle CI runs the [Behat](http://behat.org/) test suite against a Pantheon site, to ensure the plugin's compatibility with the Pantheon platform. +* [PHPUnit](https://phpunit.de/) test suite against a Solr instance. +* The [Behat](http://behat.org/) test suite against a Pantheon site, to ensure the plugin's compatibility with the Pantheon platform. Both of these test suites can be run locally, with a varying amount of setup. @@ -215,14 +215,17 @@ Add the following to your `functions.php` file. = Explicit Commit vs Autocommit = -Once solr has sent the data to the solr server, solr must COMMIT the data to the index and adjust the index and -relevancy ratings accordingly before that data can appear in search results. By default, Solr Search for WordPress does this when it sends every post. It may be necessary on occasion to disable this behavior (e.g. when importing a lot of posts via CSV). To do this, you need add the following code to your index.php in the root of your site install: +Once solr has sent the data to the solr server, solr must COMMIT the data to the index and adjust the index and relevancy ratings accordingly before that data can appear in search results. - define( 'SOLRPOWER_DISABLE_AUTOCOMMIT', true ); +By default, Solr Search for WordPress has auto-commit disabled. The index is committed when the uncommitted item is two minutes old, or the cron runs. By default, the cron runs on the Pantheon platform every hour. -When this variable is defined, Solr Search for WordPress will not commit the index until the uncommitted item is two minutes old or the cron runs. By default, the cron runs on the Pantheon platform every hour. +When autocommit is enabled, Solr Search for WordPress commits data when it sends every post. When running on Pantheon, we recommend leaving autocommit disabled to aid overall site performance. -To force-commit data when this variable is defined outside of a normal cron run, from the command line, you can run the command below or simply force a cron-run. +To enable autocommit, add the following to `wp-config.php` or an mu-plugin. + + define( 'SOLRPOWER_DISABLE_AUTOCOMMIT', false ); + +To force-commit data outside of a normal cron run, from the command line, you can run the command below or simply force a cron-run. wp solr commit @@ -237,6 +240,7 @@ Please report security bugs found in the source code of the Solr Power plugin th * Fixes typo in var which caused undefined notice [[#582](https://github.com/pantheon-systems/solr-power/pull/582)] * Update Composer dependencies [[#576](https://github.com/pantheon-systems/solr-power/pull/576)] [[#574](https://github.com/pantheon-systems/solr-power/pull/583)] [[#573](https://github.com/pantheon-systems/solr-power/pull/584)] * Updates security policy [[#589](https://github.com/pantheon-systems/solr-power/pull/589)] +* Disable auto-commit by default. [[#591](https://github.com/pantheon-systems/solr-power/pull/591)] = 2.4.5 (April 9, 2023) = * Fixes missing vendor/ directory in previous release [[#580](https://github.com/pantheon-systems/solr-power/pull/580)] @@ -438,3 +442,8 @@ Please report security bugs found in the source code of the Solr Power plugin th = 0.0 = * Note this started as a fork of this wonderful project: https://github.com/mattweber/solr-for-wordpress + +== Upgrade Notice == + += 2.5.0-dev = +Changes the default auto-commit behavior to disabled. See [the README](https://github.com/pantheon-systems/solr-power/#explicit-commit-vs-autocommit) for instructions for keeping enabled. \ No newline at end of file diff --git a/solr-power.php b/solr-power.php index d4ecc18f..b84585a0 100644 --- a/solr-power.php +++ b/solr-power.php @@ -2,7 +2,7 @@ /** * Plugin Name: Solr Power * Description: Allows WordPress sites to index and search content with ApacheSolr. - * Version: 2.4.6-dev + * Version: 2.5.0-dev * Author: Pantheon * Author URI: http://pantheon.io * Text Domain: solr-for-wordpress-on-pantheon @@ -10,7 +10,7 @@ * @package Solr_Power **/ -define( 'SOLR_POWER_VERSION', '2.4.6-dev' ); +define( 'SOLR_POWER_VERSION', '2.5.0-dev' ); /** * Copyright (c) 2011-2022 Pantheon, Matt Weber, Solr Power contributors diff --git a/tests/phpunit/class-solr-test-base.php b/tests/phpunit/class-solr-test-base.php index 467b3372..410b3930 100644 --- a/tests/phpunit/class-solr-test-base.php +++ b/tests/phpunit/class-solr-test-base.php @@ -22,6 +22,11 @@ function __construct() { function setUp() { parent::setUp(); + # Plugin now (2.5.0) defaults to true, but tests expect it. + if ( ! defined('SOLRPOWER_DISABLE_AUTOCOMMIT') ) { + define( 'SOLRPOWER_DISABLE_AUTOCOMMIT', false); + } + if ( ! SolrPower_API::get_instance()->ping_server() ) { $this->fail( 'Cannot connect to Solr. Solr is required for Solr Power tests.' ); } diff --git a/tests/phpunit/test-shouldcommit.php b/tests/phpunit/test-shouldcommit.php new file mode 100644 index 00000000..e1a9d885 --- /dev/null +++ b/tests/phpunit/test-shouldcommit.php @@ -0,0 +1,31 @@ +fail("SOLRPOWER_DISABLE_AUTOCOMMIT unexpectedly defined."); + } + $result = SolrPower_Sync::get_instance()->should_commit(); + $this->assertFalse($result); + } + + public function testShouldNotCommitWhenConstTrue(): void + { + define( 'SOLRPOWER_DISABLE_AUTOCOMMIT', true); + $result = SolrPower_Sync::get_instance()->should_commit(); + $this->assertFalse($result); + } + + public function testShouldCommitWhenConstFalse(): void + { + define( 'SOLRPOWER_DISABLE_AUTOCOMMIT', false); + $result = SolrPower_Sync::get_instance()->should_commit(); + $this->assertTrue($result); + } +} \ No newline at end of file From c1fd83491f8a65943e93432b9ad861fc16ecc39f Mon Sep 17 00:00:00 2001 From: Phil Tyler Date: Wed, 12 Jul 2023 13:06:35 -0700 Subject: [PATCH 10/11] Update CONTRIBUTING.md (#594) - Update contributing to match lessons learned with wp-redis and in-progress work on release automation. - Change latest heading to -dev version number --- CHANGELOG.md | 4 ++-- CONTRIBUTING.md | 12 ++++++------ readme.txt | 5 +++-- 3 files changed, 11 insertions(+), 10 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index d3621bf2..ee242cec 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,7 +1,7 @@ ## Changelog ## -### Latest ### -* Updates CONTRIBUTING.md [[#585](https://github.com/pantheon-systems/solr-power/pull/585)] +### 2.5.0-dev ### +* Updates CONTRIBUTING.md [[#585](https://github.com/pantheon-systems/solr-power/pull/585)] [[#594](https://github.com/pantheon-systems/solr-power/pull/594)] * Fixes typo in var which caused undefined notice [[#582](https://github.com/pantheon-systems/solr-power/pull/582)] * Update Composer dependencies [[#576](https://github.com/pantheon-systems/solr-power/pull/576)] [[#574](https://github.com/pantheon-systems/solr-power/pull/583)] [[#573](https://github.com/pantheon-systems/solr-power/pull/584)] * Updates security policy [[#589](https://github.com/pantheon-systems/solr-power/pull/589)] diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index 5dc66cdf..45e8fd96 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -4,7 +4,7 @@ Since 2.3.3 the default branch is `main`. Please make sure you are working again ## Workflow -Development and releases are structured around two branches, `develop` and `main`. The `develop` branch is the default branch for the repository, and is the source and destination for feature branches. +Development and releases are structured around two branches, `develop` and `main`. The `develop` branch 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`. @@ -31,12 +31,12 @@ Note that dependencies are installed via Composer and the `vendor` directory is 1. From `develop`, checkout a new branch `release_X.Y.Z`. 1. Make a release commit: - * Drop the `-dev` from the version number in `package.json`, `README.md`, `readme.txt`, and `solr-power.php`. - * Update the "Latest" heading in the changelog (both `CHANGELOG.md` and in `readme.txt`) to the new version number with the date + * Drop the `-dev` from the version number in `package.json`, `README.md`, `readme.txt`, CHANGELOG.md, and `solr-power.php`. For `readme.txt`, the version number must be updated both at the top of the document as well as the changelog. + * Add the date to the `** X.Y.X **` heading in the changelogs in README.md, readme.txt, and any other appropriate location. * 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 `main`. 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 `main`. "Rebase and merge" is preferred in this case. _Never_ squash to `main`. +1. After all tests pass and you have received approval from a [CODEOWNER](./CODEOWNERS), merge the PR into `main`. "merge" is preferred in this case, not rebase. _Never_ squash to `main`. 1. Pull `main` 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/solr-power/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. @@ -46,7 +46,7 @@ Note that dependencies are installed via Composer and the `vendor` directory is * `git checkout develop` * `git rebase main` * 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 + * Add new `** X.Y.X-dev **` headings to the changelogs * `git add -A .` * `git commit -m "Prepare X.Y.X-dev"` - * `git push origin develop` \ No newline at end of file + * `git push origin develop` diff --git a/readme.txt b/readme.txt index 87b3cc9a..5c22185a 100644 --- a/readme.txt +++ b/readme.txt @@ -235,8 +235,9 @@ Please report security bugs found in the source code of the Solr Power plugin th == Changelog == -= Latest = -* Updates CONTRIBUTING.md [[#585](https://github.com/pantheon-systems/solr-power/pull/585)] += 2.5.0-dev = + +* Updates CONTRIBUTING.md [[#585](https://github.com/pantheon-systems/solr-power/pull/585)] [[#594](https://github.com/pantheon-systems/solr-power/pull/594)] * Fixes typo in var which caused undefined notice [[#582](https://github.com/pantheon-systems/solr-power/pull/582)] * Update Composer dependencies [[#576](https://github.com/pantheon-systems/solr-power/pull/576)] [[#574](https://github.com/pantheon-systems/solr-power/pull/583)] [[#573](https://github.com/pantheon-systems/solr-power/pull/584)] * Updates security policy [[#589](https://github.com/pantheon-systems/solr-power/pull/589)] From d43600988c7adf9e58f80055626d41a98813d60f Mon Sep 17 00:00:00 2001 From: Phil Tyler Date: Wed, 12 Jul 2023 13:10:01 -0700 Subject: [PATCH 11/11] Release 2.5.0 --- CHANGELOG.md | 2 +- README.md | 2 +- package-lock.json | 4 ++-- package.json | 2 +- readme.txt | 6 +++--- solr-power.php | 4 ++-- 6 files changed, 10 insertions(+), 10 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index ee242cec..16cf5352 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,6 +1,6 @@ ## Changelog ## -### 2.5.0-dev ### +### 2.5.0 ### * Updates CONTRIBUTING.md [[#585](https://github.com/pantheon-systems/solr-power/pull/585)] [[#594](https://github.com/pantheon-systems/solr-power/pull/594)] * Fixes typo in var which caused undefined notice [[#582](https://github.com/pantheon-systems/solr-power/pull/582)] * Update Composer dependencies [[#576](https://github.com/pantheon-systems/solr-power/pull/576)] [[#574](https://github.com/pantheon-systems/solr-power/pull/583)] [[#573](https://github.com/pantheon-systems/solr-power/pull/584)] diff --git a/README.md b/README.md index 99701982..a9ac1ebd 100644 --- a/README.md +++ b/README.md @@ -4,7 +4,7 @@ **Requires at least:** 4.6 **Requires PHP:** 7.1 **Tested up to:** 6.2 -**Stable tag:** 2.5.0-dev +**Stable tag:** 2.5.0 **License:** GPLv2 or later **License URI:** http://www.gnu.org/licenses/gpl-2.0.html diff --git a/package-lock.json b/package-lock.json index f9a0f6fd..315b6b1a 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,12 +1,12 @@ { "name": "solr-power", - "version": "2.5.0-dev", + "version": "2.5.0", "lockfileVersion": 2, "requires": true, "packages": { "": { "name": "solr-power", - "version": "2.5.0-dev", + "version": "2.5.0", "devDependencies": { "grunt": "^1.6.1", "grunt-autoprefixer": "~3.0.4", diff --git a/package.json b/package.json index 02be736b..1a499b4b 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "solr-power", - "version": "2.5.0-dev", + "version": "2.5.0", "repository": { "type": "git", "url": "https://github.com/pantheon-systems/solr-power.git" diff --git a/readme.txt b/readme.txt index 5c22185a..03e04781 100644 --- a/readme.txt +++ b/readme.txt @@ -4,7 +4,7 @@ Tags: search Requires at least: 4.6 Requires PHP: 7.1 Tested up to: 6.2 -Stable tag: 2.5.0-dev +Stable tag: 2.5.0 License: GPLv2 or later License URI: http://www.gnu.org/licenses/gpl-2.0.html @@ -235,7 +235,7 @@ Please report security bugs found in the source code of the Solr Power plugin th == Changelog == -= 2.5.0-dev = += 2.5.0 = * Updates CONTRIBUTING.md [[#585](https://github.com/pantheon-systems/solr-power/pull/585)] [[#594](https://github.com/pantheon-systems/solr-power/pull/594)] * Fixes typo in var which caused undefined notice [[#582](https://github.com/pantheon-systems/solr-power/pull/582)] @@ -446,5 +446,5 @@ Please report security bugs found in the source code of the Solr Power plugin th == Upgrade Notice == -= 2.5.0-dev = += 2.5.0 = Changes the default auto-commit behavior to disabled. See [the README](https://github.com/pantheon-systems/solr-power/#explicit-commit-vs-autocommit) for instructions for keeping enabled. \ No newline at end of file diff --git a/solr-power.php b/solr-power.php index b84585a0..1be4c171 100644 --- a/solr-power.php +++ b/solr-power.php @@ -2,7 +2,7 @@ /** * Plugin Name: Solr Power * Description: Allows WordPress sites to index and search content with ApacheSolr. - * Version: 2.5.0-dev + * Version: 2.5.0 * Author: Pantheon * Author URI: http://pantheon.io * Text Domain: solr-for-wordpress-on-pantheon @@ -10,7 +10,7 @@ * @package Solr_Power **/ -define( 'SOLR_POWER_VERSION', '2.5.0-dev' ); +define( 'SOLR_POWER_VERSION', '2.5.0' ); /** * Copyright (c) 2011-2022 Pantheon, Matt Weber, Solr Power contributors