Opened 6 weeks ago
Closed 11 days ago
#65423 closed defect (bug) (fixed)
Is it safe to remove function_exists( 'ini_get' ) checks?
| Reported by: | siliconforks | Owned by: | siliconforks |
|---|---|---|---|
| Priority: | low | Milestone: | 7.1 |
| Component: | General | Version: | |
| Severity: | minor | Keywords: | has-patch |
| Cc: | Focuses: |
Description
I noticed that there are several places in WordPress where a check is made for function_exists( 'ini_get' ):
https://github.com/WordPress/wordpress-develop/blob/7.0/src/wp-includes/functions.php#L8841
However, there's a lot of other places in the code that simply call ini_get() with no function_exists() check. If you try to run WordPress with disable_functions=ini_get, it will simply crash the first time it calls ini_get(). So in practice I think ini_get() is simply a requirement needed to run WordPress? In that case, there's not much point in having all these function_exists( 'ini_get' ) checks - you could remove quite a bit of (essentially dead) code there...
See also: #37681
Change History (6)
#2
follow-up:
↓ 3
@
4 weeks ago
- Milestone Awaiting Review → 7.1
- Priority normal → low
The ini_get() function is called unconditionally in wp_initial_constants(). This means WP would fatal error very early if it were ever to be disabled.
So yes, I think the function_exists( 'ini_get' ) checks should be removed, because they are useless. The one instance of ini_get_all(), however, should keep function_exists( 'ini_get_all' ).
@siliconforks Do you want to open a PR?
#3
in reply to: ↑ 2
@
4 weeks ago
Replying to westonruter:
The
ini_get()function is called unconditionally inwp_initial_constants(). This means WP would fatal error very early if it were ever to be disabled.
So yes, I think the
function_exists( 'ini_get' )checks should be removed, because they are useless. The one instance ofini_get_all(), however, should keepfunction_exists( 'ini_get_all' ).
@siliconforks Do you want to open a PR?
Yes, I'll create a PR for this (unless someone else beats me to it).
This ticket was mentioned in PR #12351 on WordPress/wordpress-develop by @shreyasikhar26.
2 weeks ago
#5
- Keywords has-patch added
## Summary
Removes all function_exists( 'ini_get' ) guards from the codebase. These checks are dead code: ini_get() is called unconditionally in wp_initial_constants() during early boot, so WordPress would fatal error long before any of these guarded code paths are reached on environments where ini_get is disabled. The guards therefore provide no practical protection and only add noise.
The one remaining function_exists( 'ini_get_all' ) check is intentionally left in place, as ini_get_all() is a distinct function that is not called unconditionally on boot.
## Trac ticket
https://core.trac.wordpress.org/ticket/65423
## Use of AI Tools
AI assistance: Yes
Tool(s): Claude Code
Model(s): Claude Sonnet 4.6
![(please configure the [header_logo] section in trac.ini)](/chrome/site/your_project_logo.png)
Thanks for opening this ticket. I noticed there's already an inline comment in the codebase stating:
https://github.com/WordPress/wordpress-develop/blob/75b8768dce1ee6e24b0d864732715f086d964c86/src/wp-admin/includes/class-wp-debug-data.php#L390
This suggests the
function_exists( 'ini_get' )checks were intentionally added as defensive safeguards for environments where these functions may be unavailable. While WordPress does callini_get()directly elsewhere, it may be worth investigating whether those usages should be aligned with this approach before considering removal of the existing checks.