mirror of
https://github.com/phpv8/v8js.git
synced 2024-11-10 03:48:42 +00:00
Merge pull request #307 from stesie/issue-306
Initialize ICU as (meanwhile) needed
This commit is contained in:
commit
fe2e18851b
11
appveyor.yml
11
appveyor.yml
@ -2,13 +2,13 @@ environment:
|
||||
matrix:
|
||||
- ARTIFACT_NAME: v8js_vc14_php7_%Platform%_ts.zip
|
||||
OUTDIR: Release_TS
|
||||
V8_ASSETS: V8-5.8.301.0-%Platform%.zip
|
||||
V8_ASSETS: V8-5.8.283.31-%Platform%.zip
|
||||
- ARTIFACT_NAME: v8js_vc14_php7_%Platform%_nts.zip
|
||||
OUTDIR: Release
|
||||
CONFIGURE_EXTRA: --disable-zts
|
||||
V8_ASSETS: V8-5.8.301.0-%Platform%.zip
|
||||
V8_ASSETS: V8-5.8.283.31-%Platform%.zip
|
||||
|
||||
PHP_VERSION: 7.0.16
|
||||
PHP_VERSION: 7.0.18
|
||||
PHP_SDK: c:\projects\php-sdk
|
||||
|
||||
os: Windows Server 2012
|
||||
@ -38,6 +38,7 @@ install:
|
||||
- IF "%Platform%" == "x64" SET OUTDIR=x64\%OUTDIR%
|
||||
- mkdir %OUTDIR%
|
||||
- move ..\deps\bin\*.dll %OUTDIR%\
|
||||
- move ..\deps\bin\icudtl.dat %OUTDIR%\
|
||||
|
||||
build_script:
|
||||
- ps: >-
|
||||
@ -57,7 +58,7 @@ build_script:
|
||||
|
||||
after_build:
|
||||
- cd %OUTDIR%
|
||||
- 7z a %ARTIFACT_NAME% icu*.dll v8.dll php_v8js.dll
|
||||
- 7z a %ARTIFACT_NAME% icudtl.dat icu*.dll v8.dll php_v8js.dll
|
||||
- ps: Push-AppveyorArtifact $env:ARTIFACT_NAME
|
||||
|
||||
test_script:
|
||||
@ -65,7 +66,7 @@ test_script:
|
||||
- set NO_INTERACTION=1
|
||||
- set TEST_PHP_JUNIT=junit.xml
|
||||
- set REPORT_EXIT_STATUS=1
|
||||
- "%OUTDIR%\\php.exe run-tests.php -p %OUTDIR%\\php.exe ext/v8js/tests/ -d extension=php_v8js.dll -d extension_dir=%OUTDIR%\\"
|
||||
- "%OUTDIR%\\php.exe run-tests.php -p %OUTDIR%\\php.exe ext/v8js/tests/ -d v8js.icudtl_dat_path=%OUTDIR%/icudtl.dat -d extension=php_v8js.dll -d extension_dir=%OUTDIR%\\"
|
||||
|
||||
on_finish:
|
||||
- cd c:\projects\php-sdk\v8js-ci\vc14\%Platform%\php-%PHP_VERSION%
|
||||
|
@ -3,7 +3,7 @@ PHP_ARG_WITH(v8js, for V8 Javascript Engine,
|
||||
|
||||
if test "$PHP_V8JS" != "no"; then
|
||||
SEARCH_PATH="/usr/local /usr"
|
||||
SEARCH_FOR="include/v8.h"
|
||||
SEARCH_FOR="$PHP_LIBDIR/libv8.$SHLIB_SUFFIX_NAME"
|
||||
|
||||
if test -r $PHP_V8JS/$SEARCH_FOR; then
|
||||
case $host_os in
|
||||
@ -25,6 +25,8 @@ if test "$PHP_V8JS" != "no"; then
|
||||
done
|
||||
fi
|
||||
|
||||
AC_DEFINE_UNQUOTED([PHP_V8_EXEC_PATH], "$V8_DIR/$SEARCH_FOR", [Full path to libv8 library file])
|
||||
|
||||
if test -z "$V8_DIR"; then
|
||||
AC_MSG_RESULT([not found])
|
||||
AC_MSG_ERROR([Please reinstall the v8 distribution])
|
||||
|
@ -77,6 +77,8 @@ if (PHP_V8JS != "no") {
|
||||
AC_DEFINE("PHP_V8_API_VERSION", v8api, "", false);
|
||||
AC_DEFINE("PHP_V8_VERSION", v8ver, "", true);
|
||||
|
||||
// AC_DEFINE("PHP_V8_EXEC_PATH", "C:\\php\\bin\\v8.dll", "", true);
|
||||
|
||||
EXTENSION("v8js", "v8js_array_access.cc v8js_class.cc v8js_commonjs.cc v8js_convert.cc v8js_exceptions.cc v8js_generator_export.cc v8js_main.cc v8js_methods.cc v8js_object_export.cc v8js_timer.cc v8js_v8.cc v8js_v8object_class.cc v8js_variables.cc", "yes");
|
||||
|
||||
} else {
|
||||
|
@ -156,6 +156,9 @@ struct _v8js_process_globals {
|
||||
/* V8 command line flags */
|
||||
char *v8_flags;
|
||||
|
||||
/* Path to icudtl.dat file */
|
||||
char *icudtl_dat_path;
|
||||
|
||||
v8::Platform *v8_platform;
|
||||
};
|
||||
|
||||
|
28
tests/issue_306_basic.phpt
Normal file
28
tests/issue_306_basic.phpt
Normal file
@ -0,0 +1,28 @@
|
||||
--TEST--
|
||||
Test V8::executeString() : Issue #306 V8 crashing on toLocaleString()
|
||||
--SKIPIF--
|
||||
<?php require_once(dirname(__FILE__) . '/skipif.inc'); ?>
|
||||
--FILE--
|
||||
<?php
|
||||
|
||||
$v8 = new V8Js();
|
||||
|
||||
$expr = 'new Date("10/11/2009").toLocaleString("en-us", { month: "long" });';
|
||||
$result = $v8->executeString($expr);
|
||||
|
||||
// V8 can be compiled with i18n support and without;
|
||||
// without i18n support however toLocaleString doesn't really work,
|
||||
// it just returns the date string...
|
||||
|
||||
if ($result === 'October') {
|
||||
var_dump(true);
|
||||
} else {
|
||||
$expr = 'new Date("10/11/2009").toString();';
|
||||
var_dump($v8->executeString($expr) === $result);
|
||||
}
|
||||
|
||||
?>
|
||||
===EOF===
|
||||
--EXPECT--
|
||||
bool(true)
|
||||
===EOF===
|
28
v8js_main.cc
28
v8js_main.cc
@ -33,7 +33,7 @@ struct _v8js_process_globals v8js_process_globals;
|
||||
|
||||
/* {{{ INI Settings */
|
||||
|
||||
static ZEND_INI_MH(v8js_OnUpdateV8Flags) /* {{{ */
|
||||
static bool v8js_ini_string(char **field, const zend_string *new_value)/* {{{ */
|
||||
{
|
||||
bool immutable = false;
|
||||
|
||||
@ -56,18 +56,33 @@ static ZEND_INI_MH(v8js_OnUpdateV8Flags) /* {{{ */
|
||||
}
|
||||
|
||||
if (new_value) {
|
||||
if (v8js_process_globals.v8_flags) {
|
||||
free(v8js_process_globals.v8_flags);
|
||||
v8js_process_globals.v8_flags = NULL;
|
||||
if (*field) {
|
||||
free(*field);
|
||||
*field = NULL;
|
||||
}
|
||||
|
||||
if (!ZSTR_VAL(new_value)[0]) {
|
||||
return FAILURE;
|
||||
return SUCCESS;
|
||||
}
|
||||
v8js_process_globals.v8_flags = zend_strndup(ZSTR_VAL(new_value), ZSTR_LEN(new_value));
|
||||
|
||||
*field = zend_strndup(ZSTR_VAL(new_value), ZSTR_LEN(new_value));
|
||||
}
|
||||
|
||||
return SUCCESS;
|
||||
}
|
||||
/* }}} */
|
||||
|
||||
static ZEND_INI_MH(v8js_OnUpdateV8Flags) /* {{{ */
|
||||
{
|
||||
return v8js_ini_string(&v8js_process_globals.v8_flags, new_value);
|
||||
}
|
||||
/* }}} */
|
||||
|
||||
static ZEND_INI_MH(v8js_OnUpdateIcudatPath) /* {{{ */
|
||||
{
|
||||
return v8js_ini_string(&v8js_process_globals.icudtl_dat_path, new_value);
|
||||
}
|
||||
/* }}} */
|
||||
|
||||
static bool v8js_ini_to_bool(const zend_string *new_value) /* {{{ */
|
||||
{
|
||||
@ -106,6 +121,7 @@ static ZEND_INI_MH(v8js_OnUpdateCompatExceptions) /* {{{ */
|
||||
|
||||
ZEND_INI_BEGIN() /* {{{ */
|
||||
ZEND_INI_ENTRY("v8js.flags", NULL, ZEND_INI_ALL, v8js_OnUpdateV8Flags)
|
||||
ZEND_INI_ENTRY("v8js.icudtl_dat_path", NULL, ZEND_INI_ALL, v8js_OnUpdateIcudatPath)
|
||||
ZEND_INI_ENTRY("v8js.use_date", "0", ZEND_INI_ALL, v8js_OnUpdateUseDate)
|
||||
ZEND_INI_ENTRY("v8js.use_array_access", "0", ZEND_INI_ALL, v8js_OnUpdateUseArrayAccess)
|
||||
ZEND_INI_ENTRY("v8js.compat_php_exceptions", "0", ZEND_INI_ALL, v8js_OnUpdateCompatExceptions)
|
||||
|
12
v8js_v8.cc
12
v8js_v8.cc
@ -76,6 +76,18 @@ void v8js_v8_init() /* {{{ */
|
||||
}
|
||||
}
|
||||
|
||||
#if PHP_V8_API_VERSION >= 5003178
|
||||
/* Initialize ICU, call introduced in V8 5.3.178 */
|
||||
if (v8js_process_globals.icudtl_dat_path != NULL && v8js_process_globals.icudtl_dat_path[0] != 0) {
|
||||
v8::V8::InitializeICUDefaultLocation(nullptr, v8js_process_globals.icudtl_dat_path);
|
||||
}
|
||||
#ifdef PHP_V8_EXEC_PATH
|
||||
else {
|
||||
v8::V8::InitializeICUDefaultLocation(PHP_V8_EXEC_PATH, nullptr);
|
||||
}
|
||||
#endif
|
||||
#endif /* PHP_V8_API_VERSION >= 5003178 */
|
||||
|
||||
/* Initialize V8 */
|
||||
v8::V8::Initialize();
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user