Hey guys!
In the recent updates — in the moment I activate a brand new custom theme of mine (full of Metabox.IO glorious meta boxes) — I get a fatal error of $VALUE being NULL instead of STRING. The solution for me was simple and I suggest you guys to add something to prevent this to happen to others.
I have a settings panel where the admin can set COLORS for different HTML elements. Some of the panels have their default setting color as "EMPTY", with no color assingned (using the color metabox).
So, when the admin save his/her settings for the first time, some color values (originating from the metaboxes color pickup) are null... and sanitizer.php breaks.
To fix it down here, I just set any color in all metaboxes with "empty" value ine the color box pickup... and problem was gone. Sanitizer does not break anymore.
Here is the full stack trace of the error:
PHP Fatal error: Uncaught TypeError: Return value of RWMB_Sanitizer::sanitize_color() must be of the type string, null returned in C:\\Wps\\wp5\\wp-content\\plugins\\meta-box\\inc\\sanitizer.php:120
Stack trace:\n#0 C:\\Wps\\wp5\\wp-content\\plugins\\meta-box\\inc\\sanitizer.php(26): RWMB_Sanitizer->sanitize_color('red', Array, '', 'teialocal-paine...')\n#1 C:\\Wps\\wp5\\wp-includes\\class-wp-hook.php(308): RWMB_Sanitizer->sanitize('red', Array, '', 'teialocal-paine...')\n#2 C:\\Wps\\wp5\\wp-includes\\plugin.php(256): WP_Hook->apply_filters('red', Array)\n#3 C:\\Wps\\wp5\\wp-content\\plugins\\meta-box\\inc\\field.php(573): apply_filters_ref_array('rwmb_sanitize', Array)\n#4 C:\\Wps\\wp5\\wp-content\\plugins\\meta-box\\inc\\field.php(214): RWMB_Field::filter('sanitize', 'red', Array, '', 'teialocal-paine...')\n#5 C:\\Wps\\wp5\\wp-content\\plugins\\meta-box\\inc\\meta-box.php(253): RWMB_Field::process_value('red', 'teialocal-paine...', Array)\n#6 [internal function]: RW_Meta_Box->save_field(Array)\n#7 C:\\Wps\\wp5\\wp-content\\plugins in C:\\Wps\\wp5\\wp-content\\plugins\\meta-box\\inc\\sanitizer.php on line 120, referer: http://wp5/wp-admin/admin.php?page=painel-visual