Getting integer value for ini entries that support shorthanded sizing.

From: Date: Mon, 06 Jun 2011 11:47:59 +0000
Subject: Getting integer value for ini entries that support shorthanded sizing.
Groups: php.internals 
Request: Send a blank email to [email protected] to get a copy of this message
Hi.

Is there a mechanism to get the memory_limit value rather than the
string when it is set with the K, M or G shorthands.

I can see that ...

PHP_INI_ENTRY("memory_limit", "128M", PHP_INI_ALL, OnChangeMemoryLimit)
...
static PHP_INI_MH(OnChangeMemoryLimit)
{
	if (new_value) {
		PG(memory_limit) = zend_atol(new_value, new_value_length);
	} else {
		PG(memory_limit) = 1<<30;		/* effectively, no limit */
	}
	return zend_set_memory_limit(PG(memory_limit));
}


calls zend_atol - which does the translation.

The value is applied to the PHP Global structure, but the value
retrieved and stored in the ini_entries array from the ini file (the
string "1G" for example) is not overwritten.

Would it be worthwhile amending the INI macros so that zend_atol and
zend_atoi (and others if appropriate) where called earlier in the
sequence of events.

That way, ini_get('memory_limit') would return the memory limit in
bytes, rather than the shorthand.

Richard

-- 
Richard Quadling
Twitter : EE : Zend : PHPDoc
@RQuadling : e-e.com/M_248814.html : bit.ly/9O8vFY : bit.ly/lFnVea


Thread (1 message)

  • Richard Quadling
« previous php.internals (#53014) next »