[wp-trac] [WordPress Trac] #61879: Deprecation Warning

WordPress Trac noreply at wordpress.org
Sat Aug 24 02:30:54 UTC 2024


#61879: Deprecation Warning
--------------------------+------------------------------
 Reporter:  pcalvo        |       Owner:  (none)
     Type:  defect (bug)  |      Status:  reopened
 Priority:  normal        |   Milestone:  Awaiting Review
Component:  General       |     Version:  trunk
 Severity:  minor         |  Resolution:
 Keywords:  has-patch     |     Focuses:
--------------------------+------------------------------

Comment (by ayeshrajans):

 Hi @pcalvo - welcome to the WordPress Trac.
 Your note about ''why'' this happens is spot-on, but I would argue that
 the fix should be at the original caller, and now downstream at the
 `esc_textarea` function. We have several functions that could trigger this
 deprecation condition, and we should NOT be going through all of them and
 cast them to strings.

 Can you check backtrace and find out the reason why the `$text` variable
 is `null` in the first place?


 {{{#!php
 <?php
 function esc_textarea( $text ) {
   if ($text === null) {
     debug_print_backtrace();
   }
   // ... rest of the function...
   $safe_text = htmlspecialchars( $text, ENT_QUOTES, get_option(
 'blog_charset' ) );
         /**
 }}}

 or, you can change the `$text` parameter to `string $text` that forces PHP
 to throw and `TypeError` if the function is passed a non-string value.

-- 
Ticket URL: <https://core.trac.wordpress.org/ticket/61879#comment:5>
WordPress Trac <https://core.trac.wordpress.org/>
WordPress publishing platform


More information about the wp-trac mailing list