php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login

Patch mysqlnd_ms-error_message_improvement for mysqlnd_ms Bug #61763

Patch version 2012-04-18 13:13 UTC

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

Developer: jpauli@php.net

--- /home/julien/Downloads/mysqlnd_ms-1.3.1/mysqlnd_ms.h	2012-04-16 15:45:27.000000000 +0200
+++ ./mysqlnd_ms.h	2012-04-18 14:56:16.207248823 +0200
@@ -50,7 +50,7 @@
 ZEND_BEGIN_MODULE_GLOBALS(mysqlnd_ms)
 	zend_bool enable;
 	zend_bool force_config_usage;
-	const char * ini_file;
+	const char * json_file;
 	zval * user_pick_server;
 	zend_bool collect_statistics;
 	zend_bool multi_master;
--- /home/julien/Downloads/mysqlnd_ms-1.3.1/php_mysqlnd_ms.c	2012-04-16 15:45:27.000000000 +0200
+++ ./php_mysqlnd_ms.c	2012-04-18 14:56:02.243249411 +0200
@@ -87,7 +87,7 @@
 {
 	mysqlnd_ms_globals->enable = FALSE;
 	mysqlnd_ms_globals->force_config_usage = FALSE;
-	mysqlnd_ms_globals->ini_file = NULL;
+	mysqlnd_ms_globals->json_file = NULL;
 	mysqlnd_ms_globals->collect_statistics = FALSE;
 	mysqlnd_ms_globals->multi_master = FALSE;
 	mysqlnd_ms_globals->disable_rw_split = FALSE;
@@ -124,7 +124,7 @@
 PHP_INI_BEGIN()
 	STD_PHP_INI_BOOLEAN("mysqlnd_ms.enable", "0", PHP_INI_SYSTEM, OnUpdateBool, enable, zend_mysqlnd_ms_globals, mysqlnd_ms_globals)
 	STD_PHP_INI_ENTRY("mysqlnd_ms.force_config_usage", "0", PHP_INI_SYSTEM, OnUpdateBool, force_config_usage, zend_mysqlnd_ms_globals, mysqlnd_ms_globals)
-	STD_PHP_INI_ENTRY("mysqlnd_ms.ini_file", NULL, PHP_INI_SYSTEM, OnUpdateString, ini_file, zend_mysqlnd_ms_globals, mysqlnd_ms_globals)
+	STD_PHP_INI_ENTRY("mysqlnd_ms.json_file", NULL, PHP_INI_SYSTEM, OnUpdateString, json_file, zend_mysqlnd_ms_globals, mysqlnd_ms_globals)
 	STD_PHP_INI_ENTRY("mysqlnd_ms.collect_statistics", "0", PHP_INI_SYSTEM, OnUpdateBool, collect_statistics, zend_mysqlnd_ms_globals, mysqlnd_ms_globals)
 	STD_PHP_INI_ENTRY("mysqlnd_ms.multi_master", "0", PHP_INI_SYSTEM, OnUpdateBool, multi_master, zend_mysqlnd_ms_globals, mysqlnd_ms_globals)
 	STD_PHP_INI_ENTRY("mysqlnd_ms.disable_rw_split", "0", PHP_INI_SYSTEM, OnUpdateBool, disable_rw_split, zend_mysqlnd_ms_globals, mysqlnd_ms_globals)
--- /home/julien/Downloads/mysqlnd_ms-1.3.1/mysqlnd_ms_config_json.c	2012-04-16 15:45:26.000000000 +0200
+++ ./mysqlnd_ms_config_json.c	2012-04-18 14:56:46.795247537 +0200
@@ -222,7 +222,7 @@
 mysqlnd_ms_config_json_load_configuration(struct st_mysqlnd_ms_json_config * cfg TSRMLS_DC)
 {
 	enum_func_status ret = FAIL;
-	char * json_file_name = INI_STR("mysqlnd_ms.ini_file");
+	char * json_file_name = INI_STR("mysqlnd_ms.json_file");
 	DBG_ENTER("mysqlnd_ms_config_json_load_configuration");
 	DBG_INF_FMT("json_file=%s", json_file_name? json_file_name:"n/a");
 	if (!json_file_name) {
@@ -237,7 +237,7 @@
 
 			if (!stream) {
 				php_error_docref(NULL TSRMLS_CC, E_WARNING, MYSQLND_MS_ERROR_PREFIX
-								" Failed to parse server list ini file [%s]", json_file_name);
+								" Failed to open server list config file [%s]", json_file_name);
 				break;
 			}
 			str_data_len = php_stream_copy_to_mem(stream, &str_data, PHP_STREAM_COPY_ALL, 0);
@@ -250,6 +250,11 @@
 #else
 			php_json_decode(&json_data, str_data, str_data_len, 1 /* assoc */, 512 /* default depth */ TSRMLS_CC);
 #endif
+			if(Z_TYPE(json_data) == IS_NULL) {
+				php_error_docref(NULL TSRMLS_CC, E_WARNING, MYSQLND_MS_ERROR_PREFIX
+												" Failed to parse server list file [%s]", json_file_name);
+				break;
+			}
 			cfg->main_section = mysqlnd_ms_zval_data_to_hashtable(&json_data TSRMLS_CC);
 			zval_dtor(&json_data);
 			efree(str_data);
 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Sun Dec 22 16:01:31 2024 UTC