PclZip::create( $p_filelist )
- Source
wp-admin/includes/class-pclzip.php:275
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::create() 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
- 27–106
- 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 163.
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::create() 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) | 27 | ->privErrorReset(), ->privOptionDefaultThreshold(), ::PclZip() |
$v_size && $v_size != 2 | 32–35 | ->privErrorReset(), array_shift(), ::PclZip() |
$v_size && !is_array($p_filelist) && !is_string($p_filelist) | 43–49 | ->privErrorReset(), array_shift(), ->privOptionDefaultThreshold(), ::PclZip() |
!$v_size && is_array($p_filelist) && $v_result != 1 | 49–56 | ->privErrorReset(), ->privOptionDefaultThreshold(), ->privFileDescrExpand() |
$v_size && $v_result != 1 | 51 | ->privErrorReset(), array_shift(), optional() |
!$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 && is_array($p_filelist) && $v_result == 1 | 57–64 | ->privErrorReset(), ->privOptionDefaultThreshold(), ->privFileDescrExpand(), ->privCreate() |
!$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(), ->privCreate() |
$v_size && is_array($p_filelist) && $v_result != 1 | 65–78 | ->privErrorReset(), array_shift(), ->privOptionDefaultThreshold(), ->privFileDescrExpand() |
$v_size && $v_result == 1 && !is_array($p_filelist) && !is_string($p_filelist) | 67 | ->privErrorReset(), array_shift(), optional(), ->privOptionDefaultThreshold(), ::PclZip() |
11 further outcomes, up to 106 instructions
$v_size && is_array($p_filelist) && !$v_att_list && $v_result != 1 | 70–82 | ->privErrorReset(), array_shift(), ->privOptionDefaultThreshold(), ->privFileDescrParseAtt() |
$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(), ->privCreate() |
$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(), ->privCreate() |
$v_size && $v_result == 1 && is_array($p_filelist) && $v_result != 1 | 89–96 | ->privErrorReset(), array_shift(), optional(), ->privOptionDefaultThreshold(), ->privFileDescrExpand() |
$v_size && $v_result == 1 && is_array($p_filelist) && !$v_att_list && $v_result != 1 | 94–100 | ->privErrorReset(), array_shift(), optional(), ->privOptionDefaultThreshold(), ->privFileDescrParseAtt() |
$v_size && $v_result == 1 && !is_array($p_filelist) && is_string($p_filelist) && $v_result != 1 | 94–98 | ->privErrorReset(), array_shift(), optional(), ->privOptionDefaultThreshold(), explode(), ->privFileDescrExpand() |
$v_size && $v_result == 1 && is_array($p_filelist) | 97–104 | ->privErrorReset(), array_shift(), optional(), ->privOptionDefaultThreshold(), ->privFileDescrExpand(), ->privCreate() |
$v_size && $v_result == 1 && !is_array($p_filelist) && is_string($p_filelist) && !$v_att_list && $v_result != 1 | 99–102 | ->privErrorReset(), array_shift(), optional(), ->privOptionDefaultThreshold(), explode(), ->privFileDescrParseAtt() |
$v_size && $v_result == 1 && !is_array($p_filelist) && is_string($p_filelist) | 102–106 | ->privErrorReset(), array_shift(), optional(), ->privOptionDefaultThreshold(), explode(), ->privFileDescrExpand(), ->privCreate() |
Across PHP versions
Compiles the same on PHP 7.4, 8.1, 8.2, 8.3, 8.4, 8.5 and 8.6-dev: 163 instructions, 27–106 executed per call, 19 branches. The work does not change between versions.
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 create($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 from 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_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_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) { PclZip::privErrorLog(PCLZIP_ERR_INVALID_PARAMETER, "Invalid number / type of arguments"); 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)) { // ----- Look if the first element is also an array // This will mean that this is a file description entry if (isset($p_filelist[0]) && is_array($p_filelist[0])) {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.