make PHP_SAPI dynamic based on execution mode

It isn't really a constant anyways.

Closes #757
Esse commit está contido em:
Sean Cannella
2013-06-07 10:42:08 -07:00
commit de Sara Golemon
commit 543927cc35
13 arquivos alterados com 22 adições e 13 exclusões
+2 -1
Ver Arquivo
@@ -264,7 +264,7 @@ void BuiltinSymbols::ImportExtConstants(AnalysisResultPtr ar,
for (auto it = src.begin(); it != src.end(); ++it) {
// We make an assumption that if the constant is a callback type
// (e.g. STDIN, STDOUT, STDERR) then it will return an Object.
// And that if it's deferred (SID) it'll be a String.
// And that if it's deferred (SID, PHP_SAPI) it'll be a String.
ClassInfo::ConstantInfo *cinfo = *it;
dest->add(cinfo->name.data(),
cinfo->isDeferred() ?
@@ -394,6 +394,7 @@ bool BuiltinSymbols::Load(AnalysisResultPtr ar, bool extOnly /* = false */) {
}
}
s_constants->setDynamic(ar, "SID", true);
s_constants->setDynamic(ar, "PHP_SAPI", true);
return true;
}
+3
Ver Arquivo
@@ -36,6 +36,9 @@ if (substr($target, -4) == '.cpp') {
printf(' "SID", (const char *)((offsetof(SystemGlobals, k_SID) - '.
'offsetof(SystemGlobals, stgv_Variant)) / sizeof(Variant)), '.
"(const char *)1,\n");
printf(' "PHP_SAPI", (const char *)((offsetof(SystemGlobals, k_PHP_SAPI) - '.
'offsetof(SystemGlobals, stgv_Variant)) / sizeof(Variant)), '.
"(const char *)1,\n");
printf(" NULL, // End of constants\n");
printf(" NULL,\n");
+3
Ver Arquivo
@@ -1306,6 +1306,9 @@ void hphp_session_init() {
StatCache::requestInit();
g_vmContext->requestInit();
SystemGlobals *g = (SystemGlobals *)get_global_variables();
g->k_PHP_SAPI = StringData::GetStaticString(RuntimeOption::ExecutionMode);
}
bool hphp_is_warmup_enabled() {
+1 -1
Ver Arquivo
@@ -2,7 +2,7 @@
+----------------------------------------------------------------------+
| HipHop for PHP |
+----------------------------------------------------------------------+
| Copyright (c) 2010- Facebook, Inc. (http://www.facebook.com) |
| Copyright (c) 2010-2013 Facebook, Inc. (http://www.facebook.com) |
+----------------------------------------------------------------------+
| This source file is subject to version 3.01 of the PHP license, |
| that is bundled with this package in the file LICENSE, and is |
+1 -1
Ver Arquivo
@@ -2,7 +2,7 @@
+----------------------------------------------------------------------+
| HipHop for PHP |
+----------------------------------------------------------------------+
| Copyright (c) 2010- Facebook, Inc. (http://www.facebook.com) |
| Copyright (c) 2010-2013 Facebook, Inc. (http://www.facebook.com) |
+----------------------------------------------------------------------+
| This source file is subject to version 3.01 of the PHP license, |
| that is bundled with this package in the file LICENSE, and is |
+1 -1
Ver Arquivo
@@ -2,7 +2,7 @@
+----------------------------------------------------------------------+
| HipHop for PHP |
+----------------------------------------------------------------------+
| Copyright (c) 2010- Facebook, Inc. (http://www.facebook.com) |
| Copyright (c) 2010-2013 Facebook, Inc. (http://www.facebook.com) |
+----------------------------------------------------------------------+
| This source file is subject to version 3.01 of the PHP license, |
| that is bundled with this package in the file LICENSE, and is |
+1 -1
Ver Arquivo
@@ -2,7 +2,7 @@
+----------------------------------------------------------------------+
| HipHop for PHP |
+----------------------------------------------------------------------+
| Copyright (c) 2010- Facebook, Inc. (http://www.facebook.com) |
| Copyright (c) 2010-2013 Facebook, Inc. (http://www.facebook.com) |
+----------------------------------------------------------------------+
| This source file is subject to version 3.01 of the PHP license, |
| that is bundled with this package in the file LICENSE, and is |
+2 -1
Ver Arquivo
@@ -166,8 +166,9 @@ class GlobalNameValueTableWrapper : public NameValueTableWrapper {
Variant __realPropProxy;
Variant __lvalProxy;
Variant stgv_Variant[1];
Variant stgv_Variant[2];
#define k_SID stgv_Variant[0]
#define k_PHP_SAPI stgv_Variant[1]
};
//////////////////////////////////////////////////////////////////////
+1 -2
Ver Arquivo
@@ -1255,7 +1255,6 @@ const int64_t k_PHP_OUTPUT_HANDLER_CONT = 2;
const int64_t k_PHP_OUTPUT_HANDLER_END = 4;
const int64_t k_PHP_OUTPUT_HANDLER_START = 1;
extern const StaticString k_PHP_PREFIX("",0);
extern const StaticString k_PHP_SAPI("cli",3);
extern const StaticString k_PHP_SHLIB_SUFFIX("so",2);
extern const StaticString k_PHP_SYSCONFDIR("",0);
const int64_t k_PHP_URL_FRAGMENT = 7;
@@ -18208,7 +18207,6 @@ const char *g_class_map[] = {
"PHP_OUTPUT_HANDLER_END", (const char*)4, "i:4;",
"PHP_OUTPUT_HANDLER_START", (const char*)4, "i:1;",
"PHP_PREFIX", (const char*)7, "s:0:\"\";",
"PHP_SAPI", (const char*)10, "s:3:\"cli\";",
"PHP_SHLIB_SUFFIX", (const char*)9, "s:2:\"so\";",
"PHP_SYSCONFDIR", (const char*)7, "s:0:\"\";",
"PHP_URL_FRAGMENT", (const char*)4, "i:7;",
@@ -19049,6 +19047,7 @@ const char *g_class_map[] = {
"CURLOPT_TIMEOUT_MS", (const char *)&k_CURLOPT_TIMEOUT_MS, (const char *)0xc /* KindOfInt64 */,
"CURLOPT_CONNECTTIMEOUT_MS", (const char *)&k_CURLOPT_CONNECTTIMEOUT_MS, (const char *)0xc /* KindOfInt64 */,
"SID", (const char *)((offsetof(SystemGlobals, k_SID) - offsetof(SystemGlobals, stgv_Variant)) / sizeof(Variant)), (const char *)1,
"PHP_SAPI", (const char *)((offsetof(SystemGlobals, k_PHP_SAPI) - offsetof(SystemGlobals, stgv_Variant)) / sizeof(Variant)), (const char *)1,
NULL, // End of constants
NULL,
(const char *)0x10006000, "PDO", "", "", (const char *)0, (const char *)0,
-1
Ver Arquivo
@@ -1257,7 +1257,6 @@ extern const int64_t k_PHP_OUTPUT_HANDLER_CONT;
extern const int64_t k_PHP_OUTPUT_HANDLER_END;
extern const int64_t k_PHP_OUTPUT_HANDLER_START;
extern const StaticString k_PHP_PREFIX;
extern const StaticString k_PHP_SAPI;
extern const StaticString k_PHP_SHLIB_SUFFIX;
extern const StaticString k_PHP_SYSCONFDIR;
extern const int64_t k_PHP_URL_FRAGMENT;
-4
Ver Arquivo
@@ -4953,10 +4953,6 @@
"name": "PHP_PREFIX",
"value": ""
},
{
"name": "PHP_SAPI",
"value": "cli"
},
{
"name": "PHP_SHLIB_SUFFIX",
"value": "so"
+6
Ver Arquivo
@@ -0,0 +1,6 @@
<?php
$const = PHP_SAPI;
$value_from_func = php_sapi_name();
var_dump($const == $value_from_func);
+1
Ver Arquivo
@@ -0,0 +1 @@
bool(true)