Closed ghost closed 8 years ago
yes , this would be useful to eliminate the long resizing images process
What about this?
On sizes restore start do:
hello.jpg
, find its sizes by file name hello-...x....jpg
and remember the listsounds doable, but what if user has switched themes in lets say last 3 months , and theme he uses now has different image sizes , the check would not be reliable.
Do you mean a demo install designed for one theme will be used for completely different theme?
no I dont mean that ,
you make theme , I make theme
both based on Unyson
user uses yours , than uses mine ,
than decides to make demo
here we have to think that demo functionality is available to all of us, users and developers
in ref to that unzip function , I just checked our unzip code and we ended up uzing this lib http://www.phpclasses.org/browse/file/10410.html in combo with dZip
instead of that function. It was more reliable and gave us option to restrict up/down per user. but this one is also widely used http://www.phpconcept.net/pclzip/ and does not require any additional php.ini settings
http://www.phpconcept.net/pclzip/ Contains too much "noise", defined global constants. http://www.phpclasses.org/browse/file/10410.html is just a class, I will inspect it and figure out if it can be used to unzip in steps.
I am concerned about compatibility with different zip archives created with different zip clients. For example here is a comment from that file:
Function _loadFileListByEOF(&$fh, $stopOnFile=false){
// Check if there's a valid Central Dir signature.
// Let's consider a file comment smaller than 1024 characters...
// Actually, it length can be 65536.. But we're not going to support it.
for($x = 0; $x < 1024; $x++){
I hope everything will be fine.
this guy did it with zipacrchive , http://stackoverflow.com/questions/3263129/unzipping-larger-files-with-php ,
but see this comment http://stackoverflow.com/a/3263293/594423
looks like this does it in chunks already
$buf = zip_entry_read($zip_entry, zip_entry_filesize($zip_entry));
fwrite($fp,"$buf");
I didn't know about zip_*()
functions. I just did a test and it woks and the code is simple. Thank you very much! I will try to integrate them in unzip process.
before you dig in check this please , http://prntscr.com/cqzq6z
I am not sure if it requires PECL zip , or is also available for it . If it does requires it note that many servers dont have it by default
ZipArchive
also has this, of course we will test it on some hosting servers, and you will test it when we will create the approval.
I remember that previously I made zip and unzip in steps, but when I added/extracted one file from zip, the entire zip was loaded and processed in background (in FTP I saw a big temp file) and the process was way slower that doing everything at once. I hope with zip_*()
functions that will not happen.
I edited a Content Backup zip and added 45k files in it (Unyson svn respository). The archive is ~215Mb, my php memory limit is 40Mb. The backup restore worked fine, the unzip process was made in 2 requests/steps (also I decreased manually unzip timeout and it was made in multiple steps).
error_log(memory_get_peak_usage().':'.memory_get_peak_usage(true));
showed 18791320:2097152
which is 17.9MB:2MB
. If it will work on slow servers it will be awesome.
on it
Im getting this
[07-Oct-2016 17:42:55 UTC] PHP Warning: copy(T:/wamp64/www/Development/DemosTest/wordpress/wp-content/themes/theme_name/demo-content/clean\f\plugins\unyson\framework\extensions\learning\extensions\learning-quiz\includes\option-types\quiz-builder\items\gap-fill\class-fw-option-type-quiz-builder-item-gap-fill.php): failed to open stream: Invalid argument in T:\wamp64\www\Development\DemosTest\wordpress\wp-content\plugins\unyson\framework\extensions\backups\helpers.php on line 147
using local theme install , demo is located in
theme/demo-content
I think it's Windows path length limit
> 'T:/wamp64/www/Development/DemosTest/wordpress/wp-content/themes/theme_name/demo-content/clean/f/plugins/unyson/framework/extensions/learning/extensions/learning-quiz/includes/option-types/quiz-builder/items/gap-fill/class-fw-option-type-quiz-builder-item-gap-fill.php'.length
267
me to , doing new backup ,
well seems like same process if done from demo-content folder , will do next test on demo download
this will take looong http://prntscr.com/cr1y7h
tell me , is the process interrupted if I get out of demo install page ?
Yes
Your theme should require the plugins with TGM
That is a another issue.
k deleted, will test this more
I haven't noticed that the download task had it's own unzip script, now I changed it to use the partial unzip https://github.com/ThemeFuse/Unyson-Backups-Extension/commit/19e53488c6f9c6ccea3b03033bfec25371495d62
Code snippets soon...
This possibility was already there https://github.com/ThemeFuse/Unyson-Backups-Extension/issues/15
Important! Use this code only while developing, to export a demo install with image sizes included. Do not include this code in theme in production, because all Content Backups created by user will be with image sizes.
Add the filter in {theme}/functions.php
add_filter(
'fw:ext:backups:add-backup-task:image-sizes-remove',
'_filter_theme_fw_ext_backups_disable_image_sizes_remove',
10, 2
);
function _filter_theme_fw_ext_backups_disable_image_sizes_remove(
$do, FW_Ext_Backups_Task_Collection $collection
) {
$do = false;
return $do;
}
add_filter(
'fw:ext:backups:add-restore-task:image-sizes-restore',
'_filter_theme_fw_backups_disable_image_sizes_restore'.
10, 2
);
function _filter_theme_fw_backups_disable_image_sizes_restore(
$do, FW_Ext_Backups_Task_Collection $collection
) {
if (
$collection->get_id() === 'demo-content-install'
&&
($task = $collection->get_task('demo:demo-download'))
&&
($task_args = $task->get_args())
&&
isset($task_args['demo_id'])
&&
in_array($task_args['demo_id'], array('DEMO_ID_1', 'DEMO_ID_2'))
) {
$do = false;
}
return $do;
}
Im lost.
Use this code only while developing, to export a demo install with image sizes included
I thought we will have off switch for image sizes restore. What is image sizes remove?
Sorry but I dont understand the usage at all.
I add filters Export demo Remove filters from theme
Demo installs without image sizes restore
Right?
I add filters Export demo Remove filters from theme
Yes, this is for first filter.
Demo installs without image sizes restore
This is for the second filter. (note the DEMO_ID_X
in array)
ok but What is image sizes remove? http://prntscr.com/csnd9b
How content backup works:
@moldcraft ,
does the second filter , fw:ext:backups:add-restore-task:image-sizes-restore
also need to be removed? Not right?
cc @danyj https://github.com/ThemeFuse/Unyson/issues/1818#issuecomment-251994766