Found a small bug on /INC/SANITIZER.PHP — Line 120
- This topic has 2 replies, 2 voices, and was last updated 2 years, 1 month ago by
Teia Local Studio.
-
AuthorPosts
-
March 7, 2023 at 4:03 AM #40862
Teia Local Studio
ParticipantHey 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
March 7, 2023 at 6:36 PM #40867Peter
ModeratorHello,
Thank you for your feedback.
I'm not able to reproduce the issue on my local site with Meta Box plugin version 5.6.17, a settings page and an empty custom field color picker.
Do you type a "red" string into the color picker field? If yes, I think that would cause the issue.March 8, 2023 at 8:52 PM #40895Teia Local Studio
ParticipantHello, Peter.
Yes, yes, I have a RED string set there.
I will remove it and test again, and post the result here.Thanks so far!
G. -
AuthorPosts
- You must be logged in to reply to this topic.