wppaste
WordPress

PclZip::add( $p_filelist )

Source
wp-admin/includes/class-pclzip.php:458

Compatibility

WordPress
core
PHP
7.4–8.6-dev
  • 6.7.7
  • 6.8.8
  • 6.9.7
  • 7.0.4
  • 7.1.0

Present in every tracked release (6.7.7 to 7.1.0), and compiles on PHP 7.4 through 8.6-dev.

Parameters

$p_filelist

Performance profile

How much work a call to PclZip::add() does, and what it touches: the algorithmic scaling, the Zend instruction count per call across PHP versions, the hooks it hands control to, and the core code that calls it. Measured from the compiled opcodes, not a stopwatch, so every number is identical on any machine running the same PHP version, and every function in core is ranked by cost.

Cost class
Light

Touches nothing outside its own arguments.

Scaling
Scales with input

The body loops, so the work grows with what you pass in.

Instructions
30–110

Executed per call on PHP 8.5, depending on the branch taken. The body compiles to 168.

Plugin surface
None

Nothing here hands control to plugin code.

Called by
0

Nothing in core calls this; the cost is only what you spend yourself.

What one call costs · 23 distinct outcomes

One number would be a lie: the work depends on which branch runs. These are every distinct cost PclZip::add() can have, taken from its control-flow graph on PHP 8.5.

WhenInstructionsCalls it makes
!$v_size && !is_array($p_filelist) && !is_string($p_filelist)30->privErrorReset(), ->privOptionDefaultThreshold(), ::PclZip()
$v_size && $v_size != 232–35->privErrorReset(), array_shift(), ::PclZip()
$v_size && !is_array($p_filelist) && !is_string($p_filelist)46–52->privErrorReset(), array_shift(), ->privOptionDefaultThreshold(), ::PclZip()
!$v_size && is_array($p_filelist) && $v_result != 149–56->privErrorReset(), ->privOptionDefaultThreshold(), ->privFileDescrExpand()
!$v_size && is_array($p_filelist) && !$v_att_list && $v_result != 154–60->privErrorReset(), ->privOptionDefaultThreshold(), ->privFileDescrParseAtt()
!$v_size && !is_array($p_filelist) && is_string($p_filelist) && $v_result != 154–58->privErrorReset(), ->privOptionDefaultThreshold(), explode(), ->privFileDescrExpand()
$v_size && $v_result != 155->privErrorReset(), array_shift(), optional()
!$v_size && is_array($p_filelist) && $v_result == 157–64->privErrorReset(), ->privOptionDefaultThreshold(), ->privFileDescrExpand(), ->privAdd()
!$v_size && !is_array($p_filelist) && is_string($p_filelist) && !$v_att_list && $v_result != 159–62->privErrorReset(), ->privOptionDefaultThreshold(), explode(), ->privFileDescrParseAtt()
!$v_size && !is_array($p_filelist) && is_string($p_filelist) && $v_result == 162–66->privErrorReset(), ->privOptionDefaultThreshold(), explode(), ->privFileDescrExpand(), ->privAdd()
$v_size && is_array($p_filelist) && $v_result != 165–78->privErrorReset(), array_shift(), ->privOptionDefaultThreshold(), ->privFileDescrExpand()
$v_size && is_array($p_filelist) && !$v_att_list && $v_result != 170–82->privErrorReset(), array_shift(), ->privOptionDefaultThreshold(), ->privFileDescrParseAtt()
11 further outcomes, up to 110 instructions
$v_size && !is_array($p_filelist) && is_string($p_filelist) && $v_result != 170–80->privErrorReset(), array_shift(), ->privOptionDefaultThreshold(), explode(), ->privFileDescrExpand()
$v_size && is_array($p_filelist) && $v_result == 173–86->privErrorReset(), array_shift(), ->privOptionDefaultThreshold(), ->privFileDescrExpand(), ->privAdd()
$v_size && $v_result == 1 && !is_array($p_filelist) && !is_string($p_filelist)74->privErrorReset(), array_shift(), optional(), ->privOptionDefaultThreshold(), ::PclZip()
$v_size && !is_array($p_filelist) && is_string($p_filelist) && !$v_att_list && $v_result != 175–84->privErrorReset(), array_shift(), ->privOptionDefaultThreshold(), explode(), ->privFileDescrParseAtt()
$v_size && !is_array($p_filelist) && is_string($p_filelist) && $v_result == 178–88->privErrorReset(), array_shift(), ->privOptionDefaultThreshold(), explode(), ->privFileDescrExpand(), ->privAdd()
$v_size && $v_result == 1 && is_array($p_filelist) && $v_result != 193–100->privErrorReset(), array_shift(), optional(), ->privOptionDefaultThreshold(), ->privFileDescrExpand()
$v_size && $v_result == 1 && is_array($p_filelist) && !$v_att_list && $v_result != 198–104->privErrorReset(), array_shift(), optional(), ->privOptionDefaultThreshold(), ->privFileDescrParseAtt()
$v_size && $v_result == 1 && !is_array($p_filelist) && is_string($p_filelist) && $v_result != 198–102->privErrorReset(), array_shift(), optional(), ->privOptionDefaultThreshold(), explode(), ->privFileDescrExpand()
$v_size && $v_result == 1 && is_array($p_filelist)101–108->privErrorReset(), array_shift(), optional(), ->privOptionDefaultThreshold(), ->privFileDescrExpand(), ->privAdd()
$v_size && $v_result == 1 && !is_array($p_filelist) && is_string($p_filelist) && !$v_att_list && $v_result != 1103–106->privErrorReset(), array_shift(), optional(), ->privOptionDefaultThreshold(), explode(), ->privFileDescrParseAtt()
$v_size && $v_result == 1 && !is_array($p_filelist) && is_string($p_filelist)106–110->privErrorReset(), array_shift(), optional(), ->privOptionDefaultThreshold(), explode(), ->privFileDescrExpand(), ->privAdd()

Across PHP versions

PHPCompiledExecutedBranchesNotes
8.6-dev16830–11018
8.516830–11018
8.416830–11018
8.316830–11018
8.216830–11018
8.116830–110181 fewer instruction than PHP 7.4
7.416930–11018

An instruction is not a fixed amount of time, so a matching count is not necessarily the same speed; what it rules out is a difference in the work itself.

Uses · 7

Source code

  function add($p_filelist)  {    $v_result=1;     // ----- Reset the error handler    $this->privErrorReset();     // ----- Set default values    $v_options = array();    $v_options[PCLZIP_OPT_NO_COMPRESSION] = FALSE;     // ----- Look for variable options arguments    $v_size = func_num_args();     // ----- Look for arguments    if ($v_size > 1) {      // ----- Get the arguments      $v_arg_list = func_get_args();       // ----- Remove form the options list the first argument      array_shift($v_arg_list);      $v_size--;       // ----- Look for first arg      if ((is_int($v_arg_list[0])) && ($v_arg_list[0] > 77000)) {         // ----- Parse the options        $v_result = $this->privParseOptions($v_arg_list, $v_size, $v_options,                                            array (PCLZIP_OPT_REMOVE_PATH => 'optional',                                                   PCLZIP_OPT_REMOVE_ALL_PATH => 'optional',                                                   PCLZIP_OPT_ADD_PATH => 'optional',                                                   PCLZIP_CB_PRE_ADD => 'optional',                                                   PCLZIP_CB_POST_ADD => 'optional',                                                   PCLZIP_OPT_NO_COMPRESSION => 'optional',                                                   PCLZIP_OPT_COMMENT => 'optional',                                                   PCLZIP_OPT_ADD_COMMENT => 'optional',                                                   PCLZIP_OPT_PREPEND_COMMENT => 'optional',                                                   PCLZIP_OPT_TEMP_FILE_THRESHOLD => 'optional',                                                   PCLZIP_OPT_TEMP_FILE_ON => 'optional',                                                   PCLZIP_OPT_TEMP_FILE_OFF => 'optional'                                                   //, PCLZIP_OPT_CRYPT => 'optional'												   ));        if ($v_result != 1) {          return 0;        }      }       // ----- Look for 2 args      // Here we need to support the first historic synopsis of the      // method.      else {         // ----- Get the first argument        $v_options[PCLZIP_OPT_ADD_PATH] = $v_add_path = $v_arg_list[0];         // ----- Look for the optional second argument        if ($v_size == 2) {          $v_options[PCLZIP_OPT_REMOVE_PATH] = $v_arg_list[1];        }        else if ($v_size > 2) {          // ----- Error log          PclZip::privErrorLog(PCLZIP_ERR_INVALID_PARAMETER, "Invalid number / type of arguments");           // ----- Return          return 0;        }      }    }     // ----- Look for default option values    $this->privOptionDefaultThreshold($v_options);     // ----- Init    $v_string_list = array();    $v_att_list = array();    $v_filedescr_list = array();    $p_result_list = array();     // ----- Look if the $p_filelist is really an array    if (is_array($p_filelist)) {

Changelog

Unchanged from 6.7.7 through 7.1.0.

  1. 6.7.7
  2. 6.8.8
  3. 6.9.7
  4. 7.0.4
  5. 7.1.0

Signature, return type and hooks compared across 5 parsed releases.

About this page

Parsed data
Generated from the wordpress-develop 7.1.0 tag, from src/wp-admin/includes/class-pclzip.php, and regenerated for each WordPress release so it tracks the code rather than a snapshot of it.
Corrections
Something wrong on this page? Report it and it gets fixed in the next regeneration.