Feature #27272
closedConfigurable T3D export memory limit
100%
Description
When exporting data to .t3d with the "impexp" system extension, the export sometimes fails due to a hardcoded memory limit. It would be nice if this limit was configurable by the server admin or a TYPO3 integrator without modifying the system extension.
In typo3/sysext/impexp/class.tx_impexp.php (tested in TYPO3 4.5.3), there is the following line:
@ini_set('memory_limit','256m');
I think 128 megabyte is a common default for memory limit, the above limit may possibly have been intended to double that limitation. Explicitly setting the limit may actually lower the default memory limit (as set by the server admin in php.ini or by the TYPO3 integrator in the install-tool).
Because of excessive memory usage during export, on sites with large page trees and many tables, 256 megabyte is sometimes too low and may instead need to be a gigabyte or more. I thus suggest the limit should be the maximum of "setMemoryLimit" from the install-tool, ini_get('memory_limit') and 256m. The limit could be set like the following (sorry, should probably be a patch). I think it should be moved to impexp/modfunc1/class.tx_impexp_modfunc1.php, to a method called by the main-method, as executing code globablly (outside of functions and methods) goes against common software design.
// candidates for an appropriate memory limit
$installToolLimit = $TYPO3_CONF_VARS['SYS']['setMemoryLimit'];
$currentLimit = ini_get('memory_limit');
$minimumLimit = 256;
// if a limit is not set in the install tool, use one of the other limits
if(strlen($installToolLimit) == 0) {
$installToolLimit = 0;
}
if($currentLimit === false) {
// if a limit is currently not set, use one of the other limits
$currentLimit = 0;
} else {
// if the current limit is not a number that ends with a unit type (like 'm' or 'k'), the unit type is already 'm'
if(!is_numeric($currentLimit)) {
// convert the current limit to MB, so it can be compared with the other limits
$unitType = substr($currentLimit,-1);
$currentLimit = intval(substr($currentLimit,0,-1));
if($unitType == 'k') {
$currentLimit = intval($currentLimit / 1024);
} else if($unitType == 'g') {
$currentLimit *= 1024;
}
}
}
$desiredLimit = max($installToolLimit,$currentLimit,$minimumLimit);
// change the limit, if necessary
if($desiredLimit != $currentLimit) {
@ini_set($desiredLimit . 'm');
}
In other words, this will raise the memory limit to 256m, but will not decrease the memory limit if one has been configured by the server admin or TYPO3 integrator.
Alternatively, it could have its own setting (with a default of 256 MB), with an install-tool setting (since it is a system extension), but this may have the downside that it adds yet another install-tool setting that is easily overlooked.
Updated by Georg Ringer over 13 years ago
why not just remove the line completly? something against that?
Updated by Mr. Hudson over 13 years ago
Patch set 1 of change I3e690eea1a079ed6cadd548230afc405e005b115 has been pushed to the review server.
It is available at http://review.typo3.org/2610
Updated by Mr. Hudson over 13 years ago
Patch set 2 of change I3e690eea1a079ed6cadd548230afc405e005b115 has been pushed to the review server.
It is available at http://review.typo3.org/2610
Updated by Steffen Gebert over 13 years ago
- Category set to Backend API
- Target version set to 4.6.0-beta1
- TYPO3 Version changed from 4.5 to 4.6
Updated by Georg Ringer over 13 years ago
- Status changed from New to Resolved
- % Done changed from 0 to 100
Applied in changeset 886cb1a5f1ebd36b64b9414e1ca9bdb1bcc7e3fc.
Updated by Xavier Perseguers over 12 years ago
- Status changed from Resolved to Closed
Updated by Ernesto Baschny over 11 years ago
- Target version deleted (
4.6.0-beta1)