php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Return to Bug #61630
Patch set_include_path-array_input revision 2012-04-26 17:55 UTC by roeitell at gmail dot com

Patch set_include_path-array_input for PHP options/info functions Bug #61630

Patch version 2012-04-26 17:55 UTC

Return to Bug #61630 | Download this patch
Patch Revisions:

Developer: roeitell@gmail.com

PHP_FUNCTION(set_include_path)
{
	zval *input, *delim, *imploded;
	char *new_value, *old_value, pathsep[2];
	int new_value_len;
	char *old_value;

	if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "z", &input) == FAILURE) {
		return;
	}
	
	switch (Z_TYPE_P(input)) {
		default:
			convert_to_string_ex(&input);
		case IS_STRING:
			new_value = Z_STRVAL_P(input);
			new_value_len = Z_STRLEN_P(input);
			break;
		case IS_ARRAY:
			pathsep[0] = ZEND_PATHS_SEPARATOR;
			pathsep[1] = '\0';
			MAKE_STD_ZVAL(imploded);
			MAKE_STD_ZVAL(delim);
			ZVAL_STRING(delim, pathsep, 1);
			php_implode(delim, input, imploded TSRMLS_CC);
			new_value = Z_STRVAL_P(imploded);
			new_value_len = Z_STRLEN_P(imploded);
			FREE_ZVAL(delim);
			FREE_ZVAL(imploded);
			break;
	}

	old_value = zend_ini_string("include_path", sizeof("include_path"), 0);
	/* copy to return here, because alter might free it! */
	if (old_value) {
		RETVAL_STRING(old_value, 1);
	} else {
		RETVAL_FALSE;
	}

	if (zend_alter_ini_entry_ex("include_path", sizeof("include_path"), new_value, new_value_len, PHP_INI_USER, PHP_INI_STAGE_RUNTIME, 0 TSRMLS_CC) == FAILURE) {
		zval_dtor(return_value);
		RETURN_FALSE;
	}
}
 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Thu Apr 18 15:01:28 2024 UTC