Skip to content

Commit

Permalink
Merge branch 'develop' into fix/3764-move-offset-reset-before-message…
Browse files Browse the repository at this point in the history
…-output-in-indexer-cleanup
  • Loading branch information
felipeelia committed Nov 22, 2023
2 parents 5415615 + 3a9d13b commit 9893d01
Show file tree
Hide file tree
Showing 40 changed files with 101 additions and 69 deletions.
4 changes: 2 additions & 2 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -1254,7 +1254,7 @@ Enhancements:
* Refactor CLI indexing code for simplicity.
* Limit indexed Protected Content post types removing `revision`, `oembed_cache`, `custom_css`, `user_request`, `customize_changeset`, and `wp_block`.
* Cast taxonomy slug to array in case it's already an array in `WP_Query`.
* Remove unnecessary usage of `--network-wide` CLI paramter.
* Remove unnecessary usage of `--network-wide` CLI parameter.
* Add name, nickname, and display name to fields used for user search.
* Add `clear-transient` WP CLI command.
* Don't make product categories facetable when WooCommerce feature is not active. Props [mustafauysal](https://github.com/mustafauysal).
Expand Down Expand Up @@ -1635,7 +1635,7 @@ This is a bug fix release with some filter additions.
- WooCommerce feature breaking image search in media library. Props [@Ritesh-patel](https://github.com/Ritesh-patel)
- WooCommerce order search broken
- Stop the insansity made private. Props [@sc0ttclark](https://github.com/sc0ttclark)
- Multidimensional meta querys. Props [@Ritesh-patel](https://github.com/Ritesh-patel).
- Multidimensional meta queries. Props [@Ritesh-patel](https://github.com/Ritesh-patel).
- Properly show bulk index errors in WP-CLI
- Update ep_delete_post, include $post_type argument. Props [@Ritesh-patel](https://github.com/Ritesh-patel)
- post_type product getting set in any WP_Query if tax_query is provided in WooCommerce feature. Props [@Ritesh-patel](https://github.com/Ritesh-patel)
Expand Down
4 changes: 2 additions & 2 deletions assets/js/autosuggest/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ const { epas } = window;
if (epas.endpointUrl && epas.endpointUrl !== '') {
init();

// Publically expose API
// Publicly expose API
window.epasAPI = {
hideAutosuggestBox,
updateAutosuggestBox,
Expand Down Expand Up @@ -594,7 +594,7 @@ function init() {
* @param {Node} input - search input field
*/
const fetchResults = async (input) => {
// retrieves the PHP-genereated query to pass to ElasticSearch
// retrieves the PHP-generated query to pass to ElasticSearch
const queryJSON = getJsonQuery();

if (queryJSON.error) {
Expand Down
2 changes: 1 addition & 1 deletion assets/js/blocks/facets/common/components/range-filter.js
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ import { __ } from '@wordpress/i18n';
* @param {number} props.max Maximum value.
* @param {string} props.prefix Value prefix.
* @param {string} props.suffix Value suffix.
* @param {number[]} props.value Currnet value.
* @param {number[]} props.value Current value.
* @returns {WPElement} Component element.
*/
export default ({ clearUrl, min, max, prefix, suffix, value, ...props }) => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ import { useApiSearch } from '../../../api-search';
import { postTypeLabels } from '../../config';
import CheckboxList from '../common/checkbox-list';
import Panel from '../common/panel';
import { ActiveContraint } from '../tools/active-constraints';
import { ActiveConstraint } from '../tools/active-constraints';

/**
* Post type facet component.
Expand Down Expand Up @@ -100,7 +100,7 @@ export default ({ defaultIsOpen, label }) => {
/>

{selectedPostTypes.map((value) => (
<ActiveContraint
<ActiveConstraint
key={value}
label={postTypeLabels[value].singular}
onClick={() => onClear(value)}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ import { currencyCode } from '../../config';
import { formatPrice } from '../../utilities';
import Panel from '../common/panel';
import RangeSlider from '../common/range-slider';
import { ActiveContraint } from '../tools/active-constraints';
import { ActiveConstraint } from '../tools/active-constraints';

/**
* Price range facet.
Expand Down Expand Up @@ -137,7 +137,7 @@ export default ({ defaultIsOpen, label }) => {
</div>

{maxArg !== null && minArg !== null && (
<ActiveContraint
<ActiveConstraint
label={sprintf(
/* translators: %1$s: Minimum price. %2$s: Maximum price. */
_x('%1$s — %2$s', 'Price range', 'elasticpress'),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import { __, sprintf } from '@wordpress/i18n';
*/
import { useApiSearch } from '../../../api-search';
import { useDebounce } from '../../hooks';
import { ActiveContraint } from '../tools/active-constraints';
import { ActiveConstraint } from '../tools/active-constraints';

/**
* Search field component.
Expand Down Expand Up @@ -68,7 +68,7 @@ export default () => {
onChange={onChange}
/>
{searchTerm && (
<ActiveContraint
<ActiveConstraint
label={sprintf(
/* translators: %s: Search term. */
__('“%s”', 'elasticpress'),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ import { useApiSearch } from '../../../api-search';
import { facets, postTypeLabels } from '../../config';
import CheckboxList from '../common/checkbox-list';
import Panel from '../common/panel';
import { ActiveContraint } from '../tools/active-constraints';
import { ActiveConstraint } from '../tools/active-constraints';

/**
* Taxonomy filter component.
Expand Down Expand Up @@ -146,7 +146,7 @@ export default ({ defaultIsOpen, label, postTypes, name }) => {
{selectedTerms.map(
(value) =>
labels?.[value] && (
<ActiveContraint
<ActiveConstraint
key={value}
label={labels[value]}
onClick={() => onClear(value)}
Expand Down
2 changes: 1 addition & 1 deletion assets/js/instant-results/components/layout/results.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/**
* Internal depenencies.
* Internal dependencies.
*/
import { useEffect, useRef, WPElement } from '@wordpress/element';
import { _n, sprintf, __ } from '@wordpress/i18n';
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ const ref = createRef();
* @param {Function} props.onClick Click handler.
* @returns {WPElement} Element.
*/
export const ActiveContraint = ({ label, onClick }) => {
export const ActiveConstraint = ({ label, onClick }) => {
if (!ref.current) {
return null;
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/**
* WordPress deendencies.
* WordPress dependencies.
*/
import { WPElement } from '@wordpress/element';
import { chevronDown, chevronUp, Icon } from '@wordpress/icons';
Expand Down
4 changes: 2 additions & 2 deletions assets/js/instant-results/components/tools/sort.js
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
/**
* WordPress deendencies.
* WordPress dependencies.
*/
import { useMemo, WPElement } from '@wordpress/element';
import { __ } from '@wordpress/i18n';

/**
* Internal deendencies.
* Internal dependencies.
*/
import { useApiSearch } from '../../../api-search';
import { sortOptions } from '../../config';
Expand Down
2 changes: 1 addition & 1 deletion assets/js/instant-results/hooks.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
import { useCallback, useRef } from '@wordpress/element';

/**
* Get debounced version of a function that only runs a given ammount of time
* Get debounced version of a function that only runs a given amount of time
* after the last time it was run.
*
* @param {Function} callback Function to debounce.
Expand Down
6 changes: 3 additions & 3 deletions assets/js/synonyms/components/SynonymsEditor.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import { useContext, useEffect, WPElement } from '@wordpress/element';
* Internal dependencies.
*/
import { State, Dispatch } from '../context';
import AlterativesEditor from './editors/AlternativesEditor';
import AlternativesEditor from './editors/AlternativesEditor';
import SetsEditor from './editors/SetsEditor';
import SolrEditor from './editors/SolrEditor';

Expand Down Expand Up @@ -95,10 +95,10 @@ const SynonymsEditor = () => {
<p>{setsDescription}</p>
<SetsEditor sets={sets} />
</div>
<div className="synonym-editor synonym-editor__alteratives">
<div className="synonym-editor synonym-editor__alternatives">
<h2>{`${alternativesTitle} (${alternatives.length})`}</h2>
<p>{alternativesDescription}</p>
<AlterativesEditor alternatives={alternatives} />
<AlternativesEditor alternatives={alternatives} />
</div>
</>
)}
Expand Down
2 changes: 1 addition & 1 deletion assets/js/synonyms/utils.js
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ const reduceSolrToState = (solr, currentState) => {
*
* @param {string} value The value.
* @param {boolean} primary Whether it's a primary.
* @returns {object} Formated token
* @returns {object} Formatted token
*/
const formatToken = (value, primary = false) => {
return {
Expand Down
4 changes: 2 additions & 2 deletions assets/js/weighting/components/group.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ import { useWeightingSettings } from '../provider';
import Field from './field';

/**
* Post type propertes component.
* Post type properties component.
*
* @param {object} props Component props.
* @param {string} props.group Group.
Expand Down Expand Up @@ -42,7 +42,7 @@ export default ({ group, postType }) => {
const isMetadata = group === 'ep_metadata';

/**
* Fields that belond to this group.
* Fields that belong to this group.
*/
const defaultFields = useMemo(() => fields.filter((f) => f.group === group), [fields, group]);

Expand Down
2 changes: 1 addition & 1 deletion assets/js/weighting/provider.js
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ export const WeightingSettingsProvider = ({
* Handle data change.
*
* @param {string} postType Post type to update.
* @param {Array} values New valus.
* @param {Array} values New values.
* @returns {void}
*/
const setWeightingForPostType = (postType, values) => {
Expand Down
4 changes: 2 additions & 2 deletions assets/js/woocommerce/admin/orders/app/components/combobox.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/**
* WordPress depdendencies.
* WordPress dependencies.
*/
import { ReactElement, useCallback, useEffect, useMemo, useState } from '@wordpress/element';
import { _n, sprintf } from '@wordpress/i18n';
Expand All @@ -24,7 +24,7 @@ export default ({ children, id, isBusy, onSelect, ...props }) => {
/**
* Active descendant ID.
*
* @returns {string|null} Actve descendant id.
* @returns {string|null} Active descendant id.
*/
const activeDescendant = useMemo(() => {
return children[selected] ? children[selected].props.id : null;
Expand Down
2 changes: 1 addition & 1 deletion assets/js/woocommerce/admin/orders/hooks.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
import { useCallback, useRef } from '@wordpress/element';

/**
* Get debounced version of a function that only runs a given ammount of time
* Get debounced version of a function that only runs a given amount of time
* after the last time it was run.
*
* @param {Function} callback Function to debounce.
Expand Down
2 changes: 1 addition & 1 deletion includes/classes/DeprecatedCommand.php
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<?php
/**
* WP-CLI depreceated commands for ElasticPress
* WP-CLI deprecated commands for ElasticPress
*
* @since 4.4.0
* @package elasticpress
Expand Down
2 changes: 1 addition & 1 deletion includes/classes/Elasticsearch.php
Original file line number Diff line number Diff line change
Expand Up @@ -1695,7 +1695,7 @@ public function add_elasticpress_version_to_user_agent( $user_agent ) {
* Filter the User Agent header when submitting requests to Elasticsearch.
*
* @hook ep_remote_request_add_ep_user_agent
* @param {bool} $should_add_ep_verion Whether the ElasticPress version should be added to the User Agent string.
* @param {bool} $should_add_ep_version Whether the ElasticPress version should be added to the User Agent string.
* @return {bool} New value
* @since 3.6.1
*/
Expand Down
2 changes: 1 addition & 1 deletion includes/classes/Feature.php
Original file line number Diff line number Diff line change
Expand Up @@ -434,7 +434,7 @@ public function output_settings_box() {
* @return string
*/
public function get_epio_logo() : string {
return sprintf( '<img class="feature-epio-logo" alt="ElasticPresss.io logo" src="%s" width="110" height="20">', esc_url( plugins_url( '/images/logo-elasticpress-io.svg', EP_FILE ) ) );
return sprintf( '<img class="feature-epio-logo" alt="ElasticPress.io logo" src="%s" width="110" height="20">', esc_url( plugins_url( '/images/logo-elasticpress-io.svg', EP_FILE ) ) );
}

/**
Expand Down
2 changes: 1 addition & 1 deletion includes/classes/Feature/Facets/Types/Meta/Block.php
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
*/
class Block extends \ElasticPress\Feature\Facets\Block {
/**
* Hook block funcionality.
* Hook block functionality.
*/
public function setup() {
add_action( 'init', [ $this, 'register_block' ] );
Expand Down
2 changes: 1 addition & 1 deletion includes/classes/Feature/Facets/Types/MetaRange/Block.php
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
*/
class Block extends \ElasticPress\Feature\Facets\Block {
/**
* Hook block funcionality.
* Hook block functionality.
*/
public function setup() {
add_action( 'init', [ $this, 'register_block' ] );
Expand Down
2 changes: 1 addition & 1 deletion includes/classes/Feature/Facets/Types/Taxonomy/Block.php
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
*/
class Block extends \ElasticPress\Feature\Facets\Block {
/**
* Hook block funcionality.
* Hook block functionality.
*/
public function setup() {
add_action( 'init', [ $this, 'register_block' ] );
Expand Down
2 changes: 1 addition & 1 deletion includes/classes/Feature/Search/Weighting.php
Original file line number Diff line number Diff line change
Expand Up @@ -591,7 +591,7 @@ public function post_type_has_fields( $post_type, $args = [] ) {
* @hook ep_weighting_configuration_for_search
* @param {array} $weight_config Current weight config
* @param {array} $args WP Query arguments
* @return {array} New configutation
* @return {array} New configuration
*/
$weight_config = apply_filters( 'ep_weighting_configuration_for_search', $weight_config, $args );

Expand Down
2 changes: 1 addition & 1 deletion includes/classes/Features.php
Original file line number Diff line number Diff line change
Expand Up @@ -339,7 +339,7 @@ public function setup_features() {
}

/**
* Return currnt features settings
* Return current features settings
*
* @since 5.0.0
* @return false|array
Expand Down
10 changes: 10 additions & 0 deletions includes/classes/Indexable.php
Original file line number Diff line number Diff line change
Expand Up @@ -386,6 +386,10 @@ public function bulk_index_dynamically( $object_ids ) {

$document = $this->prepare_document( $object_id );

if ( empty( $document ) ) {
continue;
}

/**
* Conditionally kill indexing on a specific object
*
Expand All @@ -402,6 +406,12 @@ public function bulk_index_dynamically( $object_ids ) {
$documents[] = $document_str;
}

if ( empty( $documents ) ) {
return [
new \WP_Error( 'ep_bulk_index_no_documents', esc_html__( 'It was not possible to create a body request with the document IDs provided.', 'elasticpress' ), $object_ids ),
];
}

$results = $this->send_bulk_index_request( $documents );

/**
Expand Down
2 changes: 1 addition & 1 deletion includes/classes/Indexable/Comment/Comment.php
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,7 @@ public function format_args( $query_vars ) {
/**
* Support `paged` query var
*
* If `offset` is used, that takes precendence
* If `offset` is used, that takes precedence
* over this.
*/
if ( isset( $query_vars['paged'] ) && empty( $query_vars['offset'] ) && $query_vars['paged'] > 1 ) {
Expand Down
2 changes: 1 addition & 1 deletion includes/classes/Indexable/Post/Post.php
Original file line number Diff line number Diff line change
Expand Up @@ -778,7 +778,7 @@ private function get_formatted_term( \WP_Term $term, int $post_id ) : array {
}

/**
* Retreives term order for the object/term_taxonomy_id combination
* Retrieves term order for the object/term_taxonomy_id combination
*
* @param int $term_taxonomy_id Term Taxonomy ID
* @param int $object_id Post ID
Expand Down
2 changes: 1 addition & 1 deletion includes/classes/Indexable/Post/SyncManager.php
Original file line number Diff line number Diff line change
Expand Up @@ -138,7 +138,7 @@ public function maybe_delete_meta_for_all( $check, $object_id, $meta_key, $meta_
* Filter to allow cron and WP CLI processes to index/delete documents
*
* @param boolean $bypass The current filtered value
* @return boolean Boolean indicating if permission checking should be bypased or not
* @return boolean Boolean indicating if permission checking should be bypassed or not
* @since 3.6.0
*/
public function filter_bypass_permission_checks_for_machines( $bypass ) {
Expand Down
2 changes: 1 addition & 1 deletion includes/classes/Indexable/Term/SyncManager.php
Original file line number Diff line number Diff line change
Expand Up @@ -213,7 +213,7 @@ public function action_sync_on_delete( $term_id ) {
}

/**
* Enqueue sync of children terms in hierchy when deleting parent. Children terms will be reasigned to
* Enqueue sync of children terms in hierarchy when deleting parent. Children terms will be reasigned to
* a different parent and we want to reflect that change in ElasticSearch
*
* @param int $term_id Term ID.
Expand Down
6 changes: 5 additions & 1 deletion includes/classes/SyncManager.php
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ public function __construct( $indexable_slug ) {
if ( defined( 'EP_SYNC_CHUNK_LIMIT' ) && is_numeric( EP_SYNC_CHUNK_LIMIT ) ) {
/**
* We also sync when we exceed Chunk limit set.
* This is sometimes useful when posts are generated programatically.
* This is sometimes useful when posts are generated programmatically.
*/
add_action( 'ep_after_add_to_queue', [ $this, 'index_sync_on_chunk_limit' ] );
}
Expand Down Expand Up @@ -205,6 +205,10 @@ public function index_sync_queue() {

$current_blog_id = get_current_blog_id();
foreach ( $this->sync_queue as $blog_id => $sync_queue ) {
if ( empty( $sync_queue ) ) {
continue;
}

if ( $current_blog_id !== $blog_id ) {
switch_to_blog( $blog_id );
}
Expand Down
Loading

0 comments on commit 9893d01

Please sign in to comment.