Opened 17 hours ago
Last modified 17 hours ago
#66063 new defect (bug)
Check cache return value in WP_Textdomain_Registry::get_language_files_from_path()
| Reported by: | josephscott | Owned by: | |
|---|---|---|---|
| Priority: | normal | Milestone: | Awaiting Review |
| Component: | General | Version: | |
| Severity: | normal | Keywords: | has-patch |
| Cc: | Focuses: |
Description
In WP_Textdomain_Registry::get_language_files_from_path() there is a call to the cache to get the files ( GH ):
<?php $cache_key = md5( $path ); $files = wp_cache_get( $cache_key, 'translation_files' ); if ( false === $files ) {
The checks on the return value in $files are insufficient, only looking to see if it is false. It needs to make sure that it gets an array back and that every entry in that array is a string.
A non-array value from wp_cache_get() will cause a fatal error in PHP. This is another case where WordPress core could use a validating cache function. I've already seen that happen.
I have a PR to address this.
Change History (1)
This ticket was mentioned in PR #13429 on WordPress/wordpress-develop by @josephscott.
17 hours ago
#1
- Keywords has-patch added
![(please configure the [header_logo] section in trac.ini)](/chrome/site/your_project_logo.png)
…s_from_path()
https://core.trac.wordpress.org/ticket/66063
I came across this because I ran into a PHP fatal error from the lack of checking the return value from the cache:
Inside of
get_path_from_lang_dir().AI assistance: Yes
Tool(s): Claude
Model(s): Fable 5.1
Used for: Used for discussing the fatal error and narrowing down why it was happening. The code is my own.