Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Filesystem API: Introduce pre_unzip_file and post_unzip_file hooks. #4219

Open
wants to merge 4 commits into
base: trunk
Choose a base branch
from

Conversation

costdev
Copy link
Contributor

@costdev costdev commented Mar 11, 2023

This introduces two new actions: pre_unzip_file and post_unzip_file.

Both actions pass the following:

  • string $file - Full path and filename of ZIP archive.
  • string $to - Full path on the filesystem to extract archive to.
  • string[] $needed_dirs - A full list of required folders needed to be created.
  • float|false $required_space - The space required to unzip the file and copy its contents, with a 10% buffer. False if disk_free_space() returned false.
  • string $mode - The mode used to unzip. Accepts "ziparchive" or "pclzip". Default "ziparchive".

Additionally:

  • Combines the _unzip_file_ziparchive() and _unzip_file_pclzip() functions into a new function: _unzip_file().
    • Conditionally runs distinct functionality, and merges common functionality.
    • For BC, both functions act as wrappers for _unzip_file( $file, $to, $needed_dirs, ziparchive||pclzip ).
    • Note: Despite the docblock clearly stating that these functions should not be used directly, plugins still use it directly.
  • Implements _unzip_file() in unzip_file() to avoid calling the wrapper functions unnecessarily.
    • No other locations in Core use _unzip_file_ziparchive() or _unzip_file_pclzip() directly.

Trac ticket: https://core.trac.wordpress.org/ticket/37719

@costdev costdev marked this pull request as ready for review March 11, 2023 01:24
Co-authored-by: Mukesh Panchal <mukeshpanchal27@users.noreply.github.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
2 participants