Below is a differential between the unpatched vulnerable code and the patched update, for reference.
--- a/everest-backup/everest-backup.php
+++ b/everest-backup/everest-backup.php
@@ -5,7 +5,7 @@
* Description: Everest Backup is a modern tool that will take care of your website's backups, restoration, migration and cloning.
* Author: everestthemes
* Author URI: https://everestthemes.com/
- * Version: 2.3.14
+ * Version: 2.3.15
* Text Domain: everest-backup
* License: GPLv3 or later
* License URI: LICENSE
--- a/everest-backup/inc/classes/class-everest-backup.php
+++ b/everest-backup/inc/classes/class-everest-backup.php
@@ -650,6 +650,18 @@
return;
}
+ // Checked logged in or not and user has capability to activate plugins. and also nonce verify.
+ if ( ! is_user_logged_in() || ! current_user_can( 'activate_plugins' ) ) {
+ return;
+ }
+
+ $nonce = ! empty( $data['_wpnonce'] ) ? $data['_wpnonce'] : ( ! empty( $data['everest_backup_activate_addon_nonce'] ) ? $data['everest_backup_activate_addon_nonce'] : '' );
+
+ if ( empty( $nonce ) || ! wp_verify_nonce( sanitize_text_field( wp_unslash( $nonce ) ), 'everest_backup_activate_addon_nonce' ) ) {
+ everest_backup_set_notice( __( 'Security check failed.', 'everest-backup' ), 'notice-error' );
+ return;
+ }
+
if ( empty( $data['plugin'] ) ) {
everest_backup_set_notice( __( 'Plugin slug empty.', 'everest-backup' ), 'notice-error' );
return;
--- a/everest-backup/inc/functions.php
+++ b/everest-backup/inc/functions.php
@@ -826,6 +826,17 @@
* @since 1.0.5
*/
function everest_backup_activate_ebwp_addon( $plugin ) {
+ // Prevent unauthorized users from activating the addon.
+ if ( ! is_user_logged_in() || ! current_user_can( 'activate_plugins' ) ) {
+ return new WP_Error( 'unauthorized', __( 'You do not have permission to activate plugins.', 'everest-backup' ) );
+ }
+
+ $plugin = plugin_basename( sanitize_text_field( $plugin ) );
+
+ if ( 0 !== strpos( $plugin, 'everest-backup-' ) ) {
+ return new WP_Error( 'invalid_addon', __( 'Invalid Everest Backup addon.', 'everest-backup' ) );
+ }
+
return activate_plugin( $plugin, '', is_multisite() );
}
--- a/everest-backup/inc/views/addons/listings.php
+++ b/everest-backup/inc/views/addons/listings.php
@@ -117,6 +117,7 @@
<form method="post">
<input type="hidden" name="page" value="everest-backup-addons">
<input type="hidden" name="plugin" value="<?php echo esc_attr( $addon_data['plugin'] ); ?>">
+ <?php wp_nonce_field( 'everest_backup_activate_addon_nonce' ); ?>
<button type="submit" class="button button-primary"><span class="dashicons dashicons-plugins-checked"></span> <?php esc_html_e( 'Activate', 'everest-backup' ); ?></button>
</form>
<?php
--- a/everest-backup/tests/Unit/Test_Security.php
+++ b/everest-backup/tests/Unit/Test_Security.php
@@ -315,4 +315,62 @@
$this->expectException( RuntimeException::class, 403 );
$init->import_with_auth_check();
}
+
+ /**
+ * Test activate_addon access control:
+ * - Unauthenticated caller is blocked.
+ * - Unauthorized user without activate_plugins capability is blocked.
+ * - Admin with missing or invalid nonce is blocked with security check failed notice.
+ * - Admin with valid nonce proceeds.
+ */
+ public function test_activate_addon_access_control() {
+ global $mock_current_user;
+
+ require_once dirname( __DIR__, 2 ) . '/inc/classes/class-everest-backup.php';
+
+ $instance = Everest_Backup::init();
+ $reflection = new ReflectionMethod( $instance, 'activate_addon' );
+ $reflection->setAccessible( true );
+
+ // 1. Unauthenticated user.
+ $mock_current_user = array();
+ $_POST = array(
+ 'page' => 'everest-backup-addons',
+ 'plugin' => 'everest-backup-dummy/dummy.php',
+ );
+ unset( $_SESSION['ebwp_notice'] );
+ $reflection->invoke( $instance );
+ $this->assertArrayNotHasKey( 'ebwp_notice', $_SESSION ?? array(), 'Unauthenticated user must return early without activating or setting error notice.' );
+
+ // 2. User without activate_plugins capability (e.g. subscriber).
+ $mock_current_user = array(
+ 'id' => 99,
+ 'roles' => array( 'subscriber' ),
+ 'capabilities' => array( 'read' => true ),
+ );
+ $reflection->invoke( $instance );
+ $this->assertArrayNotHasKey( 'ebwp_notice', $_SESSION ?? array(), 'Subscriber must return early without activating.' );
+
+ // 3. Admin user with missing / invalid nonce.
+ $mock_current_user = array(
+ 'id' => 1,
+ 'roles' => array( 'administrator' ),
+ 'capabilities' => array( 'activate_plugins' => true ),
+ );
+ $_POST['_wpnonce'] = 'invalid_nonce';
+ @$reflection->invoke( $instance );
+ $this->assertEquals( 'notice-error', $_SESSION['ebwp_notice']['type'] ?? '' );
+ $this->assertEquals( 'Security check failed.', $_SESSION['ebwp_notice']['notice'] ?? '' );
+
+ // 4. Admin user with valid nonce.
+ $_POST['_wpnonce'] = wp_create_nonce( 'everest_backup_activate_addon_nonce' );
+ unset( $_SESSION['ebwp_notice'] );
+ @$reflection->invoke( $instance );
+ $this->assertEquals( 'notice-success', $_SESSION['ebwp_notice']['type'] ?? '' );
+ $this->assertEquals( 'Addon activated.', $_SESSION['ebwp_notice']['notice'] ?? '' );
+
+ // Cleanup.
+ $_POST = array();
+ unset( $_SESSION['ebwp_notice'] );
+ }
}
--- a/everest-backup/tests/bootstrap.php
+++ b/everest-backup/tests/bootstrap.php
@@ -250,6 +250,18 @@
}
}
+if ( ! function_exists( 'register_activation_hook' ) ) {
+ function register_activation_hook( $file, $callback ) {
+ return true;
+ }
+}
+
+if ( ! function_exists( 'register_deactivation_hook' ) ) {
+ function register_deactivation_hook( $file, $callback ) {
+ return true;
+ }
+}
+
if ( ! function_exists( 'do_action' ) ) {
function do_action( $tag, ...$args ) {
global $mock_wp_actions;
@@ -358,6 +370,36 @@
}
}
+if ( ! function_exists( 'is_user_logged_in' ) ) {
+ function is_user_logged_in() {
+ global $mock_current_user;
+ return ! empty( $mock_current_user ) && ! empty( $mock_current_user['id'] );
+ }
+}
+
+if ( ! class_exists( 'WP_Error' ) ) {
+ class WP_Error {
+ protected $code;
+ protected $message;
+ public function __construct( $code = '', $message = '', $data = '' ) {
+ $this->code = $code;
+ $this->message = $message;
+ }
+ public function get_error_message( $code = '' ) {
+ return $this->message;
+ }
+ public function get_error_code() {
+ return $this->code;
+ }
+ }
+}
+
+if ( ! function_exists( 'is_wp_error' ) ) {
+ function is_wp_error( $thing ) {
+ return $thing instanceof WP_Error;
+ }
+}
+
if ( ! function_exists( 'check_ajax_referer' ) ) {
function check_ajax_referer( $action = -1, $query_arg = false, $die = true ) {
global $mock_nonce_valid;
--- a/everest-backup/vendor/composer/installed.php
+++ b/everest-backup/vendor/composer/installed.php
@@ -3,7 +3,7 @@
'name' => 'everest-backup/everest-backup',
'pretty_version' => 'dev-main',
'version' => 'dev-main',
- 'reference' => '365b5b98c37ac2fd4ee5b59c0a12602e965f4bdb',
+ 'reference' => '06352396749e64c24e3b04b04639d4012ba2c7d8',
'type' => 'wordpress-plugin',
'install_path' => __DIR__ . '/../../',
'aliases' => array(),
@@ -13,7 +13,7 @@
'everest-backup/everest-backup' => array(
'pretty_version' => 'dev-main',
'version' => 'dev-main',
- 'reference' => '365b5b98c37ac2fd4ee5b59c0a12602e965f4bdb',
+ 'reference' => '06352396749e64c24e3b04b04639d4012ba2c7d8',
'type' => 'wordpress-plugin',
'install_path' => __DIR__ . '/../../',
'aliases' => array(),
@@ -22,7 +22,7 @@
'nelexa/zip' => array(
'pretty_version' => 'dev-master',
'version' => 'dev-master',
- 'reference' => 'd25c2ab6b993157f18bc88a753a864ce23213f60',
+ 'reference' => 'e2fb47c8e740d4709c8229973f05070bffa8008e',
'type' => 'library',
'install_path' => __DIR__ . '/../nelexa/zip',
'aliases' => array(
@@ -40,9 +40,9 @@
'dev_requirement' => false,
),
'symfony/finder' => array(
- 'pretty_version' => 'v8.1.10',
- 'version' => '8.1.10.0',
- 'reference' => '2f4c0f26106520d82e1b71759d2fb8d32d8b7a43',
+ 'pretty_version' => 'v8.1.11',
+ 'version' => '8.1.11.0',
+ 'reference' => 'a2902e479ba5691d20d51d100a715ea19ad2c837',
'type' => 'library',
'install_path' => __DIR__ . '/../symfony/finder',
'aliases' => array(),
--- a/everest-backup/vendor/nelexa/zip/.php-cs-fixer.php
+++ b/everest-backup/vendor/nelexa/zip/.php-cs-fixer.php
@@ -959,7 +959,9 @@
'object_operator_without_whitespace' => true,
// Literal octal must be in `0o` notation.
- 'octal_notation' => true,
+ // Disabled: the `0o` notation requires PHP 8.1+, but the library
+ // still supports PHP 7.4 and 8.0 at runtime.
+ 'octal_notation' => false,
/*
* Operators - when multiline - must always be at the beginning or
@@ -1296,7 +1298,9 @@
* docblock, inheritdocs) will not be fixed. [3] Manual actions are
* required if inherited signatures are not properly documented.
*/
- 'phpdoc_to_param_type' => true,
+ // Disabled: the generated parameter types may include `mixed`
+ // (PHP 8.0+), but the library still supports PHP 7.4 at runtime.
+ 'phpdoc_to_param_type' => false,
/*
* EXPERIMENTAL: Takes `@var` annotation of non-mixed types and
@@ -1322,7 +1326,9 @@
* docblock, inheritdocs) will not be fixed. [3] Manual actions are
* required if inherited signatures are not properly documented.
*/
- 'phpdoc_to_return_type' => true,
+ // Disabled: the generated return types may include `mixed`, `static`
+ // or `never` (PHP 8.0+), but the library still supports PHP 7.4.
+ 'phpdoc_to_return_type' => false,
/*
* PHPDoc should start and end with content, excluding the very
--- a/everest-backup/vendor/nelexa/zip/src/Constants/ZipCompressionMethod.php
+++ b/everest-backup/vendor/nelexa/zip/src/Constants/ZipCompressionMethod.php
@@ -87,7 +87,7 @@
public static function checkSupport(int $compressionMethod): void
{
if (!in_array($compressionMethod, self::getSupportMethods(), true)) {
- throw new ZipUnsupportMethodException(sprintf(
+ throw new ZipUnsupportMethodException(sprintf(
'Compression method %d (%s) is not supported.',
$compressionMethod,
self::getCompressionMethodName($compressionMethod)
--- a/everest-backup/vendor/nelexa/zip/src/Constants/ZipEncryptionMethod.php
+++ b/everest-backup/vendor/nelexa/zip/src/Constants/ZipEncryptionMethod.php
@@ -67,7 +67,7 @@
public static function checkSupport(int $encryptionMethod): void
{
if (!self::hasEncryptionMethod($encryptionMethod)) {
- throw new InvalidArgumentException(sprintf(
+ throw new InvalidArgumentException(sprintf(
'Encryption method %d is not supported.',
$encryptionMethod
));
--- a/everest-backup/vendor/nelexa/zip/src/Constants/ZipPlatform.php
+++ b/everest-backup/vendor/nelexa/zip/src/Constants/ZipPlatform.php
@@ -16,35 +16,91 @@
/** @var int MS-DOS OS */
public const OS_DOS = 0;
+ /** @var int Amiga OS */
+ public const OS_AMIGA = 1;
+
+ /** @var int OpenVMS */
+ public const OS_OPENVMS = 2;
+
/** @var int Unix OS */
public const OS_UNIX = 3;
- /** @var int MacOS platform */
+ /** @var int VM/CMS */
+ public const OS_VM_CMS = 4;
+
+ /** @var int AtariST */
+ public const OS_ATARI_ST = 5;
+
+ /** @var int OS/2 (HPFS) */
+ public const OS_OS_2 = 6;
+
+ /** @var int Macintosh */
+ public const OS_MACINTOSH = 7;
+
+ /** @var int Z-System */
+ public const OS_Z_SYSTEM = 8;
+
+ /** @var int CPM */
+ public const OS_CPM = 9;
+
+ /** @var int Windows NTFS / TOPS-20 */
+ public const OS_WINDOWS_NTFS = 10;
+
+ /** @var int MVS */
+ public const OS_MVS = 11;
+
+ /** @var int VSE */
+ public const OS_VSE = 12;
+
+ public const OS_QDOS = 12;
+
+ /** @var int Acorn RISC OS */
+ public const OS_ACORN_RISC = 13;
+
+ /** @var int VFAT */
+ public const OS_VFAT = 14;
+
+ /** @var int alternate MVS */
+ public const OS_ALTERNATE_MVS = 15;
+
+ /** @var int BeOS */
+ public const OS_BEOS = 16;
+
+ /** @var int Tandem */
+ public const OS_TANDEM = 17;
+
+ /** @var int OS/400 or THEOS */
+ public const OS_OS_400 = 18;
+
+ /** @var int macOS */
public const OS_MAC_OSX = 19;
+ /** @var int AtheOS */
+ public const OS_ATHEOS = 30;
+
/** @var array Zip Platforms */
private const PLATFORMS = [
self::OS_DOS => 'MS-DOS',
- 1 => 'Amiga',
- 2 => 'OpenVMS',
+ self::OS_AMIGA => 'Amiga',
+ self::OS_OPENVMS => 'OpenVMS',
self::OS_UNIX => 'Unix',
- 4 => 'VM/CMS',
- 5 => 'Atari ST',
- 6 => 'HPFS (OS/2, NT 3.x)',
- 7 => 'Macintosh',
- 8 => 'Z-System',
- 9 => 'CP/M',
- 10 => 'Windows NTFS or TOPS-20',
- 11 => 'MVS or NTFS',
- 12 => 'VSE or SMS/QDOS',
- 13 => 'Acorn RISC OS',
- 14 => 'VFAT',
- 15 => 'alternate MVS',
- 16 => 'BeOS',
- 17 => 'Tandem',
- 18 => 'OS/400',
+ self::OS_VM_CMS => 'VM/CMS',
+ self::OS_ATARI_ST => 'Atari ST',
+ self::OS_OS_2 => 'HPFS (OS/2, NT 3.x)',
+ self::OS_MACINTOSH => 'Macintosh',
+ self::OS_Z_SYSTEM => 'Z-System',
+ self::OS_CPM => 'CP/M',
+ self::OS_WINDOWS_NTFS => 'Windows NTFS or TOPS-20',
+ self::OS_MVS => 'MVS or NTFS',
+ self::OS_VSE => 'VSE or SMS/QDOS',
+ self::OS_ACORN_RISC => 'Acorn RISC OS',
+ self::OS_VFAT => 'VFAT',
+ self::OS_ALTERNATE_MVS => 'alternate MVS',
+ self::OS_BEOS => 'BeOS',
+ self::OS_TANDEM => 'Tandem',
+ self::OS_OS_400 => 'OS/400',
self::OS_MAC_OSX => 'OS/X (Darwin)',
- 30 => 'AtheOS/Syllable',
+ self::OS_ATHEOS => 'AtheOS/Syllable',
];
public static function getPlatformName(int $platform): string
--- a/everest-backup/vendor/nelexa/zip/src/Exception/Crc32Exception.php
+++ b/everest-backup/vendor/nelexa/zip/src/Exception/Crc32Exception.php
@@ -29,7 +29,7 @@
public function __construct(string $name, int $expected, int $actual)
{
parent::__construct(
- sprintf(
+ sprintf(
'%s (expected CRC32 value 0x%x, but is actually 0x%x)',
$name,
$expected,
--- a/everest-backup/vendor/nelexa/zip/src/Exception/ZipCryptoException.php
+++ b/everest-backup/vendor/nelexa/zip/src/Exception/ZipCryptoException.php
@@ -12,7 +12,7 @@
namespace PhpZipException;
/**
- * Thrown if there is an issue when reading or writing an encrypted ZIP file
+ * Thrown when reading or writing an encrypted ZIP file fails.
* or entry.
*/
class ZipCryptoException extends ZipException
--- a/everest-backup/vendor/nelexa/zip/src/Exception/ZipEntryNotFoundException.php
+++ b/everest-backup/vendor/nelexa/zip/src/Exception/ZipEntryNotFoundException.php
@@ -14,19 +14,16 @@
use PhpZipModelZipEntry;
/**
- * Thrown if entry not found.
+ * Thrown when an entry is not found.
*/
class ZipEntryNotFoundException extends ZipException
{
private string $entryName;
- /**
- * @param ZipEntry|string $entryName
- */
public function __construct($entryName)
{
$entryName = $entryName instanceof ZipEntry ? $entryName->getName() : $entryName;
- parent::__construct(sprintf(
+ parent::__construct(sprintf(
'Zip Entry "%s" was not found in the archive.',
$entryName
));
--- a/everest-backup/vendor/nelexa/zip/src/IO/Filter/Cipher/Pkware/PKCryptContext.php
+++ b/everest-backup/vendor/nelexa/zip/src/IO/Filter/Cipher/Pkware/PKCryptContext.php
@@ -26,7 +26,7 @@
public const STD_DEC_HDR_SIZE = 12;
/**
- * Crc table.
+ * CRC table.
*
* @var int[]|array
*/
@@ -361,7 +361,7 @@
}
/**
- * Update crc.
+ * Update the CRC.
*/
private function crc32(int $oldCrc, int $charAt): int
{
--- a/everest-backup/vendor/nelexa/zip/src/IO/Filter/Cipher/Pkware/PKDecryptionStreamFilter.php
+++ b/everest-backup/vendor/nelexa/zip/src/IO/Filter/Cipher/Pkware/PKDecryptionStreamFilter.php
@@ -15,7 +15,7 @@
use PhpZipModelZipEntry;
/**
- * Decryption PKWARE Traditional Encryption.
+ * PKWARE traditional encryption decryption filter.
*/
class PKDecryptionStreamFilter extends php_user_filter
{
@@ -78,6 +78,7 @@
* Decryption filter.
*
* @todo USE FFI in php 7.4
+ *
* @noinspection PhpDocSignatureInspection
*
* @param mixed $in
--- a/everest-backup/vendor/nelexa/zip/src/IO/Filter/Cipher/Pkware/PKEncryptionStreamFilter.php
+++ b/everest-backup/vendor/nelexa/zip/src/IO/Filter/Cipher/Pkware/PKEncryptionStreamFilter.php
@@ -15,7 +15,7 @@
use PhpZipModelZipEntry;
/**
- * Encryption PKWARE Traditional Encryption.
+ * PKWARE traditional encryption filter.
*/
class PKEncryptionStreamFilter extends php_user_filter
{
--- a/everest-backup/vendor/nelexa/zip/src/IO/Stream/ResponseStream.php
+++ b/everest-backup/vendor/nelexa/zip/src/IO/Stream/ResponseStream.php
@@ -14,7 +14,7 @@
use PsrHttpMessageStreamInterface;
/**
- * Implement PSR Message Stream.
+ * Implements a PSR-7 message stream.
*/
class ResponseStream implements StreamInterface
{
@@ -92,17 +92,15 @@
/**
* {@inheritDoc}
- *
- * @noinspection PhpMissingReturnTypeInspection
*/
public function getMetadata($key = null)
{
if ($this->stream === null) {
- return $key ? null : [];
+ return $key === null ? [] : null;
}
$meta = stream_get_meta_data($this->stream);
- return $meta[$key] ?? null;
+ return $key === null ? $meta : ($meta[$key] ?? null);
}
/**
@@ -173,9 +171,18 @@
return null;
}
- public function tell()
+ public function tell(): int
{
- return $this->stream ? ftell($this->stream) : false;
+ if ($this->stream === null) {
+ throw new RuntimeException('Stream is detached');
+ }
+ $position = ftell($this->stream);
+
+ if ($position === false) {
+ throw new RuntimeException('Unable to determine stream position');
+ }
+
+ return $position;
}
/**
@@ -213,11 +220,19 @@
/**
* {@inheritDoc}
*/
- public function write($string)
+ public function write($string): int
{
+ if ($this->stream === null || !$this->writable) {
+ throw new RuntimeException('Stream is not writable');
+ }
$this->size = null;
+ $written = fwrite($this->stream, $string);
+
+ if ($written === false) {
+ throw new RuntimeException('Unable to write to stream');
+ }
- return $this->stream !== null && $this->writable ? fwrite($this->stream, $string) : false;
+ return $written;
}
/**
@@ -233,7 +248,12 @@
*/
public function read($length): string
{
- return $this->stream !== null && $this->readable ? fread($this->stream, $length) : '';
+ if ($this->stream === null || !$this->readable) {
+ return '';
+ }
+ $buffer = fread($this->stream, $length);
+
+ return $buffer === false ? '' : $buffer;
}
/**
@@ -244,7 +264,12 @@
*/
public function getContents(): string
{
- return $this->stream ? stream_get_contents($this->stream) : '';
+ if ($this->stream === null) {
+ return '';
+ }
+ $contents = stream_get_contents($this->stream);
+
+ return $contents === false ? '' : $contents;
}
/**
--- a/everest-backup/vendor/nelexa/zip/src/IO/Stream/ZipEntryStreamWrapper.php
+++ b/everest-backup/vendor/nelexa/zip/src/IO/Stream/ZipEntryStreamWrapper.php
@@ -119,7 +119,7 @@
$zipData = $zipEntry->getData();
if ($zipData === null) {
- throw new ZipException(sprintf('No data for zip entry "%s"', $zipEntry->getName()));
+ throw new ZipException(sprintf('No data for zip entry "%s"', $zipEntry->getName()));
}
$this->fp = $zipData->getDataAsStream();
--- a/everest-backup/vendor/nelexa/zip/src/IO/ZipReader.php
+++ b/everest-backup/vendor/nelexa/zip/src/IO/ZipReader.php
@@ -81,13 +81,13 @@
|| (isset($meta['uri']) && is_dir($meta['uri']))
)
) {
- throw new InvalidArgumentException('Directory stream not supported');
+ throw new InvalidArgumentException('Directory streams are not supported');
}
$seekable = $meta['seekable'];
if (!$seekable) {
- throw new InvalidArgumentException('Resource does not support seekable.');
+ throw new InvalidArgumentException('The resource is not seekable.');
}
$this->size = fstat($inStream)['size'];
$this->inStream = $inStream;
@@ -194,7 +194,7 @@
&& unpack('V', fread($this->inStream, 4))[1] === ZipConstants::ZIP64_END_CD_LOC
) {
if (!$this->isZip64Support()) {
- throw new ZipException('ZIP64 not supported this archive.');
+ throw new ZipException('ZIP64 is not supported for this archive.');
}
$positionECD = $this->findZip64ECDPosition();
@@ -297,9 +297,9 @@
}
[
-// 'size' => $size,
-// 'versionMadeBy' => $versionMadeBy,
-// 'extractVersion' => $extractVersion,
+ // 'size' => $size,
+ // 'versionMadeBy' => $versionMadeBy,
+ // 'extractVersion' => $extractVersion,
'diskNo' => $diskNo,
'cdDiskNo' => $cdDiskNo,
'cdEntriesDisk' => $cdEntriesDisk,
@@ -612,7 +612,7 @@
fseek($this->inStream, $offsetLocalHeader);
if (unpack('V', fread($this->inStream, 4))[1] !== ZipConstants::LOCAL_FILE_HEADER) {
- throw new ZipException(sprintf('%s (expected Local File Header)', $entry->getName()));
+ throw new ZipException(sprintf('%s (expected Local File Header)', $entry->getName()));
}
fseek($this->inStream, $offsetLocalHeader + ZipConstants::LFH_FILENAME_LENGTH_POS);
@@ -647,7 +647,7 @@
if ($extraField === null) {
throw new ZipException(
- sprintf(
+ sprintf(
'Extra field 0x%04x (WinZip-AES Encryption) expected for compression method %d',
WinZipAesExtraField::HEADER_ID,
$zipEntry->getCompressionMethod()
@@ -696,7 +696,7 @@
public function copyUncompressedDataToStream(ZipSourceFileData $zipFileData, $outStream): void
{
if (!is_resource($outStream)) {
- throw new InvalidArgumentException('outStream is not resource');
+ throw new InvalidArgumentException('outStream is not a resource');
}
$entry = $zipFileData->getSourceEntry();
@@ -706,7 +706,7 @@
// }
if ($entry->isStrongEncryption()) {
- throw new ZipException('Not support encryption zip.');
+ throw new ZipException('Strong encryption is not supported.');
}
$compressionMethod = $entry->getCompressionMethod();
@@ -720,7 +720,7 @@
if ($isEncrypted) {
if ($entry->getPassword() === null) {
- throw new ZipException('Can not password from entry ' . $entry->getName());
+ throw new ZipException('Cannot get the password for entry ' . $entry->getName());
}
if (ZipEncryptionMethod::isWinZipAesMethod($entry->getEncryptionMethod())) {
@@ -729,7 +729,7 @@
if ($winZipAesExtra === null) {
throw new ZipException(
- sprintf('WinZip AES must contain the extra field %s', WinZipAesExtraField::HEADER_ID)
+ sprintf('WinZip AES must contain the extra field %s', WinZipAesExtraField::HEADER_ID)
);
}
$compressionMethod = $winZipAesExtra->getCompressionMethod();
@@ -796,7 +796,7 @@
default:
throw new ZipException(
- sprintf(
+ sprintf(
'%s (compression method %d (%s) is not supported)',
$entry->getName(),
$compressionMethod,
@@ -811,13 +811,31 @@
$chunkSize = 8192;
try {
+ // PHP 8.4+ emits warnings (and PHP 8.5+ notices) from stream filters,
+ // e.g. "fread(): zlib: data error" when a decryption filter produced
+ // garbage. Convert these diagnostics into ZipException so that every
+ // PHP version reports a uniform failure.
+ set_error_handler(
+ static function (int $errorNumber, string $errorString) use ($entry): bool {
+ throw new ZipException(
+ sprintf(
+ 'Error reading the contents of entry "%s". %s',
+ $entry->getName(),
+ $errorString
+ ),
+ $errorNumber
+ );
+ },
+ E_WARNING | E_USER_WARNING | E_NOTICE | E_USER_NOTICE
+ );
+
if ($skipCheckCrc) {
while ($offset < $limit) {
$length = min($chunkSize, $limit - $offset);
$buffer = fread($this->inStream, $length);
if ($buffer === false) {
- throw new ZipException(sprintf('Error reading the contents of entry "%s".', $entry->getName()));
+ throw new ZipException(sprintf('Error reading the contents of entry "%s".', $entry->getName()));
}
fwrite($outStream, $buffer);
$offset += $length;
@@ -830,7 +848,7 @@
$buffer = fread($this->inStream, $length);
if ($buffer === false) {
- throw new ZipException(sprintf('Error reading the contents of entry "%s".', $entry->getName()));
+ throw new ZipException(sprintf('Error reading the contents of entry "%s".', $entry->getName()));
}
fwrite($outStream, $buffer);
hash_update($contextHash, $buffer);
@@ -844,6 +862,8 @@
}
}
} finally {
+ restore_error_handler();
+
for ($i = count($filters); $i > 0; $i--) {
stream_filter_remove($filters[$i - 1]);
}
--- a/everest-backup/vendor/nelexa/zip/src/IO/ZipWriter.php
+++ b/everest-backup/vendor/nelexa/zip/src/IO/ZipWriter.php
@@ -145,7 +145,7 @@
if ($size > 0xFFFF) {
throw new ZipException(
- sprintf(
+ sprintf(
'%s (the total size of %s bytes for the name, extra fields and comment exceeds the maximum size of %d bytes)',
$entry->getName(),
$size,
@@ -223,7 +223,7 @@
if ($size > 0xFFFF) {
throw new ZipException(
- sprintf(
+ sprintf(
'Size extra out of range: %d. Extra data: %s',
$size,
$extraData
@@ -248,7 +248,7 @@
return;
}
- throw new ZipException(sprintf('No zip data for entry "%s"', $entry->getName()));
+ throw new ZipException(sprintf('No zip data for entry "%s"', $entry->getName()));
}
// data write variants:
@@ -436,7 +436,7 @@
default:
throw new ZipUnsupportMethodException(
- sprintf(
+ sprintf(
'%s (compression method %d (%s) is not supported)',
$entry->getName(),
$entry->getCompressionMethod(),
--- a/everest-backup/vendor/nelexa/zip/src/Model/Data/ZipFileData.php
+++ b/everest-backup/vendor/nelexa/zip/src/Model/Data/ZipFileData.php
@@ -44,7 +44,7 @@
public function getDataAsStream()
{
if (!$this->file->isReadable()) {
- throw new ZipException(sprintf('The %s file is no longer readable.', $this->file->getPathname()));
+ throw new ZipException(sprintf('The %s file is no longer readable.', $this->file->getPathname()));
}
return fopen($this->file->getPathname(), 'rb');
@@ -58,7 +58,7 @@
public function getDataAsString(): string
{
if (!$this->file->isReadable()) {
- throw new ZipException(sprintf('The %s file is no longer readable.', $this->file->getPathname()));
+ throw new ZipException(sprintf('The %s file is no longer readable.', $this->file->getPathname()));
}
return file_get_contents($this->file->getPathname());
--- a/everest-backup/vendor/nelexa/zip/src/Model/Data/ZipNewData.php
+++ b/everest-backup/vendor/nelexa/zip/src/Model/Data/ZipNewData.php
@@ -16,7 +16,7 @@
use PhpZipZipFile;
/**
- * The class contains a streaming resource with new content added to the ZIP archive.
+ * Holds a stream resource with new content to be added to the ZIP archive.
*/
class ZipNewData implements ZipData
{
@@ -35,6 +35,7 @@
/**
* @param string|resource $data Raw string data or resource
+ *
* @noinspection PhpMissingParamTypeInspection
*/
public function __construct(ZipEntry $zipEntry, $data)
@@ -69,7 +70,7 @@
public function getDataAsStream()
{
if (!is_resource($this->stream)) {
- throw new LogicException(sprintf('Resource has been closed (entry=%s).', $this->zipEntry->getName()));
+ throw new LogicException(sprintf('Resource has been closed (entry=%s).', $this->zipEntry->getName()));
}
return $this->stream;
--- a/everest-backup/vendor/nelexa/zip/src/Model/Extra/ExtraFieldsCollection.php
+++ b/everest-backup/vendor/nelexa/zip/src/Model/Extra/ExtraFieldsCollection.php
@@ -86,9 +86,6 @@
}
}
- /**
- * @param ExtraFieldsCollection $collection
- */
public function addCollection(self $collection): void
{
$this->addAll($collection->collection);
@@ -135,7 +132,7 @@
}
/**
- * Whether a offset exists.
+ * Whether an offset exists.
*
* @see http://php.net/manual/en/arrayaccess.offsetexists.php
*
--- a/everest-backup/vendor/nelexa/zip/src/Model/Extra/Fields/AbstractUnicodeExtraField.php
+++ b/everest-backup/vendor/nelexa/zip/src/Model/Extra/Fields/AbstractUnicodeExtraField.php
@@ -16,7 +16,7 @@
use PhpZipModelZipEntry;
/**
- * A common base class for Unicode extra information extra fields.
+ * A common base class for the Info-ZIP Unicode path and comment extra fields.
*/
abstract class AbstractUnicodeExtraField implements ZipExtraField
{
@@ -81,7 +81,7 @@
] = unpack('Cversion/Vcrc32', $buffer);
if ($version !== self::DEFAULT_VERSION) {
- throw new ZipException(sprintf('Unsupported version [%d] for Unicode path extra data.', $version));
+ throw new ZipException(sprintf('Unsupported version [%d] for Unicode path extra data.', $version));
}
$unicodeValue = substr($buffer, 5);
--- a/everest-backup/vendor/nelexa/zip/src/Model/Extra/Fields/ApkAlignmentExtraField.php
+++ b/everest-backup/vendor/nelexa/zip/src/Model/Extra/Fields/ApkAlignmentExtraField.php
@@ -84,8 +84,6 @@
* @param ZipEntry|null $entry optional zip entry
*
* @throws ZipException
- *
- * @return ApkAlignmentExtraField
*/
public static function unpackLocalFileData(string $buffer, ?ZipEntry $entry = null): self
{
@@ -114,8 +112,6 @@
* @param ZipEntry|null $entry optional zip entry
*
* @throws ZipException on error
- *
- * @return ApkAlignmentExtraField
*/
public static function unpackCentralDirData(string $buffer, ?ZipEntry $entry = null): self
{
@@ -146,7 +142,7 @@
public function __toString(): string
{
- return sprintf(
+ return sprintf(
'0x%04x APK Alignment: Multiple=%d Padding=%d',
self::HEADER_ID,
$this->multiple,
--- a/everest-backup/vendor/nelexa/zip/src/Model/Extra/Fields/AsiExtraField.php
+++ b/everest-backup/vendor/nelexa/zip/src/Model/Extra/Fields/AsiExtraField.php
@@ -103,8 +103,6 @@
* @param ZipEntry|null $entry optional zip entry
*
* @throws Crc32Exception
- *
- * @return AsiExtraField
*/
public static function unpackLocalFileData(string $buffer, ?ZipEntry $entry = null): self
{
@@ -113,7 +111,7 @@
$realChecksum = crc32($buffer);
if ($givenChecksum !== $realChecksum) {
- throw new Crc32Exception('Asi Unix Extra Filed Data', $givenChecksum, $realChecksum);
+ throw new Crc32Exception('Asi Unix Extra Field Data', $givenChecksum, $realChecksum);
}
[
@@ -138,8 +136,6 @@
* @param ZipEntry|null $entry optional zip entry
*
* @throws Crc32Exception
- *
- * @return AsiExtraField
*/
public static function unpackCentralDirData(string $buffer, ?ZipEntry $entry = null): self
{
@@ -273,7 +269,7 @@
public function __toString(): string
{
- return sprintf(
+ return sprintf(
'0x%04x ASI: Mode=%o UID=%d GID=%d Link="%s',
self::HEADER_ID,
$this->mode,
--- a/everest-backup/vendor/nelexa/zip/src/Model/Extra/Fields/ExtendedTimestampExtraField.php
+++ b/everest-backup/vendor/nelexa/zip/src/Model/Extra/Fields/ExtendedTimestampExtraField.php
@@ -119,13 +119,6 @@
$this->createTime = $createTime;
}
- /**
- * @param ?int $modifyTime
- * @param ?int $accessTime
- * @param ?int $createTime
- *
- * @return ExtendedTimestampExtraField
- */
public static function create(?int $modifyTime, ?int $accessTime, ?int $createTime): self
{
$flags = 0;
@@ -160,8 +153,6 @@
*
* @param string $buffer the buffer to read data from
* @param ZipEntry|null $entry optional zip entry
- *
- * @return ExtendedTimestampExtraField
*/
public static function unpackLocalFileData(string $buffer, ?ZipEntry $entry = null): self
{
@@ -197,8 +188,6 @@
*
* @param string $buffer the buffer to read data from
* @param ZipEntry|null $entry optional zip entry
- *
- * @return ExtendedTimestampExtraField
*/
public static function unpackCentralDirData(string $buffer, ?ZipEntry $entry = null): self
{
@@ -331,7 +320,7 @@
}
/**
- * Returns the create time as a a DateTimeInterface
+ * Returns the create time as a DateTimeInterface
* of this zip entry, or null if no such timestamp exists in the zip entry.
* The milliseconds are always zeroed out, since the underlying data
* offers only per-second precision.
--- a/everest-backup/vendor/nelexa/zip/src/Model/Extra/Fields/JarMarkerExtraField.php
+++ b/everest-backup/vendor/nelexa/zip/src/Model/Extra/Fields/JarMarkerExtraField.php
@@ -83,8 +83,6 @@
* @param ZipEntry|null $entry optional zip entry
*
* @throws ZipException on error
- *
- * @return JarMarkerExtraField
*/
public static function unpackLocalFileData(string $buffer, ?ZipEntry $entry = null): self
{
@@ -102,8 +100,6 @@
* @param ZipEntry|null $entry optional zip entry
*
* @throws ZipException on error
- *
- * @return JarMarkerExtraField
*/
public static function unpackCentralDirData(string $buffer, ?ZipEntry $entry = null): self
{
@@ -112,6 +108,6 @@
public function __toString(): string
{
- return sprintf('0x%04x Jar Marker', self::HEADER_ID);
+ return sprintf('0x%04x Jar Marker', self::HEADER_ID);
}
}
--- a/everest-backup/vendor/nelexa/zip/src/Model/Extra/Fields/NewUnixExtraField.php
+++ b/everest-backup/vendor/nelexa/zip/src/Model/Extra/Fields/NewUnixExtraField.php
@@ -92,15 +92,13 @@
* @param ZipEntry|null $entry optional zip entry
*
* @throws ZipException
- *
- * @return NewUnixExtraField
*/
public static function unpackLocalFileData(string $buffer, ?ZipEntry $entry = null): self
{
$length = strlen($buffer);
if ($length < 3) {
- throw new ZipException(sprintf('X7875_NewUnix length is too short, only %s bytes', $length));
+ throw new ZipException(sprintf('X7875_NewUnix length is too short, only %s bytes', $length));
}
$offset = 0;
[
@@ -124,8 +122,6 @@
* @param ZipEntry|null $entry optional zip entry
*
* @throws ZipException
- *
- * @return NewUnixExtraField
*/
public static function unpackCentralDirData(string $buffer, ?ZipEntry $entry = null): self
{
@@ -173,7 +169,7 @@
];
if (!isset($format[$size])) {
- throw new ZipException(sprintf('Invalid size bytes: %d', $size));
+ throw new ZipException(sprintf('Invalid size bytes: %d', $size));
}
return unpack($format[$size], $data)[1];
@@ -206,7 +202,7 @@
public function __toString(): string
{
- return sprintf(
+ return sprintf(
'0x%04x NewUnix: UID=%d GID=%d',
self::HEADER_ID,
$this->uid,
--- a/everest-backup/vendor/nelexa/zip/src/Model/Extra/Fields/NtfsExtraField.php
+++ b/everest-backup/vendor/nelexa/zip/src/Model/Extra/Fields/NtfsExtraField.php
@@ -56,9 +56,6 @@
$this->createNtfsTime = $createNtfsTime;
}
- /**
- * @return NtfsExtraField
- */
public static function create(
DateTimeInterface $modifyDateTime,
DateTimeInterface $accessDateTime,
@@ -88,13 +85,11 @@
* @param ZipEntry|null $entry optional zip entry
*
* @throws ZipException
- *
- * @return NtfsExtraField
*/
public static function unpackLocalFileData(string $buffer, ?ZipEntry $entry = null): self
{
if (PHP_INT_SIZE === 4) {
- throw new ZipException('not supported for php-32bit');
+ throw new ZipException('NTFS timestamps are not supported in 32-bit PHP.');
}
$buffer = substr($buffer, 4);
@@ -131,8 +126,6 @@
* @param ZipEntry|null $entry optional zip entry
*
* @throws ZipException
- *
- * @return NtfsExtraField
*/
public static function unpackCentralDirData(string $buffer, ?ZipEntry $entry = null): self
{
@@ -253,7 +246,7 @@
public static function ntfsTimeToDateTime(int $ntfsTime): DateTimeInterface
{
$timestamp = self::ntfsTimeToTimestamp($ntfsTime);
- $dateTime = DateTimeImmutable::createFromFormat('U.u', sprintf('%.6f', $timestamp));
+ $dateTime = DateTimeImmutable::createFromFormat('U.u', sprintf('%.6f', $timestamp));
if ($dateTime === false) {
throw new InvalidArgumentException('Cannot create date/time object for timestamp ' . $timestamp);
--- a/everest-backup/vendor/nelexa/zip/src/Model/Extra/Fields/OldUnixExtraField.php
+++ b/everest-backup/vendor/nelexa/zip/src/Model/Extra/Fields/OldUnixExtraField.php
@@ -102,8 +102,6 @@
*
* @param string $buffer the buffer to read data from
* @param ZipEntry|null $entry optional zip entry
- *
- * @return OldUnixExtraField
*/
public static function unpackLocalFileData(string $buffer, ?ZipEntry $entry = null): self
{
@@ -135,8 +133,6 @@
*
* @param string $buffer the buffer to read data from
* @param ZipEntry|null $entry optional zip entry
- *
- * @return OldUnixExtraField
*/
public static function unpackCentralDirData(string $buffer, ?ZipEntry $entry = null): self
{
--- a/everest-backup/vendor/nelexa/zip/src/Model/Extra/Fields/UnicodeCommentExtraField.php
+++ b/everest-backup/vendor/nelexa/zip/src/Model/Extra/Fields/UnicodeCommentExtraField.php
@@ -71,7 +71,7 @@
public function __toString(): string
{
- return sprintf(
+ return sprintf(
'0x%04x UnicodeComment: "%s"',
self::HEADER_ID,
$this->getUnicodeValue()
--- a/everest-backup/vendor/nelexa/zip/src/Model/Extra/Fields/UnicodePathExtraField.php
+++ b/everest-backup/vendor/nelexa/zip/src/Model/Extra/Fields/UnicodePathExtraField.php
@@ -72,7 +72,7 @@
public function __toString(): string
{
- return sprintf(
+ return sprintf(
'0x%04x UnicodePath: "%s"',
self::HEADER_ID,
$this->getUnicodeValue()
--- a/everest-backup/vendor/nelexa/zip/src/Model/Extra/Fields/UnrecognizedExtraField.php
+++ b/everest-backup/vendor/nelexa/zip/src/Model/Extra/Fields/UnrecognizedExtraField.php
@@ -51,12 +51,10 @@
*
* @param string $buffer the buffer to read data from
* @param ZipEntry|null $entry optional zip entry
- *
- * @return UnrecognizedExtraField
*/
public static function unpackLocalFileData(string $buffer, ?ZipEntry $entry = null): self
{
- throw new RuntimeException('Unsupport parse');
+ throw new RuntimeException('Parsing is not supported for unrecognized extra fields.');
}
/**
@@ -64,12 +62,10 @@
*
* @param string $buffer the buffer to read data from
* @param ZipEntry|null $entry optional zip entry
- *
- * @return UnrecognizedExtraField
*/
public static function unpackCentralDirData(string $buffer, ?ZipEntry $entry = null): self
{
- throw new RuntimeException('Unsupport parse');
+ throw new RuntimeException('Parsing is not supported for unrecognized extra fields.');
}
/**
--- a/everest-backup/vendor/nelexa/zip/src/Model/Extra/Fields/WinZipAesExtraField.php
+++ b/everest-backup/vendor/nelexa/zip/src/Model/Extra/Fields/WinZipAesExtraField.php
@@ -107,15 +107,13 @@
/**
* @throws ZipUnsupportMethodException
- *
- * @return WinZipAesExtraField
*/
public static function create(ZipEntry $entry): self
{
$keyStrength = array_search($entry->getEncryptionMethod(), self::MAP_KEY_STRENGTH_METHODS, true);
if ($keyStrength === false) {
- throw new InvalidArgumentException('Not support encryption method ' . $entry->getEncryptionMethod());
+ throw new InvalidArgumentException('Unsupported encryption method ' . $entry->getEncryptionMethod());
}
// WinZip 11 will continue to use AE-2, with no CRC, for very small files
@@ -152,12 +150,9 @@
/**
* Populate data from this array as if it was in local file data.
*
- * @param string $buffer the buffer to read data from
- * @param ?ZipEntry $entry
+ * @param string $buffer the buffer to read data from
*
* @throws ZipException on error
- *
- * @return WinZipAesExtraField
*/
public static function unpackLocalFileData(string $buffer, ?ZipEntry $entry = null): self
{
@@ -165,7 +160,7 @@
if ($size !== self::DATA_SIZE) {
throw new ZipException(
- sprintf(
+ sprintf(
'WinZip AES Extra data invalid size: %d. Must be %d',
$size,
self::DATA_SIZE
@@ -182,7 +177,7 @@
if ($vendorId !== self::VENDOR_ID) {
throw new ZipException(
- sprintf(
+ sprintf(
'Vendor id invalid: %d. Must be %d',
$vendorId,
self::VENDOR_ID
@@ -196,12 +191,9 @@
/**
* Populate data from this array as if it was in central directory data.
*
- * @param string $buffer the buffer to read data from
- * @param ?ZipEntry $entry
+ * @param string $buffer the buffer to read data from
*
* @throws ZipException
- *
- * @return WinZipAesExtraField
*/
public static function unpackCentralDirData(string $buffer, ?ZipEntry $entry = null): self
{
@@ -259,8 +251,8 @@
{
if (!in_array($vendorVersion, self::ALLOW_VENDOR_VERSIONS, true)) {
throw new InvalidArgumentException(
- sprintf(
- 'Unsupport WinZip AES vendor version: %d',
+ sprintf(
+ 'Unsupported WinZip AES vendor version: %d',
$vendorVersion
)
);
@@ -288,8 +280,8 @@
{
if (!isset(self::ENCRYPTION_STRENGTHS[$keyStrength])) {
throw new InvalidArgumentException(
- sprintf(
- 'Key strength %d not support value. Allow values: %s',
+ sprintf(
+ 'Invalid key strength %d. Allowed values: %s',
$keyStrength,
implode(', ', array_keys(self::ENCRYPTION_STRENGTHS))
)
@@ -345,7 +337,7 @@
public function __toString(): string
{
- return sprintf(
+ return sprintf(
'0x%04x WINZIP AES: VendorVersion=%d KeyStrength=0x%02x CompressionMethod=%s',
__CLASS__,
$this->vendorVersion,
--- a/everest-backup/vendor/nelexa/zip/src/Model/Extra/Fields/Zip64ExtraField.php
+++ b/everest-backup/vendor/nelexa/zip/src/Model/Extra/Fields/Zip64ExtraField.php
@@ -60,12 +60,9 @@
/**
* Populate data from this array as if it was in local file data.
*
- * @param string $buffer the buffer to read data from
- * @param ?ZipEntry $entry
+ * @param string $buffer the buffer to read data from
*
* @throws ZipException on error
- *
- * @return Zip64ExtraField
*/
public static function unpackLocalFileData(string $buffer, ?ZipEntry $entry = null): self
{
@@ -96,12 +93,9 @@
/**
* Populate data from this array as if it was in central directory data.
*
- * @param string $buffer the buffer to read data from
- * @param ?ZipEntry $entry
+ * @param string $buffer the buffer to read data from
*
* @throws ZipException
- *
- * @return Zip64ExtraField
*/
public static function unpackCentralDirData(string $buffer, ?ZipEntry $entry = null): self
{
--- a/everest-backup/vendor/nelexa/zip/src/Model/Extra/ZipExtraDriver.php
+++ b/everest-backup/vendor/nelexa/zip/src/Model/Extra/ZipExtraDriver.php
@@ -31,6 +31,7 @@
{
/**
* @var array<int, string>
+ *
* @psalm-var array<int, class-string<ZipExtraField>>
*/
private static array $implementations = [
@@ -58,7 +59,7 @@
{
if (!is_a($extraField, ZipExtraField::class, true)) {
throw new InvalidArgumentException(
- sprintf(
+ sprintf(
'$extraField "%s" is not implements interface %s',
(string) $extraField,
ZipExtraField::class
--- a/everest-backup/vendor/nelexa/zip/src/Model/ImmutableZipContainer.php
+++ b/everest-backup/vendor/nelexa/zip/src/Model/ImmutableZipContainer.php
@@ -21,7 +21,6 @@
/**
* @param ZipEntry[] $entries
- * @param ?string $archiveComment
*/
public function __construct(array $entries, ?string $archiveComment = null)
{
--- a/everest-backup/vendor/nelexa/zip/src/Model/ZipContainer.php
+++ b/everest-backup/vendor/nelexa/zip/src/Model/ZipContainer.php
@@ -54,9 +54,6 @@
$this->entries[$entry->getName()] = $entry;
}
- /**
- * @param string|ZipEntry $entry
- */
public function deleteEntry($entry): bool
{
$entry = $entry instanceof ZipEntry ? $entry->getName() : (string) $entry;
@@ -71,8 +68,8 @@
}
/**
- * @param string|ZipEntry $old
- * @param string|ZipEntry $new
+ * @param mixed $old
+ * @param mixed $new
*
* @throws ZipException
*
@@ -84,7 +81,7 @@
$new = $new instanceof ZipEntry ? $new->getName() : (string) $new;
if (isset($this->entries[$new])) {
- throw new InvalidArgumentException('New entry name ' . $new . ' is exists.');
+ throw new InvalidArgumentException('New entry name "' . $new . '" already exists.');
}
$entry = $this->getEntry($old);
@@ -97,7 +94,7 @@
}
/**
- * @param string|ZipEntry $entryName
+ * @param mixed $entryName
*
* @throws ZipEntryNotFoundException
*/
@@ -112,9 +109,6 @@
throw new ZipEntryNotFoundException($entryName);
}
- /**
- * @param string|ZipEntry $entryName
- */
public function getEntryOrNull($entryName): ?ZipEntry
{
$entryName = $entryName instanceof ZipEntry ? $entryName->getName() : (string) $entryName;
@@ -122,9 +116,6 @@
return $this->entries[$entryName] ?? null;
}
- /**
- * @param string|ZipEntry $entryName
- */
public function hasEntry($entryName): bool
{
$entryName = $entryName instanceof ZipEntry ? $entryName->getName() : (string) $entryName;
@@ -170,7 +161,7 @@
}
/**
- * Undo all changes done in the archive.
+ * Undo all changes made to the archive.
*/
public function unchangeAll(): void
{
@@ -197,7 +188,7 @@
}
/**
- * Revert all changes done to an entry with the given name.
+ * Revert all changes made to an entry with the given name.
*
* @param string|ZipEntry $entry Entry name or ZipEntry
*/
@@ -218,7 +209,7 @@
}
/**
- * Entries sort by name.
+ * Sort entries by name using the given comparison function.
*
* Example:
* ```php
@@ -233,7 +224,7 @@
}
/**
- * Entries sort by entry.
+ * Sort entries using the given comparison function.
*
* Example:
* ```php
@@ -253,7 +244,7 @@
$length = strlen($archiveComment);
if ($length > 0xFFFF) {
- throw new InvalidArgumentException('Length comment out of range');
+ throw new InvalidArgumentException('Comment length out of range');
}
}
$this->archiveComment = $archiveComment;
@@ -266,8 +257,6 @@
/**
* Specify a password for extracting files.
- *
- * @param ?string $password
*/
public function setReadPassword(?string $password): void
{
@@ -296,8 +285,6 @@
}
/**
- * @param ?string $writePassword
- *
* @throws ZipEntryNotFoundException
*/
public function setWritePassword(?string $writePassword): void
@@ -316,7 +303,7 @@
}
/**
- * @param string|ZipEntry $entryName
+ * @param mixed $entryName
*
* @throws ZipEntryNotFoundException
*/
--- a/everest-backup/vendor/nelexa/zip/src/Model/ZipEntry.php
+++ b/everest-backup/vendor/nelexa/zip/src/Model/ZipEntry.php
@@ -94,14 +94,14 @@
private int $localHeaderOffset = 0;
/**
- * Collections of Extra Fields in Central Directory.
+ * Collections of extra fields in the central directory.
* Keys from Header ID [int] and value Extra Field [ExtraField].
*/
protected ExtraFieldsCollection $cdExtraFields;
/**
- * Collections of Extra Fields int local header.
- * Keys from Header ID [int] and value Extra Field [ExtraField].
+ * Collections of extra fields in the local header.
+ * Keys are header IDs [int] and values are extra fields [ExtraField].
*/
protected ExtraFieldsCollection $localExtraFields;
@@ -133,16 +133,11 @@
}
/**
- * This method only internal use.
+ * This method is for internal use only.
*
* @internal
*
* @noinspection PhpTooManyParametersInspection
- *
- * @param ?string $comment
- * @param ?string $charset
- *
- * @return ZipEntry
*/
public static function create(
string $name,
@@ -188,8 +183,6 @@
*
* @param string $name New entry name
* @param string|null $charset Entry name charset
- *
- * @return ZipEntry
*/
private function setName(string $name, ?string $charset = null): self
{
@@ -228,10 +221,6 @@
/**
* @see DosCodePage::getCodePages()
- *
- * @param ?string $charset
- *
- * @return ZipEntry
*/
public function setCharset(?string $charset = null): self
{
@@ -293,8 +282,6 @@
/**
* Set platform.
- *
- * @return ZipEntry
*/
public function setCreatedOS(int $platform): self
{
@@ -313,8 +300,6 @@
/**
* Set extracted OS.
- *
- * @return ZipEntry
*/
public function setExtractedOS(int $platform): self
{
@@ -335,9 +320,6 @@
return $this->softwareVersion;
}
- /**
- * @return ZipEntry
- */
public function setSoftwareVersion(int $softwareVersion): self
{
$this->softwareVersion = $softwareVersion;
@@ -379,8 +361,6 @@
/**
* Set version needed to extract.
- *
- * @return ZipEntry
*/
public function setExtractVersion(int $version): self
{
@@ -402,8 +382,6 @@
*
* @param int $compressedSize the Compressed Size
*
- * @return ZipEntry
- *
* @internal
*/
public function setCompressedSize(int $compressedSize): self
@@ -429,8 +407,6 @@
*
* @param int $uncompressedSize the (Uncompressed) Size
*
- * @return ZipEntry
- *
* @internal
*/
public function setUncompressedSize(int $uncompressedSize): self
@@ -452,8 +428,6 @@
}
/**
- * @return ZipEntry
- *
* @internal
*/
public function setLocalHeaderOffset(int $localHeaderOffset): self
@@ -479,8 +453,6 @@
*
* @param int $gpbf general purpose bit flags
*
- * @return ZipEntry
- *
* @internal
*/
public function setGeneralPurposeBitFlags(int $gpbf): self
@@ -512,9 +484,6 @@
}
}
- /**
- * @return ZipEntry
- */
private function setGeneralBitFlag(int $mask, bool $enable): self
{
if ($enable) {
@@ -570,8 +539,6 @@
/**
* Sets the encryption property to false and removes any other
* encryption artifacts.
- *
- * @return ZipEntry
*/
public function disableEncryption(): self
{
@@ -586,8 +553,6 @@
/**
* Sets the encryption flag for this ZIP entry.
- *
- * @return ZipEntry
*/
private function setEncrypted(bool $encrypted): self
{
@@ -609,8 +574,6 @@
*
* @throws ZipUnsupportMethodException
*
- * @return ZipEntry
- *
* @see ZipCompressionMethod::STORED
* @see ZipCompressionMethod::DEFLATED
* @see ZipCompressionMethod::BZIP2
@@ -652,8 +615,6 @@
/**
* Set Dos Time.
- *
- * @return ZipEntry
*/
public function setDosTime(int $dosTime): self
{
@@ -670,8 +631,6 @@
/**
* Set time from unix timestamp.
- *
- * @return ZipEntry
*/
public function setTime(int $unixTimestamp): self
{
@@ -698,8 +657,6 @@
* Sets the external file attributes.
*
* @param int $externalAttributes the external file attributes
- *
- * @return ZipEntry
*/
public function setExternalAttributes(int $externalAttributes): self
{
@@ -730,8 +687,6 @@
* Sets the internal file attributes.
*
* @param int $internalAttributes the internal file attributes
- *
- * @return ZipEntry
*/
public function setInternalAttributes(int $internalAttributes): self
{
@@ -762,9 +717,6 @@
return $this->cdExtraFields->get($headerId);
}
- /**
- * @return ZipEntry
- */
public function setCdExtraFields(ExtraFieldsCollection $cdExtraFields): self
{
$this->cdExtraFields = $cdExtraFields;
@@ -782,9 +734,6 @@
return $this->localExtraFields[$headerId];
}
- /**
- * @return ZipEntry
- */
public function setLocalExtraFields(ExtraFieldsCollection $localExtraFields): self
{
$this->localExtraFields = $localExtraFields;
@@ -837,10 +786,6 @@
/**
* Set entry comment.
- *
- * @param ?string $comment
- *
- * @return ZipEntry
*/
public function setComment(?string $comment): self
{
@@ -866,7 +811,7 @@
}
/**
- * Return crc32 content or 0 for WinZip AES v2.
+ * Returns the CRC32 of the content, or 0 for WinZip AES v2.
*/
public function getCrc(): int
{
@@ -876,8 +821,6 @@
/**
* Set crc32 content.
*
- * @return ZipEntry
- *
* @internal
*/
public function setCrc(int $crc): self
@@ -894,11 +837,6 @@
/**
* Set password and encryption method from entry.
- *
- * @param ?string $password
- * @param ?int $encryptionMethod
- *
- * @return ZipEntry
*/
public function setPassword(?string $password, ?int $encryptionMethod = null): self
{
@@ -936,10 +874,6 @@
* @see ZipEncryptionMethod::WINZIP_AES_256
* @see ZipEncryptionMethod::WINZIP_AES_192
* @see ZipEncryptionMethod::WINZIP_AES_128
- *
- * @param ?int $encryptionMethod
- *
- * @return ZipEntry
*/
public function setEncryptionMethod(?int $encryptionMethod): self
{
@@ -959,9 +893,6 @@
return $this->compressionLevel;
}
- /**
- * @return ZipEntry
- */
public function setCompressionLevel(int $compressionLevel): self
{
if ($compressionLevel === self::UNKNOWN) {
@@ -985,7 +916,7 @@
}
/**
- * Update general purpose bit flogs.
+ * Update the general purpose bit flags.
*/
private function updateGbpfCompLevel(): void
{
@@ -1006,7 +937,7 @@
$bit1 = true;
$bit2 = true;
break;
- // default is ZipCompressionLevel::NORMAL
+ // default is ZipCompressionLevel::NORMAL
}
$this->generalPurposeBitFlags |= ($bit1 ? GeneralPurposeBitFlag::COMPRESSION_FLAG1 : 0);
@@ -1019,8 +950,6 @@
* unzip command.
*
* @param int $mode mode an int value
- *
- * @return ZipEntry
*/
public function setUnixMode(int $mode): self
{
@@ -1037,7 +966,7 @@
}
/**
- * Unix permission.
+ * Unix permissions.
*
* @return int the unix permissions
*/
@@ -1111,7 +1040,7 @@
try {
return new DateTimeImmutable('@' . $timestamp);
} catch (Exception $e) {
- throw new RuntimeException('Error create DateTime object with timestamp ' . $timestamp, 1, $e);
+ throw new RuntimeException('Cannot create a DateTime object for timestamp ' . $timestamp, 1, $e);
}
}
--- a/everest-backup/vendor/nelexa/zip/src/Model/