|
|
|
Issue Links:
|
Duplicate
|
|
This issue duplicates:
|
|
MDL-15928
Switch to using internal PHP zip and drop support for binary zip and pcl zip
|
|
|
|
|
|
|
|
| Participants: |
Dan Marsden and Fred Woolard
|
| Security Level: |
None
|
| Resolved date: |
12/Dec/08
|
| Affected Branches: |
MOODLE_19_STABLE
|
|
I'm fairly new to PHP programming, so I'm just tossing this out there to see what the more exprerienced folks think: During a restore of a sizable course backup file, the process kept failing due to a memory limit error. I adjusted the memory limit in php.ini to 256M (which I think is a bit much), and it still pukes.
Looking at the code, I notice the use of gzinflate (Zlib) in the pclzip.lib.php. Is that the best library to use? It seems the gz* functions are oriented towards compression/decompression of content sent to and from the user-agent, and not so much for files. The line (3806) where the memory limit error occurs look like: $v_file_content = @gzinflate($v_buffer);
It happens that the file content being inflated (moodle.xml) is 198MB.
I was thinking the regular Zip libraries might work a little better. So in moodlelib.php, unzip_file function, at about line 7343, I made this change:
/*
include_once("$CFG->libdir/pclzip/pclzip.lib.php");
$archive = new PclZip(cleardoubleslashes("$zippath/$zipfilename"));
if (!$list = $archive->extract(PCLZIP_OPT_PATH, $destpath,
PCLZIP_CB_PRE_EXTRACT, 'unzip_cleanfilename',
PCLZIP_OPT_EXTRACT_DIR_RESTRICTION, $destpath)) {
if (!empty($showstatus)) {
notice($archive->errorInfo(true));
}
return false;
}
*/
$archive = new ZipArchive();
if (true === ($res = $archive->open(cleardoubleslashes("$zippath/$zipfilename")))) {
$archive->extractTo($destpath);
$archive->close();
}
elseif (!empty($showstatus)) {
notice('Unzip of file failed, code:' . $res);
}
No more memory limit error. I've even lowered the memory_limit setting in php.ini to 64M.
Regards.
|
|
Description
|
I'm fairly new to PHP programming, so I'm just tossing this out there to see what the more exprerienced folks think: During a restore of a sizable course backup file, the process kept failing due to a memory limit error. I adjusted the memory limit in php.ini to 256M (which I think is a bit much), and it still pukes.
Looking at the code, I notice the use of gzinflate (Zlib) in the pclzip.lib.php. Is that the best library to use? It seems the gz* functions are oriented towards compression/decompression of content sent to and from the user-agent, and not so much for files. The line (3806) where the memory limit error occurs look like: $v_file_content = @gzinflate($v_buffer);
It happens that the file content being inflated (moodle.xml) is 198MB.
I was thinking the regular Zip libraries might work a little better. So in moodlelib.php, unzip_file function, at about line 7343, I made this change:
/*
include_once("$CFG->libdir/pclzip/pclzip.lib.php");
$archive = new PclZip(cleardoubleslashes("$zippath/$zipfilename"));
if (!$list = $archive->extract(PCLZIP_OPT_PATH, $destpath,
PCLZIP_CB_PRE_EXTRACT, 'unzip_cleanfilename',
PCLZIP_OPT_EXTRACT_DIR_RESTRICTION, $destpath)) {
if (!empty($showstatus)) {
notice($archive->errorInfo(true));
}
return false;
}
*/
$archive = new ZipArchive();
if (true === ($res = $archive->open(cleardoubleslashes("$zippath/$zipfilename")))) {
$archive->extractTo($destpath);
$archive->close();
}
elseif (!empty($showstatus)) {
notice('Unzip of file failed, code:' . $res);
}
No more memory limit error. I've even lowered the memory_limit setting in php.ini to 64M.
Regards. |
Show » |
|
MDL-15928this is planned for Moodle 2.0 - it's not possible for Moodle 1.9 and lower as it supports earlier versions of PHP
workaround for 1.9 and earlier is to use an external zip binary - see admin > Server > System paths.