elementor / elementor/elementor

PHP 8.x: Undefined array key warnings in dynamic-value-provider.php when ACF field key lacks colon separator

Open Beginner friendly
#36,406 1 comment 0 reactions 0 assignees View on GitHub
status/awaiting_triage
Dominant language
PHP
Stars
7.1k
Forks
1.6k
Avg merge
1d 5h
Merged PRs (30d)
193

Description

### Description

Elementor Pro's ACF dynamic tag integration floods PHP error logs with Undefined array key 0 and Undefined array key 1 warnings on every page request that renders an ACF dynamic tag. The warnings originate from dynamic-value-provider.php line 16 where array destructuring is performed on the result of explode(':', $key) without any null-safety guard.
The issue was introduced by a PHP 8.x behavioral change - PHP 7.x silently returned null for undefined array keys, while PHP 8.x emits E_WARNING. The warnings fire on every ACF dynamic tag render across multiple tag types (acf-text.php, acf-url.php, and others that call the same method).
In our production environment running 4 EC2 instances behind an AWS Application Load Balancer, the warning volume was significant enough to:

Flood PHP-FPM error logs and nginx error logs (via catch_workers_output)
Contribute to PHP-FPM worker pool exhaustion (pm.max_children hit at 40 workers)
Cause client-facing 460 errors (ALB client disconnects due to slow PHP-FPM response)

All ACF fields referenced in Elementor's stored post meta were verified as properly registered and fully supported per Elementor's own documentation. The issue is not a field configuration problem - it is a PHP 8.x compatibility regression in Elementor Pro's code.

File: elementor-pro/modules/dynamic-tags/acf/dynamic-value-provider.php
Line 16:
php[ $field_key, $meta_key ] = explode( ':', $key );

When $key does not contain a : separator, explode() returns a single-element array. Destructuring into two variables then produces Undefined array key 0 and Undefined array key 1 warnings under PHP 8.x.

### Steps to reproduce

Install WordPress with PHP 8.x
Install Elementor Pro and Advanced Custom Fields (ACF)
Create an ACF field group with any supported field type (URL, Text, Email)
Create a page using Elementor Pro and add an ACF dynamic tag referencing any registered field
Visit the page
Check PHP error log — Undefined array key 0 and Undefined array key 1 warnings will appear for every page load

### Expected behavior

No PHP warnings should be emitted during normal ACF dynamic tag rendering. The code should safely handle cases where the key format does not produce the expected two-part array after explode().

Replace line 16 in dynamic-value-provider.php:
php// Current code — no null-safety guard
[ $field_key, $meta_key ] = explode( ':', $key );

Suggested fix:
Replace line 16 in dynamic-value-provider.php:

// Fixed code — null guards
$parts = explode( ':', $key );
$field_key = $parts[0] ?? '';
$meta_key = $parts[1] ?? '';

This one-line fix resolves the warnings across all ACF dynamic tag types since they all call Module::get_tag_value_field() which in turn calls Dynamic_Value_Provider::get_value() where the broken destructuring lives.

### Elementor System Info

```txt
Elementor Pro: 4.1.1 (also reproduced on 4.1.2)
WordPress: 7.0
PHP: 8.x
ACF: 6.8.4
Server: AWS EC2 / Nginx / PHP-FPM
```

### Agreement

- [x] 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

Open the contributing guide

Research direction

Start with elementor-pro/modules/dynamic-tags/acf/dynamic-value-provider.php at line 16, then trace the ACF dynamic tag callers such as acf-text.php and acf-url.php. Reproduce an ACF dynamic tag render under PHP 8.x and verify that fields whose keys lack a colon no longer emit undefined array key warnings.

Written by the indexing model from the issue text.

Assessment

Tech stack
php, wordpress
Domain
backend
Issue type
Bug
Difficulty
2/5
Estimated time
1-3 hours
Activity status
Quiet
Clarity
Clearly specified
Newbie friendliness
72/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.