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
- Scaling
- Scales with input
- Instructions
- 30–110
- Plugin surface
- None
- Called by
- 0
Touches nothing outside its own arguments.
The body loops, so the work grows with what you pass in.
Executed per call on PHP 8.5, depending on the branch taken. The body compiles to 168.
Nothing here hands control to plugin code.
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.
| When | Instructions | Calls it makes |
|---|---|---|
!$v_size && !is_array($p_filelist) && !is_string($p_filelist) | 30 | ->privErrorReset(), ->privOptionDefaultThreshold(), ::PclZip() |
$v_size && $v_size != 2 | 32–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 != 1 | 49–56 | ->privErrorReset(), ->privOptionDefaultThreshold(), ->privFileDescrExpand() |
!$v_size && is_array($p_filelist) && !$v_att_list && $v_result != 1 | 54–60 | ->privErrorReset(), ->privOptionDefaultThreshold(), ->privFileDescrParseAtt() |
!$v_size && !is_array($p_filelist) && is_string($p_filelist) && $v_result != 1 | 54–58 | ->privErrorReset(), ->privOptionDefaultThreshold(), explode(), ->privFileDescrExpand() |
$v_size && $v_result != 1 | 55 | ->privErrorReset(), array_shift(), optional() |
!$v_size && is_array($p_filelist) && $v_result == 1 | 57–64 | ->privErrorReset(), ->privOptionDefaultThreshold(), ->privFileDescrExpand(), ->privAdd() |
!$v_size && !is_array($p_filelist) && is_string($p_filelist) && !$v_att_list && $v_result != 1 | 59–62 | ->privErrorReset(), ->privOptionDefaultThreshold(), explode(), ->privFileDescrParseAtt() |
!$v_size && !is_array($p_filelist) && is_string($p_filelist) && $v_result == 1 | 62–66 | ->privErrorReset(), ->privOptionDefaultThreshold(), explode(), ->privFileDescrExpand(), ->privAdd() |
$v_size && is_array($p_filelist) && $v_result != 1 | 65–78 | ->privErrorReset(), array_shift(), ->privOptionDefaultThreshold(), ->privFileDescrExpand() |
$v_size && is_array($p_filelist) && !$v_att_list && $v_result != 1 | 70–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 != 1 | 70–80 | ->privErrorReset(), array_shift(), ->privOptionDefaultThreshold(), explode(), ->privFileDescrExpand() |
$v_size && is_array($p_filelist) && $v_result == 1 | 73–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 != 1 | 75–84 | ->privErrorReset(), array_shift(), ->privOptionDefaultThreshold(), explode(), ->privFileDescrParseAtt() |
$v_size && !is_array($p_filelist) && is_string($p_filelist) && $v_result == 1 | 78–88 | ->privErrorReset(), array_shift(), ->privOptionDefaultThreshold(), explode(), ->privFileDescrExpand(), ->privAdd() |
$v_size && $v_result == 1 && is_array($p_filelist) && $v_result != 1 | 93–100 | ->privErrorReset(), array_shift(), optional(), ->privOptionDefaultThreshold(), ->privFileDescrExpand() |
$v_size && $v_result == 1 && is_array($p_filelist) && !$v_att_list && $v_result != 1 | 98–104 | ->privErrorReset(), array_shift(), optional(), ->privOptionDefaultThreshold(), ->privFileDescrParseAtt() |
$v_size && $v_result == 1 && !is_array($p_filelist) && is_string($p_filelist) && $v_result != 1 | 98–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 != 1 | 103–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
| PHP | Compiled | Executed | Branches | Notes |
|---|---|---|---|---|
| 8.6-dev | 168 | 30–110 | 18 | |
| 8.5 | 168 | 30–110 | 18 | |
| 8.4 | 168 | 30–110 | 18 | |
| 8.3 | 168 | 30–110 | 18 | |
| 8.2 | 168 | 30–110 | 18 | |
| 8.1 | 168 | 30–110 | 18 | 1 fewer instruction than PHP 7.4 |
| 7.4 | 169 | 30–110 | 18 |
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.
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.