Make WordPress Core

Opened 2 years ago

Last modified 2 years ago

#57423 new enhancement

we need to check an argument is closure in PclZip

Reported by: rpf5573's profile rpf5573 Owned by:
Milestone: Awaiting Review Priority: normal
Severity: normal Version: 6.2
Component: Administration Keywords: has-patch
Focuses: Cc:

Description

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
// ----- 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
// ----- 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();
}

Change History (1)

This ticket was mentioned in PR #3818 on WordPress/wordpress-develop by airman5573.


2 years ago
#1

  • Keywords has-patch added

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
----- 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
----- 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();

}
}}}

Trac ticket: ticket

Note: See TracTickets for help on using tickets.