Skip to content

Commit

Permalink
Merge pull request #601 from pantheon-systems/release_2.5.1
Browse files Browse the repository at this point in the history
Release 2.5.1
  • Loading branch information
pwtyler authored Jul 26, 2023
2 parents e04d9b8 + 76f37f1 commit 159491a
Show file tree
Hide file tree
Showing 13 changed files with 89 additions and 35 deletions.
4 changes: 3 additions & 1 deletion .github/workflows/build-tag.yml
Original file line number Diff line number Diff line change
Expand Up @@ -36,5 +36,7 @@ jobs:
git commit -m "Release $VERSION"
git tag "$VERSION"
git push --tags
gh release create "$VERSION" -t "$VERSION" --generate-notes
env:
TOKEN: ${{ secrets.GITHUB_TOKEN }}
TOKEN: ${{ secrets.GITHUB_TOKEN }}
GH_TOKEN: ${{ github.token }}
8 changes: 7 additions & 1 deletion .github/workflows/lint-test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,13 @@ jobs:

- name: Run PHP Lint
run: composer phpcs

validate-readme-spacing:
name: Validate README Spacing
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v3
- uses: pantheon-systems/validate-readme-spacing@v1
test-phpunit:
needs: lint
runs-on: ubuntu-latest
Expand Down
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
## Changelog ##

### 2.5.1 ###
* Fix Solr not indexing automatically [[#598](https://github.com/pantheon-systems/solr-power/pull/598)]
* Fixed issue with empty/zero value for posts_per_page [[#599](https://github.com/pantheon-systems/solr-power/pull/599)] (props @threeiem)

### 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)]
Expand Down
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
# Solr Search for WordPress #
**Contributors:** [getpantheon](https://profiles.wordpress.org/getpantheon), [Outlandish Josh](https://profiles.wordpress.org/outlandish-josh), [10up](https://profiles.wordpress.org/10up), [collinsinternet](https://profiles.wordpress.org/collinsinternet), [andrew.taylor](https://profiles.wordpress.org/andrew.taylor), [danielbachhuber](https://profiles.wordpress.org/danielbachhuber), [mattleff](https://profiles.wordpress.org/mattleff), [mikengarrett](https://profiles.wordpress.org/mikengarrett), [jazzsequence](https://profiles.wordpress.org/jazzs3quence), [jspellman](https://profiles.wordpress.org/jspellman/)
**Contributors:** [getpantheon](https://profiles.wordpress.org/getpantheon), [Outlandish Josh](https://profiles.wordpress.org/outlandish-josh), [10up](https://profiles.wordpress.org/10up), [collinsinternet](https://profiles.wordpress.org/collinsinternet), [andrew.taylor](https://profiles.wordpress.org/andrew.taylor), [danielbachhuber](https://profiles.wordpress.org/danielbachhuber), [mattleff](https://profiles.wordpress.org/mattleff), [mikengarrett](https://profiles.wordpress.org/mikengarrett), [jazzsequence](https://profiles.wordpress.org/jazzs3quence), [jspellman](https://profiles.wordpress.org/jspellman/), [pwtyler](https://profiles.wordpress.org/pwtyler/)
**Tags:** search
**Requires at least:** 4.6
**Requires PHP:** 7.1
**Tested up to:** 6.2
**Stable tag:** 2.5.0
**Stable tag:** 2.5.1
**License:** GPLv2 or later
**License URI:** http://www.gnu.org/licenses/gpl-2.0.html

Expand Down
14 changes: 13 additions & 1 deletion bin/phpunit-test.sh
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,21 @@
set -e

DIRNAME=$(dirname "$0")

reset_test_environment() {
rm -rf $WP_TESTS_DIR $WP_CORE_DIR
}

echo "Testing on WordPress single site..."
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
reset_test_environment

echo "Testing on WordPress multisite..."
bash "${DIRNAME}/install-wp-tests.sh" wordpress_test root root 127.0.0.1 latest true
WP_MULTISITE=1 composer test
reset_test_environment

echo "Testing with latest WordPress nightly version..."
bash "${DIRNAME}/install-wp-tests.sh" wordpress_test root root 127.0.0.1 nightly true
composer test
23 changes: 23 additions & 0 deletions bin/prerelease.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
#!/bin/bash
set -eou pipefail

DIRNAME=$(dirname "$0")

CURRENT_HASH=$(git rev-parse --short HEAD)

cd "$DIRNAME/.."

npm ci
npm run build
composer install --no-dev -o

VERSION=$(jq -r .version ./package.json)
PRERELEASE_VERSION="${VERSION}-${CURRENT_HASH}"

git checkout -b "prerelease-${PRERELEASE_VERSION}"
git add -f assets/* vendor/
git commit -m "Release ${PRERELEASE_VERSION}"
git tag "${PRERELEASE_VERSION}"
git push --tags

git checkout -
2 changes: 1 addition & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
"name": "pantheon-systems/solr-power",
"description": "An open source plugin to connect to Pantheon's Apache Solr search infrastructure, or your own!",
"type": "wordpress-plugin",
"license": "GPLv2 or later",
"license": "GPL-2.0-or-later",
"authors": [
{
"name": "Pantheon",
Expand Down
4 changes: 1 addition & 3 deletions includes/class-solrpower-sync.php
Original file line number Diff line number Diff line change
Expand Up @@ -433,15 +433,13 @@ function post( $documents, $commit = true, $optimize = false ) {
if ( $commit && $this->should_commit() ) {
syslog( LOG_INFO, 'telling Solr to commit' );
$update->addCommit();
$solr->update( $update );
}

if ( $optimize ) {
$update = $solr->createUpdate();
$update->addOptimize();
$solr->update( $update );
syslog( LOG_INFO, 'Optimizing: ' . get_bloginfo( 'wpurl' ) );
}
$solr->update( $update );
wp_cache_delete( 'solr_index_stats', 'solr' );
} else {
syslog( LOG_ERR, 'failed to get a solr instance created' );
Expand Down
40 changes: 23 additions & 17 deletions includes/class-solrpower-wp-query.php
Original file line number Diff line number Diff line change
Expand Up @@ -175,22 +175,26 @@ function posts_request( $request, $query ) {
if ( ! $this->is_solr_query( $query ) || false === SolrPower_Api::get_instance()->ping ) {
return $request;
}

add_filter( 'solr_query', array( SolrPower_Api::get_instance(), 'dismax_query' ), 10, 2 );
$solr_options = SolrPower_Options::get_instance()->get_option();

$solr_options = SolrPower_Options::get_instance()->get_option();
$the_page = ( ! $query->get( 'paged' ) ) ? 1 : $query->get( 'paged' );

$qry = $this->build_query( $query );

if ( '' === $qry ) { // If we don't have anything to query, let's do a wildcard.
$qry = '*';
}
$this->qry = $qry;
$offset = $query->get( 'posts_per_page' ) * ( $the_page - 1 );
$count = $query->get( 'posts_per_page' );
$fq = $this->parse_facets( $query );
$sortby = ( isset( $solr_options['s4wp_default_sort'] ) && ! empty( $solr_options['s4wp_default_sort'] ) ) ? $solr_options['s4wp_default_sort'] : 'score';
$order = ( $query->get( 'order', false ) ) ? strtolower( $query->get( 'order' ) ) : 'desc';
$extra = array();

$posts_per_page = $query->get( 'posts_per_page', get_option( 'posts_per_page', 10 ) );
$this->qry = $qry;
$offset = $posts_per_page * ( $the_page - 1 );
$count = $posts_per_page;
$fq = $this->parse_facets( $query );
$sortby = ( isset( $solr_options['s4wp_default_sort'] ) && ! empty( $solr_options['s4wp_default_sort'] ) ) ? $solr_options['s4wp_default_sort'] : 'score';
$order = ( $query->get( 'order', false ) ) ? strtolower( $query->get( 'order' ) ) : 'desc';
$extra = array();

if ( $query->get( 'orderby', false ) ) {
$orderby = $query->get( 'orderby' );

Expand All @@ -215,6 +219,7 @@ function posts_request( $request, $query ) {
}

$fields = null;

switch ( $query->get( 'fields' ) ) {
case 'ids':
$fields = 'ID';
Expand All @@ -223,27 +228,28 @@ function posts_request( $request, $query ) {
$fields = null;
break;
}

$search = SolrPower_Api::get_instance()->query( $qry, $offset, $count, $fq, $sortby, $order, $fields, $extra );

if ( is_null( $search ) ) {
$this->found_posts[ $query->solr_query_id ] = array();
$this->reset_vars();
return false;
}

$this->search = $search;

if ( $search->getFacetSet() ) {
$this->facets = $search->getFacetSet()->getFacets();
}

$this->highlighting = $search->getHighlighting();

$search = $search->getData();

$search_header = $search['responseHeader'];
$search = $search['response'];
$query->found_posts = $search['numFound'];
$this->highlighting = $search->getHighlighting();
$search = $search->getData();
$search_header = $search['responseHeader'];
$search = $search['response'];
$query->found_posts = $search['numFound'];
$this->found_posts_count[ $query->solr_query_id ] = $search['numFound'];
$query->max_num_pages = ceil( $search['numFound'] / $query->get( 'posts_per_page' ) );
$query->max_num_pages = ceil( $search['numFound'] / $posts_per_page );

SolrPower_Api::get_instance()->add_log(
array(
Expand Down
4 changes: 2 additions & 2 deletions package-lock.json

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

4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "solr-power",
"version": "2.5.0",
"version": "2.5.1",
"repository": {
"type": "git",
"url": "https://github.com/pantheon-systems/solr-power.git"
Expand All @@ -23,4 +23,4 @@
"grunt-wp-readme-to-markdown": "~2.1.0",
"node-sass": "^9.0.0"
}
}
}
9 changes: 6 additions & 3 deletions readme.txt
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
=== Solr Search for WordPress ===
Contributors: getpantheon, Outlandish Josh, 10up, collinsinternet, andrew.taylor, danielbachhuber, mattleff, mikengarrett, jazzs3quence, jspellman
Contributors: getpantheon, Outlandish Josh, 10up, collinsinternet, andrew.taylor, danielbachhuber, mattleff, mikengarrett, jazzs3quence, jspellman, pwtyler
Tags: search
Requires at least: 4.6
Requires PHP: 7.1
Tested up to: 6.2
Stable tag: 2.5.0
Stable tag: 2.5.1
License: GPLv2 or later
License URI: http://www.gnu.org/licenses/gpl-2.0.html

Expand Down Expand Up @@ -235,8 +235,11 @@ Please report security bugs found in the source code of the Solr Power plugin th

== Changelog ==

= 2.5.0 =
= 2.5.1 =
* Fix Solr not indexing automatically [[#598](https://github.com/pantheon-systems/solr-power/pull/598)]
* Fixed issue with empty/zero value for posts_per_page [[#599](https://github.com/pantheon-systems/solr-power/pull/599)] (props @threeiem)

= 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)]
Expand Down
4 changes: 2 additions & 2 deletions solr-power.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,15 +2,15 @@
/**
* Plugin Name: Solr Power
* Description: Allows WordPress sites to index and search content with ApacheSolr.
* Version: 2.5.0
* Version: 2.5.1
* Author: Pantheon
* Author URI: http://pantheon.io
* Text Domain: solr-for-wordpress-on-pantheon
*
* @package Solr_Power
**/

define( 'SOLR_POWER_VERSION', '2.5.0' );
define( 'SOLR_POWER_VERSION', '2.5.1' );

/**
* Copyright (c) 2011-2022 Pantheon, Matt Weber, Solr Power contributors
Expand Down

0 comments on commit 159491a

Please sign in to comment.