Skip to content

Fix admin color fallback for PHP 8#1491

Open
Davesaggio wants to merge 1 commit into
qtranslate:masterfrom
Davesaggio:fix-user-admin-color-php8
Open

Fix admin color fallback for PHP 8#1491
Davesaggio wants to merge 1 commit into
qtranslate:masterfrom
Davesaggio:fix-user-admin-color-php8

Conversation

@Davesaggio

Copy link
Copy Markdown

No description provided.

@Davesaggio

Copy link
Copy Markdown
Author

Summary

This fixes a PHP 8 fatal error in qtranxf_get_user_admin_color() when the current user does not have a valid admin color scheme available in $_wp_admin_css_colors.

Previously the code assumed this entry always existed and directly accessed:

$_wp_admin_css_colors[ $user_admin_color ]->colors

For non-admin users or unauthenticated/ajax contexts this could trigger a 500 error.

Fix

  • validate that the selected admin color exists
  • validate that ->colors exists and is an array
  • fall back to fresh when the user color is missing/invalid
  • return an empty array as a final safe fallback

Notes

Verified with php -l.

@Davesaggio Davesaggio closed this Jun 15, 2026
@Davesaggio Davesaggio reopened this Jun 15, 2026
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.

1 participant