Skip to content

Commit c957be8

Browse files
committed
Initialize ICU as (meanwhile) needed
1 parent 5cf93a2 commit c957be8

File tree

3 files changed

+26
-1
lines changed

3 files changed

+26
-1
lines changed

config.m4

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ PHP_ARG_WITH(v8js, for V8 Javascript Engine,
33

44
if test "$PHP_V8JS" != "no"; then
55
SEARCH_PATH="/usr/local /usr"
6-
SEARCH_FOR="include/v8.h"
6+
SEARCH_FOR="$PHP_LIBDIR/libv8.$SHLIB_DL_SUFFIX_NAME"
77

88
if test -r $PHP_V8JS/$SEARCH_FOR; then
99
case $host_os in
@@ -25,6 +25,8 @@ if test "$PHP_V8JS" != "no"; then
2525
done
2626
fi
2727

28+
AC_DEFINE_UNQUOTED([PHP_V8_EXEC_PATH], "$V8_DIR/$SEARCH_FOR", [Full path to libv8 library file])
29+
2830
if test -z "$V8_DIR"; then
2931
AC_MSG_RESULT([not found])
3032
AC_MSG_ERROR([Please reinstall the v8 distribution])

tests/issue_306_basic.phpt

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
--TEST--
2+
Test V8::executeString() : Issue #306 V8 crashing on toLocaleString()
3+
--SKIPIF--
4+
<?php require_once(dirname(__FILE__) . '/skipif.inc'); ?>
5+
--FILE--
6+
<?php
7+
8+
$v8 = new V8Js();
9+
10+
$v8 = new V8Js;
11+
$expr = 'new Date("10/11/2009").toLocaleString("en-us", { month: "long" });';
12+
var_dump( $v8->executeString($expr, null, V8Js::FLAG_FORCE_ARRAY) );
13+
14+
?>
15+
===EOF===
16+
--EXPECT--
17+
string(7) "October"
18+
===EOF===

v8js_v8.cc

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -76,6 +76,11 @@ void v8js_v8_init() /* {{{ */
7676
}
7777
}
7878

79+
#ifdef PHP_V8_EXEC_PATH
80+
/* Initialize ICU */
81+
v8::V8::InitializeICUDefaultLocation(PHP_V8_EXEC_PATH, nullptr);
82+
#endif
83+
7984
/* Initialize V8 */
8085
v8::V8::Initialize();
8186

0 commit comments

Comments
 (0)