Whenever a rendering commands emit a ton of errors (spotted a case
generating 125MB), the call to trim() makes PHP copy the stderr which
might exhaust the remaining available memory.
The new constant MediaHandler::MAX_ERR_LOG_SIZE = 65535 is used to
substr() the error log before it get trimmed and logged.
bug: 57985
Change-Id: Ibd4cf0331529d323a68273163ac230b07a6c6108
const METADATA_GOOD = true;
const METADATA_BAD = false;
const METADATA_COMPATIBLE = 2; // for old but backwards compatible.
const METADATA_GOOD = true;
const METADATA_BAD = false;
const METADATA_COMPATIBLE = 2; // for old but backwards compatible.
+ /**
+ * Max length of error logged by logErrorForExternalProcess()
+ */
+ const MAX_ERR_LOG_SIZE = 65535;
/** @var MediaHandler[] Instance cache with array of MediaHandler */
protected static $handlers = array();
/** @var MediaHandler[] Instance cache with array of MediaHandler */
protected static $handlers = array();
*
* @since 1.23
* @param $retval int
*
* @since 1.23
* @param $retval int
+ * @param $err string Error reported by command. Anything longer than
+ * MediaHandler::MAX_ERR_LOG_SIZE is stripped off.
* @param $cmd string
*/
protected function logErrorForExternalProcess( $retval, $err, $cmd ) {
* @param $cmd string
*/
protected function logErrorForExternalProcess( $retval, $err, $cmd ) {
+ # Keep error output limited (bug 57985)
+ $errMessage = trim( substr( $err, 0, self::MAX_ERR_LOG_SIZE ) );
+
wfDebugLog( 'thumbnail',
sprintf( 'thumbnail failed on %s: error %d "%s" from "%s"',
wfDebugLog( 'thumbnail',
sprintf( 'thumbnail failed on %s: error %d "%s" from "%s"',
- wfHostname(), $retval, trim( $err ), $cmd ) );
+ wfHostname(), $retval, $errMessage, $cmd ) );