-
Notifications
You must be signed in to change notification settings - Fork 216
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
Archive Zip: The execution failed. Please check error.log (Solved) #4388
Comments
### 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 Modified Line: 120 no line
|
ahrana
added a commit
to ahrana/Unyson-Backups-Extension
that referenced
this issue
Oct 23, 2024
this is the working file. details of the error. ThemeFuse/Unyson#4388
This was referenced Nov 20, 2024
if you need any Unyson errors quick help, email me, i will fix within 10 minutes, you can pay little bonus.thanks |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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');
}
/**
*/
public function get_custom_timeout(array $args, array $state = array()) {
return fw_ext('backups')->get_config('max_timeout');
}
/**
{@inheritdoc}
@param array $args
Warning!
Zip can't be executed in steps, it will execute way too long,
because it is impossible to update a zip file, every time you add a file to zip,
a new temp copy of original zip is created with new modifications, it is compressed,
and the original zip is replaced. So when the zip will grow in size,
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');
/*
*/
$max_time = time() + min( abs( $ext->get_timeout() / 2 ), 10 );
$set_compression_is_available = method_exists( $zip, 'setCompressionName' );
$files = array_slice( $this->get_all_files( $args['source_dir'] ), $state['files_count'] );
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 ( ! $files ) {
return true;
}
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 ) {
}
}`
The text was updated successfully, but these errors were encountered: