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

PHP Warning: Undefined array key "cpel_lv_languages" #17

Closed
brandon-hatch opened this issue Jan 26, 2024 · 1 comment
Closed

PHP Warning: Undefined array key "cpel_lv_languages" #17

brandon-hatch opened this issue Jan 26, 2024 · 1 comment

Comments

@brandon-hatch
Copy link

Issue:

Rest of the PHP warning:
PHP Warning: Undefined array key "cpel_lv_languages" in /plugins/connect-polylang-elementor/includes/language-visibility.php on line 134

This kicks out in the php log with custom Elementor widgets when saving a post in the elementor editor

Looks like my PHP 8.2 doesn't like that $languages doesn't have a fallback value like an empty array when instantiated, when $settings['cpel_lv_languages'] is null/empty.

Currently
$languages = (array) $settings['cpel_lv_languages'];

Solution:

Both of these lines below worked for me to solve the issue by replacing line #134:

Option 1)
Matches best with current plugin PHP code principles:
$languages = isset( $settings['cpel_lv_languages'] ) ? $settings['cpel_lv_languages'] : array();

Option 2)
PHP 7+ compatible null coalescing operator and array shorthand:
$languages = isset( $settings['cpel_lv_languages'] ) ?? [];

Plugin Versions:

Connect Polylang for Elementor: 2.4.3
Elementor 3.20.0
Elementor Pro 3.18.2
Polylang Pro 3.5.2

@pacotole
Copy link
Member

Thanks for the report. The fix will be included in the next version.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants