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 12f8ab95..16cf5352 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,27 +1,31 @@ ## Changelog ## -## 2.4.5 (April 9, 2023) ## +### 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)] +* 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)] -## 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..45e8fd96 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 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`, 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`. "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. +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 new `** X.Y.X-dev **` headings to the changelogs + * `git add -A .` + * `git commit -m "Prepare X.Y.X-dev"` + * `git push origin develop` diff --git a/README.md b/README.md index 6236f5b5..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.4.5 +**Stable tag:** 2.5.0 **License:** GPLv2 or later **License URI:** http://www.gnu.org/licenses/gpl-2.0.html @@ -204,17 +204,24 @@ 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 ``` + +## 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/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 e02ffca8..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, @@ -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": [ @@ -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/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": [], 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 f0776f33..315b6b1a 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,22 +1,22 @@ { "name": "solr-power", - "version": "2.4.5", + "version": "2.5.0", "lockfileVersion": 2, "requires": true, "packages": { "": { "name": "solr-power", - "version": "2.4.5", + "version": "2.5.0", "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", "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": { @@ -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": { @@ -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": { @@ -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": { @@ -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 7b76e68b..1a499b4b 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "solr-power", - "version": "2.4.5", + "version": "2.5.0", "repository": { "type": "git", "url": "https://github.com/pantheon-systems/solr-power.git" @@ -15,12 +15,12 @@ "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", "grunt-sass": "~3.1.0", "grunt-wp-readme-to-markdown": "~2.1.0", - "node-sass": "^8.0.0" + "node-sass": "^9.0.0" } } 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 003fc65e..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.4.5 +Stable tag: 2.5.0 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,19 +215,34 @@ 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 +== 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 == += 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)] +* 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)] @@ -428,3 +443,8 @@ To force-commit data when this variable is defined outside of a normal cron run, = 0.0 = * Note this started as a fork of this wonderful project: https://github.com/mattweber/solr-for-wordpress + +== Upgrade Notice == + += 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 7d6025ec..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.4.5 + * 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.4.5' ); +define( 'SOLR_POWER_VERSION', '2.5.0' ); /** * 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 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