Skip to content

Fixed handling of array values in logo palette frontend - #4705

Open
girishpanchal30 wants to merge 1 commit into
developmentfrom
bugfix/4697
Open

girishpanchal30 wants to merge 1 commit into
developmentfrom
bugfix/4697

Conversation

@girishpanchal30

Copy link
Copy Markdown
Contributor

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

@pirate-bot

Copy link
Copy Markdown
Collaborator

Plugin build for c18db2a is ready 🛎️!

@girishpanchal30 girishpanchal30 changed the title Fix handling of array values in logo palette frontend Fixed handling of array values in logo palette frontend Nov 19, 2026

@pirate-bot pirate-bot left a comment •

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟢 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… printed OK (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… printed Tests: 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.md says unit tests go in tests/php/unit, but phpunit.xml runs ./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

Comment on lines +338 to +343
public static function decode_logo_json( $value ): array {
if ( is_string( $value ) ) {
$value = json_decode( $value, true );
}

return is_array( $value ) ? $value : array();

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants