Open ahrana opened 3 days ago
### Look at line 120, where ZipArchive->setCompressionName() is called
In the line where setCompressionName() is called, I've added a check to ensure that both the file path and compression method are not empty before attempting to set the compression
if ( $set_compression_is_available ) {
// Ensure compression name is not empty before setting
$compression_method = apply_filters( 'fw_backup_compression_method', ZipArchive::CM_DEFAULT );
if (!empty($file_zip_path) && $compression_method !== false) {
$zip->setCompressionName( $file_zip_path, $compression_method );
}
}
}
// Zip archive will be created only after closing the object
if your extensions not Installing or activating
copy my code and paste to your themes functions.php
/**
* Remove Unyson's default GitHub API URL filter.
*
* This allows us to use our own custom GitHub API URL,
* which is important for [reason - e.g., security, custom domain, etc.].
*
* Developed by Rana / Learn With Rana
*/
function remove_unyson_github_filter() {
remove_filter('fw_github_api_url', '_fw_filter_github_api_url');
}
add_action('after_setup_theme', 'remove_unyson_github_filter');
if you can't take backup using backups and demo extension, then use my below modified code, it will work and you can take backup.
File Name : class-fw-ext-backups-task-type-zip.php
Go to the file /code/wp-content/plugins/unyson/framework/extensions/backups/includes/module/tasks/type/class-fw-ext-backups-task-type-zip.php. Look at line 120, where ZipArchive->setCompressionName() is called.
You can fix the issue in the FW_Ext_Backups_Task_Type_Zip class by adding a validation check to ensure the compression name is not empty when calling the setCompressionName() method
below is my full modified file, just replace the file:
`<?php if (!defined('FW')) die('Forbidden');
/**
Create zip */ class FW_Ext_Backups_Task_Type_Zip extends FW_Ext_Backups_Task_Type { public function get_type() { return 'zip'; }
public function get_title(array $args = array(), array $state = array()) { return __('Archive Zip', 'fw'); }
/**
/**
just adding a single file, will take a very long time. */ public function execute(array $args, array $state = array()) { { if (!isset($args['source_dir'])) { return new WP_Error( 'no_source_dir', ('Source dir not specified', 'fw') ); } elseif (!file_exists($args['source_dir'] = fw_fix_path($args['source_dir']))) { return new WP_Error( 'invalid_source_dir', ('Source dir does not exist', 'fw') ); }
}
if (empty($state)) { $state = array( 'files_count' => 0, // generate the file name only on first step 'zip_path' => $args['source_dir'] .'/'. implode('-', array( 'fw-backup', date('Y_m_d-H_i_s'), fw_ext('backups')->manifest->get_version() )) .'.zip' ); }
{ if (!class_exists('ZipArchive')) { return new WP_Error( 'zip_ext_missing', __('Zip extension missing', 'fw') ); }
}
/* @var FW_Extension_Backups $ext / $ext = fw_ext('backups'); /**
foreach ($files as $file) { if ($execution_not_finished = (time() > $max_time)) { break; }
}
// Zip archive will be created only after closing the object if ( ! $zip->close() ) { return new WP_Error( 'cannot_close_zip', __( 'Cannot close the zip file', 'fw' ) ); }
if ( $execution_not_finished ) { // There are more files to be processed, the execution hasn't finished return $state; }
/**
if (!rename($state['zip_path'], $args['destination_dir'] .'/'. basename($state['zip_path']))) { return new WP_Error( 'cannot_move_zip', __('Cannot move zip in destination dir', 'fw') ); }
return true; }
public function get_all_files( $source_dir ) {
} }`