Skip to content

Commit

Permalink
Merge pull request #647 from pantheon-systems/release_2.6.0
Browse files Browse the repository at this point in the history
Release 2.6.0
  • Loading branch information
pwtyler authored Dec 6, 2024
2 parents b1ad1fe + bb6306c commit d875680
Show file tree
Hide file tree
Showing 15 changed files with 681 additions and 3,753 deletions.
43 changes: 11 additions & 32 deletions .github/workflows/build-tag.yml
Original file line number Diff line number Diff line change
@@ -1,45 +1,24 @@
name: Build and Tag
name: Build, Tag, and Release
on:
push:
branches:
- 'main'

permissions:
pull-requests: write
contents: write

jobs:
wordpress:
name: Release
tag:
name: Tag and Release
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v3

- name: install node v12
uses: actions/setup-node@v3
uses: actions/checkout@v4
- name: Build, tag, and release
uses: pantheon-systems/plugin-release-actions/build-tag-release@v0
with:
node-version: 12

- name: Build
run: |
npm ci
npm run build
composer install --no-dev -o
- name: Setup
run: 'echo "VERSION=$(jq -r .version ./package.json)" >> $GITHUB_ENV'

- name: Tag
run: |
echo "Releasing version $VERSION ..."
git config user.name Pantheon Automation
git config user.email [email protected]
git checkout -b "release-$VERSION"
git add -f assets/* vendor/
git commit -m "Release $VERSION"
git tag "$VERSION"
git push --tags
gh release create "$VERSION" -t "$VERSION" --generate-notes -d
env:
TOKEN: ${{ secrets.GITHUB_TOKEN }}
GH_TOKEN: ${{ github.token }}
gh_token: ${{ secrets.GITHUB_TOKEN }}
build_node_assets: "true"
build_composer_assets: "true"
draft: "true"
5 changes: 5 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,10 @@
## Changelog ##

### 2.6.0 (December 05, 2024) ###
* Adds `is_solr_query` filter [[#588](https://github.com/pantheon-systems/solr-power/pull/588)] (props [@sboisvert](https://github.com/sboisvert))
* Fixes custom schema file path for Composer Managed and other non-standard uploads directories. [[#637](https://github.com/pantheon-systems/solr-power/pull/637)]
* Adds filter `solr_power_customer_schema_file_path` to specify an alternative custom schema.xml file. [[#637](https://github.com/pantheon-systems/solr-power/pull/637)]

### 2.5.3 (April 24, 2024) ###
* Fixes a very old bug that would cause tax queries to be built incorrectly. [[#622](https://github.com/pantheon-systems/solr-power/pull/622)] (props [@offshorealert](https://wordpress.org/support/users/offshorealert/))

Expand Down
6 changes: 3 additions & 3 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -37,9 +37,9 @@ Note that dependencies are installed via Composer and the `vendor` directory is
* 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. CI will build, tag and draft [a release](https://github.com/pantheon-systems/solr-power/releases/).
1. Review the drafted release, updating release notes if needed, confirm that the necessary assets are present in the newly created tag, and test on a WP install if desired.
1. Publish the drafted release.
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:
Expand Down
2 changes: 1 addition & 1 deletion Gruntfile.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
module.exports = function( grunt ) {
'use strict';
const sass = require( 'node-sass' );
const sass = require( 'sass' );
// Project configuration
grunt.initConfig( {
pkg: grunt.file.readJSON( 'package.json' ),
Expand Down
41 changes: 39 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@
**Tags:** search
**Requires at least:** 4.6
**Requires PHP:** 7.1
**Tested up to:** 6.5.2
**Stable tag:** 2.5.3
**Tested up to:** 6.7.1
**Stable tag:** 2.6.0
**License:** GPLv2 or later
**License URI:** http://www.gnu.org/licenses/gpl-2.0.html

Expand Down Expand Up @@ -194,6 +194,43 @@ Add the following to your `functions.php` file.
}
add_filter( 'solr_dismax_query', 'my_solr_dismax_query' );

### `is_solr_query` Filter

The `is_solr_query` filter controls whether Solr should be used for a specific query.

Parameters:

* $enabled (bool): Indicates whether Solr should be used for the query. Defaults to true if the query is a search or if solr_integrate is set in the query.
* $query (WP_Query): The current WordPress query object.

Return:

* bool: true to enable Solr for the query, false to disable it.

```php
add_filter( 'is_solr_query', function( $enabled, $query ) {
if ( $query->is_category( 'news' ) ) {
return false;
}
return $enabled;
}, 10, 2 );
```

## Custom Schema file path

By default, custom schema is sourced from `wp-content/uploads/solr-for-wordpress-on-pantheon/schema.xml`. This can be overridden with an absolute path using the the `solr_power_customer_schema_file_path` filter.

Parameters:
* $custom_schema_file_path (string): Default path to a custom schema file

Return:
* string: Absolute path to a custom schema.xml file.

``` php
add_filter('solr_power_customer_schema_file_path', function($custom_schema_file_path) {
return '/absolute/path/to/schema.xml';
});
```

## Common issues ##

Expand Down
18 changes: 11 additions & 7 deletions composer.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

51 changes: 39 additions & 12 deletions includes/class-solrpower-api.php
Original file line number Diff line number Diff line change
Expand Up @@ -99,20 +99,42 @@ public function __set( $key, $value ) {
}
}

/**
* Returns the absolute path to look for a custom schema.xml file.
*
* @return string
*/
public static function custom_schema_file_path() {
$upload_dir = wp_upload_dir();
$custom_schema_file_path = path_join( $upload_dir['basedir'], 'solr-for-wordpress-on-pantheon/schema.xml' );

/**
* Override the custom schema file path
*
* @param string $custom_schema_file_path The absolute path to a customer solr schema file.
*/
$custom_schema_file_path = apply_filters( 'solr_power_customer_schema_file_path', $custom_schema_file_path );

return $custom_schema_file_path;
}

/**
* Submit the schema to Solr.
*/
function submit_schema() {
/*
* Solarium does not currently support submitting schemas to the server.
* So we'll do it ourselves.
* Let's check for a custom Schema.xml. It MUST be located in
* wp-content/uploads/solr-for-wordpress-on-pantheon/schema.xml.
* Let's check for a custom Schema.xml. It defaults to
* wp-content/uploads/solr-for-wordpress-on-pantheon/schema.xml
* and can be overridden with the filter 'solr_power_customer_schema_file_path'.
*/
if ( ! empty( $_ENV['FILEMOUNT'] ) && is_file( realpath( ABSPATH ) . '/' . $_ENV['FILEMOUNT'] . '/solr-for-wordpress-on-pantheon/schema.xml' ) ) {
$schema = realpath( ABSPATH ) . '/' . $_ENV['FILEMOUNT'] . '/solr-for-wordpress-on-pantheon/schema.xml';
} else {
$schema = SOLR_POWER_PATH . '/schema.xml';

$schema = SOLR_POWER_PATH . '/schema.xml';
$custom_schema_file_path = self::custom_schema_file_path();

if ( file_exists( $custom_schema_file_path ) ) {
$schema = $custom_schema_file_path;
}

$path = $this->compute_path();
Expand All @@ -128,11 +150,11 @@ function submit_schema() {
}

if ( ! file_exists( $schema ) ) {
return $schema . ' does not exist.';
return "Schema '" . $schema . "' does not exist.";
}

if ( ! file_exists( $client_cert ) ) {
return $client_cert . ' does not exist.';
return "Client cert '" . $client_cert . "' does not exist.";
}

$file = fopen( $schema, 'r' );
Expand All @@ -157,14 +179,19 @@ function submit_schema() {
$curl_opts = curl_getinfo( $ch );
fclose( $file );
if ( 200 === (int) $curl_opts['http_code'] ) {
// Schema Upload Success.
$return_value = 'Schema Upload Success: ' . $curl_opts['http_code'];
} else {
$return_value = 'Schema Upload Error: ' . $curl_opts['http_code'];
if ( preg_match( '#<h1>(HTTP Status [\d]+ - )?(.+)</h1>#', $response, $matches ) ) {
$return_value .= ' - ' . $matches[2];
if ( $schema == $custom_schema_file_path ) {
$return_value = 'Custom ' . $return_value;
}
return $return_value;
}

// Schema Upload Failure.
$return_value = 'Schema Upload Error: ' . $curl_opts['http_code'];
if ( preg_match( '#<h1>(HTTP Status [\d]+ - )?(.+)</h1>#', $response, $matches ) ) {
$return_value .= ' - ' . $matches[2];
}
return $return_value;
}

Expand Down
11 changes: 10 additions & 1 deletion includes/class-solrpower-wp-query.php
Original file line number Diff line number Diff line change
Expand Up @@ -1251,7 +1251,16 @@ function compare_date( $field, $field_value, $compare = '=' ) {
* @return boolean
*/
private function is_solr_query( $query ) {
return $query->is_search() || $query->get( 'solr_integrate' );
$enabled = $query->is_search() || $query->get( 'solr_integrate' );
/**
* Filter is_solr_query
*
* Enables the ability to turn off Solr for queries.
*
* @param boolean $enabled Should Solr run for this query?
* @param WP_Query $query The WP_Query.
*/
return apply_filters( 'is_solr_query', $enabled, $query );
}

}
Loading

0 comments on commit d875680

Please sign in to comment.