WordPress / gutenberg

The Block Editor project for WordPress and beyond. Plugin is available from the official repository.
https://wordpress.org/gutenberg/
Other
10.39k stars 4.15k forks source link

error warning it site editor with duotones #50200

Closed tkapler closed 1 year ago

tkapler commented 1 year ago

Description

I do have custom duotones in theme.json, they work fine

this is the definition btw

            "duotone": [
                {
                    "name": "DT Powerbox 200 to 300",
                    "slug": "dt-powerbox-200-300",
                    "colors": [
                        "var(--wp--preset--color--powerbox-200)",
                        "var(--wp--preset--color--powerbox-300)"
                    ]
                },
                {
                    "name": "DT Powerbox 700 to 800",
                    "slug": "dt-powerbox-700-800",
                    "colors": [
                        "var(--wp--preset--color--powerbox-700)",
                        "var(--wp--preset--color--powerbox-800)"
                    ]
                }
            ],

But when i do use gutenberg plugin and having debug=true theese errors popup when I open Site Editor:

Warning: Trying to access array offset on value of type null in /var/www/vhosts/powerbox.one/httpdocs/wp-content/plugins/gutenberg/lib/block-supports/duotone.php on line 344
Warning: Trying to access array offset on value of type null in /var/www/vhosts/powerbox.one/httpdocs/wp-content/plugins/gutenberg/lib/block-supports/duotone.php on line 345
  | Warning: Trying to access array offset on value of type null in /var/www/vhosts/powerbox.one/httpdocs/wp-content/plugins/gutenberg/lib/block-supports/duotone.php on line 346
  | Warning: Trying to access array offset on value of type null in /var/www/vhosts/powerbox.one/httpdocs/wp-content/plugins/gutenberg/lib/block-supports/duotone.php on line 347

Step-by-step reproduction instructions

debug = true set up duotones in theme.json enable gutenberg plugin go to site editor

Screenshots, screen recording, code snippet

No response

Environment info

latest versions of guenberg and wordpress

Please confirm that you have searched existing issues in the repo.

Yes

Please confirm that you have tested with all plugins deactivated except Gutenberg.

Yes

tkapler commented 1 year ago

Interestingly - when i turn off the gutenberg plugin, the warning in site editor disapears, but instead theese errors appear on frontend

Warning: Trying to access array offset on value of type null in /var/www/vhosts/powerbox.one/httpdocs/wp-includes/block-supports/duotone.php on line 416

Warning: Trying to access array offset on value of type null in /var/www/vhosts/powerbox.one/httpdocs/wp-includes/block-supports/duotone.php on line 417

Warning: Trying to access array offset on value of type null in /var/www/vhosts/powerbox.one/httpdocs/wp-includes/block-supports/duotone.php on line 418

Warning: Trying to access array offset on value of type null in /var/www/vhosts/powerbox.one/httpdocs/wp-includes/block-supports/duotone.php on line 419

glendaviesnz commented 1 year ago

I was able to replicate this issue. It looks like currently the theme.json duotone settings are only able to support hex and RGB colors..

With debug=false I was able to add CSS vars, and the options displayed in the block toolbar, but once selected they did not work:

https://user-images.githubusercontent.com/3629020/235404865-d7fda690-f120-44e2-980e-a576db7bd9c3.mp4

We probably should look to add a guard here to prevent these warnings if the theme.json has invalid color settings.