Skip to content

Commit

Permalink
Version 2.7.0 (#1182)
Browse files Browse the repository at this point in the history
* Resolves issue for ElasticPress.io credentials to be properly saved. … (#1149)

* Resolves issue for ElasticPress.io credentials to be properly saved. Space also added to settings page title.

* Setup EPIO credentials after we have have determined if network activated.

* Do not apply absint to comment_status (#1158)

* Do not apply absint to comment_status

* Do not apply absint to ping_status.

* Add compatibility for new MLT structure (#1146)

* Add compatibility for new MLT

Check elasticsearch version and change mlt structure.
Retain compatibility for older ES versions.

* Correct conditional logic.

* Add doc bloc

* Setting array key for related posts query based upon elasticsearch version support for more_like_this structure. Added assertion to unit tests to check if elasticsearch property is part of WP_Post object.

* Add additional hook for when an blog is deleted. Also conditional logic to prevent posts from getting indexed if blog is not indexable. Fixes #1157.

* Only query for post IDs when indexing posts (#1145)

* Feature/better error notices (#1142)

* added better error messages for EP host failures

* use get_error_message() if wp_remote_retrieve_response_message() was empty

* clear out any errors if we're able to retrive the ES version

* reenable passing force to ep_get_elasticsearch_version, added classes for error spans

* updated testBadHostNotification to check for error codes and messages

* moved some logging variables so they're only used when-needed

* Let WC feature order by rand. (#1147)

* Change object to array and added additional conditional statement.

* Refactored logic to check if site is indexable.

* Add apply_filters to ep_host. (#1108)

* Fix `is_indexing_wpcli` method to check for `ep_wpcli_sync` instead of `ep_index_meta` (#1074)

* Removing second parameter on get_transient function.

* Removing unneeded code.

* Readme changelog and version bump.
  • Loading branch information
Allan Collins authored Dec 6, 2018
1 parent 8b62d07 commit 9459248
Show file tree
Hide file tree
Showing 13 changed files with 285 additions and 81 deletions.
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
ElasticPress [![Build Status](https://travis-ci.org/10up/ElasticPress.svg?branch=develop)](https://travis-ci.org/10up/ElasticPress)
ElasticPress
=============

A fast and flexible search and query engine for WordPress.

**Please note:** master is the stable branch

**Upgrade Notice:** Versions 1.6.1, 1.6.2, 1.7, 1.8, 2.1, 2.1.2, 2.2 require re-syncing.
**Upgrade Notice:** Versions 1.6.1, 1.6.2, 1.7, 1.8, 2.1, 2.1.2, 2.2, 2.7 require re-syncing.

ElasticPress, a fast and flexible search and query engine for WordPress, enables WordPress to find or “query” relevant content extremely fast through a variety of highly customizable features. WordPress out-of-the-box struggles to analyze content relevancy and can be very slow. ElasticPress supercharges your WordPress website making for happier users and administrators. The plugin even contains features for popular plugins.

Expand Down
12 changes: 6 additions & 6 deletions bin/wp-cli.php
Original file line number Diff line number Diff line change
Expand Up @@ -509,6 +509,7 @@ private function _index_helper( $args ) {
'ignore_sticky_posts' => true,
'orderby' => 'ID',
'order' => 'DESC',
'fields' => 'ids',
) );

if ( $post_in ) {
Expand All @@ -519,22 +520,21 @@ private function _index_helper( $args ) {

if ( $query->have_posts() ) {

while ( $query->have_posts() ) {
$query->the_post();
foreach ( $query->posts as $post_id ) {

if ( $no_bulk ) {
// index the posts one-by-one. not sure why someone may want to do this.
$result = ep_sync_post( get_the_ID() );
$result = ep_sync_post( $post_id );

$this->reset_transient();

do_action( 'ep_cli_post_index', get_the_ID() );
do_action( 'ep_cli_post_index', $post_id );
} else {
$result = $this->queue_post( get_the_ID(), $query->post_count, $show_bulk_errors );
$result = $this->queue_post( $post_id, $query->post_count, $show_bulk_errors );
}

if ( ! $result ) {
$errors[] = get_the_ID();
$errors[] = $post_id;
} elseif ( true === $result || isset( $result->_index ) ) {
$synced ++;
}
Expand Down
15 changes: 8 additions & 7 deletions classes/class-ep-api.php
Original file line number Diff line number Diff line change
Expand Up @@ -583,14 +583,14 @@ public function prepare_post( $post_id ) {
);
}

$post_date = $post->post_date;
$post_date_gmt = $post->post_date_gmt;
$post_modified = $post->post_modified;
$post_date = $post->post_date;
$post_date_gmt = $post->post_date_gmt;
$post_modified = $post->post_modified;
$post_modified_gmt = $post->post_modified_gmt;
$comment_count = absint( $post->comment_count );
$comment_status = absint( $post->comment_status );
$ping_status = absint( $post->ping_status );
$menu_order = absint( $post->menu_order );
$comment_count = absint( $post->comment_count );
$comment_status = $post->comment_status;
$ping_status = $post->ping_status;
$menu_order = absint( $post->menu_order );

if ( apply_filters( 'ep_ignore_invalid_dates', true, $post_id, $post ) ) {
if ( ! strtotime( $post_date ) || $post_date === "0000-00-00 00:00:00" ) {
Expand Down Expand Up @@ -2011,6 +2011,7 @@ public function get_sites( $limit = 0 ) {
$sites = array();

foreach ( $site_objects as $site ) {

$sites[] = array(
'blog_id' => $site->blog_id,
'domain' => $site->domain,
Expand Down
51 changes: 31 additions & 20 deletions classes/class-ep-config.php
Original file line number Diff line number Diff line change
Expand Up @@ -41,22 +41,6 @@ public static function factory() {

if ( ! $instance ) {
$instance = new self();

if ( ! defined( 'EP_INDEX_PREFIX' ) ) {
$index_prefix = ep_get_index_prefix();
if ( $index_prefix ) {
$index_prefix = ( ep_is_epio() && '-' !== substr( $index_prefix, - 1 ) ) ? $index_prefix . '-' : $index_prefix;
define( 'EP_INDEX_PREFIX', $index_prefix );
}
} else {
$instance::$option_prefix = true;
}

if ( ! defined( 'ES_SHIELD' ) && ep_is_epio() ) {
$credentials = ep_get_epio_credentials();
define( 'ES_SHIELD', $credentials['username'] . ':' . $credentials['token'] );
}

}

return $instance;
Expand Down Expand Up @@ -86,12 +70,12 @@ public function is_indexing() {
*/
public function is_indexing_wpcli() {
if ( defined( 'EP_IS_NETWORK' ) && EP_IS_NETWORK ) {
$index_meta = get_site_option( 'ep_index_meta', false );
$is_indexing = (bool) get_site_transient( 'ep_wpcli_sync' );
} else {
$index_meta = get_option( 'ep_index_meta', false );
$is_indexing = (bool) get_transient( 'ep_wpcli_sync' );
}

return apply_filters( 'ep_is_indexing_wpcli', ( ! empty( $index_meta ) && ! empty( $index_meta['wpcli'] ) ) );
return apply_filters( 'ep_is_indexing_wpcli', $is_indexing );
}

/**
Expand All @@ -110,7 +94,7 @@ public function get_host() {
$host = get_option( 'ep_host', false );
}

return $host;
return apply_filters( 'ep_host', $host );
}

/**
Expand Down Expand Up @@ -268,6 +252,26 @@ public function is_network( $plugin ) {
return false;

}

/**
* Setup credentials for future usage.
*/
public function setup_credentials(){
if ( ! defined( 'EP_INDEX_PREFIX' ) ) {
$index_prefix = ep_get_index_prefix();
if ( $index_prefix ) {
$index_prefix = ( ep_is_epio() && '-' !== substr( $index_prefix, - 1 ) ) ? $index_prefix . '-' : $index_prefix;
define( 'EP_INDEX_PREFIX', $index_prefix );
}
} else {
self::$option_prefix = true;
}

if ( ! defined( 'ES_SHIELD' ) && ep_is_epio() ) {
$credentials = ep_get_epio_credentials();
define( 'ES_SHIELD', $credentials['username'] . ':' . $credentials['token'] );
}
}
}

EP_Config::factory();
Expand Down Expand Up @@ -341,4 +345,11 @@ function ep_sanitize_credentials( $credentials ) {
'username' => ( isset( $credentials['username'] ) ) ? sanitize_text_field( $credentials['username'] ) : '',
'token' => ( isset( $credentials['token'] ) ) ? sanitize_text_field( $credentials['token'] ) : '',
];
}

/**
* Prepare credentials if they are set for future use.
*/
function ep_setup_credentials(){
EP_Config::factory()->setup_credentials();
}
Loading

0 comments on commit 9459248

Please sign in to comment.