Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix usage of requiresReindex #2536

Merged
merged 3 commits into from
Dec 20, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 5 additions & 2 deletions assets/js/dashboard.js
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,8 @@ $features.on('click', '.save-settings', function (event) {
}
});

const requiresConfirmation = requiresReindex && wasActive === '0' && settings.active === '1';
const requiresConfirmation =
requiresReindex === '1' && wasActive === '0' && settings.active === '1';

if (requiresConfirmation) {
// eslint-disable-next-line no-alert
Expand Down Expand Up @@ -602,10 +603,12 @@ $features.on('change', '.js-toggle-feature', function (event) {
.closest('.settings')
.querySelector('.requirements-status-notice--reindex');

if (!container) return;

const { value } = event.target;
const { requiresReindex, wasActive } = event.currentTarget.dataset;

if (requiresReindex && wasActive === '0' && value === '1') {
if (requiresReindex === '1' && wasActive === '0' && value === '1') {
container.style.display = 'block';
} else {
container.style.display = null;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@felipeelia we need to check if there is an element on container because we are retrieving only if it has .requirements-status-notice--reindex and it is causing an error when we try to access container.style.display:

Cannot read properties of null (reading 'style')

Maybe we can add an early return:

if (!container) return;

Expand Down
2 changes: 1 addition & 1 deletion dist/js/dashboard-script.min.js

Large diffs are not rendered by default.

4 changes: 4 additions & 0 deletions includes/classes/Upgrades.php
Original file line number Diff line number Diff line change
Expand Up @@ -145,6 +145,10 @@ public function upgrade_3_6_6() {

$synonyms = \ElasticPress\Features::factory()->get_registered_feature( 'search' )->synonyms;

if ( ! $synonyms ) {
return;
}

$synonyms_example_ids = $wpdb->get_col(
$wpdb->prepare(
"SELECT ID FROM {$wpdb->posts} WHERE post_type = %s AND post_content = %s LIMIT 100",
Expand Down