Repository navigation
Fixed handling of array values in logo palette frontend - #4705
girishpanchal30 wants to merge 1 commit into
Conversation
There was a problem hiding this comment.
🟢 Approved
This approves the fix, and the note asks a developer to confirm which producers can store a palette array.
Validation details
- Files reviewed: 3/3 changed files. One history question stayed open: a fix for an unexpected stored shape must cover every consumer of that value.
- The new tests pass at HEAD:
mkdir -p /workspace/c5/head && cd /repo && git archive HEAD | tar -x -C /workspace/c5/head 2>&1 | tail -2; mkdir -p /wor…printedOK (4 tests, 14 assertions)(run R5) - The new tests fail on the base code with the reported error:
cd /workspace/c5/base/neve && set -o pipefail; timeout 280 phpunit --do-not-cache-result --testdox --filter 'TestNeveLog…printedTests: 4, Assertions: 3, Errors: 4.(run R6) - A source search found no other theme path that passes a stored palette to
json_decode()unguarded. - Question for the author:
CONTRIBUTING.mdsays unit tests go intests/php/unit, butphpunit.xmlruns./tests/. Should the guide change?
Untested areas
- Starter-site import and Neve Pro conditional headers live outside this repository. Their stored palette shapes were not checked.
- The history question about every consumer of an unexpected stored shape stayed open. The note covers it.
- The suite ran from a copy of the checkout, because the bootstrap cannot load the theme from
/repo. - The variant pass did not settle these places, where the fixed cause may still reach:
inc/core/admin.php:79,263-274— unverified: Starter-site import and Pro conditional-header behavior beyond these integration points requires the matching plugin source; no claim that those dependencies normalize palettes is …inc/core/builder_migrator.php:443-456— unverified: Starter-site import and Pro conditional-header behavior beyond these integration points requires the matching plugin source; no claim that those dependencies normalize palettes is …
🤖 Automated review · run code-review-agent_6afeda4610a3c1.57547808.
🤖 Review agent — review posted ✅ on c18db2aa · approved · 0 findings · 12 min
Run code-review-agent_6afeda4610a3c1.57547808 · trail
| public static function decode_logo_json( $value ): array { | ||
| if ( is_string( $value ) ) { | ||
| $value = json_decode( $value, true ); | ||
| } | ||
|
|
||
| return is_array( $value ) ? $value : array(); |
There was a problem hiding this comment.
note decode_logo_json() now passes any stored array through without checking its members. If a stored palette array holds a non-scalar light or dark, that value reaches wp_get_attachment_image_url() in filter_logo_variants() and $custom_logo_id in the logo template. Can Neve Pro conditional headers or a starter-site import store such an array? If they only store attachment IDs, this is safe. If they can store nested values, the logo breaks or warns.
There was a problem hiding this comment.
Not changed: a palette stored as a JSON string already decodes to the same nested shape through json_decode( ..., true ) on the base code, so member handling is untouched. This PR only stops array-stored palettes from crashing. The only writers (the Customizer palette control via sanitize_logo_json(), and the starter-site importer copying exported Customizer values) store attachment IDs for light/dark.
Summary
Improved logo palette handling by introducing a dedicated utility method to decode stored values consistently into arrays, regardless of whether they are stored as JSON strings or native arrays. Updated all relevant code paths to use the new method, preventing inconsistencies caused by different storage formats. Added comprehensive tests covering both formats and edge cases.
Check before Pull Request is ready:
Closes #4697