elementor / elementor/elementor

Custom Query Filter not working after upgrading php to v8

Open
#31,399 0 comments 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

This is my second attempt of submitting this issue. The customer support told me, as a Elementor Pro user, that I would get help here in github!
Please note, it's **not about the custom code itself**, as it was mistakenly seen so in my last submission! It's about the filter, you documented [here](https://developers.elementor.com/docs/hooks/custom-query-filter/). You can use any custom code in my case, the issue remains. To make it obvious I simplified the closure this time!

For a long time I have been using the code below making use of custom query hooks on a website without any issues. But the web hoster wants me to upgrade the php version to 8.2.27. Unfortunately I noticed that this code does not work anymore with php version 8+ which leads to empty post entries (NOTE: the sample below is just for reproduction. It's not my actual custom code!). I also checked it with debugging via xdebug and can confirm that indeed the **query filter is called when running php 7** but not called at all when running php 8! Can you please help me?

```php

function custom_filter($query) {
echo "this line is not run when I switch to php 8! But it does run with php 7!";
}

add_action( 'elementor/query/single_custom_archive', 'custom_filter');
```

### Steps to reproduce

switch php version from version 7 to version 8 (e.g. 8.2.27)

### Expected behavior

a properly working custom query with php 8 like it does with php 7

### Elementor System Info

```txt
== Server Environment ==
Operating System: WINNT
Software: Apache/2.4.43 (Win32) mod_fcgid/2.3.9a
MySQL version: MySQL Community Server - GPL v8.0.16
PHP Version: 8.2.27
PHP Max Input Vars: 4000
PHP Max Post Size: 1000M
GD Installed: Yes
ZIP Installed: Yes
Write Permissions: All right
Elementor Library: Connected

== WordPress Environment ==
Version: 6.7.2
Site URL: http://tanga-local.local
Home URL: http://tanga-local.local
WP Multisite: No
Max Upload Size: 300 MB
Memory limit: 256M
Permalink Structure: /%year%/%monthnum%/%day%/%postname%/
Language: de
Timezone: Europe/Berlin
Debug Mode: Inactive

== Theme ==
Name: Dizayn Design
Version: 1.0
Author: Dizayn Design
Child Theme: Yes
Parent Theme Name: OceanWP
Parent Theme Version: 1.6.8
Parent Theme Author: Nick

== User ==
Role: administrator
WP Profile lang: de_DE
User Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/136.0.0.0 Safari/537.36

== Active Plugins ==
a3 Lazy Load
Version: 2.3.3
Author: a3rev Software

ACF Content Analysis for Yoast SEO
Version: 2.3.0
Author: Thomas Kräftner, ViktorFroberg, marol87, pekz0r, angrycreative, Team Yoast

ACF to REST API
Version: 3.3.2
Author: Aires Gonçalves

Advanced Custom Fields
Version: 5.8.1
Author: Elliot Condon

Advanced Post Types Order
Version: 5.4.1
Author: Nsp Code

Autoptimize
Version: 3.1.3
Author: Frank Goossens (futtta)

Better Font Awesome
Version: 1.7.1
Author: Mickey Kay

Custom Content Shortcode
Version: 4.0.2
Author: Eliot Akira

Custom Post Type UI
Version: 1.6.2
Author: WebDevStudios

Divi Cookie Consent
Version: 1.0.1
Author: Divi People

Duplicate Page
Version: 4.4.8
Author: mndpsingh287

Elementor
Version: 2.5.16
Author: Elementor.com

Elementor Pro
Version: 2.5.9
Author: Elementor.com

Error Log Monitor
Version: 1.7
Author: Janis Elsts

Header Footer Code Manager
Version: 1.1.6
Author: 99robots

Local Google Fonts
Version: 0.19
Author: EverPress

Maintenance
Version: 4.12
Author: WebFactory Ltd

Migrate Guru
Version: 5.65
Author: Migrate Guru

PHP Everywhere
Version: 2.0.0
Author: Alexander Fuchs

Shortcode in Menus
Version: 3.5
Author: Gagan Deep Singh

Shortcoder
Version: 4.4
Author: Aakash Chakravarthy

Simple Custom CSS and JS
Version: 3.38.1
Author: SilkyPress.com

Simple Divi Shortcode
Version: 1.0
Author: Fabrice ESQUIROL - Creaweb2b

Smush
Version: 3.6.1
Author: WPMU DEV

Widgets for Google Reviews
Version: 11.8.2
Author: Trustindex.io

WP Data Access
Version: 5.1.2
Author: Passionate Programmers B.V.

WP Database Backup
Version: 5.8.3
Author: Prashant Walke

WP Fastest Cache
Version: 0.9.0.7
Author: Emre Vona

WP Rollback
Version: 1.7.1
Author: Impress.org

WPvivid Backup Plugin
Version: 0.9.114
Author: WPvivid Backup & Migration

Yoast SEO
Version: 12.0
Author: Team Yoast

== Must-Use Plugins ==
Local WP Live Link Helper
Version: 2.0
Author: Flywheel

== Log ==
[Redacted by moderation]
```

### 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

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.