PclZip::privDirCheck( $p_dir, $p_is_dir = false )
- Source
wp-admin/includes/class-pclzip.php:5020
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_dir$p_is_diroptional- Default:
false
Performance profile
How much work a call to PclZip::privDirCheck() 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
- Heavy
- Scaling
- Constant
- Instructions
- 9–47
- Plugin surface
- None
- Called by
- 2
Reads or writes the filesystem via is_dir().
No loop in the body: the same number of instructions runs whatever you pass in.
Executed per call on PHP 8.5, depending on the branch taken. The body compiles to 50.
Nothing here hands control to plugin code.
2 places in core call this, so the cost is paid more often than your own code shows.
What it touches
- filesystemfilesystem access
is_dir()called directly
What one call costs · 6 distinct outcomes
One number would be a lie: the work depends on which branch runs. These are every distinct cost PclZip::privDirCheck() can have, taken from its control-flow graph on PHP 8.5.
| When | Instructions | Calls it makes |
|---|---|---|
| always | 9–19 | is_dir() |
!is_dir() && $p_dir != "" && mkdir() | 21–31 | is_dir(), mkdir() |
!is_dir() && $p_dir != "" && $p_parent_dir != false && $p_parent_dir != "" && $v_result != 1 | 22–30 | is_dir(), ->privDirCheck() |
!is_dir() && $p_dir != "" && $p_parent_dir != false && $p_parent_dir != "" && $v_result == 1 && mkdir() | 29–37 | is_dir(), ->privDirCheck(), mkdir() |
!is_dir() && $p_dir != "" && !mkdir() | 31–41 | is_dir(), mkdir(), ::PclZip(), ::PclZip() |
!is_dir() && $p_dir != "" && $p_parent_dir != false && $p_parent_dir != "" && $v_result == 1 && !mkdir() | 39–47 | is_dir(), ->privDirCheck(), mkdir(), ::PclZip(), ::PclZip() |
Across PHP versions
| PHP | Compiled | Executed | Branches | Notes |
|---|---|---|---|---|
| 8.6-dev | 50 | 9–47 | 8 | |
| 8.5 | 50 | 9–47 | 8 | |
| 8.4 | 50 | 9–47 | 8 | 9 fewer instructions than PHP 8.3 |
| 8.3 | 59 | 9–56 | 8 | |
| 8.2 | 59 | 9–56 | 8 | |
| 8.1 | 59 | 9–56 | 8 | |
| 7.4 | 59 | 9–56 | 8 |
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 · 3
Used by · 2
Source code
function privDirCheck($p_dir, $p_is_dir=false) { $v_result = 1; // ----- Remove the final '/' if (($p_is_dir) && (substr($p_dir, -1)=='/')) { $p_dir = substr($p_dir, 0, strlen($p_dir)-1); } // ----- Check the directory availability if ((is_dir($p_dir)) || ($p_dir == "")) { return 1; } // ----- Extract parent directory $p_parent_dir = dirname($p_dir); // ----- Just a check if ($p_parent_dir != $p_dir) { // ----- Look for parent directory if ($p_parent_dir != "") { if (($v_result = $this->privDirCheck($p_parent_dir)) != 1) { return $v_result; } } } // ----- Create the directory if (!@mkdir($p_dir, 0777)) { // ----- Error log PclZip::privErrorLog(PCLZIP_ERR_DIR_CREATE_FAIL, "Unable to create directory '$p_dir'"); // ----- Return return PclZip::errorCode(); } // ----- Return return $v_result; }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.