elementor / elementor/elementor
Display Conditions Module Breaking Blog on Each Update
- Dominant language
- PHP
- Stars
- 7.1k
- Forks
- 1.6k
- Avg merge
- 1d 5h
- Merged PRs (30d)
- 193
Description
### Description
The issue remains with
/wp-content/plugins/elementor-pro/modules/displav-conditions/module.php
On line 168 there is this code
protected function get_saved_conditions( $settings ) {
$conditions_json = ! empty( $settings['e_display_conditions'] ) ? $settings['e_display_conditions'] : [];
return ! empty( $conditions_json ) && ! empty( $conditions_json[0] )
? json_decode( $conditions_json[0], true )
: [];
}
That Elementor has wrote as their default but that conflicts with our blog pages making it so they don't display and have critical error.
So I go into the file and update it with
protected function get_saved_conditions( $settings ) {
$conditions = ! empty( $settings['e_display_conditions'] ) ? $settings['e_display_conditions'] : [];
if ( empty( $conditions ) ) {
return []; // No conditions set, return an empty array
}
// Check if it's already an array. If so, return it directly.
if ( is_array( $conditions ) && ! isset( $conditions[0] ) ) {
return $conditions;
}
//Check if the array has a string in the first index
if ( is_array( $conditions ) && isset( $conditions[0] ) && is_string($conditions[0])) {
// It looks like a JSON string was stored, so decode it.
$decoded_conditions = json_decode( $conditions[0], true );
// Add an error check in case json_decode fails
if ( json_last_error() !== JSON_ERROR_NONE ) {
// Handle the JSON decoding error. Log it, maybe return an empty array.
error_log( 'JSON decoding error in get_saved_conditions: ' . json_last_error_msg() );
return []; // Or throw an exception, depending on how you want to handle errors
}
return $decoded_conditions;
}
// If we get here, the data is in an unexpected format.
// Log an error (so you know something's up) and return an empty array
// to prevent the error from crashing the site.
error_log( 'Unexpected data format in get_saved_conditions: ' . print_r( $conditions, true ) );
return [];
}
This code has fixed the error after every update but yes it still persists
### Steps to reproduce
The issue remains with
/wp-content/plugins/elementor-pro/modules/displav-conditions/module.php
On line 168 there is this code
protected function get_saved_conditions( $settings ) {
$conditions_json = ! empty( $settings['e_display_conditions'] ) ? $settings['e_display_conditions'] : [];
return ! empty( $conditions_json ) && ! empty( $conditions_json[0] )
? json_decode( $conditions_json[0], true )
: [];
}
That Elementor has wrote as their default but that conflicts with our blog pages making it so they don't display and have critical error.
So I go into the file and update it with
protected function get_saved_conditions( $settings ) {
$conditions = ! empty( $settings['e_display_conditions'] ) ? $settings['e_display_conditions'] : [];
if ( empty( $conditions ) ) {
return []; // No conditions set, return an empty array
}
// Check if it's already an array. If so, return it directly.
if ( is_array( $conditions ) && ! isset( $conditions[0] ) ) {
return $conditions;
}
//Check if the array has a string in the first index
if ( is_array( $conditions ) && isset( $conditions[0] ) && is_string($conditions[0])) {
// It looks like a JSON string was stored, so decode it.
$decoded_conditions = json_decode( $conditions[0], true );
// Add an error check in case json_decode fails
if ( json_last_error() !== JSON_ERROR_NONE ) {
// Handle the JSON decoding error. Log it, maybe return an empty array.
error_log( 'JSON decoding error in get_saved_conditions: ' . json_last_error_msg() );
return []; // Or throw an exception, depending on how you want to handle errors
}
return $decoded_conditions;
}
// If we get here, the data is in an unexpected format.
// Log an error (so you know something's up) and return an empty array
// to prevent the error from crashing the site.
error_log( 'Unexpected data format in get_saved_conditions: ' . print_r( $conditions, true ) );
return [];
}
We are using Cyarb Theme and Active plugins (19 total):
301 Redirects, v2.85, WebFactory Ltd
BetterDocs, v4.8.2, WPDeveloper
Big File Uploads, v2.1.9, Infinite Uploads
Cloudflare, v4.14.4, Cloudflare, Inc.
CookieYes | GDPR Cookie Consent, v3.5.5, CookieYes
Cyarb Toolkit, v2.1, Envytheme
Duplicate Page, v4.5.9, mndpsingh287
Elementor, v4.2.3, Elementor.com
Elementor Pro, v4.2.2, Elementor.com
Enable Media Replace, v4.2.2, ShortPixel
Essential Addons for Elementor, v6.7.3, WPDeveloper
Integrations of Zoho CRM with Elementor form, v1.0.9, Forms Integrations
Templately, v3.7.4, Templately
The Plus Addons for Elementor, v6.5.0, POSIMYTH
UpdraftPlus Backup/Restore, v1.26.7, TeamUpdraft / DavidAnderson
Website LLMs.txt, v8.6.0, Ryan Howard
WP File Manager, v8.0.4, mndpsingh287
WPCode Lite, v2.3.8, WPCode
Yoast SEO, v28.3, Team Yoast
### Expected behavior
Expect our blog to function and fire not get critical error.
### Elementor System Info
```txt
WP Engine
Wordpress 7.1
Cyarb
Active plugins (19 total):
301 Redirects, v2.85, WebFactory Ltd
BetterDocs, v4.8.2, WPDeveloper
Big File Uploads, v2.1.9, Infinite Uploads
Cloudflare, v4.14.4, Cloudflare, Inc.
CookieYes | GDPR Cookie Consent, v3.5.5, CookieYes
Cyarb Toolkit, v2.1, Envytheme
Duplicate Page, v4.5.9, mndpsingh287
Elementor, v4.2.3, Elementor.com
Elementor Pro, v4.2.2, Elementor.com
Enable Media Replace, v4.2.2, ShortPixel
Essential Addons for Elementor, v6.7.3, WPDeveloper
Integrations of Zoho CRM with Elementor form, v1.0.9, Forms Integrations
Templately, v3.7.4, Templately
The Plus Addons for Elementor, v6.5.0, POSIMYTH
UpdraftPlus Backup/Restore, v1.26.7, TeamUpdraft / DavidAnderson
Website LLMs.txt, v8.6.0, Ryan Howard
WP File Manager, v8.0.4, mndpsingh287
WPCode Lite, v2.3.8, WPCode
Yoast SEO, v28.3, Team Yoast
```
### Agreement
- [ ] I confirm I have read and followed all the guidelines and instructions outlined in the Elementor Bug Report form.
- [x] I agree that my issue may be closed without further action if it doesn't meet all the requirements outlined in the Elementor Bug Report form.
Contributor guide
Research direction
Start at /wp-content/plugins/elementor-pro/modules/displav-conditions/module.php and inspect get_saved_conditions() around line 168. Reproduce the critical error with the listed Elementor and Elementor Pro versions, then compare the expected e_display_conditions formats with the values that cause the blog pages to fail. Done means blog pages render after an update without requiring manual file edits.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- php
- Domain
- backend, web-dev
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Active
- Clarity
- Needs clarification
- Newbie friendliness
- 42/100