Project

General

Profile

Actions

Feature #27272

closed

Configurable T3D export memory limit

Added by Jacob Hammeken over 13 years ago. Updated over 11 years ago.

Status:
Closed
Priority:
Should have
Assignee:
-
Category:
Backend API
Target version:
-
Start date:
2011-06-07
Due date:
% Done:

100%

Estimated time:
PHP Version:
Tags:
Complexity:
Sprint Focus:

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.


Related issues 3 (0 open3 closed)

Related to TYPO3 Core - Bug #18926: class.tx_impexp.php sets 256m memory_limit without checking php.iniClosedGeorg Ringer2008-06-09

Actions
Related to TYPO3 Core - Bug #17020: class.tx_impexp.php wants 256m memory_limitClosedGeorg Ringer2007-02-20

Actions
Is duplicate of TYPO3 Core - Bug #17045: T3D Export crashes with memory exhaustedClosedGeorg Ringer2007-02-27

Actions
Actions

Also available in: Atom PDF