From 2ece03bbac1f80b2373299ff298758654de906d5 Mon Sep 17 00:00:00 2001 From: Paul Tarjan Date: Wed, 15 May 2013 23:53:24 -0700 Subject: [PATCH] make get_cfg_var return false The spec says this returns false on error. --- hphp/idl/options.idl.json | 2 +- hphp/runtime/ext/ext_options.cpp | 4 ++-- hphp/runtime/ext/ext_options.h | 2 +- hphp/system/class_map.cpp | 4 ++-- hphp/test/test_ext_options.cpp | 8 ++------ 5 files changed, 8 insertions(+), 12 deletions(-) diff --git a/hphp/idl/options.idl.json b/hphp/idl/options.idl.json index ac19e6956..5ab0a1856 100644 --- a/hphp/idl/options.idl.json +++ b/hphp/idl/options.idl.json @@ -125,7 +125,7 @@ "HasDocComment" ], "return": { - "type": "String", + "type": "Variant", "desc": "Returns the current value of the PHP configuration variable specified by option, or FALSE if an error occurs." }, "args": [ diff --git a/hphp/runtime/ext/ext_options.cpp b/hphp/runtime/ext/ext_options.cpp index 66ccbb51e..ec660911e 100644 --- a/hphp/runtime/ext/ext_options.cpp +++ b/hphp/runtime/ext/ext_options.cpp @@ -118,8 +118,8 @@ Array f_get_extension_funcs(CStrRef module_name) { throw NotSupportedException(__func__, "extensions are built differently"); } -String f_get_cfg_var(CStrRef option) { - throw NotSupportedException(__func__, "global configurations not used"); +Variant f_get_cfg_var(CStrRef option) { + return false; } String f_get_current_user() { diff --git a/hphp/runtime/ext/ext_options.h b/hphp/runtime/ext/ext_options.h index ae16f005c..301a5741c 100644 --- a/hphp/runtime/ext/ext_options.h +++ b/hphp/runtime/ext/ext_options.h @@ -30,7 +30,7 @@ int64_t f_dl(CStrRef library); bool f_extension_loaded(CStrRef name); Array f_get_loaded_extensions(bool zend_extensions = false); Array f_get_extension_funcs(CStrRef module_name); -String f_get_cfg_var(CStrRef option); +Variant f_get_cfg_var(CStrRef option); String f_get_current_user(); Array f_get_defined_constants(CVarRef categorize = null_variant); String f_get_include_path(); diff --git a/hphp/system/class_map.cpp b/hphp/system/class_map.cpp index e976ed9a3..441e5efa1 100644 --- a/hphp/system/class_map.cpp +++ b/hphp/system/class_map.cpp @@ -11303,8 +11303,8 @@ const char *g_class_map[] = { NULL, NULL, (const char *)0x10006040, "get_cfg_var", "", (const char*)0, (const char*)0, - "/**\n * ( excerpt from http://php.net/manual/en/function.get-cfg-var.php )\n *\n * Gets the value of a PHP configuration option.\n *\n * This function will not return configuration information set when the\n * PHP was compiled, or read from an Apache configuration file.\n *\n * To check whether the system is using a configuration file, try\n * retrieving the value of the cfg_file_path configuration setting. If this\n * is available, a configuration file is being used.\n *\n * @option string The configuration option name.\n *\n * @return string Returns the current value of the PHP configuration\n * variable specified by option, or FALSE if an error\n * occurs.\n */", - (const char *)0x14 /* KindOfString */, (const char *)0x2000, "option", "", (const char *)0x14 /* KindOfString */, "", (const char *)0, "", (const char *)0, NULL, + "/**\n * ( excerpt from http://php.net/manual/en/function.get-cfg-var.php )\n *\n * Gets the value of a PHP configuration option.\n *\n * This function will not return configuration information set when the\n * PHP was compiled, or read from an Apache configuration file.\n *\n * To check whether the system is using a configuration file, try\n * retrieving the value of the cfg_file_path configuration setting. If this\n * is available, a configuration file is being used.\n *\n * @option string The configuration option name.\n *\n * @return mixed Returns the current value of the PHP configuration\n * variable specified by option, or FALSE if an error\n * occurs.\n */", + (const char *)0xffffffff /* KindOfUnknown: $t: Variant */, (const char *)0x2000, "option", "", (const char *)0x14 /* KindOfString */, "", (const char *)0, "", (const char *)0, NULL, NULL, NULL, NULL, diff --git a/hphp/test/test_ext_options.cpp b/hphp/test/test_ext_options.cpp index f78781487..fd82fd6f5 100644 --- a/hphp/test/test_ext_options.cpp +++ b/hphp/test/test_ext_options.cpp @@ -127,12 +127,8 @@ bool TestExtOptions::test_get_extension_funcs() { } bool TestExtOptions::test_get_cfg_var() { - try { - f_get_cfg_var(""); - } catch (const NotSupportedException& e) { - return Count(true); - } - return Count(false); + VERIFY(!f_get_cfg_var("")) + return Count(true); } bool TestExtOptions::test_get_current_user() {