[wp-trac] [WordPress Trac] #57423: we need to check an argument is closure in PclZip

WordPress Trac noreply at wordpress.org
Thu Jan 5 11:06:09 UTC 2023


#57423: we need to check an argument is closure in PclZip
----------------------------+-----------------------------
 Reporter:  rpf5573         |      Owner:  (none)
     Type:  enhancement     |     Status:  new
 Priority:  normal          |  Milestone:  Awaiting Review
Component:  Administration  |    Version:  trunk
 Severity:  normal          |   Keywords:
  Focuses:                  |
----------------------------+-----------------------------
 When we create a zip file with PclZip class, we can pass an
 PCLZIP_CB_PRE_ADD callback function in create function. And PclZip checks
 that the callback function is exist or not like below.

 {{{#!php
 <?php
 // ----- Check that the value is a valid existing function
 if (!function_exists($v_function_name)) {
   // ----- Error log
   PclZip::privErrorLog(PCLZIP_ERR_INVALID_OPTION_VALUE, "Function
 '".$v_function_name."()' is not an existing function for option
 '".PclZipUtilOptionText($p_options_list[$i])."'");

   // ----- Return
   return PclZip::errorCode();
 }
 }}}

 I want to pass a closure, but `function_exists($closure_function)` is
 false.

 So how about checking the callback function is closure also like below ?

 {{{#!php
 <?php
 // ----- Check that the value is a valid existing function
 if (!function_exists($v_function_name) && !($v_function_name instanceof
 Closure)) {
   // ----- Error log
   PclZip::privErrorLog(PCLZIP_ERR_INVALID_OPTION_VALUE, "Function
 '".$v_function_name."()' is not an existing function for option
 '".PclZipUtilOptionText($p_options_list[$i])."'");

   // ----- Return
   return PclZip::errorCode();
 }
 }}}

-- 
Ticket URL: <https://core.trac.wordpress.org/ticket/57423>
WordPress Trac <https://core.trac.wordpress.org/>
WordPress publishing platform


More information about the wp-trac mailing list