mirror of
https://github.com/bdnugget/php-src.git
synced 2026-11-24 17:35:41 +00:00
Compare commits
127
Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
ac9bbcd370 | ||
|
|
91a04638e6 | ||
|
|
380a1ea142 | ||
|
|
efb68d9399 | ||
|
|
b6921369b5 | ||
|
|
f2ce9b406b | ||
|
|
07b7ba8b40 | ||
|
|
41ddca803d | ||
|
|
0d73145490 | ||
|
|
d4ae4e79db | ||
|
|
1f78177e2b | ||
|
|
63b934b9c7 | ||
|
|
05c5c8958e | ||
|
|
0a1cc5f01c | ||
|
|
1551cc62db | ||
|
|
a1de339e17 | ||
|
|
136a9ca2cc | ||
|
|
4168e0dfe4 | ||
|
|
bbf59ae4da | ||
|
|
d080277d97 | ||
|
|
71eaaf6567 | ||
|
|
b5f5770399 | ||
|
|
33eb2ab6f1 | ||
|
|
c75a4a408b | ||
|
|
d4e0ef5dc9 | ||
|
|
90ef61d587 | ||
|
|
085c3de991 | ||
|
|
236fb29289 | ||
|
|
6c1fe05d61 | ||
|
|
eb039d5783 | ||
|
|
da110e2065 | ||
|
|
891ca5cae3 | ||
|
|
17cbee6ffe | ||
|
|
e14354af21 | ||
|
|
62fd3369cb | ||
|
|
469fc0a341 | ||
|
|
1034cbc758 | ||
|
|
12c1f0b0d9 | ||
|
|
fb88ef7231 | ||
|
|
81565fdf45 | ||
|
|
1744885c62 | ||
|
|
4ffc16611d | ||
|
|
5b1efc1d87 | ||
|
|
eb0f361439 | ||
|
|
c3019a16d5 | ||
|
|
3cddf1d7b5 | ||
|
|
2f3adeb083 | ||
|
|
567e2f1cf3 | ||
|
|
2e925f6f19 | ||
|
|
24cbd8f3fe | ||
|
|
4750c3fbe1 | ||
|
|
66d25f5266 | ||
|
|
50662f83ec | ||
|
|
5fba3ba7c3 | ||
|
|
3dabada846 | ||
|
|
0e6250fcff | ||
|
|
ecfa660a82 | ||
|
|
736ada5931 | ||
|
|
5ae7564890 | ||
|
|
38d485ca41 | ||
|
|
3b4b1a79b6 | ||
|
|
9c2f27a380 | ||
|
|
05389f7752 | ||
|
|
4e4ad9aa26 | ||
|
|
1cab3610de | ||
|
|
9f5f4d5401 | ||
|
|
d435ddbe52 | ||
|
|
60bf324ed5 | ||
|
|
f50f54a6ea | ||
|
|
223e2ac106 | ||
|
|
9da3e6c1a6 | ||
|
|
96240fc3ed | ||
|
|
d050fa87d4 | ||
|
|
3fd08b3bd4 | ||
|
|
579408b897 | ||
|
|
f11500df0c | ||
|
|
a6a3bd010a | ||
|
|
bf2dfb5fff | ||
|
|
46f74e3523 | ||
|
|
c58f254354 | ||
|
|
f5ec360df7 | ||
|
|
d938844d8f | ||
|
|
88c52b0dac | ||
|
|
61c001b2e8 | ||
|
|
ea74b9c212 | ||
|
|
a52d3efe08 | ||
|
|
75893abe89 | ||
|
|
f71b3cdd67 | ||
|
|
0839aee404 | ||
|
|
8933798d36 | ||
|
|
172d037068 | ||
|
|
d603d05398 | ||
|
|
679c87e999 | ||
|
|
0203c31f78 | ||
|
|
c83594cd7a | ||
|
|
f3aa34a90d | ||
|
|
82be5fcc4f | ||
|
|
3c365dc3ef | ||
|
|
1b9fbe540e | ||
|
|
0df4c5caea | ||
|
|
00bab0493e | ||
|
|
5dbf73a866 | ||
|
|
6bd693543b | ||
|
|
3e221129a7 | ||
|
|
85a62e9086 | ||
|
|
2122879a7a | ||
|
|
3ac5593cda | ||
|
|
6c2b670e69 | ||
|
|
a68abe830d | ||
|
|
56f265075d | ||
|
|
26c1a62b34 | ||
|
|
5441cd1f0d | ||
|
|
258c8de7fb | ||
|
|
39c6382b14 | ||
|
|
b5edcb56cb | ||
|
|
63293044f9 | ||
|
|
c6b74fe209 | ||
|
|
c3741ad973 | ||
|
|
d6ab6bc6ea | ||
|
|
56a161b619 | ||
|
|
a0526b9452 | ||
|
|
610fabf414 | ||
|
|
c2a92317f4 | ||
|
|
a223328b52 | ||
|
|
3620a91669 | ||
|
|
c32aa35d58 | ||
|
|
f5b8a3b40e |
No files matched your search
@@ -1,6 +1,57 @@
|
||||
PHP NEWS
|
||||
|||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
||||
15 Sep 2011, PHP 5.4.0 Beta
|
||||
20 Oct 2011, PHP 5.4.0 beta2
|
||||
- General improvements:
|
||||
. Improve the warning message of incompatible arguments. (Laruence)
|
||||
. Improve ternary operator performance when returning arrays. (Arnaud, Dmitry)
|
||||
|
||||
- Core:
|
||||
. Fixed bug #55749 (TOCTOU issue in getenv() on Windows builds). (Pierre)
|
||||
. Fixed bug #55707 (undefined reference to `__sync_fetch_and_add_4' on Linux
|
||||
parisc). (Felipe)
|
||||
. Fixed bug #55705 (Omitting a callable typehinted argument causes a segfault).
|
||||
(Felipe, Laruence)
|
||||
. Fixed bug #55758 (Digest Authenticate missed in 5.4) . (Laruence)
|
||||
. Fixed bug #55622 (memory corruption in parse_ini_string). (Pierre)
|
||||
. Fixed bug #55825 (Missing initial value of static locals in trait methods).
|
||||
(Laruence)
|
||||
. Fixed bug #60038 (SIGALRM cause segfault in php_error_cb). (Laruence)
|
||||
|
||||
- Openssl
|
||||
. Revert r313616 (When we have a blocking SSL socket, respect the timeout
|
||||
option, scottmac), breaks ssl support as described in bugs #55283 and #55848
|
||||
|
||||
- PDO DBlib driver:
|
||||
. Fixed bug #60033 (Incorrectly merged PDO dblib patches break
|
||||
uniqueidentifier column type). (warezthebeef at gmail dot com)
|
||||
|
||||
- Sysvshm
|
||||
. Fixed bug #55750 (memory copy issue in sysvshm extension).
|
||||
(Ilia, jeffhuang9999 at gmail dot com)
|
||||
|
||||
- Zlib:
|
||||
. Fixed bug #55544 (ob_gzhandler always conflicts with
|
||||
zlib.output_compression). (Mike)
|
||||
|
||||
- SPL:
|
||||
. FilesystemIterator, GlobIterator and (Recursive)DirectoryIterator now use
|
||||
the default stream context. (Hannes)
|
||||
. Fixed bug #55807 (Wrong value for splFileObject::SKIP_EMPTY).
|
||||
(jgotti at modedemploi dot fr, Hannes)
|
||||
|
||||
- CLI SAPI:
|
||||
. Fixed bug #55726 (Changing the working directory makes router script
|
||||
inaccessible). (Laruence)
|
||||
. Fixed bug #55747 (request headers missed in $_SERVER). (Laruence)
|
||||
. Fixed bug #55755 (SegFault when outputting header WWW-Authenticate). (Laruence)
|
||||
|
||||
- Litespeed SAPI:
|
||||
. Fixed bug #55769 (Make Fails with "Missing Separator" error). (Adam)
|
||||
|
||||
- Fileinfo:
|
||||
. Fixed bug #60094 (C++ comment fails in c89). (Laruence)
|
||||
|
||||
15 Sep 2011, PHP 5.4.0 Beta1
|
||||
- General improvements:
|
||||
. Added callable typehint. (Hannes)
|
||||
. Implemented closure rebinding as parameter to bindTo. (Gustavo Lopes)
|
||||
|
||||
@@ -202,6 +202,35 @@ function read_str_offset($n) {
|
||||
}
|
||||
}
|
||||
|
||||
function issetor($n) {
|
||||
$val = array(0,1,2,3,4,5,6,7,8,9);
|
||||
for ($i = 0; $i < $n; ++$i) {
|
||||
$x = $val ?: null;
|
||||
}
|
||||
}
|
||||
|
||||
function issetor2($n) {
|
||||
$f = false; $j = 0;
|
||||
for ($i = 0; $i < $n; ++$i) {
|
||||
$x = $f ?: $j + 1;
|
||||
}
|
||||
}
|
||||
|
||||
function ternary($n) {
|
||||
$val = array(0,1,2,3,4,5,6,7,8,9);
|
||||
$f = false;
|
||||
for ($i = 0; $i < $n; ++$i) {
|
||||
$x = $f ? null : $val;
|
||||
}
|
||||
}
|
||||
|
||||
function ternary2($n) {
|
||||
$f = false; $j = 0;
|
||||
for ($i = 0; $i < $n; ++$i) {
|
||||
$x = $f ? $f : $j + 1;
|
||||
}
|
||||
}
|
||||
|
||||
/*****/
|
||||
|
||||
function empty_loop($n) {
|
||||
@@ -318,4 +347,12 @@ read_hash(N);
|
||||
$t = end_test($t, '$x = $hash[\'v\']', $overhead);
|
||||
read_str_offset(N);
|
||||
$t = end_test($t, '$x = $str[0]', $overhead);
|
||||
issetor(N);
|
||||
$t = end_test($t, '$x = $a ?: null', $overhead);
|
||||
issetor2(N);
|
||||
$t = end_test($t, '$x = $f ?: tmp', $overhead);
|
||||
ternary(N);
|
||||
$t = end_test($t, '$x = $f ? $f : $a', $overhead);
|
||||
ternary2(N);
|
||||
$t = end_test($t, '$x = $f ? $f : tmp', $overhead);
|
||||
total($t0, "Total");
|
||||
@@ -0,0 +1,16 @@
|
||||
--TEST--
|
||||
Bug #55719 (Argument restriction should come with a more specific error message)
|
||||
--FILE--
|
||||
<?php
|
||||
Class Base {
|
||||
public function &test($foo, array $bar, $option = NULL, $extra = "lllllllllllllllllllllllllllllllllllllllllllllllllll") {
|
||||
}
|
||||
}
|
||||
|
||||
class Sub extends Base {
|
||||
public function &test() {
|
||||
}
|
||||
}
|
||||
?>
|
||||
--EXPECTF--
|
||||
Strict Standards: Declaration of Sub::test() should be compatible with & Base::test($foo, array $bar, $option = NULL, $extra = 'llllllllll...') in %sargument_restriction_001.php on line %d
|
||||
@@ -0,0 +1,16 @@
|
||||
--TEST--
|
||||
Bug #55719 (Argument restriction should come with a more specific error message)
|
||||
--FILE--
|
||||
<?php
|
||||
Abstract Class Base {
|
||||
public function test($foo, array &$bar, $option = NULL, $extra = 3.141592653589793238462643383279502884197169399375105 ) {
|
||||
}
|
||||
}
|
||||
|
||||
class Sub extends Base {
|
||||
public function test($foo, array &$bar) {
|
||||
}
|
||||
}
|
||||
?>
|
||||
--EXPECTF--
|
||||
Strict Standards: Declaration of Sub::test() should be compatible with Base::test($foo, array &$bar, $option = NULL, $extra = 3.1415926535898) in %sargument_restriction_002.php on line %d
|
||||
@@ -0,0 +1,19 @@
|
||||
--TEST--
|
||||
Bug #55719 (Argument restriction should come with a more specific error message)
|
||||
--FILE--
|
||||
<?php
|
||||
class Foo {
|
||||
}
|
||||
|
||||
Abstract Class Base {
|
||||
public function test(Foo $foo, array $bar, $option = NULL, $extra = "lllllllllllllllllllllllllllllllllllllllllllllllllll") {
|
||||
}
|
||||
}
|
||||
|
||||
class Sub extends Base {
|
||||
public function test() {
|
||||
}
|
||||
}
|
||||
?>
|
||||
--EXPECTF--
|
||||
Strict Standards: Declaration of Sub::test() should be compatible with Base::test(Foo $foo, array $bar, $option = NULL, $extra = 'llllllllll...') in %sargument_restriction_003.php on line %d
|
||||
@@ -0,0 +1,17 @@
|
||||
--TEST--
|
||||
Bug #55719 (Argument restriction should come with a more specific error message)
|
||||
--FILE--
|
||||
<?php
|
||||
class Foo {
|
||||
}
|
||||
|
||||
Abstract Class Base {
|
||||
abstract public function test(Foo $foo, array $bar, $option = NULL, $extra = 16777215) ;
|
||||
}
|
||||
|
||||
class Sub extends Base {
|
||||
public function test(Foo $foo, array $bar, $option = NULL, $extra = 0xffffff ) {
|
||||
}
|
||||
}
|
||||
?>
|
||||
--EXPECTF--
|
||||
@@ -0,0 +1,11 @@
|
||||
--TEST--
|
||||
Bug #55719 (Argument restriction should come with a more specific error message)
|
||||
--FILE--
|
||||
<?php
|
||||
class Sub implements ArrayAccess {
|
||||
public function offsetSet() {
|
||||
}
|
||||
}
|
||||
?>
|
||||
--EXPECTF--
|
||||
Fatal error: Declaration of Sub::offsetSet() must be compatible with ArrayAccess::offsetSet($offset, $value) in %sargument_restriction_005.php on line %d
|
||||
@@ -14,6 +14,6 @@ class b implements a { function f($a=1) {}}
|
||||
class c extends b {function f() {}}
|
||||
?>
|
||||
--EXPECTF--
|
||||
string(62) "Declaration of c::f() should be compatible with that of b::f()"
|
||||
string(60) "Declaration of c::f() should be compatible with b::f($a = 1)"
|
||||
|
||||
|
||||
@@ -15,4 +15,4 @@ class Test extends TestInterface {
|
||||
|
||||
?>
|
||||
--EXPECTF--
|
||||
Fatal error: Declaration of Test::__construct() must be compatible with that of TestInterface::__construct() in %s on line %d
|
||||
Fatal error: Declaration of Test::__construct() must be compatible with TestInterface::__construct(ExampleClass $var) in %s on line %d
|
||||
@@ -30,4 +30,4 @@ echo "6\n";
|
||||
4
|
||||
5
|
||||
|
||||
Fatal error: Allowed memory size of %d bytes exhausted (tried to allocate %d bytes) in %s/bug55509.php on line %d
|
||||
Fatal error: Allowed memory size of %d bytes exhausted%s(tried to allocate %d bytes) in %sbug55509.php on line %d
|
||||
@@ -0,0 +1,9 @@
|
||||
--TEST--
|
||||
Bug #55705 (Omitting a callable typehinted argument causes a segfault)
|
||||
--FILE--
|
||||
<?php
|
||||
function f(callable $c) {}
|
||||
f();
|
||||
?>
|
||||
--EXPECTF--
|
||||
Catchable fatal error: Argument 1 passed to f() must be callable, none given, called in %s on line 3 and defined in %s on line %d
|
||||
@@ -0,0 +1,17 @@
|
||||
--TEST--
|
||||
Bug #55825 (Missing initial value of static locals in trait methods)
|
||||
--FILE--
|
||||
<?php
|
||||
trait T1 {
|
||||
public function inc() {
|
||||
static $x=1;
|
||||
echo $x++ . "\n";
|
||||
}
|
||||
}
|
||||
class C { use T1; }
|
||||
$c1 = new C;
|
||||
$c1->inc();
|
||||
$c1->inc();
|
||||
--EXPECT--
|
||||
1
|
||||
2
|
||||
@@ -20,5 +20,5 @@ class test3 extends test {
|
||||
echo "Done\n";
|
||||
?>
|
||||
--EXPECTF--
|
||||
Strict Standards: Declaration of test3::foo() should be compatible with that of test::foo() in %s on line %d
|
||||
Strict Standards: Declaration of test3::foo() should be compatible with test::foo() in %s on line %d
|
||||
Done
|
||||
@@ -20,5 +20,5 @@ class test3 extends test {
|
||||
echo "Done\n";
|
||||
?>
|
||||
--EXPECTF--
|
||||
Strict Standards: Declaration of test3::foo() should be compatible with that of test::foo() in %s on line %d
|
||||
Strict Standards: Declaration of test3::foo() should be compatible with test::foo($arg) in %s on line %d
|
||||
Done
|
||||
@@ -20,5 +20,5 @@ class test3 extends test {
|
||||
echo "Done\n";
|
||||
?>
|
||||
--EXPECTF--
|
||||
Strict Standards: Declaration of test3::foo() should be compatible with that of test::foo() in %s on line %d
|
||||
Strict Standards: Declaration of test3::foo() should be compatible with test::foo($arg) in %s on line %d
|
||||
Done
|
||||
@@ -20,5 +20,5 @@ class test3 extends test {
|
||||
echo "Done\n";
|
||||
?>
|
||||
--EXPECTF--
|
||||
Strict Standards: Declaration of test3::foo() should be compatible with that of test::foo() in %s on line %d
|
||||
Strict Standards: Declaration of test3::foo() should be compatible with & test::foo() in %s on line %d
|
||||
Done
|
||||
@@ -20,5 +20,5 @@ class test3 extends test {
|
||||
echo "Done\n";
|
||||
?>
|
||||
--EXPECTF--
|
||||
Strict Standards: Declaration of test3::foo() should be compatible with that of test::foo() in %s on line %d
|
||||
Strict Standards: Declaration of test3::foo() should be compatible with test::foo($arg, $arg2 = NULL) in %s on line %d
|
||||
Done
|
||||
@@ -20,5 +20,5 @@ class test3 extends test {
|
||||
echo "Done\n";
|
||||
?>
|
||||
--EXPECTF--
|
||||
Strict Standards: Declaration of test3::foo() should be compatible with that of test::foo() in %s on line %d
|
||||
Strict Standards: Declaration of test3::foo() should be compatible with test::foo($arg, &$arg2 = NULL) in %s on line %d
|
||||
Done
|
||||
@@ -20,5 +20,5 @@ class test3 extends test {
|
||||
echo "Done\n";
|
||||
?>
|
||||
--EXPECTF--
|
||||
Strict Standards: Declaration of test3::foo() should be compatible with that of test::foo() in %s on line %d
|
||||
Strict Standards: Declaration of test3::foo() should be compatible with test::foo(Test $arg) in %s on line %d
|
||||
Done
|
||||
@@ -20,5 +20,5 @@ class test3 extends test {
|
||||
echo "Done\n";
|
||||
?>
|
||||
--EXPECTF--
|
||||
Strict Standards: Declaration of test3::foo() should be compatible with that of test::foo() in %s on line %d
|
||||
Strict Standards: Declaration of test3::foo() should be compatible with test::foo(Test $arg) in %s on line %d
|
||||
Done
|
||||
@@ -0,0 +1,34 @@
|
||||
--TEST--
|
||||
Bug #55137 (Legacy constructor not registered for class)
|
||||
--FILE--
|
||||
<?php
|
||||
|
||||
// All constructors should be registered as such
|
||||
|
||||
trait TConstructor {
|
||||
public function constructor() {
|
||||
echo "ctor executed\n";
|
||||
}
|
||||
}
|
||||
|
||||
class NewConstructor {
|
||||
use TConstructor {
|
||||
constructor as __construct;
|
||||
}
|
||||
}
|
||||
|
||||
class LegacyConstructor {
|
||||
use TConstructor {
|
||||
constructor as LegacyConstructor;
|
||||
}
|
||||
}
|
||||
|
||||
echo "New constructor: ";
|
||||
$o = new NewConstructor;
|
||||
|
||||
echo "Legacy constructor: ";
|
||||
$o = new LegacyConstructor;
|
||||
|
||||
--EXPECT--
|
||||
New constructor: ctor executed
|
||||
Legacy constructor: ctor executed
|
||||
@@ -0,0 +1,56 @@
|
||||
--TEST--
|
||||
Bug #55137 (Legacy constructor not registered for class)
|
||||
--FILE--
|
||||
<?php
|
||||
|
||||
trait TConstructor {
|
||||
public function foo() {
|
||||
echo "foo executed\n";
|
||||
}
|
||||
public function bar() {
|
||||
echo "bar executed\n";
|
||||
}
|
||||
}
|
||||
|
||||
class OverridingIsSilent1 {
|
||||
use TConstructor {
|
||||
foo as __construct;
|
||||
}
|
||||
|
||||
public function __construct() {
|
||||
echo "OverridingIsSilent1 __construct\n";
|
||||
}
|
||||
}
|
||||
|
||||
$o = new OverridingIsSilent1;
|
||||
|
||||
class OverridingIsSilent2 {
|
||||
use TConstructor {
|
||||
foo as OverridingIsSilent2;
|
||||
}
|
||||
|
||||
public function OverridingIsSilent2() {
|
||||
echo "OverridingIsSilent2 OverridingIsSilent2\n";
|
||||
}
|
||||
}
|
||||
|
||||
$o = new OverridingIsSilent2;
|
||||
|
||||
class ReportCollision {
|
||||
use TConstructor {
|
||||
bar as ReportCollision;
|
||||
foo as __construct;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
echo "ReportCollision: ";
|
||||
$o = new ReportCollision;
|
||||
|
||||
|
||||
--EXPECTF--
|
||||
OverridingIsSilent1 __construct
|
||||
OverridingIsSilent2 OverridingIsSilent2
|
||||
|
||||
Fatal error: ReportCollision has colliding constructor definitions coming from traits in %s on line %d
|
||||
|
||||
@@ -0,0 +1,46 @@
|
||||
--TEST--
|
||||
Bug #55137 (Legacy constructor not registered for class)
|
||||
--FILE--
|
||||
<?php
|
||||
|
||||
// Test that the behavior is consistent with the existing handling of new
|
||||
// and legacy constructors.
|
||||
// Here, the traits conflicts are overridden by local definitions,
|
||||
// and the two constructor definitions do not directly collide in that case.
|
||||
|
||||
trait TC1 {
|
||||
public function __construct() {
|
||||
echo "TC1 executed\n";
|
||||
}
|
||||
public function ReportCollision() {
|
||||
echo "TC1 executed\n";
|
||||
}
|
||||
}
|
||||
|
||||
trait TC2 {
|
||||
public function __construct() {
|
||||
echo "TC2 executed\n";
|
||||
}
|
||||
public function ReportCollision() {
|
||||
echo "TC1 executed\n";
|
||||
}
|
||||
}
|
||||
|
||||
class ReportCollision {
|
||||
use TC1, TC2;
|
||||
|
||||
public function __construct() {
|
||||
echo "New constructor executed\n";
|
||||
}
|
||||
public function ReportCollision() {
|
||||
echo "Legacy constructor executed\n";
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
echo "ReportCollision: ";
|
||||
$o = new ReportCollision;
|
||||
|
||||
|
||||
--EXPECTF--
|
||||
ReportCollision: New constructor executed
|
||||
@@ -0,0 +1,32 @@
|
||||
--TEST--
|
||||
Bug #55137 (Legacy constructor not registered for class)
|
||||
--FILE--
|
||||
<?php
|
||||
|
||||
// Test mixed constructors from different traits, we are more strict about
|
||||
// these cases, since that can lead to un-expected behavior.
|
||||
// It is not consistent with the normal constructor handling, but
|
||||
// here we have a chance to be more strict for the new traits.
|
||||
|
||||
trait TNew {
|
||||
public function __construct() {
|
||||
echo "TNew executed\n";
|
||||
}
|
||||
}
|
||||
|
||||
trait TLegacy {
|
||||
public function ReportCollision() {
|
||||
echo "ReportCollision executed\n";
|
||||
}
|
||||
}
|
||||
|
||||
class ReportCollision {
|
||||
use TNew, TLegacy;
|
||||
}
|
||||
|
||||
$o = new ReportCollision;
|
||||
|
||||
--EXPECTF--
|
||||
|
||||
Fatal error: ReportCollision has colliding constructor definitions coming from traits in %s on line %d
|
||||
|
||||
@@ -0,0 +1,30 @@
|
||||
--TEST--
|
||||
Bug #55137 (Legacy constructor not registered for class)
|
||||
--FILE--
|
||||
<?php
|
||||
|
||||
// Ensuring that the collision still occurs as expected.
|
||||
|
||||
trait TC1 {
|
||||
public function ReportCollision() {
|
||||
echo "TC1 executed\n";
|
||||
}
|
||||
}
|
||||
|
||||
trait TC2 {
|
||||
public function ReportCollision() {
|
||||
echo "TC1 executed\n";
|
||||
}
|
||||
}
|
||||
|
||||
class ReportCollision {
|
||||
use TC1, TC2;
|
||||
}
|
||||
|
||||
|
||||
echo "ReportCollision: ";
|
||||
$o = new ReportCollision;
|
||||
|
||||
|
||||
--EXPECTF--
|
||||
Fatal error: Trait method ReportCollision has not been applied, because there are collisions with other trait methods on ReportCollision in %s on line %d
|
||||
@@ -0,0 +1,29 @@
|
||||
--TEST--
|
||||
Bug #55137 (Legacy constructor not registered for class)
|
||||
--FILE--
|
||||
<?php
|
||||
|
||||
// Ensuring that inconsistent constructor use results in an error to avoid
|
||||
// problems creeping in.
|
||||
|
||||
trait TNew {
|
||||
public function __construct() {
|
||||
echo "TNew executed\n";
|
||||
}
|
||||
}
|
||||
|
||||
class ReportCollision {
|
||||
use TNew;
|
||||
|
||||
public function ReportCollision() {
|
||||
echo "ReportCollision executed\n";
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
echo "ReportCollision: ";
|
||||
$o = new ReportCollision;
|
||||
|
||||
|
||||
--EXPECTF--
|
||||
Fatal error: ReportCollision has colliding constructor definitions coming from traits in %s on line %d
|
||||
@@ -0,0 +1,29 @@
|
||||
--TEST--
|
||||
Bug #55137 (Legacy constructor not registered for class)
|
||||
--FILE--
|
||||
<?php
|
||||
|
||||
// Ensuring that inconsistent constructor use results in an error to avoid
|
||||
// problems creeping in.
|
||||
|
||||
trait TLegacy {
|
||||
public function ReportCollision() {
|
||||
echo "TLegacy executed\n";
|
||||
}
|
||||
}
|
||||
|
||||
class ReportCollision {
|
||||
use TLegacy;
|
||||
|
||||
public function __construct() {
|
||||
echo "ReportCollision executed\n";
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
echo "ReportCollision: ";
|
||||
$o = new ReportCollision;
|
||||
|
||||
|
||||
--EXPECTF--
|
||||
Fatal error: ReportCollision has colliding constructor definitions coming from traits in %s on line %d
|
||||
@@ -35,4 +35,4 @@ $o->sayHello(array());
|
||||
--EXPECTF--
|
||||
World!
|
||||
|
||||
Fatal error: Declaration of MyHelloWorld::sayHello() must be compatible with that of Base::sayHello() in %s on line %d
|
||||
Fatal error: Declaration of MyHelloWorld::sayHello() must be compatible with Base::sayHello(array $a) in %s on line %d
|
||||
@@ -22,13 +22,13 @@ trait C {
|
||||
}
|
||||
}
|
||||
|
||||
class Foo {
|
||||
class MyClass {
|
||||
use C, A, B {
|
||||
B::foo insteadof A, C;
|
||||
}
|
||||
}
|
||||
|
||||
$t = new Foo;
|
||||
$t = new MyClass;
|
||||
$t->foo();
|
||||
|
||||
?>
|
||||
|
||||
@@ -871,7 +871,7 @@ static void is_a_impl(INTERNAL_FUNCTION_PARAMETERS, zend_bool only_subclass)
|
||||
}
|
||||
|
||||
|
||||
/* {{{ proto bool is_subclass_of(object object, string class_name)
|
||||
/* {{{ proto bool is_subclass_of(mixed object, string class_name)
|
||||
Returns true if the object has this class as one of its parents */
|
||||
ZEND_FUNCTION(is_subclass_of)
|
||||
{
|
||||
@@ -880,7 +880,7 @@ ZEND_FUNCTION(is_subclass_of)
|
||||
/* }}} */
|
||||
|
||||
|
||||
/* {{{ proto bool is_a(object object, string class_name)
|
||||
/* {{{ proto bool is_a(mixed object, string class_name)
|
||||
Returns true if the object is of this class or has this class as one of its parents */
|
||||
ZEND_FUNCTION(is_a)
|
||||
{
|
||||
|
||||
+238
-32
@@ -1469,7 +1469,8 @@ void zend_do_free(znode *op1 TSRMLS_DC) /* {{{ */
|
||||
&& opline->result.var == op1->u.op.var) {
|
||||
if (opline->opcode == ZEND_FETCH_R ||
|
||||
opline->opcode == ZEND_FETCH_DIM_R ||
|
||||
opline->opcode == ZEND_FETCH_OBJ_R) {
|
||||
opline->opcode == ZEND_FETCH_OBJ_R ||
|
||||
opline->opcode == ZEND_QM_ASSIGN_VAR) {
|
||||
/* It's very rare and useless case. It's better to use
|
||||
additional FREE opcode and simplify the FETCH handlers
|
||||
their selves */
|
||||
@@ -2487,7 +2488,7 @@ void zend_do_pass_param(znode *param, zend_uchar op, int offset TSRMLS_DC) /* {{
|
||||
|
||||
if (function_ptr) {
|
||||
if (ARG_MAY_BE_SENT_BY_REF(function_ptr, (zend_uint) offset)) {
|
||||
if (param->op_type & (IS_VAR|IS_CV)) {
|
||||
if (param->op_type & (IS_VAR|IS_CV) && original_op != ZEND_SEND_VAL) {
|
||||
send_by_reference = 1;
|
||||
if (op == ZEND_SEND_VAR && zend_is_function_or_method_call(param)) {
|
||||
/* Method call */
|
||||
@@ -3010,7 +3011,161 @@ static zend_bool zend_do_perform_implementation_check(const zend_function *fe, c
|
||||
}
|
||||
/* }}} */
|
||||
|
||||
static void do_inheritance_check_on_method(zend_function *child, zend_function *parent TSRMLS_DC)
|
||||
#define REALLOC_BUF_IF_EXCEED(buf, offset, length, size) \
|
||||
if (UNEXPECTED(offset - buf + size >= length)) { \
|
||||
length += size + 1; \
|
||||
buf = erealloc(buf, length); \
|
||||
}
|
||||
|
||||
static char * zend_get_function_declaration(zend_function *fptr TSRMLS_DC) /* {{{ */
|
||||
{
|
||||
char *offset, *buf;
|
||||
zend_uint length = 1024;
|
||||
|
||||
offset = buf = (char *)emalloc(length * sizeof(char));
|
||||
if (fptr->op_array.fn_flags & ZEND_ACC_RETURN_REFERENCE) {
|
||||
*(offset++) = '&';
|
||||
*(offset++) = ' ';
|
||||
}
|
||||
|
||||
if (fptr->common.scope) {
|
||||
memcpy(offset, fptr->common.scope->name, fptr->common.scope->name_length);
|
||||
offset += fptr->common.scope->name_length;
|
||||
*(offset++) = ':';
|
||||
*(offset++) = ':';
|
||||
}
|
||||
|
||||
{
|
||||
size_t name_len = strlen(fptr->common.function_name);
|
||||
REALLOC_BUF_IF_EXCEED(buf, offset, length, name_len);
|
||||
memcpy(offset, fptr->common.function_name, name_len);
|
||||
offset += name_len;
|
||||
}
|
||||
|
||||
*(offset++) = '(';
|
||||
if (fptr->common.arg_info) {
|
||||
zend_uint i, required;
|
||||
zend_arg_info *arg_info = fptr->common.arg_info;
|
||||
|
||||
required = fptr->common.required_num_args;
|
||||
for (i = 0; i < fptr->common.num_args;) {
|
||||
if (arg_info->class_name) {
|
||||
REALLOC_BUF_IF_EXCEED(buf, offset, length, arg_info->class_name_len);
|
||||
memcpy(offset, arg_info->class_name, arg_info->class_name_len);
|
||||
offset += arg_info->class_name_len;
|
||||
*(offset++) = ' ';
|
||||
} else if (arg_info->type_hint) {
|
||||
zend_uint type_name_len;
|
||||
char *type_name = zend_get_type_by_const(arg_info->type_hint);
|
||||
type_name_len = strlen(type_name);
|
||||
REALLOC_BUF_IF_EXCEED(buf, offset, length, type_name_len);
|
||||
memcpy(offset, type_name, type_name_len);
|
||||
offset += type_name_len;
|
||||
*(offset++) = ' ';
|
||||
}
|
||||
|
||||
if (arg_info->pass_by_reference) {
|
||||
*(offset++) = '&';
|
||||
}
|
||||
*(offset++) = '$';
|
||||
|
||||
if (arg_info->name) {
|
||||
REALLOC_BUF_IF_EXCEED(buf, offset, length, arg_info->name_len);
|
||||
memcpy(offset, arg_info->name, arg_info->name_len);
|
||||
offset += arg_info->name_len;
|
||||
} else {
|
||||
zend_uint idx = i;
|
||||
memcpy(offset, "param", 5);
|
||||
offset += 5;
|
||||
do {
|
||||
*(offset++) = (char) (idx % 10) + '0';
|
||||
idx /= 10;
|
||||
} while (idx > 0);
|
||||
}
|
||||
if (i >= required) {
|
||||
*(offset++) = ' ';
|
||||
*(offset++) = '=';
|
||||
*(offset++) = ' ';
|
||||
if (fptr->type == ZEND_USER_FUNCTION) {
|
||||
zend_op *precv = NULL;
|
||||
{
|
||||
zend_uint idx = i;
|
||||
zend_op *op = ((zend_op_array *)fptr)->opcodes;
|
||||
zend_op *end = op + ((zend_op_array *)fptr)->last;
|
||||
|
||||
++idx;
|
||||
while (op < end) {
|
||||
if ((op->opcode == ZEND_RECV || op->opcode == ZEND_RECV_INIT)
|
||||
&& op->op1.num == (long)idx)
|
||||
{
|
||||
precv = op;
|
||||
}
|
||||
++op;
|
||||
}
|
||||
}
|
||||
if (precv && precv->opcode == ZEND_RECV_INIT && precv->op2_type != IS_UNUSED) {
|
||||
zval *zv, zv_copy;
|
||||
int use_copy;
|
||||
ALLOC_ZVAL(zv);
|
||||
*zv = *precv->op2.zv;
|
||||
zval_copy_ctor(zv);
|
||||
INIT_PZVAL(zv);
|
||||
zval_update_constant_ex(&zv, (void*)1, fptr->common.scope TSRMLS_CC);
|
||||
if (Z_TYPE_P(zv) == IS_BOOL) {
|
||||
if (Z_LVAL_P(zv)) {
|
||||
memcpy(offset, "true", 4);
|
||||
offset += 4;
|
||||
} else {
|
||||
memcpy(offset, "false", 5);
|
||||
offset += 5;
|
||||
}
|
||||
} else if (Z_TYPE_P(zv) == IS_NULL) {
|
||||
memcpy(offset, "NULL", 4);
|
||||
offset += 4;
|
||||
} else if (Z_TYPE_P(zv) == IS_STRING) {
|
||||
*(offset++) = '\'';
|
||||
REALLOC_BUF_IF_EXCEED(buf, offset, length, MIN(Z_STRLEN_P(zv), 10));
|
||||
memcpy(offset, Z_STRVAL_P(zv), MIN(Z_STRLEN_P(zv), 10));
|
||||
offset += MIN(Z_STRLEN_P(zv), 10);
|
||||
if (Z_STRLEN_P(zv) > 10) {
|
||||
*(offset++) = '.';
|
||||
*(offset++) = '.';
|
||||
*(offset++) = '.';
|
||||
}
|
||||
*(offset++) = '\'';
|
||||
} else {
|
||||
zend_make_printable_zval(zv, &zv_copy, &use_copy);
|
||||
REALLOC_BUF_IF_EXCEED(buf, offset, length, Z_STRLEN(zv_copy));
|
||||
memcpy(offset, Z_STRVAL(zv_copy), Z_STRLEN(zv_copy));
|
||||
offset += Z_STRLEN(zv_copy);
|
||||
if (use_copy) {
|
||||
zval_dtor(&zv_copy);
|
||||
}
|
||||
}
|
||||
zval_ptr_dtor(&zv);
|
||||
}
|
||||
} else {
|
||||
memcpy(offset, "NULL", 4);
|
||||
offset += 4;
|
||||
}
|
||||
}
|
||||
|
||||
if (++i < fptr->common.num_args) {
|
||||
*(offset++) = ',';
|
||||
*(offset++) = ' ';
|
||||
}
|
||||
arg_info++;
|
||||
REALLOC_BUF_IF_EXCEED(buf, offset, length, 23);
|
||||
}
|
||||
}
|
||||
*(offset++) = ')';
|
||||
*offset = '\0';
|
||||
|
||||
return buf;
|
||||
}
|
||||
/* }}} */
|
||||
|
||||
static void do_inheritance_check_on_method(zend_function *child, zend_function *parent TSRMLS_DC) /* {{{ */
|
||||
{
|
||||
zend_uint child_flags;
|
||||
zend_uint parent_flags = parent->common.fn_flags;
|
||||
@@ -3069,14 +3224,17 @@ static void do_inheritance_check_on_method(zend_function *child, zend_function *
|
||||
|
||||
if (child->common.prototype && (child->common.prototype->common.fn_flags & ZEND_ACC_ABSTRACT)) {
|
||||
if (!zend_do_perform_implementation_check(child, child->common.prototype TSRMLS_CC)) {
|
||||
zend_error(E_COMPILE_ERROR, "Declaration of %s::%s() must be compatible with that of %s::%s()", ZEND_FN_SCOPE_NAME(child), child->common.function_name, ZEND_FN_SCOPE_NAME(child->common.prototype), child->common.prototype->common.function_name);
|
||||
zend_error(E_COMPILE_ERROR, "Declaration of %s::%s() must be compatible with %s", ZEND_FN_SCOPE_NAME(child), child->common.function_name, zend_get_function_declaration(child->common.prototype TSRMLS_CC));
|
||||
}
|
||||
} else if (EG(error_reporting) & E_STRICT || EG(user_error_handler)) { /* Check E_STRICT (or custom error handler) before the check so that we save some time */
|
||||
if (!zend_do_perform_implementation_check(child, parent TSRMLS_CC)) {
|
||||
zend_error(E_STRICT, "Declaration of %s::%s() should be compatible with that of %s::%s()", ZEND_FN_SCOPE_NAME(child), child->common.function_name, ZEND_FN_SCOPE_NAME(parent), parent->common.function_name);
|
||||
char *method_prototype = zend_get_function_declaration(child->common.prototype TSRMLS_CC);
|
||||
zend_error(E_STRICT, "Declaration of %s::%s() should be compatible with %s", ZEND_FN_SCOPE_NAME(child), child->common.function_name, method_prototype);
|
||||
efree(method_prototype);
|
||||
}
|
||||
}
|
||||
}
|
||||
/* }}} */
|
||||
|
||||
static zend_bool do_inherit_method_check(HashTable *child_function_table, zend_function *parent, const zend_hash_key *hash_key, zend_class_entry *child_ce) /* {{{ */
|
||||
{
|
||||
@@ -3497,21 +3655,6 @@ static int zend_traits_merge_functions(zend_function *fn TSRMLS_DC, int num_args
|
||||
}
|
||||
/* }}} */
|
||||
|
||||
#define IS_EQUAL(mname, mname_len, str) \
|
||||
strncmp(mname, str, mname_len)
|
||||
|
||||
#define _ADD_MAGIC_METHOD(ce, mname, mname_len, fe) { \
|
||||
if (!IS_EQUAL(mname, mname_len, "__clone")) { (ce)->clone = (fe); (fe)->common.fn_flags |= ZEND_ACC_CLONE; } \
|
||||
else if (!IS_EQUAL(mname, mname_len, "__construct")) { (ce)->constructor = (fe); (fe)->common.fn_flags |= ZEND_ACC_CTOR; } \
|
||||
else if (!IS_EQUAL(mname, mname_len, "__destruct")) { (ce)->destructor = (fe); (fe)->common.fn_flags |= ZEND_ACC_DTOR; } \
|
||||
else if (!IS_EQUAL(mname, mname_len, "__get")) (ce)->__get = (fe); \
|
||||
else if (!IS_EQUAL(mname, mname_len, "__set")) (ce)->__set = (fe); \
|
||||
else if (!IS_EQUAL(mname, mname_len, "__call")) (ce)->__call = (fe); \
|
||||
else if (!IS_EQUAL(mname, mname_len, "__unset")) (ce)->__unset = (fe); \
|
||||
else if (!IS_EQUAL(mname, mname_len, "__isset")) (ce)->__isset = (fe); \
|
||||
else if (!IS_EQUAL(mname, mname_len, "__callstatic"))(ce)->__callstatic = (fe); \
|
||||
else if (!IS_EQUAL(mname, mname_len, "__tostring")) (ce)->__tostring = (fe); \
|
||||
}
|
||||
|
||||
/* {{{ Originates from php_runkit_function_copy_ctor
|
||||
Duplicate structures in an op_array where necessary to make an outright duplicate */
|
||||
@@ -3530,7 +3673,7 @@ static void zend_traits_duplicate_function(zend_function *fe, zend_class_entry *
|
||||
|
||||
ALLOC_HASHTABLE(tmpHash);
|
||||
zend_hash_init(tmpHash, zend_hash_num_elements(fe->op_array.static_variables), NULL, ZVAL_PTR_DTOR, 0);
|
||||
zend_hash_apply_with_arguments(tmpHash TSRMLS_CC, (apply_func_args_t)zval_copy_static_var, 1, fe->op_array.static_variables);
|
||||
zend_hash_apply_with_arguments(fe->op_array.static_variables TSRMLS_CC, (apply_func_args_t)zval_copy_static_var, 1, tmpHash);
|
||||
|
||||
fe->op_array.static_variables = tmpHash;
|
||||
}
|
||||
@@ -3633,7 +3776,39 @@ static void zend_traits_duplicate_function(zend_function *fe, zend_class_entry *
|
||||
fe->op_array.brk_cont_array = (zend_brk_cont_element*)estrndup((char*)fe->op_array.brk_cont_array, sizeof(zend_brk_cont_element) * fe->op_array.last_brk_cont);
|
||||
|
||||
}
|
||||
/* }}}} */
|
||||
/* }}} */
|
||||
|
||||
static void zend_add_magic_methods(zend_class_entry* ce, const char* mname, uint mname_len, zend_function* fe TSRMLS_DC) {
|
||||
if ( !strncmp(mname, ZEND_CLONE_FUNC_NAME, mname_len)) { ce->clone = fe; fe->common.fn_flags |= ZEND_ACC_CLONE; }
|
||||
else if (!strncmp(mname, ZEND_CONSTRUCTOR_FUNC_NAME, mname_len)) {
|
||||
if (ce->constructor) {
|
||||
zend_error(E_COMPILE_ERROR, "%s has colliding constructor definitions coming from traits", ce->name);
|
||||
}
|
||||
ce->constructor = fe; fe->common.fn_flags |= ZEND_ACC_CTOR;
|
||||
}
|
||||
else if (!strncmp(mname, ZEND_DESTRUCTOR_FUNC_NAME, mname_len)) { ce->destructor = fe; fe->common.fn_flags |= ZEND_ACC_DTOR; }
|
||||
else if (!strncmp(mname, ZEND_GET_FUNC_NAME, mname_len)) ce->__get = fe;
|
||||
else if (!strncmp(mname, ZEND_SET_FUNC_NAME, mname_len)) ce->__set = fe;
|
||||
else if (!strncmp(mname, ZEND_CALL_FUNC_NAME, mname_len)) ce->__call = fe;
|
||||
else if (!strncmp(mname, ZEND_UNSET_FUNC_NAME, mname_len)) ce->__unset = fe;
|
||||
else if (!strncmp(mname, ZEND_ISSET_FUNC_NAME, mname_len)) ce->__isset = fe;
|
||||
else if (!strncmp(mname, ZEND_CALLSTATIC_FUNC_NAME, mname_len)) ce->__callstatic= fe;
|
||||
else if (!strncmp(mname, ZEND_TOSTRING_FUNC_NAME, mname_len)) ce->__tostring = fe;
|
||||
else if (ce->name_length + 1 == mname_len) {
|
||||
char *lowercase_name = emalloc(ce->name_length + 1);
|
||||
zend_str_tolower_copy(lowercase_name, ce->name, ce->name_length);
|
||||
lowercase_name = (char*)zend_new_interned_string(lowercase_name, ce->name_length + 1, 1 TSRMLS_CC);
|
||||
if (!memcmp(mname, lowercase_name, mname_len)) {
|
||||
if (ce->constructor) {
|
||||
zend_error(E_COMPILE_ERROR, "%s has colliding constructor definitions coming from traits", ce->name);
|
||||
}
|
||||
ce->constructor = fe;
|
||||
fe->common.fn_flags |= ZEND_ACC_CTOR;
|
||||
}
|
||||
str_efree(lowercase_name);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
static int zend_traits_merge_functions_to_class(zend_function *fn TSRMLS_DC, int num_args, va_list args, zend_hash_key *hash_key) /* {{{ */
|
||||
{
|
||||
@@ -3701,9 +3876,7 @@ static int zend_traits_merge_functions_to_class(zend_function *fn TSRMLS_DC, int
|
||||
zend_error(E_COMPILE_ERROR, "Trait method %s has not been applied, because failure occured during updating class method table", hash_key->arKey);
|
||||
}
|
||||
|
||||
_ADD_MAGIC_METHOD(ce, hash_key->arKey, hash_key->nKeyLength, fn_copy_p);
|
||||
/* it could be necessary to update child classes as well */
|
||||
/* zend_hash_apply_with_arguments(EG(class_table) TSRMLS_CC, (apply_func_args_t)php_runkit_update_children_methods, 5, dce, dce, &dfe, dfunc, dfunc_len); */
|
||||
zend_add_magic_methods(ce, hash_key->arKey, hash_key->nKeyLength, fn_copy_p TSRMLS_CC);
|
||||
|
||||
zend_function_dtor(fn);
|
||||
} else {
|
||||
@@ -3936,6 +4109,7 @@ static void zend_do_traits_method_binding(zend_class_entry *ce TSRMLS_DC) /* {{{
|
||||
zend_hash_graceful_destroy(resulting_table);
|
||||
free(resulting_table);
|
||||
}
|
||||
/* }}} */
|
||||
|
||||
static zend_class_entry* find_first_definition(zend_class_entry *ce, size_t current_trait, const char* prop_name, int prop_name_length, ulong prop_hash, zend_class_entry *coliding_ce) /* {{{ */
|
||||
{
|
||||
@@ -6135,8 +6309,13 @@ void zend_do_jmp_set(const znode *value, znode *jmp_token, znode *colon_token TS
|
||||
int op_number = get_next_op_number(CG(active_op_array));
|
||||
zend_op *opline = get_next_op(CG(active_op_array) TSRMLS_CC);
|
||||
|
||||
opline->opcode = ZEND_JMP_SET;
|
||||
opline->result_type = IS_TMP_VAR;
|
||||
if (value->op_type == IS_VAR || value->op_type == IS_CV) {
|
||||
opline->opcode = ZEND_JMP_SET_VAR;
|
||||
opline->result_type = IS_VAR;
|
||||
} else {
|
||||
opline->opcode = ZEND_JMP_SET;
|
||||
opline->result_type = IS_TMP_VAR;
|
||||
}
|
||||
opline->result.var = get_temporary_variable(CG(active_op_array));
|
||||
SET_NODE(opline->op1, value);
|
||||
SET_UNUSED(opline->op2);
|
||||
@@ -6153,9 +6332,20 @@ void zend_do_jmp_set_else(znode *result, const znode *false_value, const znode *
|
||||
{
|
||||
zend_op *opline = get_next_op(CG(active_op_array) TSRMLS_CC);
|
||||
|
||||
opline->opcode = ZEND_QM_ASSIGN;
|
||||
opline->extended_value = 0;
|
||||
SET_NODE(opline->result, colon_token);
|
||||
if (colon_token->op_type == IS_TMP_VAR) {
|
||||
if (false_value->op_type == IS_VAR || false_value->op_type == IS_CV) {
|
||||
CG(active_op_array)->opcodes[jmp_token->u.op.opline_num].opcode = ZEND_JMP_SET_VAR;
|
||||
CG(active_op_array)->opcodes[jmp_token->u.op.opline_num].result_type = IS_VAR;
|
||||
opline->opcode = ZEND_QM_ASSIGN_VAR;
|
||||
opline->result_type = IS_VAR;
|
||||
} else {
|
||||
opline->opcode = ZEND_QM_ASSIGN;
|
||||
}
|
||||
} else {
|
||||
opline->opcode = ZEND_QM_ASSIGN_VAR;
|
||||
}
|
||||
opline->extended_value = 0;
|
||||
SET_NODE(opline->op1, false_value);
|
||||
SET_UNUSED(opline->op2);
|
||||
|
||||
@@ -6190,8 +6380,13 @@ void zend_do_qm_true(const znode *true_value, znode *qm_token, znode *colon_toke
|
||||
|
||||
CG(active_op_array)->opcodes[qm_token->u.op.opline_num].op2.opline_num = get_next_op_number(CG(active_op_array))+1; /* jmp over the ZEND_JMP */
|
||||
|
||||
opline->opcode = ZEND_QM_ASSIGN;
|
||||
opline->result_type = IS_TMP_VAR;
|
||||
if (true_value->op_type == IS_VAR || true_value->op_type == IS_CV) {
|
||||
opline->opcode = ZEND_QM_ASSIGN_VAR;
|
||||
opline->result_type = IS_VAR;
|
||||
} else {
|
||||
opline->opcode = ZEND_QM_ASSIGN;
|
||||
opline->result_type = IS_TMP_VAR;
|
||||
}
|
||||
opline->result.var = get_temporary_variable(CG(active_op_array));
|
||||
SET_NODE(opline->op1, true_value);
|
||||
SET_UNUSED(opline->op2);
|
||||
@@ -6210,8 +6405,19 @@ void zend_do_qm_false(znode *result, const znode *false_value, const znode *qm_t
|
||||
{
|
||||
zend_op *opline = get_next_op(CG(active_op_array) TSRMLS_CC);
|
||||
|
||||
opline->opcode = ZEND_QM_ASSIGN;
|
||||
SET_NODE(opline->result, qm_token);
|
||||
if (qm_token->op_type == IS_TMP_VAR) {
|
||||
if (false_value->op_type == IS_VAR || false_value->op_type == IS_CV) {
|
||||
CG(active_op_array)->opcodes[colon_token->u.op.opline_num - 1].opcode = ZEND_QM_ASSIGN_VAR;
|
||||
CG(active_op_array)->opcodes[colon_token->u.op.opline_num - 1].result_type = IS_VAR;
|
||||
opline->opcode = ZEND_QM_ASSIGN_VAR;
|
||||
opline->result_type = IS_VAR;
|
||||
} else {
|
||||
opline->opcode = ZEND_QM_ASSIGN;
|
||||
}
|
||||
} else {
|
||||
opline->opcode = ZEND_QM_ASSIGN_VAR;
|
||||
}
|
||||
SET_NODE(opline->op1, false_value);
|
||||
SET_UNUSED(opline->op2);
|
||||
|
||||
|
||||
@@ -639,6 +639,9 @@ static inline int zend_verify_arg_type(zend_function *zf, zend_uint arg_num, zva
|
||||
break;
|
||||
|
||||
case IS_CALLABLE:
|
||||
if (!arg) {
|
||||
return zend_verify_arg_error(E_RECOVERABLE_ERROR, zf, arg_num, "be callable", "", "none", "" TSRMLS_CC);
|
||||
}
|
||||
if (!zend_is_callable(arg, IS_CALLABLE_CHECK_SILENT, NULL TSRMLS_CC) && (Z_TYPE_P(arg) != IS_NULL || !cur_arg_info->allow_null)) {
|
||||
return zend_verify_arg_error(E_RECOVERABLE_ERROR, zf, arg_num, "be callable", "", zend_zval_type_name(arg), "" TSRMLS_CC);
|
||||
}
|
||||
|
||||
@@ -1299,6 +1299,7 @@ void execute_new_code(TSRMLS_D) /* {{{ */
|
||||
case ZEND_JMPZ_EX:
|
||||
case ZEND_JMPNZ_EX:
|
||||
case ZEND_JMP_SET:
|
||||
case ZEND_JMP_SET_VAR:
|
||||
opline->op2.jmp_addr = &CG(active_op_array)->opcodes[opline->op2.opline_num];
|
||||
break;
|
||||
}
|
||||
|
||||
@@ -89,7 +89,7 @@ ZEND_API void rebuild_object_properties(zend_object *zobj) /* {{{ */
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/* }}} */
|
||||
|
||||
ZEND_API HashTable *zend_std_get_properties(zval *object TSRMLS_DC) /* {{{ */
|
||||
{
|
||||
|
||||
@@ -529,6 +529,7 @@ ZEND_API int pass_two(zend_op_array *op_array TSRMLS_DC)
|
||||
case ZEND_JMPZ_EX:
|
||||
case ZEND_JMPNZ_EX:
|
||||
case ZEND_JMP_SET:
|
||||
case ZEND_JMP_SET_VAR:
|
||||
opline->op2.jmp_addr = &op_array->opcodes[opline->op2.opline_num];
|
||||
break;
|
||||
}
|
||||
|
||||
@@ -659,7 +659,7 @@ static zend_always_inline int fast_sub_function(zval *result, zval *op1, zval *o
|
||||
|
||||
if (UNEXPECTED((Z_LVAL_P(op1) & LONG_SIGN_MASK) != (Z_LVAL_P(op2) & LONG_SIGN_MASK)
|
||||
&& (Z_LVAL_P(op1) & LONG_SIGN_MASK) != (Z_LVAL_P(result) & LONG_SIGN_MASK))) {
|
||||
Z_DVAL_P(result) = (double) Z_LVAL_P(op1) + (double) Z_LVAL_P(op2);
|
||||
Z_DVAL_P(result) = (double) Z_LVAL_P(op1) - (double) Z_LVAL_P(op2);
|
||||
Z_TYPE_P(result) = IS_DOUBLE;
|
||||
} else {
|
||||
Z_TYPE_P(result) = IS_LONG;
|
||||
|
||||
+21
-5
@@ -27,10 +27,24 @@
|
||||
|
||||
#include <sys/types.h>
|
||||
#include <sys/stat.h>
|
||||
#if HAVE_SYS_MMAN_H
|
||||
# include <sys/mman.h>
|
||||
# ifndef PAGE_SIZE
|
||||
# define PAGE_SIZE 4096
|
||||
#if HAVE_MMAP
|
||||
# if HAVE_UNISTD_H
|
||||
# include <unistd.h>
|
||||
# if defined(_SC_PAGESIZE)
|
||||
# define REAL_PAGE_SIZE sysconf(_SC_PAGESIZE);
|
||||
# elif defined(_SC_PAGE_SIZE)
|
||||
# define REAL_PAGE_SIZE sysconf(_SC_PAGE_SIZE);
|
||||
# endif
|
||||
# endif
|
||||
# if HAVE_SYS_MMAN_H
|
||||
# include <sys/mman.h>
|
||||
# endif
|
||||
# ifndef REAL_PAGE_SIZE
|
||||
# ifdef PAGE_SIZE
|
||||
# define REAL_PAGE_SIZE PAGE_SIZE
|
||||
# else
|
||||
# define REAL_PAGE_SIZE 4096
|
||||
# endif
|
||||
# endif
|
||||
#endif
|
||||
|
||||
@@ -215,9 +229,11 @@ ZEND_API int zend_stream_fixup(zend_file_handle *file_handle, char **buf, size_t
|
||||
|
||||
if (old_type == ZEND_HANDLE_FP && !file_handle->handle.stream.isatty && size) {
|
||||
#if HAVE_MMAP
|
||||
size_t page_size = REAL_PAGE_SIZE;
|
||||
|
||||
if (file_handle->handle.fp &&
|
||||
size != 0 &&
|
||||
((size - 1) % PAGE_SIZE) <= PAGE_SIZE - ZEND_MMAP_AHEAD) {
|
||||
((size - 1) % page_size) <= page_size - ZEND_MMAP_AHEAD) {
|
||||
/* *buf[size] is zeroed automatically by the kernel */
|
||||
*buf = mmap(0, size + ZEND_MMAP_AHEAD, PROT_READ, MAP_PRIVATE, fileno(file_handle->handle.fp), 0);
|
||||
if (*buf != MAP_FAILED) {
|
||||
|
||||
+67
-2
@@ -4661,8 +4661,45 @@ ZEND_VM_HANDLER(152, ZEND_JMP_SET, CONST|TMP|VAR|CV, ANY)
|
||||
|
||||
if (i_zend_is_true(value)) {
|
||||
ZVAL_COPY_VALUE(&EX_T(opline->result.var).tmp_var, value);
|
||||
zendi_zval_copy_ctor(EX_T(opline->result.var).tmp_var);
|
||||
FREE_OP1();
|
||||
if (!IS_OP1_TMP_FREE()) {
|
||||
zendi_zval_copy_ctor(EX_T(opline->result.var).tmp_var);
|
||||
}
|
||||
FREE_OP1_IF_VAR();
|
||||
#if DEBUG_ZEND>=2
|
||||
printf("Conditional jmp to %d\n", opline->op2.opline_num);
|
||||
#endif
|
||||
ZEND_VM_JMP(opline->op2.jmp_addr);
|
||||
}
|
||||
|
||||
FREE_OP1();
|
||||
CHECK_EXCEPTION();
|
||||
ZEND_VM_NEXT_OPCODE();
|
||||
}
|
||||
|
||||
ZEND_VM_HANDLER(158, ZEND_JMP_SET_VAR, CONST|TMP|VAR|CV, ANY)
|
||||
{
|
||||
USE_OPLINE
|
||||
zend_free_op free_op1;
|
||||
zval *value, *ret;
|
||||
|
||||
SAVE_OPLINE();
|
||||
value = GET_OP1_ZVAL_PTR(BP_VAR_R);
|
||||
|
||||
if (i_zend_is_true(value)) {
|
||||
if (OP1_TYPE == IS_VAR || OP1_TYPE == IS_CV) {
|
||||
Z_ADDREF_P(value);
|
||||
EX_T(opline->result.var).var.ptr = value;
|
||||
EX_T(opline->result.var).var.ptr_ptr = NULL;
|
||||
} else {
|
||||
ALLOC_ZVAL(ret);
|
||||
INIT_PZVAL_COPY(ret, value);
|
||||
EX_T(opline->result.var).var.ptr = ret;
|
||||
EX_T(opline->result.var).var.ptr_ptr = NULL;
|
||||
if (!IS_OP1_TMP_FREE()) {
|
||||
zval_copy_ctor(EX_T(opline->result.var).var.ptr);
|
||||
}
|
||||
}
|
||||
FREE_OP1_IF_VAR();
|
||||
#if DEBUG_ZEND>=2
|
||||
printf("Conditional jmp to %d\n", opline->op2.opline_num);
|
||||
#endif
|
||||
@@ -4692,6 +4729,34 @@ ZEND_VM_HANDLER(22, ZEND_QM_ASSIGN, CONST|TMP|VAR|CV, ANY)
|
||||
ZEND_VM_NEXT_OPCODE();
|
||||
}
|
||||
|
||||
ZEND_VM_HANDLER(157, ZEND_QM_ASSIGN_VAR, CONST|TMP|VAR|CV, ANY)
|
||||
{
|
||||
USE_OPLINE
|
||||
zend_free_op free_op1;
|
||||
zval *value, *ret;
|
||||
|
||||
SAVE_OPLINE();
|
||||
value = GET_OP1_ZVAL_PTR(BP_VAR_R);
|
||||
|
||||
if (OP1_TYPE == IS_VAR || OP1_TYPE == IS_CV) {
|
||||
Z_ADDREF_P(value);
|
||||
EX_T(opline->result.var).var.ptr = value;
|
||||
EX_T(opline->result.var).var.ptr_ptr = NULL;
|
||||
} else {
|
||||
ALLOC_ZVAL(ret);
|
||||
INIT_PZVAL_COPY(ret, value);
|
||||
EX_T(opline->result.var).var.ptr = ret;
|
||||
EX_T(opline->result.var).var.ptr_ptr = NULL;
|
||||
if (!IS_OP1_TMP_FREE()) {
|
||||
zval_copy_ctor(EX_T(opline->result.var).var.ptr);
|
||||
}
|
||||
}
|
||||
|
||||
FREE_OP1_IF_VAR();
|
||||
CHECK_EXCEPTION();
|
||||
ZEND_VM_NEXT_OPCODE();
|
||||
}
|
||||
|
||||
ZEND_VM_HANDLER(101, ZEND_EXT_STMT, ANY, ANY)
|
||||
{
|
||||
SAVE_OPLINE();
|
||||
|
||||
+310
-5
@@ -2836,7 +2836,43 @@ static int ZEND_FASTCALL ZEND_JMP_SET_SPEC_CONST_HANDLER(ZEND_OPCODE_HANDLER_AR
|
||||
|
||||
if (i_zend_is_true(value)) {
|
||||
ZVAL_COPY_VALUE(&EX_T(opline->result.var).tmp_var, value);
|
||||
zendi_zval_copy_ctor(EX_T(opline->result.var).tmp_var);
|
||||
if (!0) {
|
||||
zendi_zval_copy_ctor(EX_T(opline->result.var).tmp_var);
|
||||
}
|
||||
|
||||
#if DEBUG_ZEND>=2
|
||||
printf("Conditional jmp to %d\n", opline->op2.opline_num);
|
||||
#endif
|
||||
ZEND_VM_JMP(opline->op2.jmp_addr);
|
||||
}
|
||||
|
||||
CHECK_EXCEPTION();
|
||||
ZEND_VM_NEXT_OPCODE();
|
||||
}
|
||||
|
||||
static int ZEND_FASTCALL ZEND_JMP_SET_VAR_SPEC_CONST_HANDLER(ZEND_OPCODE_HANDLER_ARGS)
|
||||
{
|
||||
USE_OPLINE
|
||||
|
||||
zval *value, *ret;
|
||||
|
||||
SAVE_OPLINE();
|
||||
value = opline->op1.zv;
|
||||
|
||||
if (i_zend_is_true(value)) {
|
||||
if (IS_CONST == IS_VAR || IS_CONST == IS_CV) {
|
||||
Z_ADDREF_P(value);
|
||||
EX_T(opline->result.var).var.ptr = value;
|
||||
EX_T(opline->result.var).var.ptr_ptr = NULL;
|
||||
} else {
|
||||
ALLOC_ZVAL(ret);
|
||||
INIT_PZVAL_COPY(ret, value);
|
||||
EX_T(opline->result.var).var.ptr = ret;
|
||||
EX_T(opline->result.var).var.ptr_ptr = NULL;
|
||||
if (!0) {
|
||||
zval_copy_ctor(EX_T(opline->result.var).var.ptr);
|
||||
}
|
||||
}
|
||||
|
||||
#if DEBUG_ZEND>=2
|
||||
printf("Conditional jmp to %d\n", opline->op2.opline_num);
|
||||
@@ -2866,6 +2902,33 @@ static int ZEND_FASTCALL ZEND_QM_ASSIGN_SPEC_CONST_HANDLER(ZEND_OPCODE_HANDLER_
|
||||
ZEND_VM_NEXT_OPCODE();
|
||||
}
|
||||
|
||||
static int ZEND_FASTCALL ZEND_QM_ASSIGN_VAR_SPEC_CONST_HANDLER(ZEND_OPCODE_HANDLER_ARGS)
|
||||
{
|
||||
USE_OPLINE
|
||||
|
||||
zval *value, *ret;
|
||||
|
||||
SAVE_OPLINE();
|
||||
value = opline->op1.zv;
|
||||
|
||||
if (IS_CONST == IS_VAR || IS_CONST == IS_CV) {
|
||||
Z_ADDREF_P(value);
|
||||
EX_T(opline->result.var).var.ptr = value;
|
||||
EX_T(opline->result.var).var.ptr_ptr = NULL;
|
||||
} else {
|
||||
ALLOC_ZVAL(ret);
|
||||
INIT_PZVAL_COPY(ret, value);
|
||||
EX_T(opline->result.var).var.ptr = ret;
|
||||
EX_T(opline->result.var).var.ptr_ptr = NULL;
|
||||
if (!0) {
|
||||
zval_copy_ctor(EX_T(opline->result.var).var.ptr);
|
||||
}
|
||||
}
|
||||
|
||||
CHECK_EXCEPTION();
|
||||
ZEND_VM_NEXT_OPCODE();
|
||||
}
|
||||
|
||||
static int ZEND_FASTCALL ZEND_ADD_SPEC_CONST_CONST_HANDLER(ZEND_OPCODE_HANDLER_ARGS)
|
||||
{
|
||||
USE_OPLINE
|
||||
@@ -7132,8 +7195,45 @@ static int ZEND_FASTCALL ZEND_JMP_SET_SPEC_TMP_HANDLER(ZEND_OPCODE_HANDLER_ARGS
|
||||
|
||||
if (i_zend_is_true(value)) {
|
||||
ZVAL_COPY_VALUE(&EX_T(opline->result.var).tmp_var, value);
|
||||
zendi_zval_copy_ctor(EX_T(opline->result.var).tmp_var);
|
||||
zval_dtor(free_op1.var);
|
||||
if (!1) {
|
||||
zendi_zval_copy_ctor(EX_T(opline->result.var).tmp_var);
|
||||
}
|
||||
|
||||
#if DEBUG_ZEND>=2
|
||||
printf("Conditional jmp to %d\n", opline->op2.opline_num);
|
||||
#endif
|
||||
ZEND_VM_JMP(opline->op2.jmp_addr);
|
||||
}
|
||||
|
||||
zval_dtor(free_op1.var);
|
||||
CHECK_EXCEPTION();
|
||||
ZEND_VM_NEXT_OPCODE();
|
||||
}
|
||||
|
||||
static int ZEND_FASTCALL ZEND_JMP_SET_VAR_SPEC_TMP_HANDLER(ZEND_OPCODE_HANDLER_ARGS)
|
||||
{
|
||||
USE_OPLINE
|
||||
zend_free_op free_op1;
|
||||
zval *value, *ret;
|
||||
|
||||
SAVE_OPLINE();
|
||||
value = _get_zval_ptr_tmp(opline->op1.var, EX_Ts(), &free_op1 TSRMLS_CC);
|
||||
|
||||
if (i_zend_is_true(value)) {
|
||||
if (IS_TMP_VAR == IS_VAR || IS_TMP_VAR == IS_CV) {
|
||||
Z_ADDREF_P(value);
|
||||
EX_T(opline->result.var).var.ptr = value;
|
||||
EX_T(opline->result.var).var.ptr_ptr = NULL;
|
||||
} else {
|
||||
ALLOC_ZVAL(ret);
|
||||
INIT_PZVAL_COPY(ret, value);
|
||||
EX_T(opline->result.var).var.ptr = ret;
|
||||
EX_T(opline->result.var).var.ptr_ptr = NULL;
|
||||
if (!1) {
|
||||
zval_copy_ctor(EX_T(opline->result.var).var.ptr);
|
||||
}
|
||||
}
|
||||
|
||||
#if DEBUG_ZEND>=2
|
||||
printf("Conditional jmp to %d\n", opline->op2.opline_num);
|
||||
#endif
|
||||
@@ -7163,6 +7263,33 @@ static int ZEND_FASTCALL ZEND_QM_ASSIGN_SPEC_TMP_HANDLER(ZEND_OPCODE_HANDLER_AR
|
||||
ZEND_VM_NEXT_OPCODE();
|
||||
}
|
||||
|
||||
static int ZEND_FASTCALL ZEND_QM_ASSIGN_VAR_SPEC_TMP_HANDLER(ZEND_OPCODE_HANDLER_ARGS)
|
||||
{
|
||||
USE_OPLINE
|
||||
zend_free_op free_op1;
|
||||
zval *value, *ret;
|
||||
|
||||
SAVE_OPLINE();
|
||||
value = _get_zval_ptr_tmp(opline->op1.var, EX_Ts(), &free_op1 TSRMLS_CC);
|
||||
|
||||
if (IS_TMP_VAR == IS_VAR || IS_TMP_VAR == IS_CV) {
|
||||
Z_ADDREF_P(value);
|
||||
EX_T(opline->result.var).var.ptr = value;
|
||||
EX_T(opline->result.var).var.ptr_ptr = NULL;
|
||||
} else {
|
||||
ALLOC_ZVAL(ret);
|
||||
INIT_PZVAL_COPY(ret, value);
|
||||
EX_T(opline->result.var).var.ptr = ret;
|
||||
EX_T(opline->result.var).var.ptr_ptr = NULL;
|
||||
if (!1) {
|
||||
zval_copy_ctor(EX_T(opline->result.var).var.ptr);
|
||||
}
|
||||
}
|
||||
|
||||
CHECK_EXCEPTION();
|
||||
ZEND_VM_NEXT_OPCODE();
|
||||
}
|
||||
|
||||
static int ZEND_FASTCALL ZEND_INSTANCEOF_SPEC_TMP_HANDLER(ZEND_OPCODE_HANDLER_ARGS)
|
||||
{
|
||||
USE_OPLINE
|
||||
@@ -11539,7 +11666,44 @@ static int ZEND_FASTCALL ZEND_JMP_SET_SPEC_VAR_HANDLER(ZEND_OPCODE_HANDLER_ARGS
|
||||
|
||||
if (i_zend_is_true(value)) {
|
||||
ZVAL_COPY_VALUE(&EX_T(opline->result.var).tmp_var, value);
|
||||
zendi_zval_copy_ctor(EX_T(opline->result.var).tmp_var);
|
||||
if (!0) {
|
||||
zendi_zval_copy_ctor(EX_T(opline->result.var).tmp_var);
|
||||
}
|
||||
if (free_op1.var) {zval_ptr_dtor(&free_op1.var);};
|
||||
#if DEBUG_ZEND>=2
|
||||
printf("Conditional jmp to %d\n", opline->op2.opline_num);
|
||||
#endif
|
||||
ZEND_VM_JMP(opline->op2.jmp_addr);
|
||||
}
|
||||
|
||||
if (free_op1.var) {zval_ptr_dtor(&free_op1.var);};
|
||||
CHECK_EXCEPTION();
|
||||
ZEND_VM_NEXT_OPCODE();
|
||||
}
|
||||
|
||||
static int ZEND_FASTCALL ZEND_JMP_SET_VAR_SPEC_VAR_HANDLER(ZEND_OPCODE_HANDLER_ARGS)
|
||||
{
|
||||
USE_OPLINE
|
||||
zend_free_op free_op1;
|
||||
zval *value, *ret;
|
||||
|
||||
SAVE_OPLINE();
|
||||
value = _get_zval_ptr_var(opline->op1.var, EX_Ts(), &free_op1 TSRMLS_CC);
|
||||
|
||||
if (i_zend_is_true(value)) {
|
||||
if (IS_VAR == IS_VAR || IS_VAR == IS_CV) {
|
||||
Z_ADDREF_P(value);
|
||||
EX_T(opline->result.var).var.ptr = value;
|
||||
EX_T(opline->result.var).var.ptr_ptr = NULL;
|
||||
} else {
|
||||
ALLOC_ZVAL(ret);
|
||||
INIT_PZVAL_COPY(ret, value);
|
||||
EX_T(opline->result.var).var.ptr = ret;
|
||||
EX_T(opline->result.var).var.ptr_ptr = NULL;
|
||||
if (!0) {
|
||||
zval_copy_ctor(EX_T(opline->result.var).var.ptr);
|
||||
}
|
||||
}
|
||||
if (free_op1.var) {zval_ptr_dtor(&free_op1.var);};
|
||||
#if DEBUG_ZEND>=2
|
||||
printf("Conditional jmp to %d\n", opline->op2.opline_num);
|
||||
@@ -11570,6 +11734,34 @@ static int ZEND_FASTCALL ZEND_QM_ASSIGN_SPEC_VAR_HANDLER(ZEND_OPCODE_HANDLER_AR
|
||||
ZEND_VM_NEXT_OPCODE();
|
||||
}
|
||||
|
||||
static int ZEND_FASTCALL ZEND_QM_ASSIGN_VAR_SPEC_VAR_HANDLER(ZEND_OPCODE_HANDLER_ARGS)
|
||||
{
|
||||
USE_OPLINE
|
||||
zend_free_op free_op1;
|
||||
zval *value, *ret;
|
||||
|
||||
SAVE_OPLINE();
|
||||
value = _get_zval_ptr_var(opline->op1.var, EX_Ts(), &free_op1 TSRMLS_CC);
|
||||
|
||||
if (IS_VAR == IS_VAR || IS_VAR == IS_CV) {
|
||||
Z_ADDREF_P(value);
|
||||
EX_T(opline->result.var).var.ptr = value;
|
||||
EX_T(opline->result.var).var.ptr_ptr = NULL;
|
||||
} else {
|
||||
ALLOC_ZVAL(ret);
|
||||
INIT_PZVAL_COPY(ret, value);
|
||||
EX_T(opline->result.var).var.ptr = ret;
|
||||
EX_T(opline->result.var).var.ptr_ptr = NULL;
|
||||
if (!0) {
|
||||
zval_copy_ctor(EX_T(opline->result.var).var.ptr);
|
||||
}
|
||||
}
|
||||
|
||||
if (free_op1.var) {zval_ptr_dtor(&free_op1.var);};
|
||||
CHECK_EXCEPTION();
|
||||
ZEND_VM_NEXT_OPCODE();
|
||||
}
|
||||
|
||||
static int ZEND_FASTCALL ZEND_INSTANCEOF_SPEC_VAR_HANDLER(ZEND_OPCODE_HANDLER_ARGS)
|
||||
{
|
||||
USE_OPLINE
|
||||
@@ -27127,7 +27319,43 @@ static int ZEND_FASTCALL ZEND_JMP_SET_SPEC_CV_HANDLER(ZEND_OPCODE_HANDLER_ARGS)
|
||||
|
||||
if (i_zend_is_true(value)) {
|
||||
ZVAL_COPY_VALUE(&EX_T(opline->result.var).tmp_var, value);
|
||||
zendi_zval_copy_ctor(EX_T(opline->result.var).tmp_var);
|
||||
if (!0) {
|
||||
zendi_zval_copy_ctor(EX_T(opline->result.var).tmp_var);
|
||||
}
|
||||
|
||||
#if DEBUG_ZEND>=2
|
||||
printf("Conditional jmp to %d\n", opline->op2.opline_num);
|
||||
#endif
|
||||
ZEND_VM_JMP(opline->op2.jmp_addr);
|
||||
}
|
||||
|
||||
CHECK_EXCEPTION();
|
||||
ZEND_VM_NEXT_OPCODE();
|
||||
}
|
||||
|
||||
static int ZEND_FASTCALL ZEND_JMP_SET_VAR_SPEC_CV_HANDLER(ZEND_OPCODE_HANDLER_ARGS)
|
||||
{
|
||||
USE_OPLINE
|
||||
|
||||
zval *value, *ret;
|
||||
|
||||
SAVE_OPLINE();
|
||||
value = _get_zval_ptr_cv_BP_VAR_R(EX_CVs(), opline->op1.var TSRMLS_CC);
|
||||
|
||||
if (i_zend_is_true(value)) {
|
||||
if (IS_CV == IS_VAR || IS_CV == IS_CV) {
|
||||
Z_ADDREF_P(value);
|
||||
EX_T(opline->result.var).var.ptr = value;
|
||||
EX_T(opline->result.var).var.ptr_ptr = NULL;
|
||||
} else {
|
||||
ALLOC_ZVAL(ret);
|
||||
INIT_PZVAL_COPY(ret, value);
|
||||
EX_T(opline->result.var).var.ptr = ret;
|
||||
EX_T(opline->result.var).var.ptr_ptr = NULL;
|
||||
if (!0) {
|
||||
zval_copy_ctor(EX_T(opline->result.var).var.ptr);
|
||||
}
|
||||
}
|
||||
|
||||
#if DEBUG_ZEND>=2
|
||||
printf("Conditional jmp to %d\n", opline->op2.opline_num);
|
||||
@@ -27157,6 +27385,33 @@ static int ZEND_FASTCALL ZEND_QM_ASSIGN_SPEC_CV_HANDLER(ZEND_OPCODE_HANDLER_ARG
|
||||
ZEND_VM_NEXT_OPCODE();
|
||||
}
|
||||
|
||||
static int ZEND_FASTCALL ZEND_QM_ASSIGN_VAR_SPEC_CV_HANDLER(ZEND_OPCODE_HANDLER_ARGS)
|
||||
{
|
||||
USE_OPLINE
|
||||
|
||||
zval *value, *ret;
|
||||
|
||||
SAVE_OPLINE();
|
||||
value = _get_zval_ptr_cv_BP_VAR_R(EX_CVs(), opline->op1.var TSRMLS_CC);
|
||||
|
||||
if (IS_CV == IS_VAR || IS_CV == IS_CV) {
|
||||
Z_ADDREF_P(value);
|
||||
EX_T(opline->result.var).var.ptr = value;
|
||||
EX_T(opline->result.var).var.ptr_ptr = NULL;
|
||||
} else {
|
||||
ALLOC_ZVAL(ret);
|
||||
INIT_PZVAL_COPY(ret, value);
|
||||
EX_T(opline->result.var).var.ptr = ret;
|
||||
EX_T(opline->result.var).var.ptr_ptr = NULL;
|
||||
if (!0) {
|
||||
zval_copy_ctor(EX_T(opline->result.var).var.ptr);
|
||||
}
|
||||
}
|
||||
|
||||
CHECK_EXCEPTION();
|
||||
ZEND_VM_NEXT_OPCODE();
|
||||
}
|
||||
|
||||
static int ZEND_FASTCALL ZEND_INSTANCEOF_SPEC_CV_HANDLER(ZEND_OPCODE_HANDLER_ARGS)
|
||||
{
|
||||
USE_OPLINE
|
||||
@@ -39759,6 +40014,56 @@ void zend_init_opcodes_handlers(void)
|
||||
ZEND_NULL_HANDLER,
|
||||
ZEND_NULL_HANDLER,
|
||||
ZEND_NULL_HANDLER,
|
||||
ZEND_QM_ASSIGN_VAR_SPEC_CONST_HANDLER,
|
||||
ZEND_QM_ASSIGN_VAR_SPEC_CONST_HANDLER,
|
||||
ZEND_QM_ASSIGN_VAR_SPEC_CONST_HANDLER,
|
||||
ZEND_QM_ASSIGN_VAR_SPEC_CONST_HANDLER,
|
||||
ZEND_QM_ASSIGN_VAR_SPEC_CONST_HANDLER,
|
||||
ZEND_QM_ASSIGN_VAR_SPEC_TMP_HANDLER,
|
||||
ZEND_QM_ASSIGN_VAR_SPEC_TMP_HANDLER,
|
||||
ZEND_QM_ASSIGN_VAR_SPEC_TMP_HANDLER,
|
||||
ZEND_QM_ASSIGN_VAR_SPEC_TMP_HANDLER,
|
||||
ZEND_QM_ASSIGN_VAR_SPEC_TMP_HANDLER,
|
||||
ZEND_QM_ASSIGN_VAR_SPEC_VAR_HANDLER,
|
||||
ZEND_QM_ASSIGN_VAR_SPEC_VAR_HANDLER,
|
||||
ZEND_QM_ASSIGN_VAR_SPEC_VAR_HANDLER,
|
||||
ZEND_QM_ASSIGN_VAR_SPEC_VAR_HANDLER,
|
||||
ZEND_QM_ASSIGN_VAR_SPEC_VAR_HANDLER,
|
||||
ZEND_NULL_HANDLER,
|
||||
ZEND_NULL_HANDLER,
|
||||
ZEND_NULL_HANDLER,
|
||||
ZEND_NULL_HANDLER,
|
||||
ZEND_NULL_HANDLER,
|
||||
ZEND_QM_ASSIGN_VAR_SPEC_CV_HANDLER,
|
||||
ZEND_QM_ASSIGN_VAR_SPEC_CV_HANDLER,
|
||||
ZEND_QM_ASSIGN_VAR_SPEC_CV_HANDLER,
|
||||
ZEND_QM_ASSIGN_VAR_SPEC_CV_HANDLER,
|
||||
ZEND_QM_ASSIGN_VAR_SPEC_CV_HANDLER,
|
||||
ZEND_JMP_SET_VAR_SPEC_CONST_HANDLER,
|
||||
ZEND_JMP_SET_VAR_SPEC_CONST_HANDLER,
|
||||
ZEND_JMP_SET_VAR_SPEC_CONST_HANDLER,
|
||||
ZEND_JMP_SET_VAR_SPEC_CONST_HANDLER,
|
||||
ZEND_JMP_SET_VAR_SPEC_CONST_HANDLER,
|
||||
ZEND_JMP_SET_VAR_SPEC_TMP_HANDLER,
|
||||
ZEND_JMP_SET_VAR_SPEC_TMP_HANDLER,
|
||||
ZEND_JMP_SET_VAR_SPEC_TMP_HANDLER,
|
||||
ZEND_JMP_SET_VAR_SPEC_TMP_HANDLER,
|
||||
ZEND_JMP_SET_VAR_SPEC_TMP_HANDLER,
|
||||
ZEND_JMP_SET_VAR_SPEC_VAR_HANDLER,
|
||||
ZEND_JMP_SET_VAR_SPEC_VAR_HANDLER,
|
||||
ZEND_JMP_SET_VAR_SPEC_VAR_HANDLER,
|
||||
ZEND_JMP_SET_VAR_SPEC_VAR_HANDLER,
|
||||
ZEND_JMP_SET_VAR_SPEC_VAR_HANDLER,
|
||||
ZEND_NULL_HANDLER,
|
||||
ZEND_NULL_HANDLER,
|
||||
ZEND_NULL_HANDLER,
|
||||
ZEND_NULL_HANDLER,
|
||||
ZEND_NULL_HANDLER,
|
||||
ZEND_JMP_SET_VAR_SPEC_CV_HANDLER,
|
||||
ZEND_JMP_SET_VAR_SPEC_CV_HANDLER,
|
||||
ZEND_JMP_SET_VAR_SPEC_CV_HANDLER,
|
||||
ZEND_JMP_SET_VAR_SPEC_CV_HANDLER,
|
||||
ZEND_JMP_SET_VAR_SPEC_CV_HANDLER,
|
||||
ZEND_NULL_HANDLER
|
||||
};
|
||||
zend_opcode_handlers = (opcode_handler_t*)labels;
|
||||
|
||||
@@ -157,3 +157,5 @@
|
||||
#define ZEND_ADD_TRAIT 154
|
||||
#define ZEND_BIND_TRAITS 155
|
||||
#define ZEND_SEPARATE 156
|
||||
#define ZEND_QM_ASSIGN_VAR 157
|
||||
#define ZEND_JMP_SET_VAR 158
|
||||
+2
-1
@@ -120,7 +120,7 @@ int zend_sprintf(char *buffer, const char *format, ...);
|
||||
PHP_MAJOR_VERSION=5
|
||||
PHP_MINOR_VERSION=4
|
||||
PHP_RELEASE_VERSION=0
|
||||
PHP_EXTRA_VERSION="beta1"
|
||||
PHP_EXTRA_VERSION="beta2"
|
||||
PHP_VERSION="$PHP_MAJOR_VERSION.$PHP_MINOR_VERSION.$PHP_RELEASE_VERSION$PHP_EXTRA_VERSION"
|
||||
PHP_VERSION_ID=`expr [$]PHP_MAJOR_VERSION \* 10000 + [$]PHP_MINOR_VERSION \* 100 + [$]PHP_RELEASE_VERSION`
|
||||
|
||||
@@ -684,6 +684,7 @@ utime \
|
||||
vsnprintf \
|
||||
vasprintf \
|
||||
asprintf \
|
||||
nanosleep \
|
||||
)
|
||||
|
||||
dnl Some systems (like OpenSolaris) do not have nanosleep in libc
|
||||
|
||||
+10
-12
@@ -127,6 +127,7 @@
|
||||
**************************************************************************/
|
||||
|
||||
#include "sdncal.h"
|
||||
#include <limits.h>
|
||||
|
||||
#define GREGOR_SDN_OFFSET 32045
|
||||
#define DAYS_PER_5_MONTHS 153
|
||||
@@ -146,21 +147,12 @@ void SdnToGregorian(
|
||||
long int temp;
|
||||
int dayOfYear;
|
||||
|
||||
if (sdn <= 0) {
|
||||
*pYear = 0;
|
||||
*pMonth = 0;
|
||||
*pDay = 0;
|
||||
return;
|
||||
if (sdn <= 0 ||
|
||||
sdn > (LONG_MAX - 4 * GREGOR_SDN_OFFSET) / 4) {
|
||||
goto fail;
|
||||
}
|
||||
temp = (sdn + GREGOR_SDN_OFFSET) * 4 - 1;
|
||||
|
||||
if (temp < 0) {
|
||||
*pYear = 0;
|
||||
*pMonth = 0;
|
||||
*pDay = 0;
|
||||
return;
|
||||
}
|
||||
|
||||
/* Calculate the century (year/100). */
|
||||
century = temp / DAYS_PER_400_YEARS;
|
||||
|
||||
@@ -190,6 +182,12 @@ void SdnToGregorian(
|
||||
*pYear = year;
|
||||
*pMonth = month;
|
||||
*pDay = day;
|
||||
return;
|
||||
|
||||
fail:
|
||||
*pYear = 0;
|
||||
*pMonth = 0;
|
||||
*pDay = 0;
|
||||
}
|
||||
|
||||
long int GregorianToSdn(
|
||||
|
||||
@@ -0,0 +1,36 @@
|
||||
--TEST--
|
||||
Bug #53574 (Integer overflow in SdnToJulian; leads to segfault)
|
||||
--SKIPIF--
|
||||
<?php
|
||||
include 'skipif.inc';
|
||||
if (PHP_INT_SIZE != 4) {
|
||||
die("skip this test is for 32bit platform only");
|
||||
}
|
||||
?>
|
||||
--FILE--
|
||||
<?php
|
||||
$x = 882858043;
|
||||
|
||||
var_dump(cal_from_jd($x, CAL_JULIAN));
|
||||
--EXPECT--
|
||||
array(9) {
|
||||
["date"]=>
|
||||
string(5) "0/0/0"
|
||||
["month"]=>
|
||||
int(0)
|
||||
["day"]=>
|
||||
int(0)
|
||||
["year"]=>
|
||||
int(0)
|
||||
["dow"]=>
|
||||
int(5)
|
||||
["abbrevdayname"]=>
|
||||
string(3) "Fri"
|
||||
["dayname"]=>
|
||||
string(6) "Friday"
|
||||
["abbrevmonth"]=>
|
||||
string(0) ""
|
||||
["monthname"]=>
|
||||
string(0) ""
|
||||
}
|
||||
|
||||
@@ -1,14 +1,15 @@
|
||||
--TEST--
|
||||
Bug #53574 (Integer overflow in SdnToJulian; leads to segfault)
|
||||
--SKIPIF--
|
||||
<?php include 'skipif.inc'; ?>
|
||||
<?php
|
||||
include 'skipif.inc';
|
||||
if (PHP_INT_SIZE == 4) {
|
||||
die("skip this test is for 64bit platform only");
|
||||
}
|
||||
?>
|
||||
--FILE--
|
||||
<?php
|
||||
if (PHP_INT_MAX == 0x7FFFFFFF) {
|
||||
$x = 882858043;
|
||||
} else {
|
||||
$x = 3315881921229094912;
|
||||
}
|
||||
$x = 3315881921229094912;
|
||||
|
||||
var_dump(cal_from_jd($x, CAL_JULIAN));
|
||||
--EXPECT--
|
||||
@@ -0,0 +1,36 @@
|
||||
--TEST--
|
||||
Bug #55797: Integer overflow in SdnToGregorian leads to segfault (in optimized builds)
|
||||
--SKIPIF--
|
||||
<?php
|
||||
include 'skipif.inc';
|
||||
if (PHP_INT_SIZE != 4) {
|
||||
die("skip this test is for 32bit platform only");
|
||||
}
|
||||
?>
|
||||
--FILE--
|
||||
<?php
|
||||
$x = 882858030;
|
||||
|
||||
var_dump(cal_from_jd($x, CAL_GREGORIAN));
|
||||
--EXPECTF--
|
||||
array(9) {
|
||||
["date"]=>
|
||||
string(5) "0/0/0"
|
||||
["month"]=>
|
||||
int(0)
|
||||
["day"]=>
|
||||
int(0)
|
||||
["year"]=>
|
||||
int(0)
|
||||
["dow"]=>
|
||||
int(%d)
|
||||
["abbrevdayname"]=>
|
||||
string(%d) "%s"
|
||||
["dayname"]=>
|
||||
string(%d) "%s"
|
||||
["abbrevmonth"]=>
|
||||
string(0) ""
|
||||
["monthname"]=>
|
||||
string(0) ""
|
||||
}
|
||||
|
||||
@@ -0,0 +1,36 @@
|
||||
--TEST--
|
||||
Bug #55797: Integer overflow in SdnToGregorian leads to segfault (in optimized builds)
|
||||
--SKIPIF--
|
||||
<?php
|
||||
include 'skipif.inc';
|
||||
if (PHP_INT_SIZE == 4) {
|
||||
die("skip this test is for 64bit platform only");
|
||||
}
|
||||
?>
|
||||
--FILE--
|
||||
<?php
|
||||
$x = 9223372036854743639;
|
||||
|
||||
var_dump(cal_from_jd($x, CAL_GREGORIAN));
|
||||
--EXPECTF--
|
||||
array(9) {
|
||||
["date"]=>
|
||||
string(5) "0/0/0"
|
||||
["month"]=>
|
||||
int(0)
|
||||
["day"]=>
|
||||
int(0)
|
||||
["year"]=>
|
||||
int(0)
|
||||
["dow"]=>
|
||||
int(%d)
|
||||
["abbrevdayname"]=>
|
||||
string(%d) "%s"
|
||||
["dayname"]=>
|
||||
string(%d) "%s"
|
||||
["abbrevmonth"]=>
|
||||
string(0) ""
|
||||
["monthname"]=>
|
||||
string(0) ""
|
||||
}
|
||||
|
||||
@@ -6,6 +6,7 @@ date.timezone=UTC
|
||||
<?php include 'skipif.inc'; ?>
|
||||
--FILE--
|
||||
<?php
|
||||
putenv('TZ=UTC');
|
||||
echo date("Y-m-d", easter_date(2000))."\n";
|
||||
echo date("Y-m-d", easter_date(2001))."\n";
|
||||
echo date("Y-m-d", easter_date(2002))."\n";
|
||||
|
||||
@@ -14,30 +14,37 @@ $jd_days = Array(
|
||||
);
|
||||
|
||||
foreach ($jd_days as $jd_day) {
|
||||
echo "=== ", $jd_day, "\n";
|
||||
var_dump(jdmonthname($jd_day,0));
|
||||
var_dump(jdmonthname($jd_day,1));
|
||||
var_dump(jdmonthname($jd_day,2));
|
||||
var_dump(jdmonthname($jd_day,3));
|
||||
var_dump(jdmonthname($jd_day,4));
|
||||
var_dump(jdmonthname($jd_day,5));
|
||||
echo "\n";
|
||||
}
|
||||
|
||||
echo "Done\n";
|
||||
|
||||
?>
|
||||
--EXPECTF--
|
||||
=== 2453396
|
||||
string(3) "Jan"
|
||||
string(7) "January"
|
||||
string(3) "Jan"
|
||||
string(7) "January"
|
||||
string(6) "Shevat"
|
||||
string(0) ""
|
||||
|
||||
=== 2440588
|
||||
string(3) "Jan"
|
||||
string(7) "January"
|
||||
string(3) "Dec"
|
||||
string(8) "December"
|
||||
string(5) "Tevet"
|
||||
string(0) ""
|
||||
|
||||
=== -1
|
||||
string(0) ""
|
||||
string(0) ""
|
||||
string(0) ""
|
||||
@@ -45,6 +52,8 @@ string(0) ""
|
||||
string(0) ""
|
||||
string(0) ""
|
||||
|
||||
=== Array
|
||||
|
||||
Warning: jdmonthname() expects parameter 1 to be long, array given in %s on line %d
|
||||
bool(false)
|
||||
|
||||
@@ -62,10 +71,13 @@ bool(false)
|
||||
|
||||
Warning: jdmonthname() expects parameter 1 to be long, array given in %s on line %d
|
||||
bool(false)
|
||||
|
||||
=== 10000000
|
||||
string(3) "Dec"
|
||||
string(8) "December"
|
||||
string(3) "Jul"
|
||||
string(4) "July"
|
||||
string(6) "Tishri"
|
||||
string(0) ""
|
||||
|
||||
Done
|
||||
@@ -4,11 +4,12 @@ unixtojd()
|
||||
<?php include 'skipif.inc'; ?>
|
||||
--FILE--
|
||||
<?php
|
||||
putenv('TZ=UTC');
|
||||
echo unixtojd(40000). "\n";
|
||||
echo unixtojd(1000000000). "\n";
|
||||
echo unixtojd(1152459009). "\n";
|
||||
?>
|
||||
--EXPECT--
|
||||
2440588
|
||||
2452161
|
||||
2452162
|
||||
2453926
|
||||
+10
-4
@@ -2007,10 +2007,6 @@ string_copy:
|
||||
HashTable *postfields;
|
||||
struct HttpPost *first = NULL;
|
||||
struct HttpPost *last = NULL;
|
||||
char *postval;
|
||||
char *string_key = NULL;
|
||||
ulong num_key;
|
||||
uint string_key_len;
|
||||
|
||||
postfields = HASH_OF(*zvalue);
|
||||
if (!postfields) {
|
||||
@@ -2023,12 +2019,22 @@ string_copy:
|
||||
zend_hash_get_current_data(postfields, (void **) ¤t) == SUCCESS;
|
||||
zend_hash_move_forward(postfields)
|
||||
) {
|
||||
char *postval;
|
||||
char *string_key = NULL;
|
||||
uint string_key_len;
|
||||
ulong num_key;
|
||||
|
||||
SEPARATE_ZVAL(current);
|
||||
convert_to_string_ex(current);
|
||||
|
||||
zend_hash_get_current_key_ex(postfields, &string_key, &string_key_len, &num_key, 0, NULL);
|
||||
|
||||
/* Pretend we have a string_key here */
|
||||
if(!string_key) {
|
||||
spprintf(&string_key, 0, "%ld", num_key);
|
||||
string_key_len = strlen(string_key)+1;
|
||||
}
|
||||
|
||||
postval = Z_STRVAL_PP(current);
|
||||
|
||||
/* The arguments after _NAMELENGTH and _CONTENTSLENGTH
|
||||
|
||||
@@ -0,0 +1,53 @@
|
||||
--TEST--
|
||||
Test curl_opt() function with POST params from array with a numeric key
|
||||
--SKIPIF--
|
||||
<?php
|
||||
if (!extension_loaded("curl")) exit("skip curl extension not loaded");
|
||||
if (false === getenv('PHP_CURL_HTTP_REMOTE_SERVER')) exit("skip PHP_CURL_HTTP_REMOTE_SERVER env variable is not defined");
|
||||
?>
|
||||
--FILE--
|
||||
<?php
|
||||
/* Prototype : bool curl_setopt(resource ch, int option, mixed value)
|
||||
* Description: Set an option for a cURL transfer
|
||||
* Source code: ext/curl/interface.c
|
||||
* Alias to functions:
|
||||
*/
|
||||
|
||||
$host = getenv('PHP_CURL_HTTP_REMOTE_SERVER');
|
||||
|
||||
// start testing
|
||||
echo '*** Testing curl sending through GET an POST ***' . "\n";
|
||||
|
||||
$url = "{$host}/get.php?test=getpost&get_param=Hello%20World";
|
||||
$ch = curl_init();
|
||||
|
||||
ob_start(); // start output buffering
|
||||
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
|
||||
curl_setopt($ch, CURLOPT_POST, 1);
|
||||
curl_setopt($ch, CURLOPT_POSTFIELDS, array('Hello'=>'World','Foo'=>'Bar',100=>'John Doe'));
|
||||
curl_setopt($ch, CURLOPT_URL, $url); //set the url we want to use
|
||||
|
||||
$curl_content = curl_exec($ch);
|
||||
curl_close($ch);
|
||||
|
||||
var_dump( $curl_content );
|
||||
?>
|
||||
===DONE===
|
||||
--EXPECTF--
|
||||
*** Testing curl sending through GET an POST ***
|
||||
string(203) "array(2) {
|
||||
["test"]=>
|
||||
string(7) "getpost"
|
||||
["get_param"]=>
|
||||
string(11) "Hello World"
|
||||
}
|
||||
array(3) {
|
||||
["Hello"]=>
|
||||
string(5) "World"
|
||||
["Foo"]=>
|
||||
string(3) "Bar"
|
||||
[100]=>
|
||||
string(8) "John Doe"
|
||||
}
|
||||
"
|
||||
===DONE===
|
||||
+465
-519
File diff suppressed because it is too large.
Load diff
@@ -0,0 +1,380 @@
|
||||
--TEST--
|
||||
RFC: DateTime and Daylight Saving Time Transitions (zone type 1)
|
||||
--CREDITS--
|
||||
Daniel Convissor <danielc@php.net>
|
||||
--FILE--
|
||||
<?php
|
||||
|
||||
date_default_timezone_set('America/New_York');
|
||||
$date_format = 'Y-m-d H:i:s e';
|
||||
$interval_format = 'P%dDT%hH';
|
||||
|
||||
/*
|
||||
* Forward Transitions, diff().
|
||||
*/
|
||||
|
||||
$end = new DateTime('2010-03-14 03:00:00 -0400');
|
||||
$start = new DateTime('2010-03-14 01:59:59 -0500');
|
||||
echo 'fd1 ' . $end->format($date_format) . ' - ' . $start->format($date_format)
|
||||
. ' = ' . $start->diff($end)->format('PT%hH%iM%sS') . "\n";
|
||||
|
||||
$end = new DateTime('2010-03-14 04:30:00 -0400');
|
||||
$start = new DateTime('2010-03-13 04:30:00 -0500');
|
||||
echo 'fd2 ' . $end->format($date_format) . ' - ' . $start->format($date_format)
|
||||
. ' = ' . $start->diff($end)->format($interval_format) . "\n";
|
||||
|
||||
$end = new DateTime('2010-03-14 03:30:00 -0400');
|
||||
$start = new DateTime('2010-03-13 04:30:00 -0500');
|
||||
echo 'fd3 ' . $end->format($date_format) . ' - ' . $start->format($date_format)
|
||||
. ' = ' . $start->diff($end)->format($interval_format) . "\n";
|
||||
|
||||
$end = new DateTime('2010-03-14 01:30:00 -0500');
|
||||
$start = new DateTime('2010-03-13 04:30:00 -0500');
|
||||
echo 'fd4 ' . $end->format($date_format) . ' - ' . $start->format($date_format)
|
||||
. ' = ' . $start->diff($end)->format($interval_format) . "\n";
|
||||
|
||||
$end = new DateTime('2010-03-14 01:30:00 -0500');
|
||||
$start = new DateTime('2010-03-13 01:30:00 -0500');
|
||||
echo 'fd5 ' . $end->format($date_format) . ' - ' . $start->format($date_format)
|
||||
. ' = ' . $start->diff($end)->format($interval_format) . "\n";
|
||||
|
||||
$end = new DateTime('2010-03-14 03:30:00 -0400');
|
||||
$start = new DateTime('2010-03-13 03:30:00 -0500');
|
||||
echo 'fd6 ' . $end->format($date_format) . ' - ' . $start->format($date_format)
|
||||
. ' = ' . $start->diff($end)->format($interval_format) . "\n";
|
||||
|
||||
$end = new DateTime('2010-03-14 03:30:00 -0400');
|
||||
$start = new DateTime('2010-03-13 02:30:00 -0500');
|
||||
echo 'fd7 ' . $end->format($date_format) . ' - ' . $start->format($date_format)
|
||||
. ' = ' . $start->diff($end)->format($interval_format) . "\n";
|
||||
|
||||
echo "\n";
|
||||
|
||||
/*
|
||||
* Forward Transitions, add().
|
||||
*/
|
||||
|
||||
$start = new DateTime('2010-03-14 01:59:59 -0500');
|
||||
$interval_spec = 'PT1S';
|
||||
$interval = new DateInterval($interval_spec);
|
||||
echo 'fa1 ' . $start->format($date_format) . " + $interval_spec = "
|
||||
. $start->add($interval)->format($date_format) . "\n";
|
||||
|
||||
$start = new DateTime('2010-03-13 04:30:00 -0500');
|
||||
$interval_spec = 'P1D';
|
||||
$interval = new DateInterval($interval_spec);
|
||||
echo 'fa2 ' . $start->format($date_format) . " + $interval_spec = "
|
||||
. $start->add($interval)->format($date_format) . "\n";
|
||||
|
||||
$start = new DateTime('2010-03-13 04:30:00 -0500');
|
||||
$interval_spec = 'PT22H';
|
||||
$interval = new DateInterval($interval_spec);
|
||||
echo 'fa3 ' . $start->format($date_format) . " + $interval_spec = "
|
||||
. $start->add($interval)->format($date_format) . "\n";
|
||||
|
||||
$start = new DateTime('2010-03-13 04:30:00 -0500');
|
||||
$interval_spec = 'PT21H';
|
||||
$interval = new DateInterval($interval_spec);
|
||||
echo 'fa4 ' . $start->format($date_format) . " + $interval_spec = "
|
||||
. $start->add($interval)->format($date_format) . "\n";
|
||||
|
||||
$start = new DateTime('2010-03-13 01:30:00 -0500');
|
||||
$interval_spec = 'P1D';
|
||||
$interval = new DateInterval($interval_spec);
|
||||
echo 'fa5 ' . $start->format($date_format) . " + $interval_spec = "
|
||||
. $start->add($interval)->format($date_format) . "\n";
|
||||
|
||||
$start = new DateTime('2010-03-13 02:30:00 -0500');
|
||||
$interval_spec = 'P1D';
|
||||
$interval = new DateInterval($interval_spec);
|
||||
echo 'fa6 ' . $start->format($date_format) . " + $interval_spec = "
|
||||
. $start->add($interval)->format($date_format) . "\n";
|
||||
|
||||
echo "\n";
|
||||
|
||||
/*
|
||||
* Forward Transitions, sub().
|
||||
*/
|
||||
|
||||
$end = new DateTime('2010-03-14 03:00:00 -0400');
|
||||
$interval_spec = 'PT1S';
|
||||
$interval = new DateInterval($interval_spec);
|
||||
echo 'fs1 ' . $end->format($date_format) . " - $interval_spec = "
|
||||
. $end->sub($interval)->format($date_format) . "\n";
|
||||
|
||||
$end = new DateTime('2010-03-14 04:30:00 -0400');
|
||||
$interval_spec = 'P1D';
|
||||
$interval = new DateInterval($interval_spec);
|
||||
echo 'fs2 ' . $end->format($date_format) . " - $interval_spec = "
|
||||
. $end->sub($interval)->format($date_format) . "\n";
|
||||
|
||||
$end = new DateTime('2010-03-14 03:30:00 -0400');
|
||||
$interval_spec = 'PT22H';
|
||||
$interval = new DateInterval($interval_spec);
|
||||
echo 'fs3 ' . $end->format($date_format) . " - $interval_spec = "
|
||||
. $end->sub($interval)->format($date_format) . "\n";
|
||||
|
||||
$end = new DateTime('2010-03-14 01:30:00 -0500');
|
||||
$interval_spec = 'PT21H';
|
||||
$interval = new DateInterval($interval_spec);
|
||||
echo 'fs4 ' . $end->format($date_format) . " - $interval_spec = "
|
||||
. $end->sub($interval)->format($date_format) . "\n";
|
||||
|
||||
$end = new DateTime('2010-03-14 01:30:00 -0500');
|
||||
$interval_spec = 'P1D';
|
||||
$interval = new DateInterval($interval_spec);
|
||||
echo 'fs5 ' . $end->format($date_format) . " - $interval_spec = "
|
||||
. $end->sub($interval)->format($date_format) . "\n";
|
||||
|
||||
$end = new DateTime('2010-03-15 03:30:00 -0400');
|
||||
$interval_spec = 'P1D';
|
||||
$interval = new DateInterval($interval_spec);
|
||||
echo 'fs6 ' . $end->format($date_format) . " - $interval_spec = "
|
||||
. $end->sub($interval)->format($date_format) . "\n";
|
||||
|
||||
$end = new DateTime('2010-03-15 02:30:00 -0400');
|
||||
$interval_spec = 'P1D';
|
||||
$interval = new DateInterval($interval_spec);
|
||||
echo 'fs7 ' . $end->format($date_format) . " - $interval_spec = "
|
||||
. $end->sub($interval)->format($date_format) . "\n";
|
||||
|
||||
echo "\n";
|
||||
|
||||
/*
|
||||
* Backward Transitions, diff().
|
||||
*/
|
||||
|
||||
$end = new DateTime('2010-11-07 01:00:00 -0500');
|
||||
$start = new DateTime('2010-11-07 01:59:59 -0400');
|
||||
echo 'bd1 ' . $end->format($date_format) . ' - ' . $start->format($date_format)
|
||||
. ' = ' . $start->diff($end)->format('PT%hH%iM%sS') . "\n";
|
||||
|
||||
$end = new DateTime('2010-11-07 04:30:00 -0500');
|
||||
$start = new DateTime('2010-11-06 04:30:00 -0400');
|
||||
echo 'bd2 ' . $end->format($date_format) . ' - ' . $start->format($date_format)
|
||||
. ' = ' . $start->diff($end)->format($interval_format) . "\n";
|
||||
|
||||
$end = new DateTime('2010-11-07 03:30:00 -0500');
|
||||
$start = new DateTime('2010-11-06 04:30:00 -0400');
|
||||
echo 'bd3 ' . $end->format($date_format) . ' - ' . $start->format($date_format)
|
||||
. ' = ' . $start->diff($end)->format($interval_format) . "\n";
|
||||
|
||||
$end = new DateTime('2010-11-07 02:30:00 -0500');
|
||||
$start = new DateTime('2010-11-06 04:30:00 -0400');
|
||||
echo 'bd4 ' . $end->format($date_format) . ' - ' . $start->format($date_format)
|
||||
. ' = ' . $start->diff($end)->format($interval_format) . "\n";
|
||||
|
||||
$end = new DateTime('2010-11-07 01:30:00 -0500');
|
||||
$start = new DateTime('2010-11-06 04:30:00 -0400');
|
||||
echo 'bd5 ' . $end->format($date_format) . ' - ' . $start->format($date_format)
|
||||
. ' = ' . $start->diff($end)->format($interval_format) . "\n";
|
||||
|
||||
$end = new DateTime('2010-11-07 01:30:00 -0400');
|
||||
$start = new DateTime('2010-11-06 04:30:00 -0400');
|
||||
echo 'bd6 ' . $end->format($date_format) . ' - ' . $start->format($date_format)
|
||||
. ' = ' . $start->diff($end)->format($interval_format) . "\n";
|
||||
|
||||
$end = new DateTime('2010-11-07 01:30:00 -0400');
|
||||
$start = new DateTime('2010-11-06 01:30:00 -0400');
|
||||
echo 'bd7 ' . $end->format($date_format) . ' - ' . $start->format($date_format)
|
||||
. ' = ' . $start->diff($end)->format($interval_format) . "\n";
|
||||
|
||||
$end = new DateTime('2010-11-07 01:30:00 -0500');
|
||||
$start = new DateTime('2010-11-06 01:30:00 -0400');
|
||||
echo 'bd8 ' . $end->format($date_format) . ' - ' . $start->format($date_format)
|
||||
. ' = ' . $start->diff($end)->format($interval_format) . "\n";
|
||||
|
||||
echo "\n";
|
||||
|
||||
/*
|
||||
* Backward Transitions, add().
|
||||
*/
|
||||
|
||||
$start = new DateTime('2010-11-07 01:59:59 -0400');
|
||||
$interval_spec = 'PT1S';
|
||||
$interval = new DateInterval($interval_spec);
|
||||
echo 'ba1 ' . $start->format($date_format) . " + $interval_spec = "
|
||||
. $start->add($interval)->format($date_format) . "\n";
|
||||
|
||||
$start = new DateTime('2010-11-06 04:30:00 -0400');
|
||||
$interval_spec = 'P1D';
|
||||
$interval = new DateInterval($interval_spec);
|
||||
echo 'ba2 ' . $start->format($date_format) . " + $interval_spec = "
|
||||
. $start->add($interval)->format($date_format) . "\n";
|
||||
|
||||
$start = new DateTime('2010-11-06 04:30:00 -0400');
|
||||
$interval_spec = 'PT24H';
|
||||
$interval = new DateInterval($interval_spec);
|
||||
echo 'ba3 ' . $start->format($date_format) . " + $interval_spec = "
|
||||
. $start->add($interval)->format($date_format) . "\n";
|
||||
|
||||
$start = new DateTime('2010-11-06 04:30:00 -0400');
|
||||
$interval_spec = 'PT23H';
|
||||
$interval = new DateInterval($interval_spec);
|
||||
echo 'ba4 ' . $start->format($date_format) . " + $interval_spec = "
|
||||
. $start->add($interval)->format($date_format) . "\n";
|
||||
|
||||
$start = new DateTime('2010-11-06 04:30:00 -0400');
|
||||
$interval_spec = 'PT22H';
|
||||
$interval = new DateInterval($interval_spec);
|
||||
echo 'ba5 ' . $start->format($date_format) . " + $interval_spec = "
|
||||
. $start->add($interval)->format($date_format) . "\n";
|
||||
|
||||
$start = new DateTime('2010-11-06 04:30:00 -0400');
|
||||
$interval_spec = 'PT21H';
|
||||
$interval = new DateInterval($interval_spec);
|
||||
echo 'ba6 ' . $start->format($date_format) . " + $interval_spec = "
|
||||
. $start->add($interval)->format($date_format) . "\n";
|
||||
|
||||
$start = new DateTime('2010-11-06 01:30:00 -0400');
|
||||
$interval_spec = 'P1D';
|
||||
$interval = new DateInterval($interval_spec);
|
||||
echo 'ba7 ' . $start->format($date_format) . " + $interval_spec = "
|
||||
. $start->add($interval)->format($date_format) . "\n";
|
||||
|
||||
$start = new DateTime('2010-11-06 01:30:00 -0400');
|
||||
$interval_spec = 'P1DT1H';
|
||||
$interval = new DateInterval($interval_spec);
|
||||
echo 'ba8 ' . $start->format($date_format) . " + $interval_spec = "
|
||||
. $start->add($interval)->format($date_format) . "\n";
|
||||
|
||||
$start = new DateTime('2010-11-06 04:30:00 -0400');
|
||||
$interval_spec = 'PT25H';
|
||||
$interval = new DateInterval($interval_spec);
|
||||
echo 'ba9 ' . $start->format($date_format) . " + $interval_spec = "
|
||||
. $start->add($interval)->format($date_format) . "\n";
|
||||
|
||||
$start = new DateTime('2010-11-06 03:30:00 -0400');
|
||||
$interval_spec = 'P1D';
|
||||
$interval = new DateInterval($interval_spec);
|
||||
echo 'ba10 ' . $start->format($date_format) . " + $interval_spec = "
|
||||
. $start->add($interval)->format($date_format) . "\n";
|
||||
|
||||
$start = new DateTime('2010-11-06 02:30:00 -0400');
|
||||
$interval_spec = 'P1D';
|
||||
$interval = new DateInterval($interval_spec);
|
||||
echo 'ba11 ' . $start->format($date_format) . " + $interval_spec = "
|
||||
. $start->add($interval)->format($date_format) . "\n";
|
||||
|
||||
echo "\n";
|
||||
|
||||
/*
|
||||
* Backward Transitions, sub().
|
||||
*/
|
||||
|
||||
$end = new DateTime('2010-11-07 01:00:00 -0500');
|
||||
$interval_spec = 'PT1S';
|
||||
$interval = new DateInterval($interval_spec);
|
||||
echo 'bs1 ' . $end->format($date_format) . " - $interval_spec = "
|
||||
. $end->sub($interval)->format($date_format) . "\n";
|
||||
|
||||
$end = new DateTime('2010-11-07 04:30:00 -0500');
|
||||
$interval_spec = 'P1D';
|
||||
$interval = new DateInterval($interval_spec);
|
||||
echo 'bs2 ' . $end->format($date_format) . " - $interval_spec = "
|
||||
. $end->sub($interval)->format($date_format) . "\n";
|
||||
|
||||
$end = new DateTime('2010-11-07 03:30:00 -0500');
|
||||
$interval_spec = 'PT24H';
|
||||
$interval = new DateInterval($interval_spec);
|
||||
echo 'bs3 ' . $end->format($date_format) . " - $interval_spec = "
|
||||
. $end->sub($interval)->format($date_format) . "\n";
|
||||
|
||||
$end = new DateTime('2010-11-07 02:30:00 -0500');
|
||||
$interval_spec = 'PT23H';
|
||||
$interval = new DateInterval($interval_spec);
|
||||
echo 'bs4 ' . $end->format($date_format) . " - $interval_spec = "
|
||||
. $end->sub($interval)->format($date_format) . "\n";
|
||||
|
||||
$end = new DateTime('2010-11-07 01:30:00 -0500');
|
||||
$interval_spec = 'PT22H';
|
||||
$interval = new DateInterval($interval_spec);
|
||||
echo 'bs5 ' . $end->format($date_format) . " - $interval_spec = "
|
||||
. $end->sub($interval)->format($date_format) . "\n";
|
||||
|
||||
$end = new DateTime('2010-11-07 01:30:00 -0400');
|
||||
$interval_spec = 'PT21H';
|
||||
$interval = new DateInterval($interval_spec);
|
||||
echo 'bs6 ' . $end->format($date_format) . " - $interval_spec = "
|
||||
. $end->sub($interval)->format($date_format) . "\n";
|
||||
|
||||
$end = new DateTime('2010-11-07 01:30:00 -0400');
|
||||
$interval_spec = 'P1D';
|
||||
$interval = new DateInterval($interval_spec);
|
||||
echo 'bs7 ' . $end->format($date_format) . " - $interval_spec = "
|
||||
. $end->sub($interval)->format($date_format) . "\n";
|
||||
|
||||
$end = new DateTime('2010-11-07 01:30:00 -0500');
|
||||
$interval_spec = 'P1DT1H';
|
||||
$interval = new DateInterval($interval_spec);
|
||||
echo 'bs8 ' . $end->format($date_format) . " - $interval_spec = "
|
||||
. $end->sub($interval)->format($date_format) . "\n";
|
||||
|
||||
$end = new DateTime('2010-11-07 03:30:00 -0500');
|
||||
$interval_spec = 'P1D';
|
||||
$interval = new DateInterval($interval_spec);
|
||||
echo 'bs9 ' . $end->format($date_format) . " - $interval_spec = "
|
||||
. $end->sub($interval)->format($date_format) . "\n";
|
||||
|
||||
$end = new DateTime('2010-11-07 02:30:00 -0500');
|
||||
$interval_spec = 'P1D';
|
||||
$interval = new DateInterval($interval_spec);
|
||||
echo 'bs10 ' . $end->format($date_format) . " - $interval_spec = "
|
||||
. $end->sub($interval)->format($date_format) . "\n";
|
||||
|
||||
?>
|
||||
--EXPECT--
|
||||
fd1 2010-03-14 03:00:00 -04:00 - 2010-03-14 01:59:59 -05:00 = PT0H0M1S
|
||||
fd2 2010-03-14 04:30:00 -04:00 - 2010-03-13 04:30:00 -05:00 = P0DT23H
|
||||
fd3 2010-03-14 03:30:00 -04:00 - 2010-03-13 04:30:00 -05:00 = P0DT22H
|
||||
fd4 2010-03-14 01:30:00 -05:00 - 2010-03-13 04:30:00 -05:00 = P0DT21H
|
||||
fd5 2010-03-14 01:30:00 -05:00 - 2010-03-13 01:30:00 -05:00 = P1DT0H
|
||||
fd6 2010-03-14 03:30:00 -04:00 - 2010-03-13 03:30:00 -05:00 = P0DT23H
|
||||
fd7 2010-03-14 03:30:00 -04:00 - 2010-03-13 02:30:00 -05:00 = P1DT0H
|
||||
|
||||
fa1 2010-03-14 01:59:59 -05:00 + PT1S = 2010-03-14 02:00:00 -05:00
|
||||
fa2 2010-03-13 04:30:00 -05:00 + P1D = 2010-03-14 04:30:00 -05:00
|
||||
fa3 2010-03-13 04:30:00 -05:00 + PT22H = 2010-03-14 02:30:00 -05:00
|
||||
fa4 2010-03-13 04:30:00 -05:00 + PT21H = 2010-03-14 01:30:00 -05:00
|
||||
fa5 2010-03-13 01:30:00 -05:00 + P1D = 2010-03-14 01:30:00 -05:00
|
||||
fa6 2010-03-13 02:30:00 -05:00 + P1D = 2010-03-14 02:30:00 -05:00
|
||||
|
||||
fs1 2010-03-14 03:00:00 -04:00 - PT1S = 2010-03-14 02:59:59 -04:00
|
||||
fs2 2010-03-14 04:30:00 -04:00 - P1D = 2010-03-13 04:30:00 -04:00
|
||||
fs3 2010-03-14 03:30:00 -04:00 - PT22H = 2010-03-13 05:30:00 -04:00
|
||||
fs4 2010-03-14 01:30:00 -05:00 - PT21H = 2010-03-13 04:30:00 -05:00
|
||||
fs5 2010-03-14 01:30:00 -05:00 - P1D = 2010-03-13 01:30:00 -05:00
|
||||
fs6 2010-03-15 03:30:00 -04:00 - P1D = 2010-03-14 03:30:00 -04:00
|
||||
fs7 2010-03-15 02:30:00 -04:00 - P1D = 2010-03-14 02:30:00 -04:00
|
||||
|
||||
bd1 2010-11-07 01:00:00 -05:00 - 2010-11-07 01:59:59 -04:00 = PT0H0M1S
|
||||
bd2 2010-11-07 04:30:00 -05:00 - 2010-11-06 04:30:00 -04:00 = P1DT1H
|
||||
bd3 2010-11-07 03:30:00 -05:00 - 2010-11-06 04:30:00 -04:00 = P1DT0H
|
||||
bd4 2010-11-07 02:30:00 -05:00 - 2010-11-06 04:30:00 -04:00 = P0DT23H
|
||||
bd5 2010-11-07 01:30:00 -05:00 - 2010-11-06 04:30:00 -04:00 = P0DT22H
|
||||
bd6 2010-11-07 01:30:00 -04:00 - 2010-11-06 04:30:00 -04:00 = P0DT21H
|
||||
bd7 2010-11-07 01:30:00 -04:00 - 2010-11-06 01:30:00 -04:00 = P1DT0H
|
||||
bd8 2010-11-07 01:30:00 -05:00 - 2010-11-06 01:30:00 -04:00 = P1DT1H
|
||||
|
||||
ba1 2010-11-07 01:59:59 -04:00 + PT1S = 2010-11-07 02:00:00 -04:00
|
||||
ba2 2010-11-06 04:30:00 -04:00 + P1D = 2010-11-07 04:30:00 -04:00
|
||||
ba3 2010-11-06 04:30:00 -04:00 + PT24H = 2010-11-07 04:30:00 -04:00
|
||||
ba4 2010-11-06 04:30:00 -04:00 + PT23H = 2010-11-07 03:30:00 -04:00
|
||||
ba5 2010-11-06 04:30:00 -04:00 + PT22H = 2010-11-07 02:30:00 -04:00
|
||||
ba6 2010-11-06 04:30:00 -04:00 + PT21H = 2010-11-07 01:30:00 -04:00
|
||||
ba7 2010-11-06 01:30:00 -04:00 + P1D = 2010-11-07 01:30:00 -04:00
|
||||
ba8 2010-11-06 01:30:00 -04:00 + P1DT1H = 2010-11-07 02:30:00 -04:00
|
||||
ba9 2010-11-06 04:30:00 -04:00 + PT25H = 2010-11-07 05:30:00 -04:00
|
||||
ba10 2010-11-06 03:30:00 -04:00 + P1D = 2010-11-07 03:30:00 -04:00
|
||||
ba11 2010-11-06 02:30:00 -04:00 + P1D = 2010-11-07 02:30:00 -04:00
|
||||
|
||||
bs1 2010-11-07 01:00:00 -05:00 - PT1S = 2010-11-07 00:59:59 -05:00
|
||||
bs2 2010-11-07 04:30:00 -05:00 - P1D = 2010-11-06 04:30:00 -05:00
|
||||
bs3 2010-11-07 03:30:00 -05:00 - PT24H = 2010-11-06 03:30:00 -05:00
|
||||
bs4 2010-11-07 02:30:00 -05:00 - PT23H = 2010-11-06 03:30:00 -05:00
|
||||
bs5 2010-11-07 01:30:00 -05:00 - PT22H = 2010-11-06 03:30:00 -05:00
|
||||
bs6 2010-11-07 01:30:00 -04:00 - PT21H = 2010-11-06 04:30:00 -04:00
|
||||
bs7 2010-11-07 01:30:00 -04:00 - P1D = 2010-11-06 01:30:00 -04:00
|
||||
bs8 2010-11-07 01:30:00 -05:00 - P1DT1H = 2010-11-06 00:30:00 -05:00
|
||||
bs9 2010-11-07 03:30:00 -05:00 - P1D = 2010-11-06 03:30:00 -05:00
|
||||
bs10 2010-11-07 02:30:00 -05:00 - P1D = 2010-11-06 02:30:00 -05:00
|
||||
@@ -0,0 +1,382 @@
|
||||
--TEST--
|
||||
RFC: DateTime and Daylight Saving Time Transitions (zone type 2)
|
||||
--CREDITS--
|
||||
Daniel Convissor <danielc@php.net>
|
||||
--XFAIL--
|
||||
RFC not implemented yet
|
||||
--FILE--
|
||||
<?php
|
||||
|
||||
date_default_timezone_set('America/New_York');
|
||||
$date_format = 'Y-m-d H:i:s T e';
|
||||
$interval_format = 'P%dDT%hH';
|
||||
|
||||
/*
|
||||
* Forward Transitions, diff().
|
||||
*/
|
||||
|
||||
$end = new DateTime('2010-03-14 03:00:00 EDT');
|
||||
$start = new DateTime('2010-03-14 01:59:59 EST');
|
||||
echo 'fd1 ' . $end->format($date_format) . ' - ' . $start->format($date_format)
|
||||
. ' = ' . $start->diff($end)->format('PT%hH%iM%sS') . "\n";
|
||||
|
||||
$end = new DateTime('2010-03-14 04:30:00 EDT');
|
||||
$start = new DateTime('2010-03-13 04:30:00 EST');
|
||||
echo 'fd2 ' . $end->format($date_format) . ' - ' . $start->format($date_format)
|
||||
. ' = ' . $start->diff($end)->format($interval_format) . "\n";
|
||||
|
||||
$end = new DateTime('2010-03-14 03:30:00 EDT');
|
||||
$start = new DateTime('2010-03-13 04:30:00 EST');
|
||||
echo 'fd3 ' . $end->format($date_format) . ' - ' . $start->format($date_format)
|
||||
. ' = ' . $start->diff($end)->format($interval_format) . "\n";
|
||||
|
||||
$end = new DateTime('2010-03-14 01:30:00 EST');
|
||||
$start = new DateTime('2010-03-13 04:30:00 EST');
|
||||
echo 'fd4 ' . $end->format($date_format) . ' - ' . $start->format($date_format)
|
||||
. ' = ' . $start->diff($end)->format($interval_format) . "\n";
|
||||
|
||||
$end = new DateTime('2010-03-14 01:30:00 EST');
|
||||
$start = new DateTime('2010-03-13 01:30:00 EST');
|
||||
echo 'fd5 ' . $end->format($date_format) . ' - ' . $start->format($date_format)
|
||||
. ' = ' . $start->diff($end)->format($interval_format) . "\n";
|
||||
|
||||
$end = new DateTime('2010-03-14 03:30:00 EDT');
|
||||
$start = new DateTime('2010-03-13 03:30:00 EST');
|
||||
echo 'fd6 ' . $end->format($date_format) . ' - ' . $start->format($date_format)
|
||||
. ' = ' . $start->diff($end)->format($interval_format) . "\n";
|
||||
|
||||
$end = new DateTime('2010-03-14 03:30:00 EDT');
|
||||
$start = new DateTime('2010-03-13 02:30:00 EST');
|
||||
echo 'fd7 ' . $end->format($date_format) . ' - ' . $start->format($date_format)
|
||||
. ' = ' . $start->diff($end)->format($interval_format) . "\n";
|
||||
|
||||
echo "\n";
|
||||
|
||||
/*
|
||||
* Forward Transitions, add().
|
||||
*/
|
||||
|
||||
$start = new DateTime('2010-03-14 01:59:59 EST');
|
||||
$interval_spec = 'PT1S';
|
||||
$interval = new DateInterval($interval_spec);
|
||||
echo 'fa1 ' . $start->format($date_format) . " + $interval_spec = "
|
||||
. $start->add($interval)->format($date_format) . "\n";
|
||||
|
||||
$start = new DateTime('2010-03-13 04:30:00 EST');
|
||||
$interval_spec = 'P1D';
|
||||
$interval = new DateInterval($interval_spec);
|
||||
echo 'fa2 ' . $start->format($date_format) . " + $interval_spec = "
|
||||
. $start->add($interval)->format($date_format) . "\n";
|
||||
|
||||
$start = new DateTime('2010-03-13 04:30:00 EST');
|
||||
$interval_spec = 'PT22H';
|
||||
$interval = new DateInterval($interval_spec);
|
||||
echo 'fa3 ' . $start->format($date_format) . " + $interval_spec = "
|
||||
. $start->add($interval)->format($date_format) . "\n";
|
||||
|
||||
$start = new DateTime('2010-03-13 04:30:00 EST');
|
||||
$interval_spec = 'PT21H';
|
||||
$interval = new DateInterval($interval_spec);
|
||||
echo 'fa4 ' . $start->format($date_format) . " + $interval_spec = "
|
||||
. $start->add($interval)->format($date_format) . "\n";
|
||||
|
||||
$start = new DateTime('2010-03-13 01:30:00 EST');
|
||||
$interval_spec = 'P1D';
|
||||
$interval = new DateInterval($interval_spec);
|
||||
echo 'fa5 ' . $start->format($date_format) . " + $interval_spec = "
|
||||
. $start->add($interval)->format($date_format) . "\n";
|
||||
|
||||
$start = new DateTime('2010-03-13 02:30:00 EST');
|
||||
$interval_spec = 'P1D';
|
||||
$interval = new DateInterval($interval_spec);
|
||||
echo 'fa6 ' . $start->format($date_format) . " + $interval_spec = "
|
||||
. $start->add($interval)->format($date_format) . "\n";
|
||||
|
||||
echo "\n";
|
||||
|
||||
/*
|
||||
* Forward Transitions, sub().
|
||||
*/
|
||||
|
||||
$end = new DateTime('2010-03-14 03:00:00 EDT');
|
||||
$interval_spec = 'PT1S';
|
||||
$interval = new DateInterval($interval_spec);
|
||||
echo 'fs1 ' . $end->format($date_format) . " - $interval_spec = "
|
||||
. $end->sub($interval)->format($date_format) . "\n";
|
||||
|
||||
$end = new DateTime('2010-03-14 04:30:00 EDT');
|
||||
$interval_spec = 'P1D';
|
||||
$interval = new DateInterval($interval_spec);
|
||||
echo 'fs2 ' . $end->format($date_format) . " - $interval_spec = "
|
||||
. $end->sub($interval)->format($date_format) . "\n";
|
||||
|
||||
$end = new DateTime('2010-03-14 03:30:00 EDT');
|
||||
$interval_spec = 'PT22H';
|
||||
$interval = new DateInterval($interval_spec);
|
||||
echo 'fs3 ' . $end->format($date_format) . " - $interval_spec = "
|
||||
. $end->sub($interval)->format($date_format) . "\n";
|
||||
|
||||
$end = new DateTime('2010-03-14 01:30:00 EST');
|
||||
$interval_spec = 'PT21H';
|
||||
$interval = new DateInterval($interval_spec);
|
||||
echo 'fs4 ' . $end->format($date_format) . " - $interval_spec = "
|
||||
. $end->sub($interval)->format($date_format) . "\n";
|
||||
|
||||
$end = new DateTime('2010-03-14 01:30:00 EST');
|
||||
$interval_spec = 'P1D';
|
||||
$interval = new DateInterval($interval_spec);
|
||||
echo 'fs5 ' . $end->format($date_format) . " - $interval_spec = "
|
||||
. $end->sub($interval)->format($date_format) . "\n";
|
||||
|
||||
$end = new DateTime('2010-03-15 03:30:00 EDT');
|
||||
$interval_spec = 'P1D';
|
||||
$interval = new DateInterval($interval_spec);
|
||||
echo 'fs6 ' . $end->format($date_format) . " - $interval_spec = "
|
||||
. $end->sub($interval)->format($date_format) . "\n";
|
||||
|
||||
$end = new DateTime('2010-03-15 02:30:00 EDT');
|
||||
$interval_spec = 'P1D';
|
||||
$interval = new DateInterval($interval_spec);
|
||||
echo 'fs7 ' . $end->format($date_format) . " - $interval_spec = "
|
||||
. $end->sub($interval)->format($date_format) . "\n";
|
||||
|
||||
echo "\n";
|
||||
|
||||
/*
|
||||
* Backward Transitions, diff().
|
||||
*/
|
||||
|
||||
$end = new DateTime('2010-11-07 01:00:00 EST');
|
||||
$start = new DateTime('2010-11-07 01:59:59 EDT');
|
||||
echo 'bd1 ' . $end->format($date_format) . ' - ' . $start->format($date_format)
|
||||
. ' = ' . $start->diff($end)->format('PT%hH%iM%sS') . "\n";
|
||||
|
||||
$end = new DateTime('2010-11-07 04:30:00 EST');
|
||||
$start = new DateTime('2010-11-06 04:30:00 EDT');
|
||||
echo 'bd2 ' . $end->format($date_format) . ' - ' . $start->format($date_format)
|
||||
. ' = ' . $start->diff($end)->format($interval_format) . "\n";
|
||||
|
||||
$end = new DateTime('2010-11-07 03:30:00 EST');
|
||||
$start = new DateTime('2010-11-06 04:30:00 EDT');
|
||||
echo 'bd3 ' . $end->format($date_format) . ' - ' . $start->format($date_format)
|
||||
. ' = ' . $start->diff($end)->format($interval_format) . "\n";
|
||||
|
||||
$end = new DateTime('2010-11-07 02:30:00 EST');
|
||||
$start = new DateTime('2010-11-06 04:30:00 EDT');
|
||||
echo 'bd4 ' . $end->format($date_format) . ' - ' . $start->format($date_format)
|
||||
. ' = ' . $start->diff($end)->format($interval_format) . "\n";
|
||||
|
||||
$end = new DateTime('2010-11-07 01:30:00 EST');
|
||||
$start = new DateTime('2010-11-06 04:30:00 EDT');
|
||||
echo 'bd5 ' . $end->format($date_format) . ' - ' . $start->format($date_format)
|
||||
. ' = ' . $start->diff($end)->format($interval_format) . "\n";
|
||||
|
||||
$end = new DateTime('2010-11-07 01:30:00 EDT');
|
||||
$start = new DateTime('2010-11-06 04:30:00 EDT');
|
||||
echo 'bd6 ' . $end->format($date_format) . ' - ' . $start->format($date_format)
|
||||
. ' = ' . $start->diff($end)->format($interval_format) . "\n";
|
||||
|
||||
$end = new DateTime('2010-11-07 01:30:00 EDT');
|
||||
$start = new DateTime('2010-11-06 01:30:00 EDT');
|
||||
echo 'bd7 ' . $end->format($date_format) . ' - ' . $start->format($date_format)
|
||||
. ' = ' . $start->diff($end)->format($interval_format) . "\n";
|
||||
|
||||
$end = new DateTime('2010-11-07 01:30:00 EST');
|
||||
$start = new DateTime('2010-11-06 01:30:00 EDT');
|
||||
echo 'bd8 ' . $end->format($date_format) . ' - ' . $start->format($date_format)
|
||||
. ' = ' . $start->diff($end)->format($interval_format) . "\n";
|
||||
|
||||
echo "\n";
|
||||
|
||||
/*
|
||||
* Backward Transitions, add().
|
||||
*/
|
||||
|
||||
$start = new DateTime('2010-11-07 01:59:59 EDT');
|
||||
$interval_spec = 'PT1S';
|
||||
$interval = new DateInterval($interval_spec);
|
||||
echo 'ba1 ' . $start->format($date_format) . " + $interval_spec = "
|
||||
. $start->add($interval)->format($date_format) . "\n";
|
||||
|
||||
$start = new DateTime('2010-11-06 04:30:00 EDT');
|
||||
$interval_spec = 'P1D';
|
||||
$interval = new DateInterval($interval_spec);
|
||||
echo 'ba2 ' . $start->format($date_format) . " + $interval_spec = "
|
||||
. $start->add($interval)->format($date_format) . "\n";
|
||||
|
||||
$start = new DateTime('2010-11-06 04:30:00 EDT');
|
||||
$interval_spec = 'PT24H';
|
||||
$interval = new DateInterval($interval_spec);
|
||||
echo 'ba3 ' . $start->format($date_format) . " + $interval_spec = "
|
||||
. $start->add($interval)->format($date_format) . "\n";
|
||||
|
||||
$start = new DateTime('2010-11-06 04:30:00 EDT');
|
||||
$interval_spec = 'PT23H';
|
||||
$interval = new DateInterval($interval_spec);
|
||||
echo 'ba4 ' . $start->format($date_format) . " + $interval_spec = "
|
||||
. $start->add($interval)->format($date_format) . "\n";
|
||||
|
||||
$start = new DateTime('2010-11-06 04:30:00 EDT');
|
||||
$interval_spec = 'PT22H';
|
||||
$interval = new DateInterval($interval_spec);
|
||||
echo 'ba5 ' . $start->format($date_format) . " + $interval_spec = "
|
||||
. $start->add($interval)->format($date_format) . "\n";
|
||||
|
||||
$start = new DateTime('2010-11-06 04:30:00 EDT');
|
||||
$interval_spec = 'PT21H';
|
||||
$interval = new DateInterval($interval_spec);
|
||||
echo 'ba6 ' . $start->format($date_format) . " + $interval_spec = "
|
||||
. $start->add($interval)->format($date_format) . "\n";
|
||||
|
||||
$start = new DateTime('2010-11-06 01:30:00 EDT');
|
||||
$interval_spec = 'P1D';
|
||||
$interval = new DateInterval($interval_spec);
|
||||
echo 'ba7 ' . $start->format($date_format) . " + $interval_spec = "
|
||||
. $start->add($interval)->format($date_format) . "\n";
|
||||
|
||||
$start = new DateTime('2010-11-06 01:30:00 EDT');
|
||||
$interval_spec = 'P1DT1H';
|
||||
$interval = new DateInterval($interval_spec);
|
||||
echo 'ba8 ' . $start->format($date_format) . " + $interval_spec = "
|
||||
. $start->add($interval)->format($date_format) . "\n";
|
||||
|
||||
$start = new DateTime('2010-11-06 04:30:00 EDT');
|
||||
$interval_spec = 'PT25H';
|
||||
$interval = new DateInterval($interval_spec);
|
||||
echo 'ba9 ' . $start->format($date_format) . " + $interval_spec = "
|
||||
. $start->add($interval)->format($date_format) . "\n";
|
||||
|
||||
$start = new DateTime('2010-11-06 03:30:00 EDT');
|
||||
$interval_spec = 'P1D';
|
||||
$interval = new DateInterval($interval_spec);
|
||||
echo 'ba10 ' . $start->format($date_format) . " + $interval_spec = "
|
||||
. $start->add($interval)->format($date_format) . "\n";
|
||||
|
||||
$start = new DateTime('2010-11-06 02:30:00 EDT');
|
||||
$interval_spec = 'P1D';
|
||||
$interval = new DateInterval($interval_spec);
|
||||
echo 'ba11 ' . $start->format($date_format) . " + $interval_spec = "
|
||||
. $start->add($interval)->format($date_format) . "\n";
|
||||
|
||||
echo "\n";
|
||||
|
||||
/*
|
||||
* Backward Transitions, sub().
|
||||
*/
|
||||
|
||||
$end = new DateTime('2010-11-07 01:00:00 EST');
|
||||
$interval_spec = 'PT1S';
|
||||
$interval = new DateInterval($interval_spec);
|
||||
echo 'bs1 ' . $end->format($date_format) . " - $interval_spec = "
|
||||
. $end->sub($interval)->format($date_format) . "\n";
|
||||
|
||||
$end = new DateTime('2010-11-07 04:30:00 EST');
|
||||
$interval_spec = 'P1D';
|
||||
$interval = new DateInterval($interval_spec);
|
||||
echo 'bs2 ' . $end->format($date_format) . " - $interval_spec = "
|
||||
. $end->sub($interval)->format($date_format) . "\n";
|
||||
|
||||
$end = new DateTime('2010-11-07 03:30:00 EST');
|
||||
$interval_spec = 'PT24H';
|
||||
$interval = new DateInterval($interval_spec);
|
||||
echo 'bs3 ' . $end->format($date_format) . " - $interval_spec = "
|
||||
. $end->sub($interval)->format($date_format) . "\n";
|
||||
|
||||
$end = new DateTime('2010-11-07 02:30:00 EST');
|
||||
$interval_spec = 'PT23H';
|
||||
$interval = new DateInterval($interval_spec);
|
||||
echo 'bs4 ' . $end->format($date_format) . " - $interval_spec = "
|
||||
. $end->sub($interval)->format($date_format) . "\n";
|
||||
|
||||
$end = new DateTime('2010-11-07 01:30:00 EST');
|
||||
$interval_spec = 'PT22H';
|
||||
$interval = new DateInterval($interval_spec);
|
||||
echo 'bs5 ' . $end->format($date_format) . " - $interval_spec = "
|
||||
. $end->sub($interval)->format($date_format) . "\n";
|
||||
|
||||
$end = new DateTime('2010-11-07 01:30:00 EDT');
|
||||
$interval_spec = 'PT21H';
|
||||
$interval = new DateInterval($interval_spec);
|
||||
echo 'bs6 ' . $end->format($date_format) . " - $interval_spec = "
|
||||
. $end->sub($interval)->format($date_format) . "\n";
|
||||
|
||||
$end = new DateTime('2010-11-07 01:30:00 EDT');
|
||||
$interval_spec = 'P1D';
|
||||
$interval = new DateInterval($interval_spec);
|
||||
echo 'bs7 ' . $end->format($date_format) . " - $interval_spec = "
|
||||
. $end->sub($interval)->format($date_format) . "\n";
|
||||
|
||||
$end = new DateTime('2010-11-07 01:30:00 EST');
|
||||
$interval_spec = 'P1DT1H';
|
||||
$interval = new DateInterval($interval_spec);
|
||||
echo 'bs8 ' . $end->format($date_format) . " - $interval_spec = "
|
||||
. $end->sub($interval)->format($date_format) . "\n";
|
||||
|
||||
$end = new DateTime('2010-11-07 03:30:00 EST');
|
||||
$interval_spec = 'P1D';
|
||||
$interval = new DateInterval($interval_spec);
|
||||
echo 'bs9 ' . $end->format($date_format) . " - $interval_spec = "
|
||||
. $end->sub($interval)->format($date_format) . "\n";
|
||||
|
||||
$end = new DateTime('2010-11-07 02:30:00 EST');
|
||||
$interval_spec = 'P1D';
|
||||
$interval = new DateInterval($interval_spec);
|
||||
echo 'bs10 ' . $end->format($date_format) . " - $interval_spec = "
|
||||
. $end->sub($interval)->format($date_format) . "\n";
|
||||
|
||||
?>
|
||||
--EXPECT--
|
||||
fd1 2010-03-14 03:00:00 EDT EDT - 2010-03-14 01:59:59 EST EST = PT0H0M1S
|
||||
fd2 2010-03-14 04:30:00 EDT EDT - 2010-03-13 04:30:00 EST EST = P0DT23H
|
||||
fd3 2010-03-14 03:30:00 EDT EDT - 2010-03-13 04:30:00 EST EST = P0DT22H
|
||||
fd4 2010-03-14 01:30:00 EST EST - 2010-03-13 04:30:00 EST EST = P0DT21H
|
||||
fd5 2010-03-14 01:30:00 EST EST - 2010-03-13 01:30:00 EST EST = P1DT0H
|
||||
fd6 2010-03-14 03:30:00 EDT EDT - 2010-03-13 03:30:00 EST EST = P0DT23H
|
||||
fd7 2010-03-14 03:30:00 EDT EDT - 2010-03-13 02:30:00 EST EST = P1DT0H
|
||||
|
||||
fa1 2010-03-14 01:59:59 EST EST + PT1S = 2010-03-14 02:00:00 EST EST
|
||||
fa2 2010-03-13 04:30:00 EST EST + P1D = 2010-03-14 04:30:00 EST EST
|
||||
fa3 2010-03-13 04:30:00 EST EST + PT22H = 2010-03-14 02:30:00 EST EST
|
||||
fa4 2010-03-13 04:30:00 EST EST + PT21H = 2010-03-14 01:30:00 EST EST
|
||||
fa5 2010-03-13 01:30:00 EST EST + P1D = 2010-03-14 01:30:00 EST EST
|
||||
fa6 2010-03-13 02:30:00 EST EST + P1D = 2010-03-14 02:30:00 EST EST
|
||||
|
||||
fs1 2010-03-14 03:00:00 EDT EDT - PT1S = 2010-03-14 02:59:59 EDT EDT
|
||||
fs2 2010-03-14 04:30:00 EDT EDT - P1D = 2010-03-13 04:30:00 EDT EDT
|
||||
fs3 2010-03-14 03:30:00 EDT EDT - PT22H = 2010-03-13 05:30:00 EDT EDT
|
||||
fs4 2010-03-14 01:30:00 EST EST - PT21H = 2010-03-13 04:30:00 EST EST
|
||||
fs5 2010-03-14 01:30:00 EST EST - P1D = 2010-03-13 01:30:00 EST EST
|
||||
fs6 2010-03-15 03:30:00 EDT EDT - P1D = 2010-03-14 03:30:00 EDT EDT
|
||||
fs7 2010-03-15 02:30:00 EDT EDT - P1D = 2010-03-14 02:30:00 EDT EDT
|
||||
|
||||
bd1 2010-11-07 01:00:00 EST EST - 2010-11-07 01:59:59 EDT EDT = PT0H0M1S
|
||||
bd2 2010-11-07 04:30:00 EST EST - 2010-11-06 04:30:00 EDT EDT = P1DT1H
|
||||
bd3 2010-11-07 03:30:00 EST EST - 2010-11-06 04:30:00 EDT EDT = P1DT0H
|
||||
bd4 2010-11-07 02:30:00 EST EST - 2010-11-06 04:30:00 EDT EDT = P0DT23H
|
||||
bd5 2010-11-07 01:30:00 EST EST - 2010-11-06 04:30:00 EDT EDT = P0DT22H
|
||||
bd6 2010-11-07 01:30:00 EDT EDT - 2010-11-06 04:30:00 EDT EDT = P0DT21H
|
||||
bd7 2010-11-07 01:30:00 EDT EDT - 2010-11-06 01:30:00 EDT EDT = P1DT0H
|
||||
bd8 2010-11-07 01:30:00 EST EST - 2010-11-06 01:30:00 EDT EDT = P1DT1H
|
||||
|
||||
ba1 2010-11-07 01:59:59 EDT EDT + PT1S = 2010-11-07 02:00:00 EDT EDT
|
||||
ba2 2010-11-06 04:30:00 EDT EDT + P1D = 2010-11-07 04:30:00 EDT EDT
|
||||
ba3 2010-11-06 04:30:00 EDT EDT + PT24H = 2010-11-07 04:30:00 EDT EDT
|
||||
ba4 2010-11-06 04:30:00 EDT EDT + PT23H = 2010-11-07 03:30:00 EDT EDT
|
||||
ba5 2010-11-06 04:30:00 EDT EDT + PT22H = 2010-11-07 02:30:00 EDT EDT
|
||||
ba6 2010-11-06 04:30:00 EDT EDT + PT21H = 2010-11-07 01:30:00 EDT EDT
|
||||
ba7 2010-11-06 01:30:00 EDT EDT + P1D = 2010-11-07 01:30:00 EDT EDT
|
||||
ba8 2010-11-06 01:30:00 EDT EDT + P1DT1H = 2010-11-07 02:30:00 EDT EDT
|
||||
ba9 2010-11-06 04:30:00 EDT EDT + PT25H = 2010-11-07 05:30:00 EDT EDT
|
||||
ba10 2010-11-06 03:30:00 EDT EDT + P1D = 2010-11-07 03:30:00 EDT EDT
|
||||
ba11 2010-11-06 02:30:00 EDT EDT + P1D = 2010-11-07 02:30:00 EDT EDT
|
||||
|
||||
bs1 2010-11-07 01:00:00 EST EST - PT1S = 2010-11-07 00:59:59 EST EST
|
||||
bs2 2010-11-07 04:30:00 EST EST - P1D = 2010-11-06 04:30:00 EST EST
|
||||
bs3 2010-11-07 03:30:00 EST EST - PT24H = 2010-11-06 03:30:00 EST EST
|
||||
bs4 2010-11-07 02:30:00 EST EST - PT23H = 2010-11-06 03:30:00 EST EST
|
||||
bs5 2010-11-07 01:30:00 EST EST - PT22H = 2010-11-06 03:30:00 EST EST
|
||||
bs6 2010-11-07 01:30:00 EDT EDT - PT21H = 2010-11-06 04:30:00 EDT EDT
|
||||
bs7 2010-11-07 01:30:00 EDT EDT - P1D = 2010-11-06 01:30:00 EDT EDT
|
||||
bs8 2010-11-07 01:30:00 EST EST - P1DT1H = 2010-11-06 00:30:00 EST EST
|
||||
bs9 2010-11-07 03:30:00 EST EST - P1D = 2010-11-06 03:30:00 EST EST
|
||||
bs10 2010-11-07 02:30:00 EST EST - P1D = 2010-11-06 02:30:00 EST EST
|
||||
@@ -0,0 +1,399 @@
|
||||
--TEST--
|
||||
RFC: DateTime and Daylight Saving Time Transitions (zone type 3)
|
||||
--CREDITS--
|
||||
Daniel Convissor <danielc@php.net>
|
||||
--XFAIL--
|
||||
RFC not implemented yet
|
||||
--FILE--
|
||||
<?php
|
||||
|
||||
date_default_timezone_set('America/New_York');
|
||||
$date_format = 'Y-m-d H:i:s T e';
|
||||
$interval_format = 'P%dDT%hH';
|
||||
|
||||
/*
|
||||
* Forward Transitions, diff().
|
||||
*/
|
||||
|
||||
$end = new DateTime('2010-03-14 03:00:00');
|
||||
$start = new DateTime('2010-03-14 01:59:59');
|
||||
echo 'fd1 ' . $end->format($date_format) . ' - ' . $start->format($date_format)
|
||||
. ' = ' . $start->diff($end)->format('PT%hH%iM%sS') . "\n";
|
||||
|
||||
$end = new DateTime('2010-03-14 04:30:00');
|
||||
$start = new DateTime('2010-03-13 04:30:00');
|
||||
echo 'fd2 ' . $end->format($date_format) . ' - ' . $start->format($date_format)
|
||||
. ' = ' . $start->diff($end)->format($interval_format) . "\n";
|
||||
|
||||
$end = new DateTime('2010-03-14 03:30:00');
|
||||
$start = new DateTime('2010-03-13 04:30:00');
|
||||
echo 'fd3 ' . $end->format($date_format) . ' - ' . $start->format($date_format)
|
||||
. ' = ' . $start->diff($end)->format($interval_format) . "\n";
|
||||
|
||||
$end = new DateTime('2010-03-14 01:30:00');
|
||||
$start = new DateTime('2010-03-13 04:30:00');
|
||||
echo 'fd4 ' . $end->format($date_format) . ' - ' . $start->format($date_format)
|
||||
. ' = ' . $start->diff($end)->format($interval_format) . "\n";
|
||||
|
||||
$end = new DateTime('2010-03-14 01:30:00');
|
||||
$start = new DateTime('2010-03-13 01:30:00');
|
||||
echo 'fd5 ' . $end->format($date_format) . ' - ' . $start->format($date_format)
|
||||
. ' = ' . $start->diff($end)->format($interval_format) . "\n";
|
||||
|
||||
$end = new DateTime('2010-03-14 03:30:00');
|
||||
$start = new DateTime('2010-03-13 03:30:00');
|
||||
echo 'fd6 ' . $end->format($date_format) . ' - ' . $start->format($date_format)
|
||||
. ' = ' . $start->diff($end)->format($interval_format) . "\n";
|
||||
|
||||
$end = new DateTime('2010-03-14 03:30:00');
|
||||
$start = new DateTime('2010-03-13 02:30:00');
|
||||
echo 'fd7 ' . $end->format($date_format) . ' - ' . $start->format($date_format)
|
||||
. ' = ' . $start->diff($end)->format($interval_format) . "\n";
|
||||
|
||||
echo "\n";
|
||||
|
||||
/*
|
||||
* Forward Transitions, add().
|
||||
*/
|
||||
|
||||
$start = new DateTime('2010-03-14 01:59:59');
|
||||
$interval_spec = 'PT1S';
|
||||
$interval = new DateInterval($interval_spec);
|
||||
echo 'fa1 ' . $start->format($date_format) . " + $interval_spec = "
|
||||
. $start->add($interval)->format($date_format) . "\n";
|
||||
|
||||
$start = new DateTime('2010-03-13 04:30:00');
|
||||
$interval_spec = 'P1D';
|
||||
$interval = new DateInterval($interval_spec);
|
||||
echo 'fa2 ' . $start->format($date_format) . " + $interval_spec = "
|
||||
. $start->add($interval)->format($date_format) . "\n";
|
||||
|
||||
$start = new DateTime('2010-03-13 04:30:00');
|
||||
$interval_spec = 'PT22H';
|
||||
$interval = new DateInterval($interval_spec);
|
||||
echo 'fa3 ' . $start->format($date_format) . " + $interval_spec = "
|
||||
. $start->add($interval)->format($date_format) . "\n";
|
||||
|
||||
$start = new DateTime('2010-03-13 04:30:00');
|
||||
$interval_spec = 'PT21H';
|
||||
$interval = new DateInterval($interval_spec);
|
||||
echo 'fa4 ' . $start->format($date_format) . " + $interval_spec = "
|
||||
. $start->add($interval)->format($date_format) . "\n";
|
||||
|
||||
$start = new DateTime('2010-03-13 01:30:00');
|
||||
$interval_spec = 'P1D';
|
||||
$interval = new DateInterval($interval_spec);
|
||||
echo 'fa5 ' . $start->format($date_format) . " + $interval_spec = "
|
||||
. $start->add($interval)->format($date_format) . "\n";
|
||||
|
||||
$start = new DateTime('2010-03-13 02:30:00');
|
||||
$interval_spec = 'P1D';
|
||||
$interval = new DateInterval($interval_spec);
|
||||
echo 'fa6 ' . $start->format($date_format) . " + $interval_spec = "
|
||||
. $start->add($interval)->format($date_format) . "\n";
|
||||
|
||||
echo "\n";
|
||||
|
||||
/*
|
||||
* Forward Transitions, sub().
|
||||
*/
|
||||
|
||||
$end = new DateTime('2010-03-14 03:00:00');
|
||||
$interval_spec = 'PT1S';
|
||||
$interval = new DateInterval($interval_spec);
|
||||
echo 'fs1 ' . $end->format($date_format) . " - $interval_spec = "
|
||||
. $end->sub($interval)->format($date_format) . "\n";
|
||||
|
||||
$end = new DateTime('2010-03-14 04:30:00');
|
||||
$interval_spec = 'P1D';
|
||||
$interval = new DateInterval($interval_spec);
|
||||
echo 'fs2 ' . $end->format($date_format) . " - $interval_spec = "
|
||||
. $end->sub($interval)->format($date_format) . "\n";
|
||||
|
||||
$end = new DateTime('2010-03-14 03:30:00');
|
||||
$interval_spec = 'PT22H';
|
||||
$interval = new DateInterval($interval_spec);
|
||||
echo 'fs3 ' . $end->format($date_format) . " - $interval_spec = "
|
||||
. $end->sub($interval)->format($date_format) . "\n";
|
||||
|
||||
$end = new DateTime('2010-03-14 01:30:00');
|
||||
$interval_spec = 'PT21H';
|
||||
$interval = new DateInterval($interval_spec);
|
||||
echo 'fs4 ' . $end->format($date_format) . " - $interval_spec = "
|
||||
. $end->sub($interval)->format($date_format) . "\n";
|
||||
|
||||
$end = new DateTime('2010-03-14 01:30:00');
|
||||
$interval_spec = 'P1D';
|
||||
$interval = new DateInterval($interval_spec);
|
||||
echo 'fs5 ' . $end->format($date_format) . " - $interval_spec = "
|
||||
. $end->sub($interval)->format($date_format) . "\n";
|
||||
|
||||
$end = new DateTime('2010-03-15 03:30:00');
|
||||
$interval_spec = 'P1D';
|
||||
$interval = new DateInterval($interval_spec);
|
||||
echo 'fs6 ' . $end->format($date_format) . " - $interval_spec = "
|
||||
. $end->sub($interval)->format($date_format) . "\n";
|
||||
|
||||
$end = new DateTime('2010-03-15 02:30:00');
|
||||
$interval_spec = 'P1D';
|
||||
$interval = new DateInterval($interval_spec);
|
||||
echo 'fs7 ' . $end->format($date_format) . " - $interval_spec = "
|
||||
. $end->sub($interval)->format($date_format) . "\n";
|
||||
|
||||
echo "\n";
|
||||
|
||||
|
||||
/*
|
||||
* For backward transitions, must create objects with zone type 2
|
||||
* where specifying Daylight or Standard time is required
|
||||
* then converting them to zone type 3.
|
||||
*/
|
||||
|
||||
$tz = new DateTimeZone('America/New_York');
|
||||
|
||||
/*
|
||||
* Backward Transitions, diff().
|
||||
*/
|
||||
|
||||
$end = new DateTime('2010-11-07 01:00:00 EST');
|
||||
$end->setTimeZone($tz);
|
||||
$start = new DateTime('2010-11-07 01:59:59');
|
||||
echo 'bd1 ' . $end->format($date_format) . ' - ' . $start->format($date_format)
|
||||
. ' = ' . $start->diff($end)->format('PT%hH%iM%sS') . "\n";
|
||||
|
||||
$end = new DateTime('2010-11-07 04:30:00');
|
||||
$start = new DateTime('2010-11-06 04:30:00');
|
||||
echo 'bd2 ' . $end->format($date_format) . ' - ' . $start->format($date_format)
|
||||
. ' = ' . $start->diff($end)->format($interval_format) . "\n";
|
||||
|
||||
$end = new DateTime('2010-11-07 03:30:00');
|
||||
$start = new DateTime('2010-11-06 04:30:00');
|
||||
echo 'bd3 ' . $end->format($date_format) . ' - ' . $start->format($date_format)
|
||||
. ' = ' . $start->diff($end)->format($interval_format) . "\n";
|
||||
|
||||
$end = new DateTime('2010-11-07 02:30:00');
|
||||
$start = new DateTime('2010-11-06 04:30:00');
|
||||
echo 'bd4 ' . $end->format($date_format) . ' - ' . $start->format($date_format)
|
||||
. ' = ' . $start->diff($end)->format($interval_format) . "\n";
|
||||
|
||||
$end = new DateTime('2010-11-07 01:30:00 EST');
|
||||
$end->setTimeZone($tz);
|
||||
$start = new DateTime('2010-11-06 04:30:00');
|
||||
echo 'bd5 ' . $end->format($date_format) . ' - ' . $start->format($date_format)
|
||||
. ' = ' . $start->diff($end)->format($interval_format) . "\n";
|
||||
|
||||
$end = new DateTime('2010-11-07 01:30:00 EDT');
|
||||
$end->setTimeZone($tz);
|
||||
$start = new DateTime('2010-11-06 04:30:00');
|
||||
echo 'bd6 ' . $end->format($date_format) . ' - ' . $start->format($date_format)
|
||||
. ' = ' . $start->diff($end)->format($interval_format) . "\n";
|
||||
|
||||
$end = new DateTime('2010-11-07 01:30:00');
|
||||
$start = new DateTime('2010-11-06 01:30:00');
|
||||
echo 'bd7 ' . $end->format($date_format) . ' - ' . $start->format($date_format)
|
||||
. ' = ' . $start->diff($end)->format($interval_format) . "\n";
|
||||
|
||||
$end = new DateTime('2010-11-07 01:30:00 EST');
|
||||
$end->setTimeZone($tz);
|
||||
$start = new DateTime('2010-11-06 01:30:00');
|
||||
echo 'bd8 ' . $end->format($date_format) . ' - ' . $start->format($date_format)
|
||||
. ' = ' . $start->diff($end)->format($interval_format) . "\n";
|
||||
|
||||
echo "\n";
|
||||
|
||||
/*
|
||||
* Backward Transitions, add().
|
||||
*/
|
||||
|
||||
$start = new DateTime('2010-11-07 01:59:59');
|
||||
$interval_spec = 'PT1S';
|
||||
$interval = new DateInterval($interval_spec);
|
||||
echo 'ba1 ' . $start->format($date_format) . " + $interval_spec = "
|
||||
. $start->add($interval)->format($date_format) . "\n";
|
||||
|
||||
$start = new DateTime('2010-11-06 04:30:00');
|
||||
$interval_spec = 'P1D';
|
||||
$interval = new DateInterval($interval_spec);
|
||||
echo 'ba2 ' . $start->format($date_format) . " + $interval_spec = "
|
||||
. $start->add($interval)->format($date_format) . "\n";
|
||||
|
||||
$start = new DateTime('2010-11-06 04:30:00');
|
||||
$interval_spec = 'PT24H';
|
||||
$interval = new DateInterval($interval_spec);
|
||||
echo 'ba3 ' . $start->format($date_format) . " + $interval_spec = "
|
||||
. $start->add($interval)->format($date_format) . "\n";
|
||||
|
||||
$start = new DateTime('2010-11-06 04:30:00');
|
||||
$interval_spec = 'PT23H';
|
||||
$interval = new DateInterval($interval_spec);
|
||||
echo 'ba4 ' . $start->format($date_format) . " + $interval_spec = "
|
||||
. $start->add($interval)->format($date_format) . "\n";
|
||||
|
||||
$start = new DateTime('2010-11-06 04:30:00');
|
||||
$interval_spec = 'PT22H';
|
||||
$interval = new DateInterval($interval_spec);
|
||||
echo 'ba5 ' . $start->format($date_format) . " + $interval_spec = "
|
||||
. $start->add($interval)->format($date_format) . "\n";
|
||||
|
||||
$start = new DateTime('2010-11-06 04:30:00');
|
||||
$interval_spec = 'PT21H';
|
||||
$interval = new DateInterval($interval_spec);
|
||||
echo 'ba6 ' . $start->format($date_format) . " + $interval_spec = "
|
||||
. $start->add($interval)->format($date_format) . "\n";
|
||||
|
||||
$start = new DateTime('2010-11-06 01:30:00');
|
||||
$interval_spec = 'P1D';
|
||||
$interval = new DateInterval($interval_spec);
|
||||
echo 'ba7 ' . $start->format($date_format) . " + $interval_spec = "
|
||||
. $start->add($interval)->format($date_format) . "\n";
|
||||
|
||||
$start = new DateTime('2010-11-06 01:30:00');
|
||||
$interval_spec = 'P1DT1H';
|
||||
$interval = new DateInterval($interval_spec);
|
||||
echo 'ba8 ' . $start->format($date_format) . " + $interval_spec = "
|
||||
. $start->add($interval)->format($date_format) . "\n";
|
||||
|
||||
$start = new DateTime('2010-11-06 04:30:00');
|
||||
$interval_spec = 'PT25H';
|
||||
$interval = new DateInterval($interval_spec);
|
||||
echo 'ba9 ' . $start->format($date_format) . " + $interval_spec = "
|
||||
. $start->add($interval)->format($date_format) . "\n";
|
||||
|
||||
$start = new DateTime('2010-11-06 03:30:00');
|
||||
$interval_spec = 'P1D';
|
||||
$interval = new DateInterval($interval_spec);
|
||||
echo 'ba10 ' . $start->format($date_format) . " + $interval_spec = "
|
||||
. $start->add($interval)->format($date_format) . "\n";
|
||||
|
||||
$start = new DateTime('2010-11-06 02:30:00');
|
||||
$interval_spec = 'P1D';
|
||||
$interval = new DateInterval($interval_spec);
|
||||
echo 'ba11 ' . $start->format($date_format) . " + $interval_spec = "
|
||||
. $start->add($interval)->format($date_format) . "\n";
|
||||
|
||||
echo "\n";
|
||||
|
||||
/*
|
||||
* Backward Transitions, sub().
|
||||
*/
|
||||
|
||||
$end = new DateTime('2010-11-07 01:00:00 EST');
|
||||
$end->setTimeZone($tz);
|
||||
$interval_spec = 'PT1S';
|
||||
$interval = new DateInterval($interval_spec);
|
||||
echo 'bs1 ' . $end->format($date_format) . " - $interval_spec = "
|
||||
. $end->sub($interval)->format($date_format) . "\n";
|
||||
|
||||
$end = new DateTime('2010-11-07 04:30:00');
|
||||
$interval_spec = 'P1D';
|
||||
$interval = new DateInterval($interval_spec);
|
||||
echo 'bs2 ' . $end->format($date_format) . " - $interval_spec = "
|
||||
. $end->sub($interval)->format($date_format) . "\n";
|
||||
|
||||
$end = new DateTime('2010-11-07 03:30:00');
|
||||
$interval_spec = 'PT24H';
|
||||
$interval = new DateInterval($interval_spec);
|
||||
echo 'bs3 ' . $end->format($date_format) . " - $interval_spec = "
|
||||
. $end->sub($interval)->format($date_format) . "\n";
|
||||
|
||||
$end = new DateTime('2010-11-07 02:30:00');
|
||||
$interval_spec = 'PT23H';
|
||||
$interval = new DateInterval($interval_spec);
|
||||
echo 'bs4 ' . $end->format($date_format) . " - $interval_spec = "
|
||||
. $end->sub($interval)->format($date_format) . "\n";
|
||||
|
||||
$end = new DateTime('2010-11-07 01:30:00 EST');
|
||||
$end->setTimeZone($tz);
|
||||
$interval_spec = 'PT22H';
|
||||
$interval = new DateInterval($interval_spec);
|
||||
echo 'bs5 ' . $end->format($date_format) . " - $interval_spec = "
|
||||
. $end->sub($interval)->format($date_format) . "\n";
|
||||
|
||||
$end = new DateTime('2010-11-07 01:30:00 EDT');
|
||||
$end->setTimeZone($tz);
|
||||
$interval_spec = 'PT21H';
|
||||
$interval = new DateInterval($interval_spec);
|
||||
echo 'bs6 ' . $end->format($date_format) . " - $interval_spec = "
|
||||
. $end->sub($interval)->format($date_format) . "\n";
|
||||
|
||||
$end = new DateTime('2010-11-07 01:30:00');
|
||||
$interval_spec = 'P1D';
|
||||
$interval = new DateInterval($interval_spec);
|
||||
echo 'bs7 ' . $end->format($date_format) . " - $interval_spec = "
|
||||
. $end->sub($interval)->format($date_format) . "\n";
|
||||
|
||||
$end = new DateTime('2010-11-07 01:30:00 EST');
|
||||
$end->setTimeZone($tz);
|
||||
$interval_spec = 'P1DT1H';
|
||||
$interval = new DateInterval($interval_spec);
|
||||
echo 'bs8 ' . $end->format($date_format) . " - $interval_spec = "
|
||||
. $end->sub($interval)->format($date_format) . "\n";
|
||||
|
||||
$end = new DateTime('2010-11-07 03:30:00');
|
||||
$interval_spec = 'P1D';
|
||||
$interval = new DateInterval($interval_spec);
|
||||
echo 'bs9 ' . $end->format($date_format) . " - $interval_spec = "
|
||||
. $end->sub($interval)->format($date_format) . "\n";
|
||||
|
||||
$end = new DateTime('2010-11-07 02:30:00');
|
||||
$interval_spec = 'P1D';
|
||||
$interval = new DateInterval($interval_spec);
|
||||
echo 'bs10 ' . $end->format($date_format) . " - $interval_spec = "
|
||||
. $end->sub($interval)->format($date_format) . "\n";
|
||||
|
||||
?>
|
||||
--EXPECT--
|
||||
fd1 2010-03-14 03:00:00 EDT America/New_York - 2010-03-14 01:59:59 EST America/New_York = PT0H0M1S
|
||||
fd2 2010-03-14 04:30:00 EDT America/New_York - 2010-03-13 04:30:00 EST America/New_York = P1DT0H
|
||||
fd3 2010-03-14 03:30:00 EDT America/New_York - 2010-03-13 04:30:00 EST America/New_York = P0DT22H
|
||||
fd4 2010-03-14 01:30:00 EST America/New_York - 2010-03-13 04:30:00 EST America/New_York = P0DT21H
|
||||
fd5 2010-03-14 01:30:00 EST America/New_York - 2010-03-13 01:30:00 EST America/New_York = P1DT0H
|
||||
fd6 2010-03-14 03:30:00 EDT America/New_York - 2010-03-13 03:30:00 EST America/New_York = P1DT0H
|
||||
fd7 2010-03-14 03:30:00 EDT America/New_York - 2010-03-13 02:30:00 EST America/New_York = P1DT1H
|
||||
|
||||
fa1 2010-03-14 01:59:59 EST America/New_York + PT1S = 2010-03-14 03:00:00 EDT America/New_York
|
||||
fa2 2010-03-13 04:30:00 EST America/New_York + P1D = 2010-03-14 04:30:00 EDT America/New_York
|
||||
fa3 2010-03-13 04:30:00 EST America/New_York + PT22H = 2010-03-14 03:30:00 EDT America/New_York
|
||||
fa4 2010-03-13 04:30:00 EST America/New_York + PT21H = 2010-03-14 01:30:00 EST America/New_York
|
||||
fa5 2010-03-13 01:30:00 EST America/New_York + P1D = 2010-03-14 01:30:00 EST America/New_York
|
||||
fa6 2010-03-13 02:30:00 EST America/New_York + P1D = 2010-03-14 03:30:00 EDT America/New_York
|
||||
|
||||
fs1 2010-03-14 03:00:00 EDT America/New_York - PT1S = 2010-03-14 01:59:59 EST America/New_York
|
||||
fs2 2010-03-14 04:30:00 EDT America/New_York - P1D = 2010-03-13 04:30:00 EST America/New_York
|
||||
fs3 2010-03-14 03:30:00 EDT America/New_York - PT22H = 2010-03-13 04:30:00 EST America/New_York
|
||||
fs4 2010-03-14 01:30:00 EST America/New_York - PT21H = 2010-03-13 04:30:00 EST America/New_York
|
||||
fs5 2010-03-14 01:30:00 EST America/New_York - P1D = 2010-03-13 01:30:00 EST America/New_York
|
||||
fs6 2010-03-15 03:30:00 EDT America/New_York - P1D = 2010-03-14 03:30:00 EDT America/New_York
|
||||
fs7 2010-03-15 03:30:00 EDT America/New_York - P1D = 2010-03-14 03:30:00 EDT America/New_York
|
||||
|
||||
bd1 2010-11-07 01:00:00 EST America/New_York - 2010-11-07 01:59:59 EDT America/New_York = PT0H0M1S
|
||||
bd2 2010-11-07 04:30:00 EST America/New_York - 2010-11-06 04:30:00 EDT America/New_York = P1DT0H
|
||||
bd3 2010-11-07 03:30:00 EST America/New_York - 2010-11-06 04:30:00 EDT America/New_York = P0DT24H
|
||||
bd4 2010-11-07 02:30:00 EST America/New_York - 2010-11-06 04:30:00 EDT America/New_York = P0DT23H
|
||||
bd5 2010-11-07 01:30:00 EST America/New_York - 2010-11-06 04:30:00 EDT America/New_York = P0DT22H
|
||||
bd6 2010-11-07 01:30:00 EDT America/New_York - 2010-11-06 04:30:00 EDT America/New_York = P0DT21H
|
||||
bd7 2010-11-07 01:30:00 EDT America/New_York - 2010-11-06 01:30:00 EDT America/New_York = P1DT0H
|
||||
bd8 2010-11-07 01:30:00 EST America/New_York - 2010-11-06 01:30:00 EDT America/New_York = P1DT1H
|
||||
|
||||
ba1 2010-11-07 01:59:59 EDT America/New_York + PT1S = 2010-11-07 01:00:00 EST America/New_York
|
||||
ba2 2010-11-06 04:30:00 EDT America/New_York + P1D = 2010-11-07 04:30:00 EST America/New_York
|
||||
ba3 2010-11-06 04:30:00 EDT America/New_York + PT24H = 2010-11-07 03:30:00 EST America/New_York
|
||||
ba4 2010-11-06 04:30:00 EDT America/New_York + PT23H = 2010-11-07 02:30:00 EST America/New_York
|
||||
ba5 2010-11-06 04:30:00 EDT America/New_York + PT22H = 2010-11-07 01:30:00 EST America/New_York
|
||||
ba6 2010-11-06 04:30:00 EDT America/New_York + PT21H = 2010-11-07 01:30:00 EDT America/New_York
|
||||
ba7 2010-11-06 01:30:00 EDT America/New_York + P1D = 2010-11-07 01:30:00 EDT America/New_York
|
||||
ba8 2010-11-06 01:30:00 EDT America/New_York + P1DT1H = 2010-11-07 01:30:00 EST America/New_York
|
||||
ba9 2010-11-06 04:30:00 EDT America/New_York + PT25H = 2010-11-07 04:30:00 EST America/New_York
|
||||
ba10 2010-11-06 03:30:00 EDT America/New_York + P1D = 2010-11-07 03:30:00 EST America/New_York
|
||||
ba11 2010-11-06 02:30:00 EDT America/New_York + P1D = 2010-11-07 02:30:00 EST America/New_York
|
||||
|
||||
bs1 2010-11-07 01:00:00 EST America/New_York - PT1S = 2010-11-07 01:59:59 EDT America/New_York
|
||||
bs2 2010-11-07 04:30:00 EST America/New_York - P1D = 2010-11-06 04:30:00 EDT America/New_York
|
||||
bs3 2010-11-07 03:30:00 EST America/New_York - PT24H = 2010-11-06 04:30:00 EDT America/New_York
|
||||
bs4 2010-11-07 02:30:00 EST America/New_York - PT23H = 2010-11-06 04:30:00 EDT America/New_York
|
||||
bs5 2010-11-07 01:30:00 EST America/New_York - PT22H = 2010-11-06 04:30:00 EDT America/New_York
|
||||
bs6 2010-11-07 01:30:00 EDT America/New_York - PT21H = 2010-11-06 04:30:00 EDT America/New_York
|
||||
bs7 2010-11-07 01:30:00 EDT America/New_York - P1D = 2010-11-06 01:30:00 EDT America/New_York
|
||||
bs8 2010-11-07 01:30:00 EST America/New_York - P1DT1H = 2010-11-06 00:30:00 EDT America/New_York
|
||||
bs9 2010-11-07 03:30:00 EST America/New_York - P1D = 2010-11-06 03:30:00 EDT America/New_York
|
||||
bs10 2010-11-07 02:30:00 EST America/New_York - P1D = 2010-11-06 02:30:00 EDT America/New_York
|
||||
@@ -244,8 +244,8 @@ static void php_enchant_broker_free(zend_rsrc_list_entry *rsrc TSRMLS_DC) /* {{{
|
||||
if (broker->pbroker) {
|
||||
if (broker->dictcnt && broker->dict) {
|
||||
if (broker->dict) {
|
||||
int total, tofree;
|
||||
tofree = total = broker->dictcnt-1;
|
||||
int total;
|
||||
total = broker->dictcnt-1;
|
||||
do {
|
||||
zend_list_delete(broker->dict[total]->rsrc_id);
|
||||
efree(broker->dict[total]);
|
||||
@@ -357,8 +357,8 @@ PHP_FUNCTION(enchant_broker_init)
|
||||
enchant_broker *broker;
|
||||
EnchantBroker *pbroker;
|
||||
|
||||
if (ZEND_NUM_ARGS()) {
|
||||
ZEND_WRONG_PARAM_COUNT();
|
||||
if (zend_parse_parameters_none() == FAILURE) {
|
||||
return;
|
||||
}
|
||||
|
||||
pbroker = enchant_broker_init();
|
||||
@@ -542,6 +542,11 @@ PHP_FUNCTION(enchant_broker_request_dict)
|
||||
}
|
||||
|
||||
PHP_ENCHANT_GET_BROKER;
|
||||
|
||||
if (taglen == 0) {
|
||||
php_error_docref(NULL TSRMLS_CC, E_WARNING, "Tag cannot be empty");
|
||||
RETURN_FALSE;
|
||||
}
|
||||
|
||||
d = enchant_broker_request_dict(pbroker->pbroker, (const char *)tag);
|
||||
if (d) {
|
||||
|
||||
+102
-78
@@ -1,6 +1,6 @@
|
||||
diff -u libmagic.orig/apprentice.c libmagic/apprentice.c
|
||||
--- libmagic.orig/apprentice.c 2009-03-18 15:19:23.000000000 +0000
|
||||
+++ libmagic/apprentice.c 2010-01-28 11:02:24.000000000 +0000
|
||||
--- libmagic.orig/apprentice.c 2011-09-15 23:28:13.000000000 +0800
|
||||
+++ libmagic/apprentice.c 2011-09-15 23:29:29.000000000 +0800
|
||||
@@ -29,6 +29,8 @@
|
||||
* apprentice - make one pass through /etc/magic, learning its secrets.
|
||||
*/
|
||||
@@ -10,12 +10,20 @@ diff -u libmagic.orig/apprentice.c libmagic/apprentice.c
|
||||
#include "file.h"
|
||||
|
||||
#ifndef lint
|
||||
@@ -38,17 +40,24 @@
|
||||
@@ -38,17 +40,32 @@
|
||||
#include "magic.h"
|
||||
#include "patchlevel.h"
|
||||
#include <stdlib.h>
|
||||
-#ifdef HAVE_UNISTD_H
|
||||
+
|
||||
+#if defined(__hpux) && !defined(HAVE_STRTOULL)
|
||||
+#if SIZEOF_LONG == 8
|
||||
+# define strtoull strtoul
|
||||
+#else
|
||||
+# define strtoull __strtoull
|
||||
+#endif
|
||||
+#endif
|
||||
+
|
||||
+#ifdef PHP_WIN32
|
||||
+#include "win32/unistd.h"
|
||||
+#if _MSC_VER <= 1300
|
||||
@@ -39,7 +47,7 @@ diff -u libmagic.orig/apprentice.c libmagic/apprentice.c
|
||||
|
||||
#define EATAB {while (isascii((unsigned char) *l) && \
|
||||
isspace((unsigned char) *l)) ++l;}
|
||||
@@ -116,12 +125,10 @@
|
||||
@@ -116,12 +133,10 @@
|
||||
private int parse_strength(struct magic_set *, struct magic_entry *, const char *);
|
||||
private int parse_apple(struct magic_set *, struct magic_entry *, const char *);
|
||||
|
||||
@@ -52,7 +60,7 @@ diff -u libmagic.orig/apprentice.c libmagic/apprentice.c
|
||||
private struct {
|
||||
const char *name;
|
||||
size_t len;
|
||||
@@ -135,38 +142,7 @@
|
||||
@@ -135,38 +150,7 @@
|
||||
{ NULL, 0, NULL }
|
||||
};
|
||||
|
||||
@@ -92,7 +100,7 @@ diff -u libmagic.orig/apprentice.c libmagic/apprentice.c
|
||||
|
||||
static const struct type_tbl_s {
|
||||
const char name[16];
|
||||
@@ -222,6 +198,10 @@
|
||||
@@ -222,6 +206,10 @@
|
||||
# undef XX_NULL
|
||||
};
|
||||
|
||||
@@ -103,7 +111,7 @@ diff -u libmagic.orig/apprentice.c libmagic/apprentice.c
|
||||
private int
|
||||
get_type(const char *l, const char **t)
|
||||
{
|
||||
@@ -279,15 +259,17 @@
|
||||
@@ -279,15 +267,17 @@
|
||||
if (rv != 0)
|
||||
return -1;
|
||||
rv = apprentice_compile(ms, &magic, &nmagic, fn);
|
||||
@@ -126,7 +134,7 @@ diff -u libmagic.orig/apprentice.c libmagic/apprentice.c
|
||||
if (rv != 0)
|
||||
return -1;
|
||||
}
|
||||
@@ -299,11 +281,7 @@
|
||||
@@ -299,11 +289,7 @@
|
||||
return -1;
|
||||
}
|
||||
|
||||
@@ -139,7 +147,7 @@ diff -u libmagic.orig/apprentice.c libmagic/apprentice.c
|
||||
|
||||
ml->magic = magic;
|
||||
ml->nmagic = nmagic;
|
||||
@@ -315,7 +293,6 @@
|
||||
@@ -315,7 +301,6 @@
|
||||
mlist->prev = ml;
|
||||
|
||||
return 0;
|
||||
@@ -147,7 +155,7 @@ diff -u libmagic.orig/apprentice.c libmagic/apprentice.c
|
||||
}
|
||||
|
||||
protected void
|
||||
@@ -324,22 +301,18 @@
|
||||
@@ -324,22 +309,18 @@
|
||||
if (p == NULL)
|
||||
return;
|
||||
switch (type) {
|
||||
@@ -176,7 +184,7 @@ diff -u libmagic.orig/apprentice.c libmagic/apprentice.c
|
||||
default:
|
||||
abort();
|
||||
}
|
||||
@@ -357,20 +330,17 @@
|
||||
@@ -357,20 +338,17 @@
|
||||
|
||||
if (fn == NULL)
|
||||
fn = getenv("MAGIC");
|
||||
@@ -205,7 +213,7 @@ diff -u libmagic.orig/apprentice.c libmagic/apprentice.c
|
||||
mlist->next = mlist->prev = mlist;
|
||||
|
||||
while (fn) {
|
||||
@@ -384,13 +354,13 @@
|
||||
@@ -384,13 +362,13 @@
|
||||
fn = p;
|
||||
}
|
||||
if (errs == -1) {
|
||||
@@ -222,7 +230,7 @@ diff -u libmagic.orig/apprentice.c libmagic/apprentice.c
|
||||
return mlist;
|
||||
}
|
||||
|
||||
@@ -523,6 +493,7 @@
|
||||
@@ -523,6 +501,7 @@
|
||||
abort();
|
||||
}
|
||||
|
||||
@@ -230,7 +238,7 @@ diff -u libmagic.orig/apprentice.c libmagic/apprentice.c
|
||||
/*
|
||||
* Magic entries with no description get a bonus because they depend
|
||||
* on subsequent magic entries to print something.
|
||||
@@ -538,8 +509,8 @@
|
||||
@@ -538,8 +517,8 @@
|
||||
private int
|
||||
apprentice_sort(const void *a, const void *b)
|
||||
{
|
||||
@@ -241,7 +249,7 @@ diff -u libmagic.orig/apprentice.c libmagic/apprentice.c
|
||||
size_t sa = apprentice_magic_strength(ma->mp);
|
||||
size_t sb = apprentice_magic_strength(mb->mp);
|
||||
if (sa == sb)
|
||||
@@ -617,34 +588,51 @@
|
||||
@@ -617,34 +596,51 @@
|
||||
load_1(struct magic_set *ms, int action, const char *fn, int *errs,
|
||||
struct magic_entry **marray, uint32_t *marraycount)
|
||||
{
|
||||
@@ -303,7 +311,7 @@ diff -u libmagic.orig/apprentice.c libmagic/apprentice.c
|
||||
memcmp(bang[i].name, line + 2,
|
||||
bang[i].len) == 0)
|
||||
break;
|
||||
@@ -670,12 +658,11 @@
|
||||
@@ -670,12 +666,11 @@
|
||||
}
|
||||
continue;
|
||||
}
|
||||
@@ -318,7 +326,7 @@ diff -u libmagic.orig/apprentice.c libmagic/apprentice.c
|
||||
}
|
||||
}
|
||||
|
||||
@@ -690,7 +677,6 @@
|
||||
@@ -690,7 +685,6 @@
|
||||
int errs = 0;
|
||||
struct magic_entry *marray;
|
||||
uint32_t marraycount, i, mentrycount = 0, starttest;
|
||||
@@ -326,7 +334,7 @@ diff -u libmagic.orig/apprentice.c libmagic/apprentice.c
|
||||
char subfn[MAXPATHLEN];
|
||||
struct stat st;
|
||||
DIR *dir;
|
||||
@@ -698,12 +684,8 @@
|
||||
@@ -698,12 +692,8 @@
|
||||
|
||||
ms->flags |= MAGIC_CHECK; /* Enable checks for parsed files */
|
||||
|
||||
@@ -341,7 +349,7 @@ diff -u libmagic.orig/apprentice.c libmagic/apprentice.c
|
||||
marraycount = 0;
|
||||
|
||||
/* print silly verbose header for USG compat. */
|
||||
@@ -713,14 +695,14 @@
|
||||
@@ -713,14 +703,14 @@
|
||||
/* load directory or file */
|
||||
/* FIXME: Read file names and sort them to prevent
|
||||
non-determinism. See Debian bug #488562. */
|
||||
@@ -358,7 +366,7 @@ diff -u libmagic.orig/apprentice.c libmagic/apprentice.c
|
||||
load_1(ms, action, subfn, &errs,
|
||||
&marray, &marraycount);
|
||||
}
|
||||
@@ -790,12 +772,7 @@
|
||||
@@ -790,12 +780,7 @@
|
||||
for (i = 0; i < marraycount; i++)
|
||||
mentrycount += marray[i].cont_count;
|
||||
|
||||
@@ -372,7 +380,7 @@ diff -u libmagic.orig/apprentice.c libmagic/apprentice.c
|
||||
|
||||
mentrycount = 0;
|
||||
for (i = 0; i < marraycount; i++) {
|
||||
@@ -805,8 +782,8 @@
|
||||
@@ -805,8 +790,8 @@
|
||||
}
|
||||
out:
|
||||
for (i = 0; i < marraycount; i++)
|
||||
@@ -383,7 +391,7 @@ diff -u libmagic.orig/apprentice.c libmagic/apprentice.c
|
||||
if (errs) {
|
||||
*magicp = NULL;
|
||||
*nmagicp = 0;
|
||||
@@ -1081,11 +1058,7 @@
|
||||
@@ -1081,11 +1066,7 @@
|
||||
if (me->cont_count == me->max_count) {
|
||||
struct magic *nm;
|
||||
size_t cnt = me->max_count + ALLOC_CHUNK;
|
||||
@@ -396,7 +404,7 @@ diff -u libmagic.orig/apprentice.c libmagic/apprentice.c
|
||||
me->mp = m = nm;
|
||||
me->max_count = cnt;
|
||||
}
|
||||
@@ -1097,23 +1070,13 @@
|
||||
@@ -1097,23 +1078,13 @@
|
||||
struct magic_entry *mp;
|
||||
|
||||
maxmagic += ALLOC_INCR;
|
||||
@@ -423,7 +431,7 @@ diff -u libmagic.orig/apprentice.c libmagic/apprentice.c
|
||||
me->mp = m;
|
||||
me->max_count = ALLOC_CHUNK;
|
||||
} else
|
||||
@@ -1264,7 +1227,7 @@
|
||||
@@ -1264,7 +1235,7 @@
|
||||
|
||||
m->mask_op = 0;
|
||||
if (*l == '~') {
|
||||
@@ -432,7 +440,7 @@ diff -u libmagic.orig/apprentice.c libmagic/apprentice.c
|
||||
m->mask_op |= FILE_OPINVERSE;
|
||||
else if (ms->flags & MAGIC_CHECK)
|
||||
file_magwarn(ms, "'~' invalid for string types");
|
||||
@@ -1274,7 +1237,7 @@
|
||||
@@ -1274,7 +1245,7 @@
|
||||
m->str_flags = 0;
|
||||
m->num_mask = 0;
|
||||
if ((op = get_op(*l)) != -1) {
|
||||
@@ -441,7 +449,7 @@ diff -u libmagic.orig/apprentice.c libmagic/apprentice.c
|
||||
uint64_t val;
|
||||
++l;
|
||||
m->mask_op |= op;
|
||||
@@ -1423,11 +1386,6 @@
|
||||
@@ -1423,11 +1394,6 @@
|
||||
if (check_format(ms, m) == -1)
|
||||
return -1;
|
||||
}
|
||||
@@ -453,7 +461,7 @@ diff -u libmagic.orig/apprentice.c libmagic/apprentice.c
|
||||
m->mimetype[0] = '\0'; /* initialise MIME type to none */
|
||||
if (m->cont_level == 0)
|
||||
++(*nmentryp); /* make room for next */
|
||||
@@ -2053,56 +2011,68 @@
|
||||
@@ -2053,56 +2019,68 @@
|
||||
|
||||
/*
|
||||
* handle a compiled file.
|
||||
@@ -545,7 +553,7 @@ diff -u libmagic.orig/apprentice.c libmagic/apprentice.c
|
||||
ptr = (uint32_t *)(void *)*magicp;
|
||||
if (*ptr != MAGICNO) {
|
||||
if (swap4(*ptr) != MAGICNO) {
|
||||
@@ -2110,42 +2080,65 @@
|
||||
@@ -2110,42 +2088,65 @@
|
||||
goto error1;
|
||||
}
|
||||
needsbyteswap = 1;
|
||||
@@ -626,7 +634,7 @@ diff -u libmagic.orig/apprentice.c libmagic/apprentice.c
|
||||
return -1;
|
||||
}
|
||||
|
||||
@@ -2159,41 +2152,50 @@
|
||||
@@ -2159,41 +2160,50 @@
|
||||
apprentice_compile(struct magic_set *ms, struct magic **magicp,
|
||||
uint32_t *nmagicp, const char *fn)
|
||||
{
|
||||
@@ -688,7 +696,7 @@ diff -u libmagic.orig/apprentice.c libmagic/apprentice.c
|
||||
return rv;
|
||||
}
|
||||
|
||||
@@ -2206,6 +2208,7 @@
|
||||
@@ -2206,6 +2216,7 @@
|
||||
{
|
||||
const char *p, *q;
|
||||
char *buf;
|
||||
@@ -696,7 +704,7 @@ diff -u libmagic.orig/apprentice.c libmagic/apprentice.c
|
||||
|
||||
if (strip) {
|
||||
if ((p = strrchr(fn, '/')) != NULL)
|
||||
@@ -2227,14 +2230,14 @@
|
||||
@@ -2227,14 +2238,14 @@
|
||||
q++;
|
||||
/* Compatibility with old code that looked in .mime */
|
||||
if (ms->flags & MAGIC_MIME) {
|
||||
@@ -715,7 +723,7 @@ diff -u libmagic.orig/apprentice.c libmagic/apprentice.c
|
||||
|
||||
/* Compatibility with old code that looked in .mime */
|
||||
if (strstr(p, ".mime") != NULL)
|
||||
@@ -2324,7 +2327,7 @@
|
||||
@@ -2324,7 +2335,7 @@
|
||||
m->offset = swap4((uint32_t)m->offset);
|
||||
m->in_offset = swap4((uint32_t)m->in_offset);
|
||||
m->lineno = swap4((uint32_t)m->lineno);
|
||||
@@ -725,8 +733,8 @@ diff -u libmagic.orig/apprentice.c libmagic/apprentice.c
|
||||
m->str_flags = swap4(m->str_flags);
|
||||
}
|
||||
diff -u libmagic.orig/ascmagic.c libmagic/ascmagic.c
|
||||
--- libmagic.orig/ascmagic.c 2009-03-17 21:52:35.000000000 +0000
|
||||
+++ libmagic/ascmagic.c 2009-12-23 19:39:50.000000000 +0000
|
||||
--- libmagic.orig/ascmagic.c 2011-09-15 23:28:13.000000000 +0800
|
||||
+++ libmagic/ascmagic.c 2011-09-15 23:28:26.000000000 +0800
|
||||
@@ -144,10 +144,8 @@
|
||||
/* malloc size is a conservative overestimate; could be
|
||||
improved, or at least realloced after conversion. */
|
||||
@@ -750,8 +758,8 @@ diff -u libmagic.orig/ascmagic.c libmagic/ascmagic.c
|
||||
return rv;
|
||||
}
|
||||
diff -u libmagic.orig/cdf.c libmagic/cdf.c
|
||||
--- libmagic.orig/cdf.c 2009-05-06 15:29:47.000000000 +0100
|
||||
+++ libmagic/cdf.c 2009-12-23 19:39:50.000000000 +0000
|
||||
--- libmagic.orig/cdf.c 2011-09-15 23:28:13.000000000 +0800
|
||||
+++ libmagic/cdf.c 2011-09-15 23:29:29.000000000 +0800
|
||||
@@ -40,7 +40,17 @@
|
||||
#include <err.h>
|
||||
#endif
|
||||
@@ -815,8 +823,8 @@ diff -u libmagic.orig/cdf.c libmagic/cdf.c
|
||||
break;
|
||||
case CDF_CLIPBOARD:
|
||||
diff -u libmagic.orig/cdf.h libmagic/cdf.h
|
||||
--- libmagic.orig/cdf.h 2009-04-29 20:03:02.000000000 +0100
|
||||
+++ libmagic/cdf.h 2009-12-23 19:39:50.000000000 +0000
|
||||
--- libmagic.orig/cdf.h 2011-09-15 23:28:13.000000000 +0800
|
||||
+++ libmagic/cdf.h 2011-09-15 23:29:29.000000000 +0800
|
||||
@@ -42,7 +42,11 @@
|
||||
|
||||
typedef struct {
|
||||
@@ -844,8 +852,8 @@ diff -u libmagic.orig/cdf.h libmagic/cdf.h
|
||||
void cdf_swap_header(cdf_header_t *);
|
||||
void cdf_unpack_header(cdf_header_t *, char *);
|
||||
diff -u libmagic.orig/cdf_time.c libmagic/cdf_time.c
|
||||
--- libmagic.orig/cdf_time.c 2009-03-10 11:44:29.000000000 +0000
|
||||
+++ libmagic/cdf_time.c 2009-12-23 19:39:50.000000000 +0000
|
||||
--- libmagic.orig/cdf_time.c 2011-09-15 23:28:13.000000000 +0800
|
||||
+++ libmagic/cdf_time.c 2011-10-19 22:51:40.000000000 +0800
|
||||
@@ -96,7 +96,7 @@
|
||||
}
|
||||
|
||||
@@ -866,6 +874,15 @@ diff -u libmagic.orig/cdf_time.c libmagic/cdf_time.c
|
||||
|
||||
t /= CDF_TIME_PREC;
|
||||
tm.tm_sec = t % 60;
|
||||
@@ -117,7 +117,7 @@
|
||||
tm.tm_hour = t % 24;
|
||||
t /= 24;
|
||||
|
||||
- // XXX: Approx
|
||||
+ /* XXX: Approx */
|
||||
tm.tm_year = CDF_BASE_YEAR + (t / 365);
|
||||
|
||||
rdays = cdf_getdays(tm.tm_year);
|
||||
@@ -143,7 +143,7 @@
|
||||
}
|
||||
|
||||
@@ -894,8 +911,8 @@ diff -u libmagic.orig/cdf_time.c libmagic/cdf_time.c
|
||||
static const char *ref = "Sat Apr 23 01:30:00 1977";
|
||||
char *p, *q;
|
||||
diff -u libmagic.orig/compress.c libmagic/compress.c
|
||||
--- libmagic.orig/compress.c 2009-03-23 14:21:51.000000000 +0000
|
||||
+++ libmagic/compress.c 2009-12-23 19:39:50.000000000 +0000
|
||||
--- libmagic.orig/compress.c 2011-09-15 23:28:13.000000000 +0800
|
||||
+++ libmagic/compress.c 2011-09-15 23:28:26.000000000 +0800
|
||||
@@ -32,6 +32,7 @@
|
||||
* uncompress(method, old, n, newch) - uncompress old into new,
|
||||
* using method, return sizeof new
|
||||
@@ -1040,8 +1057,8 @@ diff -u libmagic.orig/compress.c libmagic/compress.c
|
||||
}
|
||||
+#endif /* if PHP_FILEINFO_UNCOMPRESS */
|
||||
diff -u libmagic.orig/file.h libmagic/file.h
|
||||
--- libmagic.orig/file.h 2009-03-17 21:52:35.000000000 +0000
|
||||
+++ libmagic/file.h 2009-12-23 19:39:50.000000000 +0000
|
||||
--- libmagic.orig/file.h 2011-09-15 23:28:13.000000000 +0800
|
||||
+++ libmagic/file.h 2011-09-15 23:28:26.000000000 +0800
|
||||
@@ -33,9 +33,7 @@
|
||||
#ifndef __file_h__
|
||||
#define __file_h__
|
||||
@@ -1195,8 +1212,8 @@ diff -u libmagic.orig/file.h libmagic/file.h
|
||||
#define QUICK
|
||||
#endif
|
||||
diff -u libmagic.orig/fsmagic.c libmagic/fsmagic.c
|
||||
--- libmagic.orig/fsmagic.c 2009-03-17 21:52:35.000000000 +0000
|
||||
+++ libmagic/fsmagic.c 2009-12-23 19:39:50.000000000 +0000
|
||||
--- libmagic.orig/fsmagic.c 2011-09-15 23:28:13.000000000 +0800
|
||||
+++ libmagic/fsmagic.c 2011-09-15 23:28:26.000000000 +0800
|
||||
@@ -60,29 +60,19 @@
|
||||
#endif
|
||||
#undef HAVE_MAJOR
|
||||
@@ -1555,8 +1572,8 @@ diff -u libmagic.orig/fsmagic.c libmagic/fsmagic.c
|
||||
|
||||
/*
|
||||
diff -u libmagic.orig/funcs.c libmagic/funcs.c
|
||||
--- libmagic.orig/funcs.c 2009-04-07 12:07:00.000000000 +0100
|
||||
+++ libmagic/funcs.c 2009-12-23 19:39:50.000000000 +0000
|
||||
--- libmagic.orig/funcs.c 2011-09-15 23:28:13.000000000 +0800
|
||||
+++ libmagic/funcs.c 2011-09-15 23:28:26.000000000 +0800
|
||||
@@ -41,52 +41,36 @@
|
||||
#if defined(HAVE_WCTYPE_H)
|
||||
#include <wctype.h>
|
||||
@@ -1785,8 +1802,8 @@ diff -u libmagic.orig/funcs.c libmagic/funcs.c
|
||||
ms->c.li[level].got_match = 0;
|
||||
#ifdef ENABLE_CONDITIONALS
|
||||
diff -u libmagic.orig/magic.c libmagic/magic.c
|
||||
--- libmagic.orig/magic.c 2009-03-20 21:25:41.000000000 +0000
|
||||
+++ libmagic/magic.c 2009-12-23 19:39:50.000000000 +0000
|
||||
--- libmagic.orig/magic.c 2011-09-15 23:28:13.000000000 +0800
|
||||
+++ libmagic/magic.c 2011-09-15 23:29:29.000000000 +0800
|
||||
@@ -34,14 +34,19 @@
|
||||
#include "magic.h"
|
||||
|
||||
@@ -2130,8 +2147,8 @@ diff -u libmagic.orig/magic.c libmagic/magic.c
|
||||
public const char *
|
||||
magic_error(struct magic_set *ms)
|
||||
diff -u libmagic.orig/magic.h libmagic/magic.h
|
||||
--- libmagic.orig/magic.h 2009-03-17 21:52:35.000000000 +0000
|
||||
+++ libmagic/magic.h 2009-12-23 19:39:50.000000000 +0000
|
||||
--- libmagic.orig/magic.h 2011-09-15 23:28:13.000000000 +0800
|
||||
+++ libmagic/magic.h 2011-09-15 23:28:26.000000000 +0800
|
||||
@@ -70,6 +70,7 @@
|
||||
void magic_close(magic_t);
|
||||
|
||||
@@ -2149,8 +2166,8 @@ diff -u libmagic.orig/magic.h libmagic/magic.h
|
||||
|
||||
#ifdef __cplusplus
|
||||
diff -u libmagic.orig/patchlevel.h libmagic/patchlevel.h
|
||||
--- libmagic.orig/patchlevel.h 2009-05-06 21:32:48.000000000 +0100
|
||||
+++ libmagic/patchlevel.h 2009-12-23 19:39:50.000000000 +0000
|
||||
--- libmagic.orig/patchlevel.h 2011-09-15 23:28:13.000000000 +0800
|
||||
+++ libmagic/patchlevel.h 2011-09-15 23:28:26.000000000 +0800
|
||||
@@ -3,23 +3,23 @@
|
||||
|
||||
/*
|
||||
@@ -2188,18 +2205,26 @@ diff -u libmagic.orig/patchlevel.h libmagic/patchlevel.h
|
||||
* Revision 1.69 2008/07/02 15:27:05 christos
|
||||
* welcome to 4.25
|
||||
diff -u libmagic.orig/print.c libmagic/print.c
|
||||
--- libmagic.orig/print.c 2009-03-17 21:52:35.000000000 +0000
|
||||
+++ libmagic/print.c 2009-12-23 19:39:50.000000000 +0000
|
||||
@@ -29,6 +29,8 @@
|
||||
--- libmagic.orig/print.c 2011-09-15 23:28:13.000000000 +0800
|
||||
+++ libmagic/print.c 2011-09-15 23:29:29.000000000 +0800
|
||||
@@ -28,6 +28,8 @@
|
||||
/*
|
||||
* print.c - debugging printout routines
|
||||
*/
|
||||
|
||||
+#define _GNU_SOURCE
|
||||
+#include "php.h"
|
||||
+
|
||||
|
||||
#include "file.h"
|
||||
|
||||
#ifndef lint
|
||||
@@ -45,157 +47,21 @@
|
||||
@@ -35,6 +37,7 @@
|
||||
FILE_RCSID("@(#)$File: print.c,v 1.66 2009/02/03 20:27:51 christos Exp $")
|
||||
#endif /* lint */
|
||||
|
||||
+#include <stdio.h>
|
||||
#include <string.h>
|
||||
#include <stdarg.h>
|
||||
#include <stdlib.h>
|
||||
@@ -45,157 +48,21 @@
|
||||
|
||||
#define SZOF(a) (sizeof(a) / sizeof(a[0]))
|
||||
|
||||
@@ -2365,8 +2390,8 @@ diff -u libmagic.orig/print.c libmagic/print.c
|
||||
|
||||
protected const char *
|
||||
diff -u libmagic.orig/readcdf.c libmagic/readcdf.c
|
||||
--- libmagic.orig/readcdf.c 2009-05-06 21:48:22.000000000 +0100
|
||||
+++ libmagic/readcdf.c 2009-12-23 19:39:50.000000000 +0000
|
||||
--- libmagic.orig/readcdf.c 2011-09-15 23:28:13.000000000 +0800
|
||||
+++ libmagic/readcdf.c 2011-09-15 23:29:29.000000000 +0800
|
||||
@@ -30,7 +30,11 @@
|
||||
#endif
|
||||
|
||||
@@ -2413,8 +2438,8 @@ diff -u libmagic.orig/readcdf.c libmagic/readcdf.c
|
||||
if ((ec = strchr(c, '\n')) != NULL)
|
||||
*ec = '\0';
|
||||
diff -u libmagic.orig/readelf.c libmagic/readelf.c
|
||||
--- libmagic.orig/readelf.c 2009-03-17 21:52:35.000000000 +0000
|
||||
+++ libmagic/readelf.c 2009-12-23 19:39:50.000000000 +0000
|
||||
--- libmagic.orig/readelf.c 2011-09-15 23:28:13.000000000 +0800
|
||||
+++ libmagic/readelf.c 2011-09-15 23:28:26.000000000 +0800
|
||||
@@ -49,7 +49,7 @@
|
||||
off_t, int *, int);
|
||||
private int doshn(struct magic_set *, int, int, int, off_t, int, size_t, int *,
|
||||
@@ -2480,8 +2505,8 @@ diff -u libmagic.orig/readelf.c libmagic/readelf.c
|
||||
case SHT_SUNW_cap:
|
||||
{
|
||||
diff -u libmagic.orig/softmagic.c libmagic/softmagic.c
|
||||
--- libmagic.orig/softmagic.c 2009-03-27 22:42:49.000000000 +0000
|
||||
+++ libmagic/softmagic.c 2009-12-23 19:39:50.000000000 +0000
|
||||
--- libmagic.orig/softmagic.c 2011-09-15 23:28:13.000000000 +0800
|
||||
+++ libmagic/softmagic.c 2011-09-15 23:29:29.000000000 +0800
|
||||
@@ -41,6 +41,11 @@
|
||||
#include <stdlib.h>
|
||||
#include <time.h>
|
||||
@@ -2662,7 +2687,7 @@ diff -u libmagic.orig/softmagic.c libmagic/softmagic.c
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1672,6 +1645,66 @@
|
||||
@@ -1672,6 +1645,65 @@
|
||||
return file_strncmp(a, b, len, flags);
|
||||
}
|
||||
|
||||
@@ -2673,7 +2698,6 @@ diff -u libmagic.orig/softmagic.c libmagic/softmagic.c
|
||||
+ char *t;
|
||||
+
|
||||
+ t = (char *) safe_emalloc(Z_STRLEN_P(pattern), 2, 5);
|
||||
+ memset(t, '\0', sizeof(t));
|
||||
+
|
||||
+ t[j++] = '~';
|
||||
+
|
||||
@@ -2729,7 +2753,7 @@ diff -u libmagic.orig/softmagic.c libmagic/softmagic.c
|
||||
private int
|
||||
magiccheck(struct magic_set *ms, struct magic *m)
|
||||
{
|
||||
@@ -1828,67 +1861,162 @@
|
||||
@@ -1828,67 +1860,162 @@
|
||||
break;
|
||||
}
|
||||
case FILE_REGEX: {
|
||||
@@ -2773,7 +2797,7 @@ diff -u libmagic.orig/softmagic.c libmagic/softmagic.c
|
||||
+
|
||||
+ convert_libmagic_pattern(pattern, options);
|
||||
+
|
||||
+#if PHP_API_VERSION < 20100412
|
||||
+#if (PHP_MAJOR_VERSION < 6)
|
||||
+ if ((pce = pcre_get_compiled_regex_cache(Z_STRVAL_P(pattern), Z_STRLEN_P(pattern) TSRMLS_CC)) == NULL) {
|
||||
#else
|
||||
- pmatch[0].rm_so = 0;
|
||||
@@ -2800,7 +2824,7 @@ diff -u libmagic.orig/softmagic.c libmagic/softmagic.c
|
||||
+ haystack = estrndup(ms->search.s, ms->search.s_len);
|
||||
+
|
||||
+ /* match v = 0, no match v = 1 */
|
||||
+#if PHP_API_VERSION < 20100412
|
||||
+#if (PHP_MAJOR_VERSION < 6)
|
||||
+ php_pcre_match_impl(pce, haystack, ms->search.s_len, retval, subpats, 1, 1, PREG_OFFSET_CAPTURE, 0 TSRMLS_CC);
|
||||
+#else
|
||||
+ php_pcre_match_impl(pce, IS_STRING, haystack, ms->search.s_len, retval, subpats, 1, 1, PREG_OFFSET_CAPTURE, 0 TSRMLS_CC);
|
||||
@@ -2944,7 +2968,7 @@ diff -u libmagic.orig/softmagic.c libmagic/softmagic.c
|
||||
default:
|
||||
file_magerror(ms, "invalid type %d in magiccheck()", m->type);
|
||||
return -1;
|
||||
@@ -1900,7 +2028,7 @@
|
||||
@@ -1900,7 +2027,7 @@
|
||||
case 'x':
|
||||
if ((ms->flags & MAGIC_DEBUG) != 0)
|
||||
(void) fprintf(stderr, "%llu == *any* = 1\n",
|
||||
@@ -2953,7 +2977,7 @@ diff -u libmagic.orig/softmagic.c libmagic/softmagic.c
|
||||
matched = 1;
|
||||
break;
|
||||
|
||||
@@ -1908,7 +2036,7 @@
|
||||
@@ -1908,7 +2035,7 @@
|
||||
matched = v != l;
|
||||
if ((ms->flags & MAGIC_DEBUG) != 0)
|
||||
(void) fprintf(stderr, "%llu != %llu = %d\n",
|
||||
@@ -2962,7 +2986,7 @@ diff -u libmagic.orig/softmagic.c libmagic/softmagic.c
|
||||
matched);
|
||||
break;
|
||||
|
||||
@@ -1916,7 +2044,7 @@
|
||||
@@ -1916,7 +2043,7 @@
|
||||
matched = v == l;
|
||||
if ((ms->flags & MAGIC_DEBUG) != 0)
|
||||
(void) fprintf(stderr, "%llu == %llu = %d\n",
|
||||
@@ -2971,7 +2995,7 @@ diff -u libmagic.orig/softmagic.c libmagic/softmagic.c
|
||||
matched);
|
||||
break;
|
||||
|
||||
@@ -1925,14 +2053,14 @@
|
||||
@@ -1925,14 +2052,14 @@
|
||||
matched = v > l;
|
||||
if ((ms->flags & MAGIC_DEBUG) != 0)
|
||||
(void) fprintf(stderr, "%llu > %llu = %d\n",
|
||||
@@ -2989,7 +3013,7 @@ diff -u libmagic.orig/softmagic.c libmagic/softmagic.c
|
||||
}
|
||||
break;
|
||||
|
||||
@@ -1941,14 +2069,14 @@
|
||||
@@ -1941,14 +2068,14 @@
|
||||
matched = v < l;
|
||||
if ((ms->flags & MAGIC_DEBUG) != 0)
|
||||
(void) fprintf(stderr, "%llu < %llu = %d\n",
|
||||
@@ -3007,7 +3031,7 @@ diff -u libmagic.orig/softmagic.c libmagic/softmagic.c
|
||||
}
|
||||
break;
|
||||
|
||||
@@ -1956,16 +2084,16 @@
|
||||
@@ -1956,16 +2083,16 @@
|
||||
matched = (v & l) == l;
|
||||
if ((ms->flags & MAGIC_DEBUG) != 0)
|
||||
(void) fprintf(stderr, "((%llx & %llx) == %llx) = %d\n",
|
||||
|
||||
@@ -117,7 +117,7 @@ cdf_timestamp_to_timespec(struct timeval *ts, cdf_timestamp_t t)
|
||||
tm.tm_hour = t % 24;
|
||||
t /= 24;
|
||||
|
||||
// XXX: Approx
|
||||
/* XXX: Approx */
|
||||
tm.tm_year = CDF_BASE_YEAR + (t / 365);
|
||||
|
||||
rdays = cdf_getdays(tm.tm_year);
|
||||
|
||||
@@ -29,8 +29,8 @@
|
||||
* print.c - debugging printout routines
|
||||
*/
|
||||
|
||||
#define _GNU_SOURCE
|
||||
#include "php.h"
|
||||
#include "main/snprintf.h"
|
||||
|
||||
#include "file.h"
|
||||
|
||||
@@ -38,6 +38,7 @@
|
||||
FILE_RCSID("@(#)$File: print.c,v 1.66 2009/02/03 20:27:51 christos Exp $")
|
||||
#endif /* lint */
|
||||
|
||||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
#include <stdarg.h>
|
||||
#include <stdlib.h>
|
||||
|
||||
@@ -1,5 +1,9 @@
|
||||
<?php /* $Id$ */
|
||||
|
||||
if (!extension_loaded("interbase")) print "skip";
|
||||
if (!extension_loaded("interbase")) print "skip interbase extension not available";
|
||||
require("interbase.inc");
|
||||
if(!@ibase_connect($test_base)){
|
||||
die("skip cannot connnect");
|
||||
}
|
||||
|
||||
?>
|
||||
@@ -11,6 +11,7 @@ date.timezone="America/Los_Angeles"
|
||||
* Test for the datefmt_parse function
|
||||
*/
|
||||
|
||||
putenv('TZ=America/Los_Angeles');
|
||||
|
||||
function ut_main()
|
||||
{
|
||||
|
||||
+1
-1
@@ -297,7 +297,7 @@ static void json_encode_array(smart_str *buf, zval **val, int options TSRMLS_DC)
|
||||
|
||||
json_pretty_print_indent(buf, options TSRMLS_CC);
|
||||
|
||||
json_escape_string(buf, key, key_len - 1, options TSRMLS_CC);
|
||||
json_escape_string(buf, key, key_len - 1, options & ~PHP_JSON_NUMERIC_CHECK TSRMLS_CC);
|
||||
smart_str_appendc(buf, ':');
|
||||
|
||||
json_pretty_print_char(buf, options, ' ' TSRMLS_CC);
|
||||
|
||||
@@ -0,0 +1,13 @@
|
||||
--TEST--
|
||||
Bug #55543 (json_encode() with JSON_NUMERIC_CHECK & numeric string properties)
|
||||
--SKIPIF--
|
||||
<?php if (!extension_loaded("json")) print "skip"; ?>
|
||||
--FILE--
|
||||
<?php
|
||||
$a = new stdClass;
|
||||
$a->{"1"} = "5";
|
||||
|
||||
var_dump(json_encode($a, JSON_NUMERIC_CHECK));
|
||||
?>
|
||||
--EXPECT--
|
||||
string(7) "{"1":5}"
|
||||
@@ -42,7 +42,7 @@ static const unsigned short mb_tbl_code2uni_docomo1[] = { // 0x28c2 - 0x29db
|
||||
0xEE11, 0x2709, 0xEE12, 0xEE13,
|
||||
0xf4b4, 0xf193, 0xf194, 0xf511,
|
||||
0x21a9, 0xf191, 0xf50d, 0xf195,
|
||||
0xf6a9, 0x0000, 0x0023, 0xE82D,
|
||||
0xf6a9, 0x27bf, 0x0023, 0xE82D,
|
||||
0x0031, 0x0032, 0x0033, 0x0034,
|
||||
0x0035, 0x0036, 0x0037, 0x0038,
|
||||
0x0039, 0x0030, 0x2764, 0xf493,
|
||||
@@ -275,7 +275,7 @@ static const unsigned short mb_tbl_code2uni_sb1[] = { // 0x27a9 - 0x2861
|
||||
0xf6a2, 0xf201, 0xf49f, 0x2734,
|
||||
0x2733, 0xf51e, 0xf6ad, 0xf530,
|
||||
0x267f, 0xf4f6, 0x2665, 0x2666,
|
||||
0x2660, 0x2663, 0x0023, 0x0000,
|
||||
0x2660, 0x2663, 0x0023, 0x27bf,
|
||||
0xf195, 0xf199, 0xf192, 0xf236,
|
||||
0xf21a, 0xf237, 0xf238, 0xf534,
|
||||
0xf532, 0xf533, 0x0031, 0x0032,
|
||||
@@ -426,8 +426,8 @@ static const unsigned short mb_tbl_uni_docomo2code2_key[] = { // 0x203c - 0x3299
|
||||
0x26f5, 0x26fd, 0x2702, 0x2708,
|
||||
0x2709, 0x270a, 0x270b, 0x270c,
|
||||
0x270f, 0x2712, 0x2728, 0x2757,
|
||||
0x2764, 0x27b0, 0x2934, 0x2935,
|
||||
0x3030, 0x3299, };
|
||||
0x2764, 0x27b0, 0x27bf, 0x2934,
|
||||
0x2935, 0x3030, 0x3299, };
|
||||
|
||||
static const unsigned short mb_tbl_uni_docomo2code2_value[] = { // 0x203c - 0x3299
|
||||
0x2988, 0x2987, 0x29b6, 0x29c0,
|
||||
@@ -444,8 +444,8 @@ static const unsigned short mb_tbl_uni_docomo2code2_value[] = { // 0x203c - 0x32
|
||||
0x2927, 0x28ef, 0x28f9, 0x28e6,
|
||||
0x2957, 0x2917, 0x2919, 0x2918,
|
||||
0x299d, 0x2932, 0x297e, 0x2986,
|
||||
0x2970, 0x298e, 0x2979, 0x2984,
|
||||
0x298d, 0x29b8, };
|
||||
0x2970, 0x298e, 0x2963, 0x2979,
|
||||
0x2984, 0x298d, 0x29b8, };
|
||||
|
||||
static const int mb_tbl_uni_docomo2code2_len = sizeof(mb_tbl_uni_docomo2code2_key)/sizeof(unsigned short);
|
||||
|
||||
@@ -929,9 +929,9 @@ static const unsigned short mb_tbl_uni_sb2code2_key[] = { // 0x2122 - 0x3299
|
||||
0x270a, 0x270b, 0x270c, 0x2728,
|
||||
0x2733, 0x2734, 0x274c, 0x2753,
|
||||
0x2754, 0x2755, 0x2757, 0x2764,
|
||||
0x27a1, 0x2b05, 0x2b06, 0x2b07,
|
||||
0x2b50, 0x2b55, 0x303d, 0x3297,
|
||||
0x3299, };
|
||||
0x27a1, 0x27bf, 0x2b05, 0x2b06,
|
||||
0x2b07, 0x2b50, 0x2b55, 0x303d,
|
||||
0x3297, 0x3299, };
|
||||
|
||||
static const unsigned short mb_tbl_uni_sb2code2_value[] = { // 0x2122 - 0x3299
|
||||
0x2b2e, 0x283e, 0x283d, 0x283f,
|
||||
@@ -949,9 +949,9 @@ static const unsigned short mb_tbl_uni_sb2code2_value[] = { // 0x2122 - 0x3299
|
||||
0x2930, 0x2932, 0x2931, 0x29ad,
|
||||
0x280d, 0x280c, 0x29b2, 0x2940,
|
||||
0x29b5, 0x29b6, 0x2941, 0x2942,
|
||||
0x283b, 0x283c, 0x2839, 0x283a,
|
||||
0x29ae, 0x29b1, 0x27d4, 0x298c,
|
||||
0x2994, };
|
||||
0x283b, 0x2818, 0x283c, 0x2839,
|
||||
0x283a, 0x29ae, 0x29b1, 0x27d4,
|
||||
0x298c, 0x2994, };
|
||||
|
||||
static const int mb_tbl_uni_sb2code2_len = sizeof(mb_tbl_uni_sb2code2_key)/sizeof(unsigned short);
|
||||
|
||||
|
||||
@@ -176,7 +176,7 @@ const unsigned short mbfl_sb2uni_pua[6][3] = {
|
||||
{0x2921, 0x297a, 0xe001},
|
||||
{0x2980, 0x29cc, 0xe301},
|
||||
{0x2a99, 0x2ae4, 0xe401},
|
||||
{0x2af8, 0x2b2e, 0xe501},
|
||||
{0x2af8, 0x2b2f, 0xe501},
|
||||
};
|
||||
|
||||
const unsigned short mbfl_kddi2uni_pua_b[8][3] = {
|
||||
|
||||
@@ -52,7 +52,7 @@ const unsigned char mblen_table_utf8[] = {
|
||||
2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
|
||||
2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
|
||||
3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3,
|
||||
4, 4, 4, 4, 4, 4, 4, 4, 1, 1, 1, 1, 1, 1, 1, 1
|
||||
4, 4, 4, 4, 4, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1
|
||||
};
|
||||
|
||||
static const char *mbfl_encoding_utf8_aliases[] = {"utf8", NULL};
|
||||
|
||||
@@ -2954,6 +2954,80 @@ collector_encode_hex_htmlnumericentity(int c, void *data)
|
||||
return c;
|
||||
}
|
||||
|
||||
int mbfl_filt_decode_htmlnumericentity_flush(mbfl_convert_filter *filter)
|
||||
{
|
||||
struct collector_htmlnumericentity_data *pc = (struct collector_htmlnumericentity_data *)filter;
|
||||
int n, s, r, d;
|
||||
|
||||
if (pc->status) {
|
||||
switch (pc->status) {
|
||||
case 1: /* '&' */
|
||||
(*pc->decoder->filter_function)(0x26, pc->decoder); /* '&' */
|
||||
break;
|
||||
case 2: /* '#' */
|
||||
(*pc->decoder->filter_function)(0x26, pc->decoder); /* '&' */
|
||||
(*pc->decoder->filter_function)(0x23, pc->decoder); /* '#' */
|
||||
break;
|
||||
case 3: /* '0'-'9' */
|
||||
(*pc->decoder->filter_function)(0x26, pc->decoder); /* '&' */
|
||||
(*pc->decoder->filter_function)(0x23, pc->decoder); /* '#' */
|
||||
|
||||
s = pc->cache;
|
||||
r = 1;
|
||||
n = pc->digit;
|
||||
while (n > 0) {
|
||||
r *= 10;
|
||||
n--;
|
||||
}
|
||||
s %= r;
|
||||
r /= 10;
|
||||
while (r > 0) {
|
||||
d = s/r;
|
||||
s %= r;
|
||||
r /= 10;
|
||||
(*pc->decoder->filter_function)(mbfl_hexchar_table[d], pc->decoder);
|
||||
}
|
||||
|
||||
break;
|
||||
case 4: /* 'x' */
|
||||
(*pc->decoder->filter_function)(0x26, pc->decoder); /* '&' */
|
||||
(*pc->decoder->filter_function)(0x23, pc->decoder); /* '#' */
|
||||
(*pc->decoder->filter_function)(0x78, pc->decoder); /* 'x' */
|
||||
break;
|
||||
case 5: /* '0'-'9','a'-'f' */
|
||||
(*pc->decoder->filter_function)(0x26, pc->decoder); /* '&' */
|
||||
(*pc->decoder->filter_function)(0x23, pc->decoder); /* '#' */
|
||||
(*pc->decoder->filter_function)(0x78, pc->decoder); /* 'x' */
|
||||
|
||||
s = pc->cache;
|
||||
r = 1;
|
||||
n = pc->digit;
|
||||
while (n > 0) {
|
||||
r *= 16;
|
||||
n--;
|
||||
}
|
||||
s %= r;
|
||||
r /= 16;
|
||||
while (r > 0) {
|
||||
d = s/r;
|
||||
s %= r;
|
||||
r /= 16;
|
||||
(*pc->decoder->filter_function)(mbfl_hexchar_table[d], pc->decoder);
|
||||
}
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
pc->status = 0;
|
||||
pc->cache = 0;
|
||||
pc->digit = 0;
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
mbfl_string *
|
||||
mbfl_html_numeric_entity(
|
||||
mbfl_string *string,
|
||||
@@ -2996,7 +3070,8 @@ mbfl_html_numeric_entity(
|
||||
encoder = mbfl_convert_filter_new(
|
||||
string->no_encoding,
|
||||
mbfl_no_encoding_wchar,
|
||||
collector_decode_htmlnumericentity, 0, &pc);
|
||||
collector_decode_htmlnumericentity,
|
||||
(int (*)(void*))mbfl_filt_decode_htmlnumericentity_flush, &pc);
|
||||
}
|
||||
if (pc.decoder == NULL || encoder == NULL) {
|
||||
mbfl_convert_filter_delete(encoder);
|
||||
|
||||
@@ -3183,7 +3183,7 @@ PHP_FUNCTION(mb_detect_encoding)
|
||||
/* make encoding list */
|
||||
list = NULL;
|
||||
size = 0;
|
||||
if (ZEND_NUM_ARGS() >= 2 && Z_STRVAL_P(encoding_list)) {
|
||||
if (ZEND_NUM_ARGS() >= 2 && !ZVAL_IS_NULL(encoding_list)) {
|
||||
switch (Z_TYPE_P(encoding_list)) {
|
||||
case IS_ARRAY:
|
||||
if (FAILURE == php_mb_parse_encoding_array(encoding_list, &list, &size, 0 TSRMLS_CC)) {
|
||||
|
||||
@@ -0,0 +1,25 @@
|
||||
--TEST--
|
||||
Bug #40685 (mb_decode_numericentity() removes '&' in the string)
|
||||
--SKIPIF--
|
||||
<?php extension_loaded('mbstring') or die('skip mbstring not available'); ?>
|
||||
--FILE--
|
||||
<?php
|
||||
$map = array(0, 0x10FFFF, 0, 0xFFFFFF);
|
||||
var_dump(mb_decode_numericentity('&', $map, 'UTF-8'));
|
||||
var_dump(mb_decode_numericentity('&&&', $map, 'UTF-8'));
|
||||
var_dump(mb_decode_numericentity('&#', $map, 'UTF-8'));
|
||||
var_dump(mb_decode_numericentity('&#x', $map, 'UTF-8'));
|
||||
var_dump(mb_decode_numericentity('=', $map, 'UTF-8'));
|
||||
var_dump(mb_decode_numericentity('=', $map, 'UTF-8'));
|
||||
var_dump(mb_decode_numericentity('=', $map, 'UTF-8'));
|
||||
var_dump(mb_decode_numericentity('=', $map, 'UTF-8'));
|
||||
?>
|
||||
--EXPECTF--
|
||||
string(1) "&"
|
||||
string(3) "&&&"
|
||||
string(2) "&#"
|
||||
string(3) "&#x"
|
||||
string(4) "="
|
||||
string(5) "="
|
||||
string(1) "="
|
||||
string(1) "="
|
||||
@@ -0,0 +1,172 @@
|
||||
--TEST--
|
||||
Emoji (Pictogram characters for cellular phone in Japan) test based on Unicode 6.0
|
||||
--SKIPIF--
|
||||
<?php extension_loaded('mbstring') or die('skip mbstring not available'); ?>
|
||||
--FILE--
|
||||
<?php
|
||||
mb_substitute_character(0x3f);
|
||||
|
||||
echo "SJIS-Mobile to Unicode\n";
|
||||
var_dump(bin2hex(mb_convert_encoding("\xf8\x9f", "UCS-4BE", "SJIS-Mobile#DOCOMO")));
|
||||
var_dump(bin2hex(mb_convert_encoding("\xf6\x60", "UCS-4BE", "SJIS-Mobile#KDDI")));
|
||||
var_dump(bin2hex(mb_convert_encoding("\xf9\x8b", "UCS-4BE", "SJIS-Mobile#SOFTBANK")));
|
||||
|
||||
var_dump(bin2hex(mb_convert_encoding("\xf9\xe6", "UCS-4BE", "SJIS-Mobile#DOCOMO")));
|
||||
var_dump(bin2hex(mb_convert_encoding("\xf6\xec", "UCS-4BE", "SJIS-Mobile#KDDI")));
|
||||
var_dump(bin2hex(mb_convert_encoding("\xf7\x50", "UCS-4BE", "SJIS-Mobile#SOFTBANK")));
|
||||
|
||||
var_dump(bin2hex(mb_convert_encoding("\xf9\x85", "UCS-4BE", "SJIS-Mobile#DOCOMO")));
|
||||
var_dump(bin2hex(mb_convert_encoding("\xf4\x89", "UCS-4BE", "SJIS-Mobile#KDDI")));
|
||||
var_dump(bin2hex(mb_convert_encoding("\xf7\xb0", "UCS-4BE", "SJIS-Mobile#SOFTBANK")));
|
||||
|
||||
var_dump(bin2hex(mb_convert_encoding("\xf3\xd2", "UCS-4BE", "SJIS-Mobile#KDDI")));
|
||||
var_dump(bin2hex(mb_convert_encoding("\xfb\xb3", "UCS-4BE", "SJIS-Mobile#SOFTBANK")));
|
||||
|
||||
echo "Unicode to SJIS-Mobile\n";
|
||||
var_dump(bin2hex(mb_convert_encoding("\x00\x00\x26\x00", "SJIS-Mobile#DOCOMO", "UCS-4BE")));
|
||||
var_dump(bin2hex(mb_convert_encoding("\x00\x00\x26\x00", "SJIS-Mobile#KDDI", "UCS-4BE")));
|
||||
var_dump(bin2hex(mb_convert_encoding("\x00\x00\x26\x00", "SJIS-Mobile#SOFTBANK", "UCS-4BE")));
|
||||
|
||||
var_dump(bin2hex(mb_convert_encoding("\x00\x01\xf3\x40", "SJIS-Mobile#DOCOMO", "UCS-4BE")));
|
||||
var_dump(bin2hex(mb_convert_encoding("\x00\x01\xf3\x40", "SJIS-Mobile#KDDI", "UCS-4BE")));
|
||||
var_dump(bin2hex(mb_convert_encoding("\x00\x01\xf3\x40", "SJIS-Mobile#SOFTBANK", "UCS-4BE")));
|
||||
|
||||
var_dump(bin2hex(mb_convert_encoding("\x00\x00\x00\x23\x00\x00\x20\xe3", "SJIS-Mobile#DOCOMO", "UCS-4BE")));
|
||||
var_dump(bin2hex(mb_convert_encoding("\x00\x00\x00\x23\x00\x00\x20\xe3", "SJIS-Mobile#KDDI", "UCS-4BE")));
|
||||
var_dump(bin2hex(mb_convert_encoding("\x00\x00\x00\x23\x00\x00\x20\xe3", "SJIS-Mobile#SOFTBANK", "UCS-4BE")));
|
||||
|
||||
var_dump(bin2hex(mb_convert_encoding("\x00\x01\xf1\xe8\x00\x01\xf1\xf3", "SJIS-Mobile#DOCOMO", "UCS-4BE")));
|
||||
var_dump(bin2hex(mb_convert_encoding("\x00\x01\xf1\xe8\x00\x01\xf1\xf3", "SJIS-Mobile#KDDI", "UCS-4BE")));
|
||||
var_dump(bin2hex(mb_convert_encoding("\x00\x01\xf1\xe8\x00\x01\xf1\xf3", "SJIS-Mobile#SOFTBANK", "UCS-4BE")));
|
||||
|
||||
echo "UTF-8-Mobile to Unicode\n";
|
||||
var_dump(bin2hex(mb_convert_encoding("\xee\x98\xbe", "UCS-4BE", "UTF-8-Mobile#DOCOMO")));
|
||||
var_dump(bin2hex(mb_convert_encoding("\xee\xbd\xa0", "UCS-4BE", "UTF-8-Mobile#KDDI")));
|
||||
var_dump(bin2hex(mb_convert_encoding("\xee\x81\x8a", "UCS-4BE", "UTF-8-Mobile#SOFTBANK")));
|
||||
|
||||
var_dump(bin2hex(mb_convert_encoding("\xee\x9d\x81", "UCS-4BE", "UTF-8-Mobile#DOCOMO")));
|
||||
var_dump(bin2hex(mb_convert_encoding("\xee\xbf\xac", "UCS-4BE", "UTF-8-Mobile#KDDI")));
|
||||
var_dump(bin2hex(mb_convert_encoding("\xee\x84\x90", "UCS-4BE", "UTF-8-Mobile#SOFTBANK")));
|
||||
|
||||
var_dump(bin2hex(mb_convert_encoding("\xee\x9b\xa0", "UCS-4BE", "UTF-8-Mobile#DOCOMO")));
|
||||
var_dump(bin2hex(mb_convert_encoding("\xee\xb6\x89", "UCS-4BE", "UTF-8-Mobile#KDDI")));
|
||||
var_dump(bin2hex(mb_convert_encoding("\xee\x88\x90", "UCS-4BE", "UTF-8-Mobile#SOFTBANK")));
|
||||
|
||||
var_dump(bin2hex(mb_convert_encoding("\xee\xb3\x92", "UCS-4BE", "UTF-8-Mobile#KDDI")));
|
||||
var_dump(bin2hex(mb_convert_encoding("\xee\x94\x93", "UCS-4BE", "UTF-8-Mobile#SOFTBANK")));
|
||||
|
||||
echo "Unicode to UTF8-Mobile\n";
|
||||
var_dump(bin2hex(mb_convert_encoding("\x00\x00\x26\x00", "UTF-8-Mobile#DOCOMO", "UCS-4BE")));
|
||||
var_dump(bin2hex(mb_convert_encoding("\x00\x00\x26\x00", "UTF-8-Mobile#KDDI", "UCS-4BE")));
|
||||
var_dump(bin2hex(mb_convert_encoding("\x00\x00\x26\x00", "UTF-8-Mobile#SOFTBANK", "UCS-4BE")));
|
||||
|
||||
var_dump(bin2hex(mb_convert_encoding("\x00\x01\xf3\x40", "UTF-8-Mobile#DOCOMO", "UCS-4BE")));
|
||||
var_dump(bin2hex(mb_convert_encoding("\x00\x01\xf3\x40", "UTF-8-Mobile#KDDI", "UCS-4BE")));
|
||||
var_dump(bin2hex(mb_convert_encoding("\x00\x01\xf3\x40", "UTF-8-Mobile#SOFTBANK", "UCS-4BE")));
|
||||
|
||||
var_dump(bin2hex(mb_convert_encoding("\x00\x00\x00\x23\x00\x00\x20\xe3", "UTF-8-Mobile#DOCOMO", "UCS-4BE")));
|
||||
var_dump(bin2hex(mb_convert_encoding("\x00\x00\x00\x23\x00\x00\x20\xe3", "UTF-8-Mobile#KDDI", "UCS-4BE")));
|
||||
var_dump(bin2hex(mb_convert_encoding("\x00\x00\x00\x23\x00\x00\x20\xe3", "UTF-8-Mobile#SOFTBANK", "UCS-4BE")));
|
||||
|
||||
var_dump(bin2hex(mb_convert_encoding("\x00\x01\xf1\xe8\x00\x01\xf1\xf3", "UTF-8-Mobile#DOCOMO", "UCS-4BE")));
|
||||
var_dump(bin2hex(mb_convert_encoding("\x00\x01\xf1\xe8\x00\x01\xf1\xf3", "UTF-8-Mobile#KDDI", "UCS-4BE")));
|
||||
var_dump(bin2hex(mb_convert_encoding("\x00\x01\xf1\xe8\x00\x01\xf1\xf3", "UTF-8-Mobile#SOFTBANK", "UCS-4BE")));
|
||||
|
||||
echo "Unicode to ISO-2022-JP-MOBILE#KDDI\n";
|
||||
var_dump(bin2hex(mb_convert_encoding("\x00\x00\x26\x00", "ISO-2022-JP-MOBILE#KDDI", "UCS-4BE")));
|
||||
|
||||
echo "ISO-2022-JP-MOBILE#KDDI to Unicode\n";
|
||||
var_dump(bin2hex(mb_convert_encoding("\x1b\x24\x42\x75\x41\x1b\x28\x42", "UCS-4BE", "ISO-2022-JP-MOBILE#KDDI")));
|
||||
|
||||
echo "SJIS-Mobile to Unicode (Google) \n";
|
||||
var_dump(bin2hex(mb_convert_encoding("\xf9\x86", "UCS-4BE", "SJIS-Mobile#DOCOMO")));
|
||||
var_dump(bin2hex(mb_convert_encoding("\xf7\x48", "UCS-4BE", "SJIS-Mobile#KDDI")));
|
||||
var_dump(bin2hex(mb_convert_encoding("\xfb\xd8", "UCS-4BE", "SJIS-Mobile#SOFTBANK")));
|
||||
|
||||
echo "Unicode (Google) to SJIS-Mobile\n";
|
||||
var_dump(bin2hex(mb_convert_encoding("\x00\x0f\xe8\x2d", "SJIS-Mobile#DOCOMO", "UCS-4BE")));
|
||||
var_dump(bin2hex(mb_convert_encoding("\x00\x0f\xe8\x2d", "SJIS-Mobile#KDDI", "UCS-4BE")));
|
||||
var_dump(bin2hex(mb_convert_encoding("\x00\x0f\xee\x70", "SJIS-Mobile#SOFTBANK", "UCS-4BE")));
|
||||
|
||||
echo "UTF-8-Mobile to Unicode (Google) \n";
|
||||
var_dump(bin2hex(mb_convert_encoding("\xee\x9b\xa1", "UCS-4BE", "UTF-8-Mobile#DOCOMO")));
|
||||
var_dump(bin2hex(mb_convert_encoding("\xef\x81\x88", "UCS-4BE", "UTF-8-Mobile#KDDI")));
|
||||
var_dump(bin2hex(mb_convert_encoding("\xee\x94\xb8", "UCS-4BE", "UTF-8-Mobile#SOFTBANK")));//
|
||||
|
||||
echo "Unicode (Google) to UTF-8-Mobile\n";
|
||||
var_dump(bin2hex(mb_convert_encoding("\x00\x0f\xe8\x2d", "UTF-8-Mobile#DOCOMO", "UCS-4BE")));
|
||||
var_dump(bin2hex(mb_convert_encoding("\x00\x0f\xe8\x2d", "UTF-8-Mobile#KDDI", "UCS-4BE")));
|
||||
var_dump(bin2hex(mb_convert_encoding("\x00\x0f\xee\x70", "UTF-8-Mobile#SOFTBANK", "UCS-4BE")));//
|
||||
|
||||
?>
|
||||
--EXPECT--
|
||||
SJIS-Mobile to Unicode
|
||||
string(8) "00002600"
|
||||
string(8) "00002600"
|
||||
string(8) "00002600"
|
||||
string(8) "0001f340"
|
||||
string(8) "0001f340"
|
||||
string(8) "0001f340"
|
||||
string(16) "00000023000020e3"
|
||||
string(16) "00000023000020e3"
|
||||
string(16) "00000023000020e3"
|
||||
string(16) "0001f1e80001f1f3"
|
||||
string(16) "0001f1e80001f1f3"
|
||||
Unicode to SJIS-Mobile
|
||||
string(4) "f89f"
|
||||
string(4) "f660"
|
||||
string(4) "f98b"
|
||||
string(4) "f9e6"
|
||||
string(4) "f6ec"
|
||||
string(4) "f750"
|
||||
string(4) "f985"
|
||||
string(4) "f489"
|
||||
string(4) "f7b0"
|
||||
string(4) "3f3f"
|
||||
string(4) "f3d2"
|
||||
string(4) "fbb3"
|
||||
UTF-8-Mobile to Unicode
|
||||
string(8) "00002600"
|
||||
string(8) "00002600"
|
||||
string(8) "00002600"
|
||||
string(8) "0001f340"
|
||||
string(8) "0001f340"
|
||||
string(8) "0001f340"
|
||||
string(16) "00000023000020e3"
|
||||
string(16) "00000023000020e3"
|
||||
string(16) "00000023000020e3"
|
||||
string(16) "0001f1e80001f1f3"
|
||||
string(16) "0001f1e80001f1f3"
|
||||
Unicode to UTF8-Mobile
|
||||
string(6) "ee98be"
|
||||
string(6) "eebda0"
|
||||
string(6) "ee818a"
|
||||
string(6) "ee9d81"
|
||||
string(6) "eebfac"
|
||||
string(6) "ee8490"
|
||||
string(6) "ee9ba0"
|
||||
string(6) "eeb689"
|
||||
string(6) "ee8890"
|
||||
string(16) "f09f87a8f09f87b3"
|
||||
string(6) "eeb392"
|
||||
string(6) "ee9493"
|
||||
Unicode to ISO-2022-JP-MOBILE#KDDI
|
||||
string(16) "1b244275411b2842"
|
||||
ISO-2022-JP-MOBILE#KDDI to Unicode
|
||||
string(8) "00002600"
|
||||
SJIS-Mobile to Unicode (Google)
|
||||
string(8) "000fe82d"
|
||||
string(8) "000fe82d"
|
||||
string(8) "000fee70"
|
||||
Unicode (Google) to SJIS-Mobile
|
||||
string(4) "f986"
|
||||
string(4) "f748"
|
||||
string(4) "fbd8"
|
||||
UTF-8-Mobile to Unicode (Google)
|
||||
string(8) "000fe82d"
|
||||
string(8) "000fe82d"
|
||||
string(8) "000fee70"
|
||||
Unicode (Google) to UTF-8-Mobile
|
||||
string(6) "ee9ba1"
|
||||
string(6) "ef8188"
|
||||
string(6) "ee94b8"
|
||||
@@ -530,7 +530,7 @@ static PHP_GINIT_FUNCTION(mysql)
|
||||
/* }}} */
|
||||
|
||||
#ifdef MYSQL_USE_MYSQLND
|
||||
static MYSQLND *mysql_convert_zv_to_mysqlnd(zval *zv TSRMLS_DC)
|
||||
static MYSQLND * mysql_convert_zv_to_mysqlnd(zval * zv TSRMLS_DC)
|
||||
{
|
||||
php_mysql_conn *mysql;
|
||||
|
||||
@@ -548,7 +548,7 @@ static MYSQLND *mysql_convert_zv_to_mysqlnd(zval *zv TSRMLS_DC)
|
||||
return mysql->conn;
|
||||
}
|
||||
|
||||
static mysqlnd_api_extension_t mysqlnd_api_ext = {
|
||||
static MYSQLND_REVERSE_API mysql_reverse_api = {
|
||||
&mysql_module_entry,
|
||||
mysql_convert_zv_to_mysqlnd
|
||||
};
|
||||
@@ -583,7 +583,7 @@ ZEND_MODULE_STARTUP_D(mysql)
|
||||
#endif
|
||||
|
||||
#ifdef MYSQL_USE_MYSQLND
|
||||
mysqlnd_register_api_extension(&mysqlnd_api_ext);
|
||||
mysqlnd_reverse_api_register_api(&mysql_reverse_api TSRMLS_CC);
|
||||
#endif
|
||||
|
||||
return SUCCESS;
|
||||
|
||||
+7
-7
@@ -528,24 +528,24 @@ PHP_MYSQLI_EXPORT(zend_object_value) mysqli_objects_new(zend_class_entry *class_
|
||||
/* }}} */
|
||||
|
||||
#ifdef MYSQLI_USE_MYSQLND
|
||||
static MYSQLND *mysqli_convert_zv_to_mysqlnd(zval *zv TSRMLS_DC)
|
||||
static MYSQLND *mysqli_convert_zv_to_mysqlnd(zval * zv TSRMLS_DC)
|
||||
{
|
||||
if (Z_TYPE_P(zv) == IS_OBJECT && Z_OBJCE_P(zv) == mysqli_link_class_entry) {
|
||||
MY_MYSQL *mysql;
|
||||
MYSQLI_RESOURCE *my_res;
|
||||
mysqli_object *intern = (mysqli_object *)zend_object_store_get_object(zv TSRMLS_CC);
|
||||
MY_MYSQL * mysql;
|
||||
MYSQLI_RESOURCE * my_res;
|
||||
mysqli_object * intern = (mysqli_object *)zend_object_store_get_object(zv TSRMLS_CC);
|
||||
if (!(my_res = (MYSQLI_RESOURCE *)intern->ptr)) {
|
||||
/* We know that we have a mysqli object, so this failure should be emitted */
|
||||
php_error_docref(NULL TSRMLS_CC, E_WARNING, "Couldn't fetch %s", intern->zo.ce->name);
|
||||
return NULL;
|
||||
}
|
||||
mysql = ((MY_MYSQL *)my_res->ptr)->mysql;
|
||||
mysql = (MY_MYSQL *)(my_res->ptr);
|
||||
return mysql ? mysql->mysql : NULL;
|
||||
}
|
||||
return NULL;
|
||||
}
|
||||
|
||||
static mysqlnd_api_extension_t mysqli_api_ext = {
|
||||
static MYSQLND_REVERSE_API mysqli_reverse_api = {
|
||||
&mysqli_module_entry,
|
||||
mysqli_convert_zv_to_mysqlnd
|
||||
};
|
||||
@@ -839,7 +839,7 @@ PHP_MINIT_FUNCTION(mysqli)
|
||||
|
||||
|
||||
#ifdef MYSQLI_USE_MYSQLND
|
||||
mysqlnd_register_api_extension(&mysqli_api_ext);
|
||||
mysqlnd_reverse_api_register_api(&mysqli_reverse_api TSRMLS_CC);
|
||||
#endif
|
||||
|
||||
return SUCCESS;
|
||||
|
||||
@@ -1057,7 +1057,12 @@ static void php_add_field_properties(zval *value, const MYSQL_FIELD *field TSRML
|
||||
add_property_string(value, "orgtable",(field->org_table ? field->org_table : ""), 1);
|
||||
add_property_string(value, "def",(field->def ? field->def : ""), 1);
|
||||
add_property_string(value, "db",(field->db ? field->db : ""), 1);
|
||||
add_property_string(value, "catalog",(field->catalog ? field->catalog : ""), 1);
|
||||
|
||||
/* FIXME: manually set the catalog to "def" due to bug in
|
||||
* libmysqlclient which does not initialize field->catalog
|
||||
* and in addition, the catalog is always be "def"
|
||||
*/
|
||||
add_property_string(value, "catalog", "def", 1);
|
||||
|
||||
add_property_long(value, "max_length", field->max_length);
|
||||
add_property_long(value, "length", field->length);
|
||||
|
||||
@@ -251,6 +251,36 @@ MYSQLI_MAP_PROPERTY_FUNC_STRING(link_sqlstate_read, mysql_sqlstate, MYSQLI_GET_M
|
||||
MYSQLI_MAP_PROPERTY_FUNC_LONG(link_thread_id_read, mysql_thread_id, MYSQLI_GET_MYSQL(MYSQLI_STATUS_VALID), ulong, "%lu")
|
||||
MYSQLI_MAP_PROPERTY_FUNC_LONG(link_warning_count_read, mysql_warning_count, MYSQLI_GET_MYSQL(MYSQLI_STATUS_VALID), ulong, "%lu")
|
||||
|
||||
/* {{{ property link_stat_read */
|
||||
static int link_stat_read(mysqli_object *obj, zval **retval TSRMLS_DC)\
|
||||
{\
|
||||
MY_MYSQL *mysql;
|
||||
|
||||
MAKE_STD_ZVAL(*retval);
|
||||
ZVAL_NULL(*retval);
|
||||
|
||||
CHECK_STATUS(MYSQLI_STATUS_INITIALIZED);
|
||||
|
||||
mysql = (MY_MYSQL *)((MYSQLI_RESOURCE *)(obj->ptr))->ptr;
|
||||
|
||||
if (mysql) {
|
||||
char * stat_msg;
|
||||
#if defined(MYSQLI_USE_MYSQLND)
|
||||
uint stat_msg_len;
|
||||
if (mysqlnd_stat(mysql->mysql, &stat_msg, &stat_msg_len) == PASS) {
|
||||
ZVAL_STRINGL(*retval, stat_msg, stat_msg_len, 0);
|
||||
}
|
||||
#else
|
||||
if ((stat_msg = (char *) mysql_stat(mysql->mysql))) {
|
||||
ZVAL_STRING(*retval, stat_msg, 1);
|
||||
}
|
||||
#endif
|
||||
}
|
||||
return SUCCESS;
|
||||
}
|
||||
/* }}} */
|
||||
|
||||
|
||||
/* result properties */
|
||||
|
||||
/* {{{ property result_type_read */
|
||||
@@ -424,6 +454,7 @@ const mysqli_property_entry mysqli_link_property_entries[] = {
|
||||
{"insert_id", sizeof("insert_id") - 1, link_insert_id_read, NULL},
|
||||
{"server_info", sizeof("server_info") - 1, link_server_info_read, NULL},
|
||||
{"server_version", sizeof("server_version") - 1, link_server_version_read, NULL},
|
||||
{"stat", sizeof("stat") - 1, link_stat_read, NULL},
|
||||
{"sqlstate", sizeof("sqlstate") - 1, link_sqlstate_read, NULL},
|
||||
{"protocol_version",sizeof("protocol_version") - 1, link_protocol_version_read, NULL},
|
||||
{"thread_id", sizeof("thread_id") - 1, link_thread_id_read, NULL},
|
||||
@@ -447,6 +478,7 @@ const zend_property_info mysqli_link_property_info_entries[] = {
|
||||
{ZEND_ACC_PUBLIC, "insert_id", sizeof("insert_id") - 1, -1, 0, NULL, 0, NULL},
|
||||
{ZEND_ACC_PUBLIC, "server_info", sizeof("server_info") - 1, -1, 0, NULL, 0, NULL},
|
||||
{ZEND_ACC_PUBLIC, "server_version", sizeof("server_version") - 1, -1, 0, NULL, 0, NULL},
|
||||
{ZEND_ACC_PUBLIC, "stat", sizeof("stat") - 1, -1, 0, NULL, 0, NULL},
|
||||
{ZEND_ACC_PUBLIC, "sqlstate", sizeof("sqlstate") - 1, -1, 0, NULL, 0, NULL},
|
||||
{ZEND_ACC_PUBLIC, "protocol_version", sizeof("protocol_version")-1, -1, 0, NULL, 0, NULL},
|
||||
{ZEND_ACC_PUBLIC, "thread_id", sizeof("thread_id") - 1, -1, 0, NULL, 0, NULL},
|
||||
|
||||
@@ -92,6 +92,8 @@ object(mysqli)#%d (%d) {
|
||||
%unicode|string%(%d) "%s"
|
||||
[%u|b%"server_version"]=>
|
||||
int(%d)
|
||||
[%u|b%"stat"]=>
|
||||
string(%d) "Uptime: %d Threads: %d Questions: %d Slow queries: %d Opens: %d Flush tables: %d Open tables: %d Queries per second avg: %d.%d"
|
||||
[%u|b%"sqlstate"]=>
|
||||
%unicode|string%(5) "00000"
|
||||
[%u|b%"protocol_version"]=>
|
||||
@@ -130,6 +132,8 @@ object(mysqli)#%d (%d) {
|
||||
NULL
|
||||
[%u|b%"server_version"]=>
|
||||
NULL
|
||||
[%u|b%"stat"]=>
|
||||
NULL
|
||||
[%u|b%"sqlstate"]=>
|
||||
NULL
|
||||
[%u|b%"protocol_version"]=>
|
||||
|
||||
@@ -0,0 +1,20 @@
|
||||
--TEST--
|
||||
Bug #55859 mysqli->stat property access gives error
|
||||
--SKIPIF--
|
||||
<?php
|
||||
require_once('skipif.inc');
|
||||
require_once('skipifconnectfailure.inc');
|
||||
?>
|
||||
--FILE--
|
||||
<?php
|
||||
require_once("connect.inc");
|
||||
|
||||
if (!$link = my_mysqli_connect($host, $user, $passwd, $db, $port, $socket)) {
|
||||
printf("[001] Connect failed, [%d] %s\n", mysqli_connect_errno(), mysqli_connect_error());
|
||||
}
|
||||
var_dump(mysqli_stat($link) === $link->stat);
|
||||
echo "done!";
|
||||
?>
|
||||
--EXPECT--
|
||||
bool(true)
|
||||
done!
|
||||
@@ -151,6 +151,11 @@ require_once('skipifconnectfailure.inc');
|
||||
$mysqli->sqlstate, gettype($mysqli->sqlstate),
|
||||
mysqli_sqlstate($link), gettype(mysqli_sqlstate($link)));
|
||||
|
||||
assert(mysqli_stat($link) === $mysqli->stat);
|
||||
printf("mysqli->stat = '%s'/%s ('%s'/%s)\n",
|
||||
$mysqli->stat, gettype($mysqli->stat),
|
||||
mysqli_stat($link), gettype(mysqli_stat($link)));
|
||||
|
||||
assert(mysqli_get_host_info($link) === $mysqli->host_info);
|
||||
printf("mysqli->host_info = '%s'/%s ('%s'/%s)\n",
|
||||
$mysqli->host_info, gettype($mysqli->host_info),
|
||||
@@ -236,6 +241,7 @@ protocol_version
|
||||
server_info
|
||||
server_version
|
||||
sqlstate
|
||||
stat
|
||||
thread_id
|
||||
warning_count
|
||||
|
||||
@@ -254,6 +260,7 @@ info
|
||||
insert_id
|
||||
server_info
|
||||
server_version
|
||||
stat
|
||||
sqlstate
|
||||
protocol_version
|
||||
thread_id
|
||||
@@ -269,6 +276,7 @@ mysqli->error_list = 'Array'/array ('Array'/array)
|
||||
mysqli->field_count = '0'/integer ('0'/integer)
|
||||
mysqli->insert_id = '0'/integer ('0'/integer)
|
||||
mysqli->sqlstate = '00000'/%unicode|string% ('00000'/%unicode|string%)
|
||||
mysqli->stat = 'Uptime: %d Threads: %d Questions: %d Slow queries: %d Opens: %d Flush tables: %d Open tables: %d Queries per second avg: %d.%d'/string ('Uptime: %d Threads: %d Questions: %d Slow queries: %d Opens: %d Flush tables: %d Open tables: %d Queries per second avg: %d.%d'/string)
|
||||
mysqli->host_info = '%s'/%unicode|string% ('%s'/%unicode|string%)
|
||||
mysqli->info = ''/NULL (''/%unicode|string%)
|
||||
mysqli->thread_id = '%d'/integer ('%d'/integer)
|
||||
|
||||
@@ -160,6 +160,7 @@ protocol_version = 'NULL'
|
||||
server_info = 'NULL'
|
||||
server_version = 'NULL'
|
||||
sqlstate = 'NULL'
|
||||
stat = 'NULL'
|
||||
thread_id = 'NULL'
|
||||
warning_count = 'NULL'
|
||||
|
||||
@@ -178,6 +179,7 @@ info = 'NULL'
|
||||
insert_id = 'NULL'
|
||||
server_info = 'NULL'
|
||||
server_version = 'NULL'
|
||||
stat = 'NULL'
|
||||
sqlstate = 'NULL'
|
||||
protocol_version = 'NULL'
|
||||
thread_id = 'NULL'
|
||||
@@ -231,6 +233,7 @@ protocol_version = 'NULL'
|
||||
server_info = 'NULL'
|
||||
server_version = 'NULL'
|
||||
sqlstate = 'NULL'
|
||||
stat = 'NULL'
|
||||
thread_id = 'NULL'
|
||||
warning_count = 'NULL'
|
||||
|
||||
@@ -249,6 +252,7 @@ info = 'NULL'
|
||||
insert_id = 'NULL'
|
||||
server_info = 'NULL'
|
||||
server_version = 'NULL'
|
||||
stat = 'NULL'
|
||||
sqlstate = 'NULL'
|
||||
protocol_version = 'NULL'
|
||||
thread_id = 'NULL'
|
||||
|
||||
@@ -1201,6 +1201,14 @@ isStatic: no
|
||||
isDefault: yes
|
||||
Modifiers: 256
|
||||
|
||||
Inspecting property 'stat'
|
||||
isPublic: yes
|
||||
isPrivate: no
|
||||
isProtected: no
|
||||
isStatic: no
|
||||
isDefault: yes
|
||||
Modifiers: 256
|
||||
|
||||
Inspecting property 'thread_id'
|
||||
isPublic: yes
|
||||
isPrivate: no
|
||||
@@ -1232,6 +1240,7 @@ Default property 'protocol_version'
|
||||
Default property 'server_info'
|
||||
Default property 'server_version'
|
||||
Default property 'sqlstate'
|
||||
Default property 'stat'
|
||||
Default property 'thread_id'
|
||||
Default property 'warning_count'
|
||||
done!
|
||||
@@ -120,6 +120,8 @@ object(mysqli)#%d (%d) {
|
||||
%unicode|string%(%d) "%s"
|
||||
[%u|b%"server_version"]=>
|
||||
int(%d)
|
||||
[%u|b%"stat"]=>
|
||||
NULL
|
||||
[%u|b%"sqlstate"]=>
|
||||
%unicode|string%(5) "HY000"
|
||||
[%u|b%"protocol_version"]=>
|
||||
|
||||
@@ -205,6 +205,8 @@ object(mysqli)#%d (%d) {
|
||||
NULL
|
||||
[%u|b%"server_version"]=>
|
||||
NULL
|
||||
[%u|b%"stat"]=>
|
||||
NULL
|
||||
[%u|b%"sqlstate"]=>
|
||||
NULL
|
||||
[%u|b%"protocol_version"]=>
|
||||
|
||||
@@ -14,6 +14,7 @@ if (PHP_MYSQLND != "no") {
|
||||
"mysqlnd_charset.c " +
|
||||
"mysqlnd_debug.c " +
|
||||
"mysqlnd_loaddata.c " +
|
||||
"mysqlnd_reverse_api.c " +
|
||||
"mysqlnd_net.c " +
|
||||
"mysqlnd_plugin.c " +
|
||||
"mysqlnd_ps.c " +
|
||||
|
||||
@@ -19,7 +19,7 @@ dnl If some extension uses mysqlnd it will get compiled in PHP core
|
||||
if test "$PHP_MYSQLND" != "no" || test "$PHP_MYSQLND_ENABLED" = "yes"; then
|
||||
mysqlnd_ps_sources="mysqlnd_ps.c mysqlnd_ps_codec.c"
|
||||
mysqlnd_base_sources="mysqlnd.c mysqlnd_alloc.c mysqlnd_bt.c mysqlnd_charset.c mysqlnd_wireprotocol.c \
|
||||
mysqlnd_loaddata.c mysqlnd_net.c \
|
||||
mysqlnd_loaddata.c mysqlnd_reverse_api.c mysqlnd_net.c \
|
||||
mysqlnd_statistics.c mysqlnd_auth.c \
|
||||
mysqlnd_result.c mysqlnd_result_meta.c mysqlnd_debug.c\
|
||||
mysqlnd_block_alloc.c mysqlnd_plugin.c php_mysqlnd.c"
|
||||
|
||||
+18
-51
@@ -27,6 +27,7 @@
|
||||
#include "mysqlnd_statistics.h"
|
||||
#include "mysqlnd_charset.h"
|
||||
#include "mysqlnd_debug.h"
|
||||
#include "mysqlnd_reverse_api.h"
|
||||
|
||||
/*
|
||||
TODO :
|
||||
@@ -68,8 +69,6 @@ static struct st_mysqlnd_conn_methods *mysqlnd_conn_methods;
|
||||
|
||||
static struct st_mysqlnd_plugin_core mysqlnd_plugin_core;
|
||||
|
||||
static HashTable mysqlnd_api_ext_ht;
|
||||
|
||||
/* {{{ mysqlnd_error_list_pdtor */
|
||||
static void
|
||||
mysqlnd_error_list_pdtor(void * pDest)
|
||||
@@ -93,7 +92,7 @@ PHPAPI void mysqlnd_library_end(TSRMLS_D)
|
||||
mysqlnd_stats_end(mysqlnd_global_stats);
|
||||
mysqlnd_global_stats = NULL;
|
||||
mysqlnd_library_initted = FALSE;
|
||||
zend_hash_destroy(&mysqlnd_api_ext_ht);
|
||||
mysqlnd_reverse_api_end(TSRMLS_C);
|
||||
}
|
||||
}
|
||||
/* }}} */
|
||||
@@ -219,7 +218,7 @@ MYSQLND_METHOD_PRIVATE(mysqlnd_conn, dtor)(MYSQLND * conn TSRMLS_DC)
|
||||
conn->m->free_options(conn TSRMLS_CC);
|
||||
|
||||
if (conn->net) {
|
||||
mysqlnd_net_free(conn->net TSRMLS_CC);
|
||||
mysqlnd_net_free(conn->net, conn->stats, &conn->error_info TSRMLS_CC);
|
||||
conn->net = NULL;
|
||||
}
|
||||
|
||||
@@ -389,6 +388,7 @@ MYSQLND_METHOD(mysqlnd_conn, simple_command)(MYSQLND * conn, enum php_mysqlnd_se
|
||||
DBG_ERR_FMT("Error while sending %s packet", mysqlnd_command_to_text[command]);
|
||||
php_error(E_WARNING, "Error while sending %s packet. PID=%d", mysqlnd_command_to_text[command], getpid());
|
||||
}
|
||||
CONN_SET_STATE(conn, CONN_QUIT_SENT);
|
||||
DBG_ERR("Server is gone");
|
||||
ret = FAIL;
|
||||
} else if (ok_packet != PROT_LAST) {
|
||||
@@ -644,8 +644,7 @@ MYSQLND_METHOD(mysqlnd_conn, connect)(MYSQLND * conn,
|
||||
unsigned int mysql_flags
|
||||
TSRMLS_DC)
|
||||
{
|
||||
char *errstr = NULL;
|
||||
int errcode = 0, host_len;
|
||||
size_t host_len;
|
||||
zend_bool unix_socket = FALSE;
|
||||
zend_bool named_pipe = FALSE;
|
||||
zend_bool reconnect = FALSE;
|
||||
@@ -756,7 +755,9 @@ MYSQLND_METHOD(mysqlnd_conn, connect)(MYSQLND * conn,
|
||||
goto err; /* OOM */
|
||||
}
|
||||
|
||||
if (FAIL == conn->net->m.connect(conn->net, conn->scheme, conn->scheme_len, conn->persistent, &errstr, &errcode TSRMLS_CC)) {
|
||||
if (FAIL == conn->net->m.connect_ex(conn->net, conn->scheme, conn->scheme_len, conn->persistent,
|
||||
conn->stats, &conn->error_info TSRMLS_CC))
|
||||
{
|
||||
goto err;
|
||||
}
|
||||
|
||||
@@ -952,13 +953,13 @@ MYSQLND_METHOD(mysqlnd_conn, connect)(MYSQLND * conn,
|
||||
err:
|
||||
PACKET_FREE(greet_packet);
|
||||
|
||||
if (errstr) {
|
||||
DBG_ERR_FMT("[%u] %.128s (trying to connect via %s)", errcode, errstr, conn->scheme);
|
||||
SET_CLIENT_ERROR(conn->error_info, errcode? errcode:CR_CONNECTION_ERROR, UNKNOWN_SQLSTATE, errstr);
|
||||
php_error_docref(NULL TSRMLS_CC, E_WARNING, "[%u] %.128s (trying to connect via %s)", errcode, errstr, conn->scheme);
|
||||
/* no mnd_ since we don't allocate it */
|
||||
efree(errstr);
|
||||
DBG_ERR_FMT("[%u] %.128s (trying to connect via %s)", conn->error_info.error_no, conn->error_info.error, conn->scheme);
|
||||
if (!conn->error_info.error_no) {
|
||||
SET_CLIENT_ERROR(conn->error_info, CR_CONNECTION_ERROR, UNKNOWN_SQLSTATE, conn->error_info.error? conn->error_info.error:"Unknown error");
|
||||
php_error_docref(NULL TSRMLS_CC, E_WARNING, "[%u] %.128s (trying to connect via %s)",
|
||||
conn->error_info.error_no, conn->error_info.error, conn->scheme);
|
||||
}
|
||||
|
||||
conn->m->free_contents(conn TSRMLS_CC);
|
||||
MYSQLND_INC_CONN_STATISTIC(conn->stats, STAT_CONNECT_FAILURE);
|
||||
|
||||
@@ -1161,7 +1162,7 @@ static int mysqlnd_stream_array_from_fd_set(MYSQLND **conn_array, fd_set *fds TS
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
/* }}} */
|
||||
|
||||
#ifndef PHP_WIN32
|
||||
#define php_select(m, r, w, e, t) select(m, r, w, e, t)
|
||||
@@ -1680,7 +1681,7 @@ MYSQLND_METHOD(mysqlnd_conn, close)(MYSQLND * conn, enum_connection_close_type c
|
||||
DBG_ENTER("mysqlnd_conn::close");
|
||||
DBG_INF_FMT("conn=%llu", conn->thread_id);
|
||||
|
||||
if (conn->state >= CONN_READY) {
|
||||
if (CONN_GET_STATE(conn) >= CONN_READY) {
|
||||
MYSQLND_INC_CONN_STATISTIC(conn->stats, statistic);
|
||||
MYSQLND_DEC_CONN_STATISTIC(conn->stats, STAT_OPENED_CONNECTIONS);
|
||||
if (conn->persistent) {
|
||||
@@ -2483,7 +2484,7 @@ MYSQLND_METHOD(mysqlnd_conn, init)(MYSQLND * conn TSRMLS_DC)
|
||||
mysqlnd_stats_init(&conn->stats, STAT_LAST);
|
||||
SET_ERROR_AFF_ROWS(conn);
|
||||
|
||||
conn->net = mysqlnd_net_init(conn->persistent TSRMLS_CC);
|
||||
conn->net = mysqlnd_net_init(conn->persistent, conn->stats, &conn->error_info TSRMLS_CC);
|
||||
conn->protocol = mysqlnd_protocol_init(conn->persistent TSRMLS_CC);
|
||||
|
||||
DBG_RETURN(conn->stats && conn->net && conn->protocol? PASS:FAIL);
|
||||
@@ -2545,45 +2546,11 @@ PHPAPI void mysqlnd_library_init(TSRMLS_D)
|
||||
mysqlnd_debug_trace_plugin_register(TSRMLS_C);
|
||||
mysqlnd_register_builtin_authentication_plugins(TSRMLS_C);
|
||||
|
||||
zend_hash_init(&mysqlnd_api_ext_ht, 3, NULL, NULL, 1);
|
||||
mysqlnd_reverse_api_init(TSRMLS_C);
|
||||
}
|
||||
}
|
||||
/* }}} */
|
||||
|
||||
/* {{{ myslqnd_get_api_extensions */
|
||||
PHPAPI HashTable *mysqlnd_get_api_extensions()
|
||||
{
|
||||
return &mysqlnd_api_ext_ht;
|
||||
}
|
||||
/* }}} */
|
||||
|
||||
/* {{{ mysqlnd_register_api_extension */
|
||||
PHPAPI void mysqlnd_register_api_extension(mysqlnd_api_extension_t *apiext)
|
||||
{
|
||||
zend_hash_add(&mysqlnd_api_ext_ht, apiext->module->name, strlen(apiext->module->name)+1, &apiext, sizeof(mysqlnd_api_extension_t), NULL);
|
||||
}
|
||||
/* }}} */
|
||||
|
||||
/* {{{ zval_to_mysqlnd */
|
||||
PHPAPI MYSQLND* zval_to_mysqlnd(zval *zv TSRMLS_DC)
|
||||
{
|
||||
MYSQLND* retval;
|
||||
mysqlnd_api_extension_t **elem;
|
||||
|
||||
for (zend_hash_internal_pointer_reset(&mysqlnd_api_ext_ht);
|
||||
zend_hash_get_current_data(&mysqlnd_api_ext_ht, (void **)&elem) == SUCCESS;
|
||||
zend_hash_move_forward(&mysqlnd_api_ext_ht)) {
|
||||
if ((*elem)->conversion_cb) {
|
||||
retval = (*elem)->conversion_cb(zv TSRMLS_CC);
|
||||
if (retval) {
|
||||
return retval;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return NULL;
|
||||
}
|
||||
/* }}} */
|
||||
|
||||
/* {{{ mysqlnd_conn_get_methods */
|
||||
PHPAPI struct st_mysqlnd_conn_methods * mysqlnd_conn_get_methods()
|
||||
|
||||
@@ -90,6 +90,9 @@ PHPAPI void ** _mysqlnd_plugin_get_plugin_stmt_data(const MYSQLND_STMT * stmt, u
|
||||
PHPAPI void ** _mysqlnd_plugin_get_plugin_protocol_data(const MYSQLND_PROTOCOL * protocol, unsigned int plugin_id TSRMLS_DC);
|
||||
#define mysqlnd_plugin_get_plugin_protocol_data(p, p_id) _mysqlnd_plugin_get_plugin_protocol_data((p), (p_id) TSRMLS_CC)
|
||||
|
||||
PHPAPI void ** _mysqlnd_plugin_get_plugin_net_data(const MYSQLND_NET * net, unsigned int plugin_id TSRMLS_DC);
|
||||
#define mysqlnd_plugin_get_plugin_net_data(n, p_id) _mysqlnd_plugin_get_plugin_net_data((n), (p_id) TSRMLS_CC)
|
||||
|
||||
|
||||
PHPAPI struct st_mysqlnd_conn_methods * mysqlnd_conn_get_methods();
|
||||
PHPAPI void mysqlnd_conn_set_methods(struct st_mysqlnd_conn_methods *methods);
|
||||
@@ -310,15 +313,6 @@ PHPAPI ZEND_EXTERN_MODULE_GLOBALS(mysqlnd)
|
||||
|
||||
PHPAPI void mysqlnd_minfo_print_hash(zval *values);
|
||||
|
||||
typedef struct {
|
||||
zend_module_entry *module;
|
||||
MYSQLND *(*conversion_cb)(zval *zv TSRMLS_DC);
|
||||
} mysqlnd_api_extension_t;
|
||||
|
||||
PHPAPI HashTable *mysqlnd_get_api_extensions();
|
||||
PHPAPI void mysqlnd_register_api_extension(mysqlnd_api_extension_t *apiext);
|
||||
PHPAPI MYSQLND* zval_to_mysqlnd(zval *zv TSRMLS_DC);
|
||||
|
||||
#endif /* MYSQLND_H */
|
||||
|
||||
|
||||
|
||||
@@ -105,8 +105,6 @@ mysqlnd_auth_handshake(MYSQLND * conn,
|
||||
auth_packet->auth_plugin_name = auth_protocol;
|
||||
|
||||
if (!PACKET_WRITE(auth_packet, conn)) {
|
||||
CONN_SET_STATE(conn, CONN_QUIT_SENT);
|
||||
SET_CLIENT_ERROR(conn->error_info, CR_SERVER_GONE_ERROR, UNKNOWN_SQLSTATE, mysqlnd_server_gone);
|
||||
goto end;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -21,6 +21,7 @@
|
||||
/* $Id: mysqlnd_debug.c 309303 2011-03-16 12:42:59Z andrey $ */
|
||||
|
||||
#include "php.h"
|
||||
#include "Zend/zend_builtin_functions.h"
|
||||
|
||||
/* Follows code borrowed from zend_builtin_functions.c because the functions there are static */
|
||||
|
||||
|
||||
@@ -495,8 +495,8 @@ const MYSQLND_CHARSET mysqlnd_charsets[] =
|
||||
{ 42, "latin7", "latin7_general_cs", 1, 1, "", NULL, NULL},
|
||||
{ 43, "macce", "macce_bin", 1, 1, "", NULL, NULL},
|
||||
{ 44, "cp1250", "cp1250_croatian_ci", 1, 1, "", NULL, NULL},
|
||||
{ 45, UTF8_MB4, UTF8_MB4"_general_ci", 1, 3, "UTF-8 Unicode", mysqlnd_mbcharlen_utf8, check_mb_utf8_valid},
|
||||
{ 46, UTF8_MB4, UTF8_MB4"_bin", 1, 3, "UTF-8 Unicode", mysqlnd_mbcharlen_utf8, check_mb_utf8_valid},
|
||||
{ 45, UTF8_MB4, UTF8_MB4"_general_ci", 1, 4, "UTF-8 Unicode", mysqlnd_mbcharlen_utf8, check_mb_utf8_valid},
|
||||
{ 46, UTF8_MB4, UTF8_MB4"_bin", 1, 4, "UTF-8 Unicode", mysqlnd_mbcharlen_utf8, check_mb_utf8_valid},
|
||||
{ 47, "latin1", "latin1_bin", 1, 1, "", NULL, NULL},
|
||||
{ 48, "latin1", "latin1_general_ci", 1, 1, "", NULL, NULL},
|
||||
{ 49, "latin1", "latin1_general_cs", 1, 1, "", NULL, NULL},
|
||||
|
||||
@@ -162,20 +162,21 @@ mysqlnd_handle_local_infile(MYSQLND *conn, const char *filename, zend_bool *is_w
|
||||
int bufsize;
|
||||
size_t ret;
|
||||
MYSQLND_INFILE infile;
|
||||
MYSQLND_NET * net = conn->net;
|
||||
|
||||
DBG_ENTER("mysqlnd_handle_local_infile");
|
||||
|
||||
if (!(conn->options.flags & CLIENT_LOCAL_FILES)) {
|
||||
php_error_docref(NULL TSRMLS_CC, E_WARNING, "LOAD DATA LOCAL INFILE forbidden");
|
||||
/* write empty packet to server */
|
||||
ret = conn->net->m.send(conn, empty_packet, 0 TSRMLS_CC);
|
||||
ret = net->m.send_ex(net, empty_packet, 0, conn->stats, &conn->error_info TSRMLS_CC);
|
||||
*is_warning = TRUE;
|
||||
goto infile_error;
|
||||
}
|
||||
|
||||
infile = conn->infile;
|
||||
/* allocate buffer for reading data */
|
||||
buf = (zend_uchar *)mnd_ecalloc(1, buflen);
|
||||
buf = (zend_uchar *) mnd_ecalloc(1, buflen);
|
||||
|
||||
*is_warning = FALSE;
|
||||
|
||||
@@ -188,13 +189,13 @@ mysqlnd_handle_local_infile(MYSQLND *conn, const char *filename, zend_bool *is_w
|
||||
tmp_error_no = infile.local_infile_error(info, tmp_buf, sizeof(tmp_buf) TSRMLS_CC);
|
||||
SET_CLIENT_ERROR(conn->error_info, tmp_error_no, UNKNOWN_SQLSTATE, tmp_buf);
|
||||
/* write empty packet to server */
|
||||
ret = conn->net->m.send(conn, empty_packet, 0 TSRMLS_CC);
|
||||
ret = net->m.send_ex(net, empty_packet, 0, conn->stats, &conn->error_info TSRMLS_CC);
|
||||
goto infile_error;
|
||||
}
|
||||
|
||||
/* read data */
|
||||
while ((bufsize = infile.local_infile_read (info, buf + MYSQLND_HEADER_SIZE, buflen - MYSQLND_HEADER_SIZE TSRMLS_CC)) > 0) {
|
||||
if ((ret = conn->net->m.send(conn, buf, bufsize TSRMLS_CC)) == 0) {
|
||||
if ((ret = net->m.send_ex(net, buf, bufsize, conn->stats, &conn->error_info TSRMLS_CC)) == 0) {
|
||||
DBG_ERR_FMT("Error during read : %d %s %s", CR_SERVER_LOST, UNKNOWN_SQLSTATE, lost_conn);
|
||||
SET_CLIENT_ERROR(conn->error_info, CR_SERVER_LOST, UNKNOWN_SQLSTATE, lost_conn);
|
||||
goto infile_error;
|
||||
@@ -202,7 +203,7 @@ mysqlnd_handle_local_infile(MYSQLND *conn, const char *filename, zend_bool *is_w
|
||||
}
|
||||
|
||||
/* send empty packet for eof */
|
||||
if ((ret = conn->net->m.send(conn, empty_packet, 0 TSRMLS_CC)) == 0) {
|
||||
if ((ret = net->m.send_ex(net, empty_packet, 0, conn->stats, &conn->error_info TSRMLS_CC)) == 0) {
|
||||
SET_CLIENT_ERROR(conn->error_info, CR_SERVER_LOST, UNKNOWN_SQLSTATE, lost_conn);
|
||||
goto infile_error;
|
||||
}
|
||||
|
||||
+261
-138
@@ -59,48 +59,88 @@ mysqlnd_set_sock_no_delay(php_stream * stream TSRMLS_DC)
|
||||
/* }}} */
|
||||
|
||||
|
||||
/* {{{ mysqlnd_net::network_read */
|
||||
/* {{{ mysqlnd_net::network_read_ex */
|
||||
static enum_func_status
|
||||
MYSQLND_METHOD(mysqlnd_net, network_read)(MYSQLND * conn, zend_uchar * buffer, size_t count TSRMLS_DC)
|
||||
MYSQLND_METHOD(mysqlnd_net, network_read_ex)(MYSQLND_NET * const net, zend_uchar * const buffer, const size_t count,
|
||||
MYSQLND_STATS * const stats, MYSQLND_ERROR_INFO * const error_info TSRMLS_DC)
|
||||
{
|
||||
enum_func_status return_value = PASS;
|
||||
size_t to_read = count, ret;
|
||||
size_t old_chunk_size = conn->net->stream->chunk_size;
|
||||
DBG_ENTER("mysqlnd_net::network_read");
|
||||
size_t old_chunk_size = net->stream->chunk_size;
|
||||
zend_uchar * p = buffer;
|
||||
|
||||
DBG_ENTER("mysqlnd_net::network_read_ex");
|
||||
DBG_INF_FMT("count="MYSQLND_SZ_T_SPEC, count);
|
||||
conn->net->stream->chunk_size = MIN(to_read, conn->net->options.net_read_buffer_size);
|
||||
|
||||
net->stream->chunk_size = MIN(to_read, net->options.net_read_buffer_size);
|
||||
while (to_read) {
|
||||
if (!(ret = php_stream_read(conn->net->stream, (char *) buffer, to_read))) {
|
||||
if (!(ret = php_stream_read(net->stream, (char *) p, to_read))) {
|
||||
DBG_ERR_FMT("Error while reading header from socket");
|
||||
return_value = FAIL;
|
||||
break;
|
||||
}
|
||||
buffer += ret;
|
||||
p += ret;
|
||||
to_read -= ret;
|
||||
}
|
||||
MYSQLND_INC_CONN_STATISTIC_W_VALUE(conn->stats, STAT_BYTES_RECEIVED, count - to_read);
|
||||
conn->net->stream->chunk_size = old_chunk_size;
|
||||
MYSQLND_INC_CONN_STATISTIC_W_VALUE(stats, STAT_BYTES_RECEIVED, count - to_read);
|
||||
net->stream->chunk_size = old_chunk_size;
|
||||
DBG_RETURN(return_value);
|
||||
}
|
||||
/* }}} */
|
||||
|
||||
|
||||
/* {{{ mysqlnd_net::network_write */
|
||||
/* {{{ mysqlnd_net::network_write_ex */
|
||||
static size_t
|
||||
MYSQLND_METHOD(mysqlnd_net, network_write)(MYSQLND * const conn, const zend_uchar * const buf, size_t count TSRMLS_DC)
|
||||
MYSQLND_METHOD(mysqlnd_net, network_write_ex)(MYSQLND_NET * const net, const zend_uchar * const buffer, const size_t count,
|
||||
MYSQLND_STATS * const stats, MYSQLND_ERROR_INFO * const error_info TSRMLS_DC)
|
||||
{
|
||||
size_t ret;
|
||||
DBG_ENTER("mysqlnd_net::network_write");
|
||||
ret = php_stream_write(conn->net->stream, (char *)buf, count);
|
||||
DBG_ENTER("mysqlnd_net::network_write_ex");
|
||||
ret = php_stream_write(net->stream, (char *)buffer, count);
|
||||
DBG_RETURN(ret);
|
||||
}
|
||||
/* }}} */
|
||||
|
||||
|
||||
|
||||
/* {{{ mysqlnd_net::connect */
|
||||
/* {{{ mysqlnd_net::open_pipe */
|
||||
static enum_func_status
|
||||
MYSQLND_METHOD(mysqlnd_net, connect)(MYSQLND_NET * net, const char * const scheme, size_t scheme_len, zend_bool persistent, char **errstr, int * errcode TSRMLS_DC)
|
||||
MYSQLND_METHOD(mysqlnd_net, open_pipe)(MYSQLND_NET * const net, const char * const scheme, const size_t scheme_len,
|
||||
const zend_bool persistent,
|
||||
MYSQLND_STATS * const conn_stats, MYSQLND_ERROR_INFO * const error_info TSRMLS_DC)
|
||||
{
|
||||
#if PHP_API_VERSION < 20100412
|
||||
unsigned int streams_options = ENFORCE_SAFE_MODE;
|
||||
#else
|
||||
unsigned int streams_options = 0;
|
||||
#endif
|
||||
DBG_ENTER("mysqlnd_net::open_pipe");
|
||||
if (persistent) {
|
||||
streams_options |= STREAM_OPEN_PERSISTENT;
|
||||
}
|
||||
streams_options |= IGNORE_URL;
|
||||
net->stream = php_stream_open_wrapper((char*) scheme + sizeof("pipe://") - 1, "r+", streams_options, NULL);
|
||||
if (!net->stream) {
|
||||
SET_CLIENT_ERROR(*error_info, CR_CONNECTION_ERROR, UNKNOWN_SQLSTATE, "Unknown errror while connecting");
|
||||
DBG_RETURN(FAIL);
|
||||
}
|
||||
/*
|
||||
Streams are not meant for C extensions! Thus we need a hack. Every connected stream will
|
||||
be registered as resource (in EG(regular_list). So far, so good. However, it won't be
|
||||
unregistered yntil the script ends. So, we need to take care of that.
|
||||
*/
|
||||
net->stream->in_free = 1;
|
||||
zend_hash_index_del(&EG(regular_list), net->stream->rsrc_id);
|
||||
net->stream->in_free = 0;
|
||||
|
||||
DBG_RETURN(PASS);
|
||||
}
|
||||
/* }}} */
|
||||
|
||||
|
||||
/* {{{ mysqlnd_net::open_tcp_or_unix */
|
||||
static enum_func_status
|
||||
MYSQLND_METHOD(mysqlnd_net, open_tcp_or_unix)(MYSQLND_NET * const net, const char * const scheme, const size_t scheme_len,
|
||||
const zend_bool persistent,
|
||||
MYSQLND_STATS * const conn_stats, MYSQLND_ERROR_INFO * const error_info TSRMLS_DC)
|
||||
{
|
||||
#if PHP_API_VERSION < 20100412
|
||||
unsigned int streams_options = ENFORCE_SAFE_MODE;
|
||||
@@ -110,52 +150,39 @@ MYSQLND_METHOD(mysqlnd_net, connect)(MYSQLND_NET * net, const char * const schem
|
||||
unsigned int streams_flags = STREAM_XPORT_CLIENT | STREAM_XPORT_CONNECT;
|
||||
char * hashed_details = NULL;
|
||||
int hashed_details_len = 0;
|
||||
char * errstr = NULL;
|
||||
int errcode = 0;
|
||||
struct timeval tv;
|
||||
DBG_ENTER("mysqlnd_net::connect");
|
||||
|
||||
net->packet_no = net->compressed_envelope_packet_no = 0;
|
||||
DBG_ENTER("mysqlnd_net::open_tcp_or_unix");
|
||||
|
||||
if (net->stream) {
|
||||
/* close before opening a new one */
|
||||
DBG_INF_FMT("Freeing stream. abstract=%p", net->stream->abstract);
|
||||
if (net->persistent) {
|
||||
php_stream_free(net->stream, PHP_STREAM_FREE_CLOSE_PERSISTENT | PHP_STREAM_FREE_RSRC_DTOR);
|
||||
} else {
|
||||
php_stream_free(net->stream, PHP_STREAM_FREE_CLOSE);
|
||||
}
|
||||
net->stream = NULL;
|
||||
if (persistent) {
|
||||
hashed_details_len = mnd_sprintf(&hashed_details, 0, "%p", net);
|
||||
DBG_INF_FMT("hashed_details=%s", hashed_details);
|
||||
}
|
||||
|
||||
if (scheme_len > (sizeof("pipe://") - 1) && !memcmp(scheme, "pipe://", sizeof("pipe://") - 1)) {
|
||||
if (persistent) {
|
||||
streams_options |= STREAM_OPEN_PERSISTENT;
|
||||
}
|
||||
streams_options |= IGNORE_URL;
|
||||
net->stream = php_stream_open_wrapper((char*) scheme + sizeof("pipe://") - 1, "r+", streams_options, NULL);
|
||||
} else {
|
||||
if (persistent) {
|
||||
hashed_details_len = mnd_sprintf(&hashed_details, 0, "%p", net);
|
||||
DBG_INF_FMT("hashed_details=%s", hashed_details);
|
||||
}
|
||||
|
||||
if (net->options.timeout_connect) {
|
||||
tv.tv_sec = net->options.timeout_connect;
|
||||
tv.tv_usec = 0;
|
||||
}
|
||||
|
||||
DBG_INF_FMT("calling php_stream_xport_create");
|
||||
net->stream = php_stream_xport_create(scheme, scheme_len, streams_options, streams_flags,
|
||||
hashed_details, (net->options.timeout_connect) ? &tv : NULL,
|
||||
NULL /*ctx*/, errstr, errcode);
|
||||
if (net->options.timeout_connect) {
|
||||
tv.tv_sec = net->options.timeout_connect;
|
||||
tv.tv_usec = 0;
|
||||
}
|
||||
if (*errstr || !net->stream) {
|
||||
|
||||
DBG_INF_FMT("calling php_stream_xport_create");
|
||||
net->stream = php_stream_xport_create(scheme, scheme_len, streams_options, streams_flags,
|
||||
hashed_details, (net->options.timeout_connect) ? &tv : NULL,
|
||||
NULL /*ctx*/, &errstr, &errcode);
|
||||
if (errstr || !net->stream) {
|
||||
DBG_ERR("Error");
|
||||
if (hashed_details) {
|
||||
mnd_sprintf_free(hashed_details);
|
||||
}
|
||||
*errcode = CR_CONNECTION_ERROR;
|
||||
errcode = CR_CONNECTION_ERROR;
|
||||
SET_CLIENT_ERROR(*error_info, errcode? errcode:CR_CONNECTION_ERROR, UNKNOWN_SQLSTATE, errstr);
|
||||
if (errstr) {
|
||||
/* no mnd_ since we don't allocate it */
|
||||
efree(errstr);
|
||||
}
|
||||
DBG_RETURN(FAIL);
|
||||
}
|
||||
|
||||
if (hashed_details) {
|
||||
/*
|
||||
If persistent, the streams register it in EG(persistent_list).
|
||||
@@ -180,20 +207,30 @@ MYSQLND_METHOD(mysqlnd_net, connect)(MYSQLND_NET * net, const char * const schem
|
||||
#endif
|
||||
mnd_sprintf_free(hashed_details);
|
||||
}
|
||||
|
||||
/*
|
||||
Streams are not meant for C extensions! Thus we need a hack. Every connected stream will
|
||||
be registered as resource (in EG(regular_list). So far, so good. However, it won't be
|
||||
unregistered till the script ends. So, we need to take care of that.
|
||||
unregistered yntil the script ends. So, we need to take care of that.
|
||||
*/
|
||||
net->stream->in_free = 1;
|
||||
zend_hash_index_del(&EG(regular_list), net->stream->rsrc_id);
|
||||
net->stream->in_free = 0;
|
||||
|
||||
if (!net->options.timeout_read) {
|
||||
/* should always happen because read_timeout cannot be set via API */
|
||||
net->options.timeout_read = (unsigned int) MYSQLND_G(net_read_timeout);
|
||||
}
|
||||
DBG_RETURN(PASS);
|
||||
}
|
||||
/* }}} */
|
||||
|
||||
|
||||
/* {{{ mysqlnd_net::connect_ex */
|
||||
static void
|
||||
MYSQLND_METHOD(mysqlnd_net, post_connect_set_opt)(MYSQLND_NET * const net,
|
||||
const char * const scheme, const size_t scheme_len,
|
||||
MYSQLND_STATS * const conn_stats, MYSQLND_ERROR_INFO * const error_info TSRMLS_DC)
|
||||
{
|
||||
DBG_ENTER("mysqlnd_net::post_connect_set_opt");
|
||||
if (net->options.timeout_read) {
|
||||
struct timeval tv;
|
||||
DBG_INF_FMT("setting %u as PHP_STREAM_OPTION_READ_TIMEOUT", net->options.timeout_read);
|
||||
tv.tv_sec = net->options.timeout_read;
|
||||
tv.tv_usec = 0;
|
||||
@@ -205,13 +242,33 @@ MYSQLND_METHOD(mysqlnd_net, connect)(MYSQLND_NET * net, const char * const schem
|
||||
mysqlnd_set_sock_no_delay(net->stream TSRMLS_CC);
|
||||
}
|
||||
|
||||
{
|
||||
unsigned int buf_size = MYSQLND_G(net_read_buffer_size); /* this is long, cast to unsigned int*/
|
||||
net->m.set_client_option(net, MYSQLND_OPT_NET_READ_BUFFER_SIZE, (char *)&buf_size TSRMLS_CC);
|
||||
DBG_VOID_RETURN;
|
||||
}
|
||||
/* }}} */
|
||||
|
||||
|
||||
/* {{{ mysqlnd_net::connect_ex */
|
||||
static enum_func_status
|
||||
MYSQLND_METHOD(mysqlnd_net, connect_ex)(MYSQLND_NET * const net, const char * const scheme, const size_t scheme_len,
|
||||
const zend_bool persistent,
|
||||
MYSQLND_STATS * const conn_stats, MYSQLND_ERROR_INFO * const error_info TSRMLS_DC)
|
||||
{
|
||||
enum_func_status ret = FAIL;
|
||||
func_mysqlnd_net__open_stream open_stream = NULL;
|
||||
DBG_ENTER("mysqlnd_net::connect_ex");
|
||||
|
||||
net->packet_no = net->compressed_envelope_packet_no = 0;
|
||||
|
||||
net->m.close_stream(net, conn_stats, error_info TSRMLS_CC);
|
||||
|
||||
open_stream = (scheme_len > (sizeof("pipe://") - 1) && !memcmp(scheme, "pipe://", sizeof("pipe://") - 1))? net->m.open_pipe:
|
||||
net->m.open_tcp_or_unix;
|
||||
|
||||
if (PASS == (ret = open_stream(net, scheme, scheme_len, persistent, conn_stats, error_info TSRMLS_CC))) {
|
||||
net->m.post_connect_set_opt(net, scheme, scheme_len, conn_stats, error_info TSRMLS_CC);
|
||||
}
|
||||
|
||||
|
||||
DBG_RETURN(PASS);
|
||||
DBG_RETURN(ret);
|
||||
}
|
||||
/* }}} */
|
||||
|
||||
@@ -225,34 +282,32 @@ MYSQLND_METHOD(mysqlnd_net, connect)(MYSQLND_NET * net, const char * const schem
|
||||
#define STORE_HEADER_SIZE(safe_storage, buffer) COPY_HEADER((safe_storage), (buffer))
|
||||
#define RESTORE_HEADER_SIZE(buffer, safe_storage) STORE_HEADER_SIZE((safe_storage), (buffer))
|
||||
|
||||
/* {{{ mysqlnd_net::send */
|
||||
|
||||
/* {{{ mysqlnd_net::send_ex */
|
||||
/*
|
||||
IMPORTANT : It's expected that buf has place in the beginning for MYSQLND_HEADER_SIZE !!!!
|
||||
IMPORTANT : It's expected that buffer has place in the beginning for MYSQLND_HEADER_SIZE !!!!
|
||||
This is done for performance reasons in the caller of this function.
|
||||
Otherwise we will have to do send two TCP packets, or do new alloc and memcpy.
|
||||
Neither are quick, thus the clients of this function are obligated to do
|
||||
what they are asked for.
|
||||
|
||||
`count` is actually the length of the payload data. Thus :
|
||||
count + MYSQLND_HEADER_SIZE = sizeof(buf) (not the pointer but the actual buffer)
|
||||
count + MYSQLND_HEADER_SIZE = sizeof(buffer) (not the pointer but the actual buffer)
|
||||
*/
|
||||
size_t
|
||||
MYSQLND_METHOD(mysqlnd_net, send)(MYSQLND * const conn, zend_uchar * const buf, size_t count TSRMLS_DC)
|
||||
static size_t
|
||||
MYSQLND_METHOD(mysqlnd_net, send_ex)(MYSQLND_NET * const net, zend_uchar * const buffer, const size_t count,
|
||||
MYSQLND_STATS * const conn_stats, MYSQLND_ERROR_INFO * const error_info TSRMLS_DC)
|
||||
{
|
||||
zend_uchar safe_buf[((MYSQLND_HEADER_SIZE) + (sizeof(zend_uchar)) - 1) / (sizeof(zend_uchar))];
|
||||
zend_uchar *safe_storage = safe_buf;
|
||||
MYSQLND_NET *net = conn->net;
|
||||
size_t old_chunk_size = net->stream->chunk_size;
|
||||
size_t ret, packets_sent = 1;
|
||||
zend_uchar * safe_storage = safe_buf;
|
||||
size_t bytes_sent, packets_sent = 1;
|
||||
size_t left = count;
|
||||
zend_uchar *p = (zend_uchar *) buf;
|
||||
zend_uchar * p = (zend_uchar *) buffer;
|
||||
zend_uchar * compress_buf = NULL;
|
||||
size_t to_be_sent;
|
||||
|
||||
DBG_ENTER("mysqlnd_net::send");
|
||||
DBG_INF_FMT("conn=%llu count=" MYSQLND_SZ_T_SPEC " compression=%u", conn->thread_id, count, net->compressed);
|
||||
|
||||
net->stream->chunk_size = MYSQLND_MAX_PACKET_SIZE;
|
||||
DBG_ENTER("mysqlnd_net::send_ex");
|
||||
DBG_INF_FMT("count=" MYSQLND_SZ_T_SPEC " compression=%u", count, net->compressed);
|
||||
|
||||
if (net->compressed == TRUE) {
|
||||
size_t comp_buf_size = MYSQLND_HEADER_SIZE + COMPRESSED_HEADER_SIZE + MYSQLND_HEADER_SIZE + MIN(left, MYSQLND_MAX_PACKET_SIZE);
|
||||
@@ -287,7 +342,8 @@ MYSQLND_METHOD(mysqlnd_net, send)(MYSQLND * const conn, zend_uchar * const buf,
|
||||
int3store(compress_buf, payload_size);
|
||||
int1store(compress_buf + 3, net->packet_no);
|
||||
DBG_INF_FMT("writing "MYSQLND_SZ_T_SPEC" bytes to the network", payload_size + MYSQLND_HEADER_SIZE + COMPRESSED_HEADER_SIZE);
|
||||
ret = conn->net->m.network_write(conn, compress_buf, payload_size + MYSQLND_HEADER_SIZE + COMPRESSED_HEADER_SIZE TSRMLS_CC);
|
||||
bytes_sent = net->m.network_write_ex(net, compress_buf, payload_size + MYSQLND_HEADER_SIZE + COMPRESSED_HEADER_SIZE,
|
||||
conn_stats, error_info TSRMLS_CC);
|
||||
net->compressed_envelope_packet_no++;
|
||||
#if WHEN_WE_NEED_TO_CHECK_WHETHER_COMPRESSION_WORKS_CORRECTLY
|
||||
if (res == Z_OK) {
|
||||
@@ -318,7 +374,7 @@ MYSQLND_METHOD(mysqlnd_net, send)(MYSQLND * const conn, zend_uchar * const buf,
|
||||
STORE_HEADER_SIZE(safe_storage, p);
|
||||
int3store(p, to_be_sent);
|
||||
int1store(p + 3, net->packet_no);
|
||||
ret = conn->net->m.network_write(conn, p, to_be_sent + MYSQLND_HEADER_SIZE TSRMLS_CC);
|
||||
bytes_sent = net->m.network_write_ex(net, p, to_be_sent + MYSQLND_HEADER_SIZE, conn_stats, error_info TSRMLS_CC);
|
||||
RESTORE_HEADER_SIZE(p, safe_storage);
|
||||
net->compressed_envelope_packet_no++;
|
||||
}
|
||||
@@ -334,26 +390,25 @@ MYSQLND_METHOD(mysqlnd_net, send)(MYSQLND * const conn, zend_uchar * const buf,
|
||||
indeed it then loop once more, then to_be_sent will become 0, left will stay 0. Empty
|
||||
packet will be sent and this loop will end.
|
||||
*/
|
||||
} while (ret && (left > 0 || to_be_sent == MYSQLND_MAX_PACKET_SIZE));
|
||||
} while (bytes_sent && (left > 0 || to_be_sent == MYSQLND_MAX_PACKET_SIZE));
|
||||
|
||||
DBG_INF_FMT("packet_size="MYSQLND_SZ_T_SPEC" packet_no=%u", left, net->packet_no);
|
||||
/* Even for zero size payload we have to send a packet */
|
||||
if (!ret) {
|
||||
DBG_ERR_FMT("Can't %u send bytes", count);
|
||||
conn->state = CONN_QUIT_SENT;
|
||||
SET_CLIENT_ERROR(conn->error_info, CR_SERVER_GONE_ERROR, UNKNOWN_SQLSTATE, mysqlnd_server_gone);
|
||||
}
|
||||
|
||||
MYSQLND_INC_CONN_STATISTIC_W_VALUE3(conn->stats,
|
||||
MYSQLND_INC_CONN_STATISTIC_W_VALUE3(conn_stats,
|
||||
STAT_BYTES_SENT, count + packets_sent * MYSQLND_HEADER_SIZE,
|
||||
STAT_PROTOCOL_OVERHEAD_OUT, packets_sent * MYSQLND_HEADER_SIZE,
|
||||
STAT_PACKETS_SENT, packets_sent);
|
||||
|
||||
net->stream->chunk_size = old_chunk_size;
|
||||
if (compress_buf) {
|
||||
mnd_efree(compress_buf);
|
||||
}
|
||||
DBG_RETURN(ret);
|
||||
|
||||
/* Even for zero size payload we have to send a packet */
|
||||
if (!bytes_sent) {
|
||||
DBG_ERR_FMT("Can't %u send bytes", count);
|
||||
SET_CLIENT_ERROR(*error_info, CR_SERVER_GONE_ERROR, UNKNOWN_SQLSTATE, mysqlnd_server_gone);
|
||||
}
|
||||
DBG_RETURN(bytes_sent);
|
||||
}
|
||||
/* }}} */
|
||||
|
||||
@@ -423,19 +478,19 @@ mysqlnd_create_read_buffer(size_t count TSRMLS_DC)
|
||||
/* }}} */
|
||||
|
||||
|
||||
/* {{{ mysqlnd_read_compressed_packet_from_stream_and_fill_read_buffer */
|
||||
/* {{{ mysqlnd_net::read_compressed_packet_from_stream_and_fill_read_buffer */
|
||||
static enum_func_status
|
||||
mysqlnd_read_compressed_packet_from_stream_and_fill_read_buffer(MYSQLND * conn, size_t net_payload_size TSRMLS_DC)
|
||||
MYSQLND_METHOD(mysqlnd_net, read_compressed_packet_from_stream_and_fill_read_buffer)
|
||||
(MYSQLND_NET * net, size_t net_payload_size, MYSQLND_STATS * conn_stats, MYSQLND_ERROR_INFO * error_info TSRMLS_DC)
|
||||
{
|
||||
MYSQLND_NET * net = conn->net;
|
||||
size_t decompressed_size;
|
||||
enum_func_status ret = PASS;
|
||||
zend_uchar * compressed_data = NULL;
|
||||
zend_uchar comp_header[COMPRESSED_HEADER_SIZE];
|
||||
DBG_ENTER("mysqlnd_read_compressed_packet_from_stream_and_fill_read_buffer");
|
||||
DBG_ENTER("mysqlnd_net::read_compressed_packet_from_stream_and_fill_read_buffe");
|
||||
|
||||
/* Read the compressed header */
|
||||
if (FAIL == conn->net->m.network_read(conn, comp_header, COMPRESSED_HEADER_SIZE TSRMLS_CC)) {
|
||||
if (FAIL == net->m.network_read_ex(net, comp_header, COMPRESSED_HEADER_SIZE, conn_stats, error_info TSRMLS_CC)) {
|
||||
DBG_RETURN(FAIL);
|
||||
}
|
||||
decompressed_size = uint3korr(comp_header);
|
||||
@@ -445,7 +500,7 @@ mysqlnd_read_compressed_packet_from_stream_and_fill_read_buffer(MYSQLND * conn,
|
||||
|
||||
if (decompressed_size) {
|
||||
compressed_data = mnd_emalloc(net_payload_size);
|
||||
if (FAIL == conn->net->m.network_read(conn, compressed_data, net_payload_size TSRMLS_CC)) {
|
||||
if (FAIL == net->m.network_read_ex(net, compressed_data, net_payload_size, conn_stats, error_info TSRMLS_CC)) {
|
||||
ret = FAIL;
|
||||
goto end;
|
||||
}
|
||||
@@ -457,7 +512,7 @@ mysqlnd_read_compressed_packet_from_stream_and_fill_read_buffer(MYSQLND * conn,
|
||||
} else {
|
||||
DBG_INF_FMT("The server decided not to compress the data. Our job is easy. Copying %u bytes", net_payload_size);
|
||||
net->uncompressed_data = mysqlnd_create_read_buffer(net_payload_size TSRMLS_CC);
|
||||
if (FAIL == conn->net->m.network_read(conn, net->uncompressed_data->data, net_payload_size TSRMLS_CC)) {
|
||||
if (FAIL == net->m.network_read_ex(net, net->uncompressed_data->data, net_payload_size, conn_stats, error_info TSRMLS_CC)) {
|
||||
ret = FAIL;
|
||||
goto end;
|
||||
}
|
||||
@@ -474,8 +529,8 @@ end:
|
||||
|
||||
/* {{{ mysqlnd_net::decode */
|
||||
static enum_func_status
|
||||
MYSQLND_METHOD(mysqlnd_net, decode)(zend_uchar * uncompressed_data, size_t uncompressed_data_len,
|
||||
const zend_uchar * const compressed_data, size_t compressed_data_len TSRMLS_DC)
|
||||
MYSQLND_METHOD(mysqlnd_net, decode)(zend_uchar * uncompressed_data, const size_t uncompressed_data_len,
|
||||
const zend_uchar * const compressed_data, const size_t compressed_data_len TSRMLS_DC)
|
||||
{
|
||||
#ifdef MYSQLND_COMPRESSION_ENABLED
|
||||
int error;
|
||||
@@ -499,7 +554,7 @@ MYSQLND_METHOD(mysqlnd_net, decode)(zend_uchar * uncompressed_data, size_t uncom
|
||||
/* {{{ mysqlnd_net::encode */
|
||||
static enum_func_status
|
||||
MYSQLND_METHOD(mysqlnd_net, encode)(zend_uchar * compress_buffer, size_t * compress_buffer_len,
|
||||
const zend_uchar * const uncompressed_data, size_t uncompressed_data_len TSRMLS_DC)
|
||||
const zend_uchar * const uncompressed_data, const size_t uncompressed_data_len TSRMLS_DC)
|
||||
{
|
||||
#ifdef MYSQLND_COMPRESSION_ENABLED
|
||||
int error;
|
||||
@@ -523,15 +578,15 @@ MYSQLND_METHOD(mysqlnd_net, encode)(zend_uchar * compress_buffer, size_t * compr
|
||||
/* }}} */
|
||||
|
||||
|
||||
/* {{{ mysqlnd_net::receive */
|
||||
/* {{{ mysqlnd_net::receive_ex */
|
||||
static enum_func_status
|
||||
MYSQLND_METHOD(mysqlnd_net, receive)(MYSQLND * conn, zend_uchar * buffer, size_t count TSRMLS_DC)
|
||||
MYSQLND_METHOD(mysqlnd_net, receive_ex)(MYSQLND_NET * const net, zend_uchar * const buffer, const size_t count,
|
||||
MYSQLND_STATS * const conn_stats, MYSQLND_ERROR_INFO * const error_info TSRMLS_DC)
|
||||
{
|
||||
size_t to_read = count;
|
||||
zend_uchar * p = buffer;
|
||||
MYSQLND_NET * net = conn->net;
|
||||
|
||||
DBG_ENTER("mysqlnd_net::receive");
|
||||
DBG_ENTER("mysqlnd_net::receive_ex");
|
||||
#ifdef MYSQLND_COMPRESSION_ENABLED
|
||||
if (net->compressed) {
|
||||
if (net->uncompressed_data) {
|
||||
@@ -553,7 +608,7 @@ MYSQLND_METHOD(mysqlnd_net, receive)(MYSQLND * conn, zend_uchar * buffer, size_t
|
||||
size_t net_payload_size;
|
||||
zend_uchar packet_no;
|
||||
|
||||
if (FAIL == net->m.network_read(conn, net_header, MYSQLND_HEADER_SIZE TSRMLS_CC)) {
|
||||
if (FAIL == net->m.network_read_ex(net, net_header, MYSQLND_HEADER_SIZE, conn_stats, error_info TSRMLS_CC)) {
|
||||
DBG_RETURN(FAIL);
|
||||
}
|
||||
net_payload_size = uint3korr(net_header);
|
||||
@@ -571,7 +626,7 @@ MYSQLND_METHOD(mysqlnd_net, receive)(MYSQLND * conn, zend_uchar * buffer, size_t
|
||||
DBG_INF_FMT("HEADER: hwd_packet_no=%u size=%3u", packet_no, (unsigned long) net_payload_size);
|
||||
#endif
|
||||
/* Now let's read from the wire, decompress it and fill the read buffer */
|
||||
mysqlnd_read_compressed_packet_from_stream_and_fill_read_buffer(conn, net_payload_size TSRMLS_CC);
|
||||
net->m.read_compressed_packet_from_stream_and_fill_read_buffer(net, net_payload_size, conn_stats, error_info TSRMLS_CC);
|
||||
|
||||
/*
|
||||
Now a bit of recursion - read from the read buffer,
|
||||
@@ -579,12 +634,12 @@ MYSQLND_METHOD(mysqlnd_net, receive)(MYSQLND * conn, zend_uchar * buffer, size_t
|
||||
is not enough, then the recursive call will try to
|
||||
satisfy it until it is satisfied.
|
||||
*/
|
||||
DBG_RETURN(net->m.receive(conn, p, to_read TSRMLS_CC));
|
||||
DBG_RETURN(net->m.receive_ex(net, p, to_read, conn_stats, error_info TSRMLS_CC));
|
||||
}
|
||||
DBG_RETURN(PASS);
|
||||
}
|
||||
#endif /* MYSQLND_COMPRESSION_ENABLED */
|
||||
DBG_RETURN(net->m.network_read(conn, p, to_read TSRMLS_CC));
|
||||
DBG_RETURN(net->m.network_read_ex(net, p, to_read, conn_stats, error_info TSRMLS_CC));
|
||||
}
|
||||
/* }}} */
|
||||
|
||||
@@ -675,10 +730,10 @@ MYSQLND_METHOD(mysqlnd_net, set_client_option)(MYSQLND_NET * const net, enum mys
|
||||
case MYSQL_OPT_SSL_VERIFY_SERVER_CERT:
|
||||
net->options.ssl_verify_peer = value? ((*(zend_bool *)value)? TRUE:FALSE): FALSE;
|
||||
break;
|
||||
#ifdef WHEN_SUPPORTED_BY_MYSQLI
|
||||
case MYSQL_OPT_READ_TIMEOUT:
|
||||
net->options.timeout_read = *(unsigned int*) value;
|
||||
break;
|
||||
#ifdef WHEN_SUPPORTED_BY_MYSQLI
|
||||
case MYSQL_OPT_WRITE_TIMEOUT:
|
||||
net->options.timeout_write = *(unsigned int*) value;
|
||||
break;
|
||||
@@ -837,7 +892,7 @@ MYSQLND_METHOD(mysqlnd_net, disable_ssl)(MYSQLND_NET * const net TSRMLS_DC)
|
||||
/* }}} */
|
||||
|
||||
|
||||
/* {{{ mysqlnd_net::set_client_option */
|
||||
/* {{{ mysqlnd_net::free_contents */
|
||||
static void
|
||||
MYSQLND_METHOD(mysqlnd_net, free_contents)(MYSQLND_NET * net TSRMLS_DC)
|
||||
{
|
||||
@@ -874,26 +929,112 @@ MYSQLND_METHOD(mysqlnd_net, free_contents)(MYSQLND_NET * net TSRMLS_DC)
|
||||
}
|
||||
/* }}} */
|
||||
|
||||
|
||||
/* {{{ mysqlnd_net::close_stream */
|
||||
static void
|
||||
MYSQLND_METHOD(mysqlnd_net, close_stream)(MYSQLND_NET * const net, MYSQLND_STATS * const stats, MYSQLND_ERROR_INFO * const error_info TSRMLS_DC)
|
||||
{
|
||||
DBG_ENTER("mysqlnd_net::close_stream");
|
||||
if (net && net->stream) {
|
||||
zend_bool pers = net->persistent;
|
||||
DBG_INF_FMT("Freeing stream. abstract=%p", net->stream->abstract);
|
||||
if (pers) {
|
||||
if (EG(active)) {
|
||||
php_stream_free(net->stream, PHP_STREAM_FREE_CLOSE_PERSISTENT | PHP_STREAM_FREE_RSRC_DTOR);
|
||||
} else {
|
||||
/*
|
||||
otherwise we will crash because the EG(persistent_list) has been freed already,
|
||||
before the modules are shut down
|
||||
*/
|
||||
php_stream_free(net->stream, PHP_STREAM_FREE_CLOSE | PHP_STREAM_FREE_RSRC_DTOR);
|
||||
}
|
||||
} else {
|
||||
php_stream_free(net->stream, PHP_STREAM_FREE_CLOSE);
|
||||
}
|
||||
net->stream = NULL;
|
||||
}
|
||||
|
||||
DBG_VOID_RETURN;
|
||||
}
|
||||
/* }}} */
|
||||
|
||||
|
||||
/* {{{ mysqlnd_net::init */
|
||||
static enum_func_status
|
||||
MYSQLND_METHOD(mysqlnd_net, init)(MYSQLND_NET * const net, MYSQLND_STATS * const stats, MYSQLND_ERROR_INFO * const error_info TSRMLS_DC)
|
||||
{
|
||||
unsigned int buf_size;
|
||||
DBG_ENTER("mysqlnd_net::init");
|
||||
|
||||
buf_size = MYSQLND_G(net_cmd_buffer_size); /* this is long, cast to unsigned int*/
|
||||
net->m.set_client_option(net, MYSQLND_OPT_NET_CMD_BUFFER_SIZE, (char *) &buf_size TSRMLS_CC);
|
||||
|
||||
buf_size = MYSQLND_G(net_read_buffer_size); /* this is long, cast to unsigned int*/
|
||||
net->m.set_client_option(net, MYSQLND_OPT_NET_READ_BUFFER_SIZE, (char *)&buf_size TSRMLS_CC);
|
||||
|
||||
buf_size = MYSQLND_G(net_read_timeout); /* this is long, cast to unsigned int*/
|
||||
net->m.set_client_option(net, MYSQL_OPT_READ_TIMEOUT, (char *)&buf_size TSRMLS_CC);
|
||||
|
||||
DBG_RETURN(PASS);
|
||||
}
|
||||
/* }}} */
|
||||
|
||||
|
||||
/* {{{ mysqlnd_net::dtor */
|
||||
static void
|
||||
MYSQLND_METHOD(mysqlnd_net, dtor)(MYSQLND_NET * const net, MYSQLND_STATS * const stats, MYSQLND_ERROR_INFO * const error_info TSRMLS_DC)
|
||||
{
|
||||
DBG_ENTER("mysqlnd_net::dtor");
|
||||
if (net) {
|
||||
zend_bool pers = net->persistent;
|
||||
|
||||
net->m.free_contents(net TSRMLS_CC);
|
||||
net->m.close_stream(net, stats, error_info TSRMLS_CC);
|
||||
if (net->cmd_buffer.buffer) {
|
||||
DBG_INF("Freeing cmd buffer");
|
||||
mnd_pefree(net->cmd_buffer.buffer, pers);
|
||||
net->cmd_buffer.buffer = NULL;
|
||||
}
|
||||
mnd_pefree(net, pers);
|
||||
}
|
||||
DBG_VOID_RETURN;
|
||||
}
|
||||
/* }}} */
|
||||
|
||||
|
||||
static
|
||||
MYSQLND_CLASS_METHODS_START(mysqlnd_net)
|
||||
MYSQLND_METHOD(mysqlnd_net, connect),
|
||||
MYSQLND_METHOD(mysqlnd_net, send),
|
||||
MYSQLND_METHOD(mysqlnd_net, receive),
|
||||
MYSQLND_METHOD(mysqlnd_net, init),
|
||||
MYSQLND_METHOD(mysqlnd_net, dtor),
|
||||
MYSQLND_METHOD(mysqlnd_net, connect_ex),
|
||||
MYSQLND_METHOD(mysqlnd_net, close_stream),
|
||||
MYSQLND_METHOD(mysqlnd_net, open_pipe),
|
||||
MYSQLND_METHOD(mysqlnd_net, open_tcp_or_unix),
|
||||
NULL, /* unused 1 */
|
||||
NULL, /* unused 2 */
|
||||
MYSQLND_METHOD(mysqlnd_net, post_connect_set_opt),
|
||||
MYSQLND_METHOD(mysqlnd_net, set_client_option),
|
||||
MYSQLND_METHOD(mysqlnd_net, network_read),
|
||||
MYSQLND_METHOD(mysqlnd_net, network_write),
|
||||
MYSQLND_METHOD(mysqlnd_net, decode),
|
||||
MYSQLND_METHOD(mysqlnd_net, encode),
|
||||
MYSQLND_METHOD(mysqlnd_net, consume_uneaten_data),
|
||||
MYSQLND_METHOD(mysqlnd_net, free_contents),
|
||||
MYSQLND_METHOD(mysqlnd_net, enable_ssl),
|
||||
MYSQLND_METHOD(mysqlnd_net, disable_ssl)
|
||||
MYSQLND_METHOD(mysqlnd_net, disable_ssl),
|
||||
MYSQLND_METHOD(mysqlnd_net, network_read_ex),
|
||||
MYSQLND_METHOD(mysqlnd_net, network_write_ex),
|
||||
MYSQLND_METHOD(mysqlnd_net, send_ex),
|
||||
MYSQLND_METHOD(mysqlnd_net, receive_ex),
|
||||
#ifdef MYSQLND_COMPRESSION_ENABLED
|
||||
MYSQLND_METHOD(mysqlnd_net, read_compressed_packet_from_stream_and_fill_read_buffer)
|
||||
#else
|
||||
NULL
|
||||
#endif
|
||||
MYSQLND_CLASS_METHODS_END;
|
||||
|
||||
|
||||
/* {{{ mysqlnd_net_init */
|
||||
PHPAPI MYSQLND_NET *
|
||||
mysqlnd_net_init(zend_bool persistent TSRMLS_DC)
|
||||
mysqlnd_net_init(zend_bool persistent, MYSQLND_STATS * stats, MYSQLND_ERROR_INFO * error_info TSRMLS_DC)
|
||||
{
|
||||
size_t alloc_size = sizeof(MYSQLND_NET) + mysqlnd_plugin_count() * sizeof(void *);
|
||||
MYSQLND_NET * net = mnd_pecalloc(1, alloc_size, persistent);
|
||||
@@ -904,9 +1045,9 @@ mysqlnd_net_init(zend_bool persistent TSRMLS_DC)
|
||||
net->persistent = persistent;
|
||||
net->m = mysqlnd_mysqlnd_net_methods;
|
||||
|
||||
{
|
||||
unsigned int buf_size = MYSQLND_G(net_cmd_buffer_size); /* this is long, cast to unsigned int*/
|
||||
net->m.set_client_option(net, MYSQLND_OPT_NET_CMD_BUFFER_SIZE, (char *) &buf_size TSRMLS_CC);
|
||||
if (PASS != net->m.init(net, stats, error_info TSRMLS_CC)) {
|
||||
net->m.dtor(net, stats, error_info TSRMLS_CC);
|
||||
net = NULL;
|
||||
}
|
||||
}
|
||||
DBG_RETURN(net);
|
||||
@@ -916,29 +1057,11 @@ mysqlnd_net_init(zend_bool persistent TSRMLS_DC)
|
||||
|
||||
/* {{{ mysqlnd_net_free */
|
||||
PHPAPI void
|
||||
mysqlnd_net_free(MYSQLND_NET * const net TSRMLS_DC)
|
||||
mysqlnd_net_free(MYSQLND_NET * const net, MYSQLND_STATS * stats, MYSQLND_ERROR_INFO * error_info TSRMLS_DC)
|
||||
{
|
||||
DBG_ENTER("mysqlnd_net_free");
|
||||
|
||||
if (net) {
|
||||
zend_bool pers = net->persistent;
|
||||
|
||||
net->m.free_contents(net TSRMLS_CC);
|
||||
if (net->cmd_buffer.buffer) {
|
||||
DBG_INF("Freeing cmd buffer");
|
||||
mnd_pefree(net->cmd_buffer.buffer, pers);
|
||||
net->cmd_buffer.buffer = NULL;
|
||||
}
|
||||
if (net->stream) {
|
||||
DBG_INF_FMT("Freeing stream. abstract=%p", net->stream->abstract);
|
||||
if (pers) {
|
||||
php_stream_free(net->stream, PHP_STREAM_FREE_CLOSE_PERSISTENT | PHP_STREAM_FREE_RSRC_DTOR);
|
||||
} else {
|
||||
php_stream_free(net->stream, PHP_STREAM_FREE_CLOSE);
|
||||
}
|
||||
net->stream = NULL;
|
||||
}
|
||||
mnd_pefree(net, pers);
|
||||
net->m.dtor(net, stats, error_info TSRMLS_CC);
|
||||
}
|
||||
DBG_VOID_RETURN;
|
||||
}
|
||||
|
||||
@@ -23,8 +23,8 @@
|
||||
#ifndef MYSQLND_NET_H
|
||||
#define MYSQLND_NET_H
|
||||
|
||||
PHPAPI MYSQLND_NET * mysqlnd_net_init(zend_bool persistent TSRMLS_DC);
|
||||
PHPAPI void mysqlnd_net_free(MYSQLND_NET * const net TSRMLS_DC);
|
||||
PHPAPI MYSQLND_NET * mysqlnd_net_init(zend_bool persistent, MYSQLND_STATS * stats, MYSQLND_ERROR_INFO * error_info TSRMLS_DC);
|
||||
PHPAPI void mysqlnd_net_free(MYSQLND_NET * const net, MYSQLND_STATS * stats, MYSQLND_ERROR_INFO * error_info TSRMLS_DC);
|
||||
|
||||
PHPAPI struct st_mysqlnd_net_methods * mysqlnd_net_get_methods();
|
||||
|
||||
|
||||
@@ -0,0 +1,103 @@
|
||||
/*
|
||||
+----------------------------------------------------------------------+
|
||||
| PHP Version 5 |
|
||||
+----------------------------------------------------------------------+
|
||||
| Copyright (c) 2006-2011 The PHP Group |
|
||||
+----------------------------------------------------------------------+
|
||||
| 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 |
|
||||
| available through the world-wide-web at the following url: |
|
||||
| http://www.php.net/license/3_01.txt |
|
||||
| If you did not receive a copy of the PHP license and are unable to |
|
||||
| obtain it through the world-wide-web, please send a note to |
|
||||
| license@php.net so we can mail you a copy immediately. |
|
||||
+----------------------------------------------------------------------+
|
||||
| Authors: Andrey Hristov <andrey@mysql.com> |
|
||||
| Georg Richter <georg@mysql.com> |
|
||||
| Ulf Wendel <uwendel@mysql.com> |
|
||||
+----------------------------------------------------------------------+
|
||||
*/
|
||||
|
||||
/* $Id: mysqlnd.c 317989 2011-10-10 20:49:28Z andrey $ */
|
||||
#include "php.h"
|
||||
#include "mysqlnd.h"
|
||||
#include "mysqlnd_wireprotocol.h"
|
||||
#include "mysqlnd_priv.h"
|
||||
#include "mysqlnd_result.h"
|
||||
#include "mysqlnd_statistics.h"
|
||||
#include "mysqlnd_charset.h"
|
||||
#include "mysqlnd_debug.h"
|
||||
|
||||
|
||||
static HashTable mysqlnd_api_ext_ht;
|
||||
|
||||
|
||||
/* {{{ mysqlnd_reverse_api_init */
|
||||
PHPAPI void
|
||||
mysqlnd_reverse_api_init(TSRMLS_D)
|
||||
{
|
||||
zend_hash_init(&mysqlnd_api_ext_ht, 3, NULL, NULL, 1);
|
||||
}
|
||||
/* }}} */
|
||||
|
||||
|
||||
/* {{{ mysqlnd_reverse_api_end */
|
||||
PHPAPI void
|
||||
mysqlnd_reverse_api_end(TSRMLS_D)
|
||||
{
|
||||
zend_hash_destroy(&mysqlnd_api_ext_ht);
|
||||
}
|
||||
/* }}} */
|
||||
|
||||
|
||||
/* {{{ myslqnd_get_api_extensions */
|
||||
PHPAPI HashTable *
|
||||
mysqlnd_reverse_api_get_api_list(TSRLMLS_D)
|
||||
{
|
||||
return &mysqlnd_api_ext_ht;
|
||||
}
|
||||
/* }}} */
|
||||
|
||||
|
||||
/* {{{ mysqlnd_reverse_api_register_api */
|
||||
PHPAPI void
|
||||
mysqlnd_reverse_api_register_api(MYSQLND_REVERSE_API * apiext TSRMLS_DC)
|
||||
{
|
||||
zend_hash_add(&mysqlnd_api_ext_ht, apiext->module->name, strlen(apiext->module->name) + 1, &apiext,
|
||||
sizeof(MYSQLND_REVERSE_API), NULL);
|
||||
}
|
||||
/* }}} */
|
||||
|
||||
|
||||
/* {{{ zval_to_mysqlnd */
|
||||
PHPAPI MYSQLND *
|
||||
zval_to_mysqlnd(zval * zv TSRMLS_DC)
|
||||
{
|
||||
MYSQLND * retval;
|
||||
MYSQLND_REVERSE_API ** elem;
|
||||
|
||||
for (zend_hash_internal_pointer_reset(&mysqlnd_api_ext_ht);
|
||||
zend_hash_get_current_data(&mysqlnd_api_ext_ht, (void **)&elem) == SUCCESS;
|
||||
zend_hash_move_forward(&mysqlnd_api_ext_ht))
|
||||
{
|
||||
if ((*elem)->conversion_cb) {
|
||||
retval = (*elem)->conversion_cb(zv TSRMLS_CC);
|
||||
if (retval) {
|
||||
return retval;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return NULL;
|
||||
}
|
||||
/* }}} */
|
||||
|
||||
|
||||
/*
|
||||
* Local variables:
|
||||
* tab-width: 4
|
||||
* c-basic-offset: 4
|
||||
* End:
|
||||
* vim600: noet sw=4 ts=4 fdm=marker
|
||||
* vim<600: noet sw=4 ts=4
|
||||
*/
|
||||
@@ -0,0 +1,45 @@
|
||||
/*
|
||||
+----------------------------------------------------------------------+
|
||||
| PHP Version 5 |
|
||||
+----------------------------------------------------------------------+
|
||||
| Copyright (c) 2006-2011 The PHP Group |
|
||||
+----------------------------------------------------------------------+
|
||||
| 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 |
|
||||
| available through the world-wide-web at the following url: |
|
||||
| http://www.php.net/license/3_01.txt |
|
||||
| If you did not receive a copy of the PHP license and are unable to |
|
||||
| obtain it through the world-wide-web, please send a note to |
|
||||
| license@php.net so we can mail you a copy immediately. |
|
||||
+----------------------------------------------------------------------+
|
||||
| Authors: Andrey Hristov <andrey@mysql.com> |
|
||||
| Georg Richter <georg@mysql.com> |
|
||||
| Ulf Wendel <uwendel@mysql.com> |
|
||||
+----------------------------------------------------------------------+
|
||||
*/
|
||||
/* $Id: mysqlnd.h 318051 2011-10-12 16:18:02Z andrey $ */
|
||||
|
||||
#ifndef MYSQLND_REVERSE_API_H
|
||||
#define MYSQLND_REVERSE_API_H
|
||||
struct st_mysqlnd_api_extension;
|
||||
|
||||
PHPAPI void mysqlnd_reverse_api_init(TSRMLS_D);
|
||||
PHPAPI void mysqlnd_reverse_api_end(TSRMLS_D);
|
||||
|
||||
PHPAPI HashTable * mysqlnd_reverse_api_get_api_list(TSRMLS_D);
|
||||
|
||||
PHPAPI void mysqlnd_reverse_api_register_api(struct st_mysqlnd_api_extension * apiext TSRMLS_DC);
|
||||
|
||||
PHPAPI MYSQLND * zval_to_mysqlnd(zval * zv TSRMLS_DC);
|
||||
|
||||
#endif /* MYSQLND_REVERSE_API_H */
|
||||
|
||||
/*
|
||||
* Local variables:
|
||||
* tab-width: 4
|
||||
* c-basic-offset: 4
|
||||
* End:
|
||||
* vim600: noet sw=4 ts=4 fdm=marker
|
||||
* vim<600: noet sw=4 ts=4
|
||||
*/
|
||||
|
||||
@@ -260,28 +260,39 @@ typedef struct st_mysqlnd_read_buffer {
|
||||
|
||||
|
||||
|
||||
typedef enum_func_status (*func_mysqlnd_net__connect)(MYSQLND_NET * net, const char * const scheme, size_t scheme_len, zend_bool persistent, char **errstr, int * errcode TSRMLS_DC);
|
||||
typedef size_t (*func_mysqlnd_net__send)(MYSQLND * const conn, zend_uchar * const buf, size_t count TSRMLS_DC);
|
||||
typedef enum_func_status (*func_mysqlnd_net__receive)(MYSQLND * conn, zend_uchar * buffer, size_t count TSRMLS_DC);
|
||||
typedef enum_func_status (*func_mysqlnd_net__set_client_option)(MYSQLND_NET * const net, enum_mysqlnd_option option, const char * const value TSRMLS_DC);
|
||||
typedef enum_func_status (*func_mysqlnd_net__network_read)(MYSQLND * conn, zend_uchar * buffer, size_t count TSRMLS_DC);
|
||||
typedef size_t (*func_mysqlnd_net__network_write)(MYSQLND * const conn, const zend_uchar * const buf, size_t count TSRMLS_DC);
|
||||
typedef enum_func_status (*func_mysqlnd_net__decode)(zend_uchar * uncompressed_data, size_t uncompressed_data_len, const zend_uchar * const compressed_data, size_t compressed_data_len TSRMLS_DC);
|
||||
typedef enum_func_status (*func_mysqlnd_net__encode)(zend_uchar * compress_buffer, size_t * compress_buffer_len, const zend_uchar * const uncompressed_data, size_t uncompressed_data_len TSRMLS_DC);
|
||||
typedef enum_func_status (*func_mysqlnd_net__decode)(zend_uchar * uncompressed_data, const size_t uncompressed_data_len, const zend_uchar * const compressed_data, const size_t compressed_data_len TSRMLS_DC);
|
||||
typedef enum_func_status (*func_mysqlnd_net__encode)(zend_uchar * compress_buffer, size_t * compress_buffer_len, const zend_uchar * const uncompressed_data, const size_t uncompressed_data_len TSRMLS_DC);
|
||||
typedef size_t (*func_mysqlnd_net__consume_uneaten_data)(MYSQLND_NET * const net, enum php_mysqlnd_server_command cmd TSRMLS_DC);
|
||||
typedef void (*func_mysqlnd_net__free_contents)(MYSQLND_NET * net TSRMLS_DC);
|
||||
typedef enum_func_status (*func_mysqlnd_net__enable_ssl)(MYSQLND_NET * const net TSRMLS_DC);
|
||||
typedef enum_func_status (*func_mysqlnd_net__disable_ssl)(MYSQLND_NET * const net TSRMLS_DC);
|
||||
|
||||
typedef enum_func_status (*func_mysqlnd_net__network_read_ex)(MYSQLND_NET * const net, zend_uchar * const buffer, const size_t count, MYSQLND_STATS * const stats, MYSQLND_ERROR_INFO * const error_info TSRMLS_DC);
|
||||
typedef size_t (*func_mysqlnd_net__network_write_ex)(MYSQLND_NET * const net, const zend_uchar * const buf, const size_t count, MYSQLND_STATS * const stats, MYSQLND_ERROR_INFO * const error_info TSRMLS_DC);
|
||||
typedef size_t (*func_mysqlnd_net__send_ex)(MYSQLND_NET * const net, zend_uchar * const buffer, const size_t count, MYSQLND_STATS * const conn_stats, MYSQLND_ERROR_INFO * const error_info TSRMLS_DC);
|
||||
typedef enum_func_status (*func_mysqlnd_net__receive_ex)(MYSQLND_NET * const net, zend_uchar * const buffer, const size_t count, MYSQLND_STATS * const conn_stats, MYSQLND_ERROR_INFO * const error_info TSRMLS_DC);
|
||||
typedef enum_func_status (*func_mysqlnd_net__init)(MYSQLND_NET * const net, MYSQLND_STATS * const stats, MYSQLND_ERROR_INFO * const error_info TSRMLS_DC);
|
||||
typedef void (*func_mysqlnd_net__dtor)(MYSQLND_NET * const net, MYSQLND_STATS * const conn_stats, MYSQLND_ERROR_INFO * const error_info TSRMLS_DC);
|
||||
typedef enum_func_status (*func_mysqlnd_net__connect_ex)(MYSQLND_NET * const net, const char * const scheme, const size_t scheme_len, const zend_bool persistent, MYSQLND_STATS * const conn_stats, MYSQLND_ERROR_INFO * const error_info TSRMLS_DC);
|
||||
typedef void (*func_mysqlnd_net__close_stream)(MYSQLND_NET * const net, MYSQLND_STATS * const conn_stats, MYSQLND_ERROR_INFO * const error_info TSRMLS_DC);
|
||||
typedef enum_func_status (*func_mysqlnd_net__open_stream)(MYSQLND_NET * const net, const char * const scheme, const size_t scheme_len, const zend_bool persistent, MYSQLND_STATS * const conn_stats, MYSQLND_ERROR_INFO * const error_info TSRMLS_DC);
|
||||
typedef void (*func_mysqlnd_net__post_connect_set_opt)(MYSQLND_NET * const net, const char * const scheme, const size_t scheme_len, MYSQLND_STATS * const conn_stats, MYSQLND_ERROR_INFO * const error_info TSRMLS_DC);
|
||||
typedef enum_func_status (*func_mysqlnd_net__read_compressed_packet_from_stream_and_fill_read_buffer)(MYSQLND_NET * net, size_t net_payload_size, MYSQLND_STATS * conn_stats, MYSQLND_ERROR_INFO * error_info TSRMLS_DC);
|
||||
|
||||
struct st_mysqlnd_net_methods
|
||||
{
|
||||
func_mysqlnd_net__connect connect;
|
||||
func_mysqlnd_net__send send;
|
||||
func_mysqlnd_net__receive receive;
|
||||
func_mysqlnd_net__init init;
|
||||
func_mysqlnd_net__dtor dtor;
|
||||
func_mysqlnd_net__connect_ex connect_ex;
|
||||
func_mysqlnd_net__close_stream close_stream;
|
||||
func_mysqlnd_net__open_stream open_pipe;
|
||||
func_mysqlnd_net__open_stream open_tcp_or_unix;
|
||||
|
||||
void * unused1;
|
||||
void * unused2;
|
||||
func_mysqlnd_net__post_connect_set_opt post_connect_set_opt;
|
||||
|
||||
func_mysqlnd_net__set_client_option set_client_option;
|
||||
func_mysqlnd_net__network_read network_read;
|
||||
func_mysqlnd_net__network_write network_write;
|
||||
func_mysqlnd_net__decode decode;
|
||||
func_mysqlnd_net__encode encode;
|
||||
func_mysqlnd_net__consume_uneaten_data consume_uneaten_data;
|
||||
@@ -289,11 +300,18 @@ struct st_mysqlnd_net_methods
|
||||
func_mysqlnd_net__enable_ssl enable_ssl;
|
||||
func_mysqlnd_net__disable_ssl disable_ssl;
|
||||
|
||||
void * unused1;
|
||||
void * unused2;
|
||||
func_mysqlnd_net__network_read_ex network_read_ex;
|
||||
func_mysqlnd_net__network_write_ex network_write_ex;
|
||||
func_mysqlnd_net__send_ex send_ex;
|
||||
func_mysqlnd_net__receive_ex receive_ex;
|
||||
|
||||
func_mysqlnd_net__read_compressed_packet_from_stream_and_fill_read_buffer read_compressed_packet_from_stream_and_fill_read_buffer;
|
||||
|
||||
void * unused3;
|
||||
void * unused4;
|
||||
void * unused5;
|
||||
void * unused6;
|
||||
void * unused7;
|
||||
};
|
||||
|
||||
|
||||
@@ -711,8 +729,6 @@ struct st_mysqlnd_stmt_methods
|
||||
struct st_mysqlnd_net
|
||||
{
|
||||
php_stream *stream;
|
||||
struct st_mysqlnd_net_methods m;
|
||||
|
||||
/* sequence for simple checking of correct packets */
|
||||
zend_uchar packet_no;
|
||||
zend_bool compressed;
|
||||
@@ -729,6 +745,8 @@ struct st_mysqlnd_net
|
||||
MYSQLND_NET_OPTIONS options;
|
||||
|
||||
zend_bool persistent;
|
||||
|
||||
struct st_mysqlnd_net_methods m;
|
||||
};
|
||||
|
||||
|
||||
@@ -1005,4 +1023,11 @@ struct st_mysqlnd_authentication_plugin
|
||||
};
|
||||
|
||||
|
||||
typedef struct st_mysqlnd_reverse_api
|
||||
{
|
||||
zend_module_entry * module;
|
||||
MYSQLND *(*conversion_cb)(zval * zv TSRMLS_DC);
|
||||
} MYSQLND_REVERSE_API;
|
||||
|
||||
|
||||
#endif /* MYSQLND_STRUCTS_H */
|
||||
@@ -33,7 +33,7 @@
|
||||
#define PACKET_READ_HEADER_AND_BODY(packet, conn, buf, buf_size, packet_type_as_text, packet_type) \
|
||||
{ \
|
||||
DBG_INF_FMT("buf=%p size=%u", (buf), (buf_size)); \
|
||||
if (FAIL == mysqlnd_read_header((conn), &((packet)->header) TSRMLS_CC)) {\
|
||||
if (FAIL == mysqlnd_read_header((conn)->net, &((packet)->header), (conn)->stats, &((conn)->error_info) TSRMLS_CC)) {\
|
||||
CONN_SET_STATE(conn, CONN_QUIT_SENT); \
|
||||
SET_CLIENT_ERROR(conn->error_info, CR_SERVER_GONE_ERROR, UNKNOWN_SQLSTATE, mysqlnd_server_gone);\
|
||||
php_error_docref(NULL TSRMLS_CC, E_WARNING, "%s", mysqlnd_server_gone); \
|
||||
@@ -45,7 +45,7 @@
|
||||
(buf_size), (packet)->header.size, (packet)->header.size - (buf_size)); \
|
||||
DBG_RETURN(FAIL); \
|
||||
}\
|
||||
if (FAIL == conn->net->m.receive((conn), (buf), (packet)->header.size TSRMLS_CC)) { \
|
||||
if (FAIL == conn->net->m.receive_ex((conn)->net, (buf), (packet)->header.size, (conn)->stats, &((conn)->error_info) TSRMLS_CC)) { \
|
||||
CONN_SET_STATE(conn, CONN_QUIT_SENT); \
|
||||
SET_CLIENT_ERROR(conn->error_info, CR_SERVER_GONE_ERROR, UNKNOWN_SQLSTATE, mysqlnd_server_gone);\
|
||||
php_error_docref(NULL TSRMLS_CC, E_WARNING, "%s", mysqlnd_server_gone); \
|
||||
@@ -256,14 +256,14 @@ end:
|
||||
|
||||
/* {{{ mysqlnd_read_header */
|
||||
static enum_func_status
|
||||
mysqlnd_read_header(MYSQLND * conn, MYSQLND_PACKET_HEADER * header TSRMLS_DC)
|
||||
mysqlnd_read_header(MYSQLND_NET * net, MYSQLND_PACKET_HEADER * header,
|
||||
MYSQLND_STATS * conn_stats, MYSQLND_ERROR_INFO * error_info TSRMLS_DC)
|
||||
{
|
||||
MYSQLND_NET * net = conn->net;
|
||||
zend_uchar buffer[MYSQLND_HEADER_SIZE];
|
||||
|
||||
DBG_ENTER("mysqlnd_read_header_name");
|
||||
DBG_INF_FMT("compressed=%u conn_id=%u", net->compressed, conn->thread_id);
|
||||
if (FAIL == net->m.receive(conn, buffer, MYSQLND_HEADER_SIZE TSRMLS_CC)) {
|
||||
DBG_ENTER(mysqlnd_read_header_name);
|
||||
DBG_INF_FMT("compressed=%u", net->compressed);
|
||||
if (FAIL == net->m.receive_ex(net, buffer, MYSQLND_HEADER_SIZE, conn_stats, error_info TSRMLS_CC)) {
|
||||
DBG_RETURN(FAIL);
|
||||
}
|
||||
|
||||
@@ -273,7 +273,7 @@ mysqlnd_read_header(MYSQLND * conn, MYSQLND_PACKET_HEADER * header TSRMLS_DC)
|
||||
#ifdef MYSQLND_DUMP_HEADER_N_BODY
|
||||
DBG_INF_FMT("HEADER: prot_packet_no=%u size=%3u", header->packet_no, header->size);
|
||||
#endif
|
||||
MYSQLND_INC_CONN_STATISTIC_W_VALUE2(conn->stats,
|
||||
MYSQLND_INC_CONN_STATISTIC_W_VALUE2(conn_stats,
|
||||
STAT_PROTOCOL_OVERHEAD_IN, MYSQLND_HEADER_SIZE,
|
||||
STAT_PACKETS_RECEIVED, 1);
|
||||
|
||||
@@ -299,7 +299,7 @@ mysqlnd_read_header(MYSQLND * conn, MYSQLND_PACKET_HEADER * header TSRMLS_DC)
|
||||
|
||||
/* {{{ php_mysqlnd_greet_read */
|
||||
static enum_func_status
|
||||
php_mysqlnd_greet_read(void *_packet, MYSQLND *conn TSRMLS_DC)
|
||||
php_mysqlnd_greet_read(void * _packet, MYSQLND * conn TSRMLS_DC)
|
||||
{
|
||||
zend_uchar buf[2048];
|
||||
zend_uchar *p = buf;
|
||||
@@ -435,7 +435,7 @@ premature_end:
|
||||
|
||||
/* {{{ php_mysqlnd_greet_free_mem */
|
||||
static
|
||||
void php_mysqlnd_greet_free_mem(void *_packet, zend_bool stack_allocation TSRMLS_DC)
|
||||
void php_mysqlnd_greet_free_mem(void * _packet, zend_bool stack_allocation TSRMLS_DC)
|
||||
{
|
||||
MYSQLND_PACKET_GREET *p= (MYSQLND_PACKET_GREET *) _packet;
|
||||
if (p->server_version) {
|
||||
@@ -461,7 +461,7 @@ void php_mysqlnd_greet_free_mem(void *_packet, zend_bool stack_allocation TSRMLS
|
||||
|
||||
/* {{{ php_mysqlnd_auth_write */
|
||||
static
|
||||
size_t php_mysqlnd_auth_write(void *_packet, MYSQLND * conn TSRMLS_DC)
|
||||
size_t php_mysqlnd_auth_write(void * _packet, MYSQLND * conn TSRMLS_DC)
|
||||
{
|
||||
zend_uchar buffer[AUTH_WRITE_BUFFER_LEN];
|
||||
zend_uchar *p = buffer + MYSQLND_HEADER_SIZE; /* start after the header */
|
||||
@@ -539,7 +539,11 @@ size_t php_mysqlnd_auth_write(void *_packet, MYSQLND * conn TSRMLS_DC)
|
||||
}
|
||||
DBG_RETURN(p - buffer - MYSQLND_HEADER_SIZE);
|
||||
} else {
|
||||
DBG_RETURN(conn->net->m.send(conn, buffer, p - buffer - MYSQLND_HEADER_SIZE TSRMLS_CC));
|
||||
size_t sent = conn->net->m.send_ex(conn->net, buffer, p - buffer - MYSQLND_HEADER_SIZE, conn->stats, &conn->error_info TSRMLS_CC);
|
||||
if (!sent) {
|
||||
CONN_SET_STATE(conn, CONN_QUIT_SENT);
|
||||
}
|
||||
DBG_RETURN(sent);
|
||||
}
|
||||
}
|
||||
/* }}} */
|
||||
@@ -547,7 +551,7 @@ size_t php_mysqlnd_auth_write(void *_packet, MYSQLND * conn TSRMLS_DC)
|
||||
|
||||
/* {{{ php_mysqlnd_auth_free_mem */
|
||||
static
|
||||
void php_mysqlnd_auth_free_mem(void *_packet, zend_bool stack_allocation TSRMLS_DC)
|
||||
void php_mysqlnd_auth_free_mem(void * _packet, zend_bool stack_allocation TSRMLS_DC)
|
||||
{
|
||||
if (!stack_allocation) {
|
||||
MYSQLND_PACKET_AUTH * p = (MYSQLND_PACKET_AUTH *) _packet;
|
||||
@@ -561,7 +565,7 @@ void php_mysqlnd_auth_free_mem(void *_packet, zend_bool stack_allocation TSRMLS_
|
||||
|
||||
/* {{{ php_mysqlnd_auth_response_read */
|
||||
static enum_func_status
|
||||
php_mysqlnd_auth_response_read(void *_packet, MYSQLND *conn TSRMLS_DC)
|
||||
php_mysqlnd_auth_response_read(void * _packet, MYSQLND * conn TSRMLS_DC)
|
||||
{
|
||||
zend_uchar local_buf[AUTH_RESP_BUFFER_SIZE];
|
||||
size_t buf_len = conn->net->cmd_buffer.buffer? conn->net->cmd_buffer.length: AUTH_RESP_BUFFER_SIZE;
|
||||
@@ -653,7 +657,7 @@ premature_end:
|
||||
|
||||
/* {{{ php_mysqlnd_auth_response_free_mem */
|
||||
static void
|
||||
php_mysqlnd_auth_response_free_mem(void *_packet, zend_bool stack_allocation TSRMLS_DC)
|
||||
php_mysqlnd_auth_response_free_mem(void * _packet, zend_bool stack_allocation TSRMLS_DC)
|
||||
{
|
||||
MYSQLND_PACKET_AUTH_RESPONSE * p = (MYSQLND_PACKET_AUTH_RESPONSE *) _packet;
|
||||
if (p->message) {
|
||||
@@ -680,8 +684,8 @@ php_mysqlnd_auth_response_free_mem(void *_packet, zend_bool stack_allocation TSR
|
||||
|
||||
|
||||
/* {{{ php_mysqlnd_change_auth_response_write */
|
||||
static
|
||||
size_t php_mysqlnd_change_auth_response_write(void *_packet, MYSQLND * conn TSRMLS_DC)
|
||||
static size_t
|
||||
php_mysqlnd_change_auth_response_write(void * _packet, MYSQLND * conn TSRMLS_DC)
|
||||
{
|
||||
MYSQLND_PACKET_CHANGE_AUTH_RESPONSE *packet= (MYSQLND_PACKET_CHANGE_AUTH_RESPONSE *) _packet;
|
||||
zend_uchar * buffer = conn->net->cmd_buffer.length >= packet->auth_data_len? conn->net->cmd_buffer.buffer : mnd_emalloc(packet->auth_data_len);
|
||||
@@ -695,19 +699,22 @@ size_t php_mysqlnd_change_auth_response_write(void *_packet, MYSQLND * conn TSRM
|
||||
}
|
||||
|
||||
{
|
||||
size_t ret = conn->net->m.send(conn, buffer, p - buffer - MYSQLND_HEADER_SIZE TSRMLS_CC);
|
||||
size_t sent = conn->net->m.send_ex(conn->net, buffer, p - buffer - MYSQLND_HEADER_SIZE, conn->stats, &conn->error_info TSRMLS_CC);
|
||||
if (buffer != conn->net->cmd_buffer.buffer) {
|
||||
mnd_efree(buffer);
|
||||
}
|
||||
DBG_RETURN(ret);
|
||||
if (!sent) {
|
||||
CONN_SET_STATE(conn, CONN_QUIT_SENT);
|
||||
}
|
||||
DBG_RETURN(sent);
|
||||
}
|
||||
}
|
||||
/* }}} */
|
||||
|
||||
|
||||
/* {{{ php_mysqlnd_change_auth_response_free_mem */
|
||||
static
|
||||
void php_mysqlnd_change_auth_response_free_mem(void *_packet, zend_bool stack_allocation TSRMLS_DC)
|
||||
static void
|
||||
php_mysqlnd_change_auth_response_free_mem(void * _packet, zend_bool stack_allocation TSRMLS_DC)
|
||||
{
|
||||
if (!stack_allocation) {
|
||||
MYSQLND_PACKET_CHANGE_AUTH_RESPONSE * p = (MYSQLND_PACKET_CHANGE_AUTH_RESPONSE *) _packet;
|
||||
@@ -721,7 +728,7 @@ void php_mysqlnd_change_auth_response_free_mem(void *_packet, zend_bool stack_al
|
||||
|
||||
/* {{{ php_mysqlnd_ok_read */
|
||||
static enum_func_status
|
||||
php_mysqlnd_ok_read(void *_packet, MYSQLND *conn TSRMLS_DC)
|
||||
php_mysqlnd_ok_read(void * _packet, MYSQLND * conn TSRMLS_DC)
|
||||
{
|
||||
zend_uchar local_buf[OK_BUFFER_SIZE];
|
||||
size_t buf_len = conn->net->cmd_buffer.buffer? conn->net->cmd_buffer.length : OK_BUFFER_SIZE;
|
||||
@@ -790,7 +797,7 @@ premature_end:
|
||||
|
||||
/* {{{ php_mysqlnd_ok_free_mem */
|
||||
static void
|
||||
php_mysqlnd_ok_free_mem(void *_packet, zend_bool stack_allocation TSRMLS_DC)
|
||||
php_mysqlnd_ok_free_mem(void * _packet, zend_bool stack_allocation TSRMLS_DC)
|
||||
{
|
||||
MYSQLND_PACKET_OK *p= (MYSQLND_PACKET_OK *) _packet;
|
||||
if (p->message) {
|
||||
@@ -806,7 +813,7 @@ php_mysqlnd_ok_free_mem(void *_packet, zend_bool stack_allocation TSRMLS_DC)
|
||||
|
||||
/* {{{ php_mysqlnd_eof_read */
|
||||
static enum_func_status
|
||||
php_mysqlnd_eof_read(void *_packet, MYSQLND *conn TSRMLS_DC)
|
||||
php_mysqlnd_eof_read(void * _packet, MYSQLND * conn TSRMLS_DC)
|
||||
{
|
||||
/*
|
||||
EOF packet is since 4.1 five bytes long,
|
||||
@@ -873,7 +880,7 @@ premature_end:
|
||||
|
||||
/* {{{ php_mysqlnd_eof_free_mem */
|
||||
static
|
||||
void php_mysqlnd_eof_free_mem(void *_packet, zend_bool stack_allocation TSRMLS_DC)
|
||||
void php_mysqlnd_eof_free_mem(void * _packet, zend_bool stack_allocation TSRMLS_DC)
|
||||
{
|
||||
if (!stack_allocation) {
|
||||
mnd_pefree(_packet, ((MYSQLND_PACKET_EOF *)_packet)->header.persistent);
|
||||
@@ -883,13 +890,13 @@ void php_mysqlnd_eof_free_mem(void *_packet, zend_bool stack_allocation TSRMLS_D
|
||||
|
||||
|
||||
/* {{{ php_mysqlnd_cmd_write */
|
||||
size_t php_mysqlnd_cmd_write(void *_packet, MYSQLND *conn TSRMLS_DC)
|
||||
size_t php_mysqlnd_cmd_write(void * _packet, MYSQLND * conn TSRMLS_DC)
|
||||
{
|
||||
/* Let's have some space, which we can use, if not enough, we will allocate new buffer */
|
||||
MYSQLND_PACKET_COMMAND *packet= (MYSQLND_PACKET_COMMAND *) _packet;
|
||||
MYSQLND_NET *net = conn->net;
|
||||
MYSQLND_PACKET_COMMAND * packet= (MYSQLND_PACKET_COMMAND *) _packet;
|
||||
MYSQLND_NET * net = conn->net;
|
||||
unsigned int error_reporting = EG(error_reporting);
|
||||
size_t written = 0;
|
||||
size_t sent = 0;
|
||||
|
||||
DBG_ENTER("php_mysqlnd_cmd_write");
|
||||
/*
|
||||
@@ -913,9 +920,9 @@ size_t php_mysqlnd_cmd_write(void *_packet, MYSQLND *conn TSRMLS_DC)
|
||||
zend_uchar buffer[MYSQLND_HEADER_SIZE + 1];
|
||||
|
||||
int1store(buffer + MYSQLND_HEADER_SIZE, packet->command);
|
||||
written = conn->net->m.send(conn, buffer, 1 TSRMLS_CC);
|
||||
sent = net->m.send_ex(net, buffer, 1, conn->stats, &conn->error_info TSRMLS_CC);
|
||||
} else {
|
||||
size_t tmp_len = packet->arg_len + 1 + MYSQLND_HEADER_SIZE, ret;
|
||||
size_t tmp_len = packet->arg_len + 1 + MYSQLND_HEADER_SIZE;
|
||||
zend_uchar *tmp, *p;
|
||||
tmp = (tmp_len > net->cmd_buffer.length)? mnd_emalloc(tmp_len):net->cmd_buffer.buffer;
|
||||
if (!tmp) {
|
||||
@@ -928,26 +935,28 @@ size_t php_mysqlnd_cmd_write(void *_packet, MYSQLND *conn TSRMLS_DC)
|
||||
|
||||
memcpy(p, packet->argument, packet->arg_len);
|
||||
|
||||
ret = conn->net->m.send(conn, tmp, tmp_len - MYSQLND_HEADER_SIZE TSRMLS_CC);
|
||||
sent = net->m.send_ex(net, tmp, tmp_len - MYSQLND_HEADER_SIZE, conn->stats, &conn->error_info TSRMLS_CC);
|
||||
if (tmp != net->cmd_buffer.buffer) {
|
||||
MYSQLND_INC_CONN_STATISTIC(conn->stats, STAT_CMD_BUFFER_TOO_SMALL);
|
||||
mnd_efree(tmp);
|
||||
}
|
||||
written = ret;
|
||||
}
|
||||
end:
|
||||
if (error_reporting) {
|
||||
/* restore error reporting */
|
||||
EG(error_reporting) = error_reporting;
|
||||
}
|
||||
DBG_RETURN(written);
|
||||
if (!sent) {
|
||||
CONN_SET_STATE(conn, CONN_QUIT_SENT);
|
||||
}
|
||||
DBG_RETURN(sent);
|
||||
}
|
||||
/* }}} */
|
||||
|
||||
|
||||
/* {{{ php_mysqlnd_cmd_free_mem */
|
||||
static
|
||||
void php_mysqlnd_cmd_free_mem(void *_packet, zend_bool stack_allocation TSRMLS_DC)
|
||||
void php_mysqlnd_cmd_free_mem(void * _packet, zend_bool stack_allocation TSRMLS_DC)
|
||||
{
|
||||
if (!stack_allocation) {
|
||||
MYSQLND_PACKET_COMMAND * p = (MYSQLND_PACKET_COMMAND *) _packet;
|
||||
@@ -959,7 +968,7 @@ void php_mysqlnd_cmd_free_mem(void *_packet, zend_bool stack_allocation TSRMLS_D
|
||||
|
||||
/* {{{ php_mysqlnd_rset_header_read */
|
||||
static enum_func_status
|
||||
php_mysqlnd_rset_header_read(void *_packet, MYSQLND *conn TSRMLS_DC)
|
||||
php_mysqlnd_rset_header_read(void * _packet, MYSQLND * conn TSRMLS_DC)
|
||||
{
|
||||
enum_func_status ret = PASS;
|
||||
size_t buf_len = conn->net->cmd_buffer.length;
|
||||
@@ -1063,7 +1072,7 @@ premature_end:
|
||||
|
||||
/* {{{ php_mysqlnd_rset_header_free_mem */
|
||||
static
|
||||
void php_mysqlnd_rset_header_free_mem(void *_packet, zend_bool stack_allocation TSRMLS_DC)
|
||||
void php_mysqlnd_rset_header_free_mem(void * _packet, zend_bool stack_allocation TSRMLS_DC)
|
||||
{
|
||||
MYSQLND_PACKET_RSET_HEADER *p= (MYSQLND_PACKET_RSET_HEADER *) _packet;
|
||||
DBG_ENTER("php_mysqlnd_rset_header_free_mem");
|
||||
@@ -1097,7 +1106,7 @@ static size_t rset_field_offsets[] =
|
||||
|
||||
/* {{{ php_mysqlnd_rset_field_read */
|
||||
static enum_func_status
|
||||
php_mysqlnd_rset_field_read(void *_packet, MYSQLND *conn TSRMLS_DC)
|
||||
php_mysqlnd_rset_field_read(void * _packet, MYSQLND * conn TSRMLS_DC)
|
||||
{
|
||||
/* Should be enough for the metadata of a single row */
|
||||
MYSQLND_PACKET_RES_FIELD *packet= (MYSQLND_PACKET_RES_FIELD *) _packet;
|
||||
@@ -1290,7 +1299,7 @@ premature_end:
|
||||
|
||||
/* {{{ php_mysqlnd_rset_field_free_mem */
|
||||
static
|
||||
void php_mysqlnd_rset_field_free_mem(void *_packet, zend_bool stack_allocation TSRMLS_DC)
|
||||
void php_mysqlnd_rset_field_free_mem(void * _packet, zend_bool stack_allocation TSRMLS_DC)
|
||||
{
|
||||
MYSQLND_PACKET_RES_FIELD *p= (MYSQLND_PACKET_RES_FIELD *) _packet;
|
||||
/* p->metadata was passed to us as temporal buffer */
|
||||
@@ -1304,13 +1313,13 @@ void php_mysqlnd_rset_field_free_mem(void *_packet, zend_bool stack_allocation T
|
||||
/* {{{ php_mysqlnd_read_row_ex */
|
||||
static enum_func_status
|
||||
php_mysqlnd_read_row_ex(MYSQLND * conn, MYSQLND_MEMORY_POOL * result_set_memory_pool,
|
||||
MYSQLND_MEMORY_POOL_CHUNK **buffer,
|
||||
size_t *data_size, zend_bool persistent_alloc,
|
||||
MYSQLND_MEMORY_POOL_CHUNK ** buffer,
|
||||
size_t * data_size, zend_bool persistent_alloc,
|
||||
unsigned int prealloc_more_bytes TSRMLS_DC)
|
||||
{
|
||||
enum_func_status ret = PASS;
|
||||
MYSQLND_PACKET_HEADER header;
|
||||
zend_uchar *p = NULL;
|
||||
zend_uchar * p = NULL;
|
||||
zend_bool first_iteration = TRUE;
|
||||
|
||||
DBG_ENTER("php_mysqlnd_read_row_ex");
|
||||
@@ -1325,7 +1334,7 @@ php_mysqlnd_read_row_ex(MYSQLND * conn, MYSQLND_MEMORY_POOL * result_set_memory_
|
||||
|
||||
*data_size = prealloc_more_bytes;
|
||||
while (1) {
|
||||
if (FAIL == mysqlnd_read_header(conn , &header TSRMLS_CC)) {
|
||||
if (FAIL == mysqlnd_read_header(conn->net, &header, conn->stats, &conn->error_info TSRMLS_CC)) {
|
||||
ret = FAIL;
|
||||
break;
|
||||
}
|
||||
@@ -1365,7 +1374,7 @@ php_mysqlnd_read_row_ex(MYSQLND * conn, MYSQLND_MEMORY_POOL * result_set_memory_
|
||||
p = (*buffer)->ptr + (*data_size - header.size);
|
||||
}
|
||||
|
||||
if (PASS != (ret = conn->net->m.receive(conn, p, header.size TSRMLS_CC))) {
|
||||
if (PASS != (ret = conn->net->m.receive_ex(conn->net, p, header.size, conn->stats, &conn->error_info TSRMLS_CC))) {
|
||||
DBG_ERR("Empty row packet body");
|
||||
php_error(E_WARNING, "Empty row packet body");
|
||||
break;
|
||||
@@ -1393,8 +1402,8 @@ php_mysqlnd_rowp_read_binary_protocol(MYSQLND_MEMORY_POOL_CHUNK * row_buffer, zv
|
||||
MYSQLND_STATS * stats TSRMLS_DC)
|
||||
{
|
||||
unsigned int i;
|
||||
zend_uchar *p = row_buffer->ptr;
|
||||
zend_uchar *null_ptr, bit;
|
||||
zend_uchar * p = row_buffer->ptr;
|
||||
zend_uchar * null_ptr, bit;
|
||||
zval **current_field, **end_field, **start_field;
|
||||
|
||||
DBG_ENTER("php_mysqlnd_rowp_read_binary_protocol");
|
||||
@@ -1494,9 +1503,9 @@ php_mysqlnd_rowp_read_text_protocol(MYSQLND_MEMORY_POOL_CHUNK * row_buffer, zval
|
||||
unsigned int i;
|
||||
zend_bool last_field_was_string = FALSE;
|
||||
zval **current_field, **end_field, **start_field;
|
||||
zend_uchar *p = row_buffer->ptr;
|
||||
zend_uchar * p = row_buffer->ptr;
|
||||
size_t data_size = row_buffer->app;
|
||||
zend_uchar *bit_area = (zend_uchar*) row_buffer->ptr + data_size + 1; /* we allocate from here */
|
||||
zend_uchar * bit_area = (zend_uchar*) row_buffer->ptr + data_size + 1; /* we allocate from here */
|
||||
|
||||
DBG_ENTER("php_mysqlnd_rowp_read_text_protocol");
|
||||
|
||||
@@ -1719,9 +1728,9 @@ php_mysqlnd_rowp_read_text_protocol(MYSQLND_MEMORY_POOL_CHUNK * row_buffer, zval
|
||||
if PS => packet->fields is passed from outside
|
||||
*/
|
||||
static enum_func_status
|
||||
php_mysqlnd_rowp_read(void *_packet, MYSQLND *conn TSRMLS_DC)
|
||||
php_mysqlnd_rowp_read(void * _packet, MYSQLND * conn TSRMLS_DC)
|
||||
{
|
||||
MYSQLND_NET *net = conn->net;
|
||||
MYSQLND_NET * net = conn->net;
|
||||
zend_uchar *p;
|
||||
enum_func_status ret = PASS;
|
||||
size_t old_chunk_size = net->stream->chunk_size;
|
||||
@@ -1814,7 +1823,7 @@ end:
|
||||
|
||||
/* {{{ php_mysqlnd_rowp_free_mem */
|
||||
static void
|
||||
php_mysqlnd_rowp_free_mem(void *_packet, zend_bool stack_allocation TSRMLS_DC)
|
||||
php_mysqlnd_rowp_free_mem(void * _packet, zend_bool stack_allocation TSRMLS_DC)
|
||||
{
|
||||
MYSQLND_PACKET_ROW *p;
|
||||
|
||||
@@ -1842,7 +1851,7 @@ php_mysqlnd_rowp_free_mem(void *_packet, zend_bool stack_allocation TSRMLS_DC)
|
||||
|
||||
/* {{{ php_mysqlnd_stats_read */
|
||||
static enum_func_status
|
||||
php_mysqlnd_stats_read(void *_packet, MYSQLND *conn TSRMLS_DC)
|
||||
php_mysqlnd_stats_read(void * _packet, MYSQLND * conn TSRMLS_DC)
|
||||
{
|
||||
MYSQLND_PACKET_STATS *packet= (MYSQLND_PACKET_STATS *) _packet;
|
||||
size_t buf_len = conn->net->cmd_buffer.length;
|
||||
@@ -1864,7 +1873,7 @@ php_mysqlnd_stats_read(void *_packet, MYSQLND *conn TSRMLS_DC)
|
||||
|
||||
/* {{{ php_mysqlnd_stats_free_mem */
|
||||
static
|
||||
void php_mysqlnd_stats_free_mem(void *_packet, zend_bool stack_allocation TSRMLS_DC)
|
||||
void php_mysqlnd_stats_free_mem(void * _packet, zend_bool stack_allocation TSRMLS_DC)
|
||||
{
|
||||
MYSQLND_PACKET_STATS *p= (MYSQLND_PACKET_STATS *) _packet;
|
||||
if (p->message) {
|
||||
@@ -1884,7 +1893,7 @@ void php_mysqlnd_stats_free_mem(void *_packet, zend_bool stack_allocation TSRMLS
|
||||
|
||||
/* {{{ php_mysqlnd_prepare_read */
|
||||
static enum_func_status
|
||||
php_mysqlnd_prepare_read(void *_packet, MYSQLND *conn TSRMLS_DC)
|
||||
php_mysqlnd_prepare_read(void * _packet, MYSQLND * conn TSRMLS_DC)
|
||||
{
|
||||
/* In case of an error, we should have place to put it */
|
||||
size_t buf_len = conn->net->cmd_buffer.length;
|
||||
@@ -1960,7 +1969,7 @@ premature_end:
|
||||
|
||||
/* {{{ php_mysqlnd_prepare_free_mem */
|
||||
static void
|
||||
php_mysqlnd_prepare_free_mem(void *_packet, zend_bool stack_allocation TSRMLS_DC)
|
||||
php_mysqlnd_prepare_free_mem(void * _packet, zend_bool stack_allocation TSRMLS_DC)
|
||||
{
|
||||
MYSQLND_PACKET_PREPARE_RESPONSE *p= (MYSQLND_PACKET_PREPARE_RESPONSE *) _packet;
|
||||
if (!stack_allocation) {
|
||||
@@ -1972,7 +1981,7 @@ php_mysqlnd_prepare_free_mem(void *_packet, zend_bool stack_allocation TSRMLS_DC
|
||||
|
||||
/* {{{ php_mysqlnd_chg_user_read */
|
||||
static enum_func_status
|
||||
php_mysqlnd_chg_user_read(void *_packet, MYSQLND *conn TSRMLS_DC)
|
||||
php_mysqlnd_chg_user_read(void * _packet, MYSQLND * conn TSRMLS_DC)
|
||||
{
|
||||
/* There could be an error message */
|
||||
size_t buf_len = conn->net->cmd_buffer.length;
|
||||
@@ -2035,7 +2044,7 @@ premature_end:
|
||||
|
||||
/* {{{ php_mysqlnd_chg_user_free_mem */
|
||||
static void
|
||||
php_mysqlnd_chg_user_free_mem(void *_packet, zend_bool stack_allocation TSRMLS_DC)
|
||||
php_mysqlnd_chg_user_free_mem(void * _packet, zend_bool stack_allocation TSRMLS_DC)
|
||||
{
|
||||
MYSQLND_PACKET_CHG_USER_RESPONSE * p = (MYSQLND_PACKET_CHG_USER_RESPONSE *) _packet;
|
||||
|
||||
|
||||
@@ -25,6 +25,7 @@
|
||||
#include "mysqlnd_priv.h"
|
||||
#include "mysqlnd_debug.h"
|
||||
#include "mysqlnd_statistics.h"
|
||||
#include "mysqlnd_reverse_api.h"
|
||||
#include "ext/standard/info.h"
|
||||
#include "ext/standard/php_smart_str.h"
|
||||
|
||||
@@ -135,10 +136,10 @@ mysqlnd_minfo_dump_loaded_plugins(void *pDest, void * buf TSRMLS_DC)
|
||||
|
||||
/* {{{ mysqlnd_minfo_dump_api_plugins */
|
||||
static int
|
||||
mysqlnd_minfo_dump_api_plugins(void *pDest, void * buf TSRMLS_DC)
|
||||
mysqlnd_minfo_dump_api_plugins(void * pDest, void * buf TSRMLS_DC)
|
||||
{
|
||||
smart_str * buffer = (smart_str *) buf;
|
||||
mysqlnd_api_extension_t *ext = *(mysqlnd_api_extension_t **) pDest;
|
||||
MYSQLND_REVERSE_API * ext = *(MYSQLND_REVERSE_API **) pDest;
|
||||
if (buffer->len) {
|
||||
smart_str_appendc(buffer, ',');
|
||||
}
|
||||
@@ -188,7 +189,7 @@ PHP_MINFO_FUNCTION(mysqlnd)
|
||||
php_info_print_table_row(2, "Loaded plugins", tmp_str.c);
|
||||
smart_str_free(&tmp_str);
|
||||
|
||||
zend_hash_apply_with_argument(mysqlnd_get_api_extensions(), mysqlnd_minfo_dump_api_plugins, &tmp_str TSRMLS_CC);
|
||||
zend_hash_apply_with_argument(mysqlnd_reverse_api_get_api_list(TSRMLS_C), mysqlnd_minfo_dump_api_plugins, &tmp_str TSRMLS_CC);
|
||||
smart_str_0(&tmp_str);
|
||||
php_info_print_table_row(2, "API Extensions", tmp_str.c);
|
||||
smart_str_free(&tmp_str);
|
||||
|
||||
@@ -10,6 +10,9 @@ $ov = preg_match('/Compile-time ORACLE_HOME/', $phpinfo);
|
||||
if ($ov !== 1) {
|
||||
die ("skip Test only valid when OCI8 is built with an ORACLE_HOME");
|
||||
}
|
||||
if (preg_match('/Unknown/', oci_client_version()) == 1) {
|
||||
die("skip expected output only valid with Oracle clients > 9gR2");
|
||||
}
|
||||
?>
|
||||
--ENV--
|
||||
ORACLE_HOME=""
|
||||
|
||||
@@ -204,36 +204,6 @@ static size_t php_openssl_sockop_write(php_stream *stream, const char *buf, size
|
||||
return didwrite;
|
||||
}
|
||||
|
||||
static void php_openssl_stream_wait_for_data(php_stream *stream, php_netstream_data_t *sock TSRMLS_DC)
|
||||
{
|
||||
int retval;
|
||||
struct timeval *ptimeout;
|
||||
|
||||
if (sock->socket == -1) {
|
||||
return;
|
||||
}
|
||||
|
||||
sock->timeout_event = 0;
|
||||
|
||||
if (sock->timeout.tv_sec == -1)
|
||||
ptimeout = NULL;
|
||||
else
|
||||
ptimeout = &sock->timeout;
|
||||
|
||||
while(1) {
|
||||
retval = php_pollfd_for(sock->socket, PHP_POLLREADABLE, ptimeout);
|
||||
|
||||
if (retval == 0)
|
||||
sock->timeout_event = 1;
|
||||
|
||||
if (retval >= 0)
|
||||
break;
|
||||
|
||||
if (php_socket_errno() != EINTR)
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
static size_t php_openssl_sockop_read(php_stream *stream, char *buf, size_t count TSRMLS_DC)
|
||||
{
|
||||
php_openssl_netstream_data_t *sslsock = (php_openssl_netstream_data_t*)stream->abstract;
|
||||
@@ -243,13 +213,6 @@ static size_t php_openssl_sockop_read(php_stream *stream, char *buf, size_t coun
|
||||
int retry = 1;
|
||||
|
||||
do {
|
||||
if (sslsock->s.is_blocked) {
|
||||
php_openssl_stream_wait_for_data(stream, &(sslsock->s) TSRMLS_CC);
|
||||
if (sslsock->s.timeout_event) {
|
||||
break;
|
||||
}
|
||||
/* there is no guarantee that there is application data available but something is there */
|
||||
}
|
||||
nr_bytes = SSL_read(sslsock->ssl_handle, buf, count);
|
||||
|
||||
if (nr_bytes <= 0) {
|
||||
|
||||
@@ -2339,6 +2339,7 @@ static zend_object_value dbstmt_clone_obj(zval *zobject TSRMLS_DC)
|
||||
}
|
||||
|
||||
zend_object_handlers pdo_dbstmt_object_handlers;
|
||||
static int pdo_row_serialize(zval *object, unsigned char **buffer, zend_uint *buf_len, zend_serialize_data *data TSRMLS_DC);
|
||||
|
||||
void pdo_stmt_init(TSRMLS_D)
|
||||
{
|
||||
@@ -2362,6 +2363,7 @@ void pdo_stmt_init(TSRMLS_D)
|
||||
pdo_row_ce = zend_register_internal_class(&ce TSRMLS_CC);
|
||||
pdo_row_ce->ce_flags |= ZEND_ACC_FINAL_CLASS; /* when removing this a lot of handlers need to be redone */
|
||||
pdo_row_ce->create_object = pdo_row_new;
|
||||
pdo_row_ce->serialize = pdo_row_serialize;
|
||||
}
|
||||
|
||||
static void free_statement(pdo_stmt_t *stmt TSRMLS_DC)
|
||||
@@ -2802,6 +2804,12 @@ zend_object_value pdo_row_new(zend_class_entry *ce TSRMLS_DC)
|
||||
|
||||
return retval;
|
||||
}
|
||||
|
||||
static int pdo_row_serialize(zval *object, unsigned char **buffer, zend_uint *buf_len, zend_serialize_data *data TSRMLS_DC)
|
||||
{
|
||||
php_error_docref(NULL TSRMLS_CC, E_WARNING, "PDORow instances may not be serialized");
|
||||
return FAILURE;
|
||||
}
|
||||
/* }}} */
|
||||
|
||||
/*
|
||||
|
||||
@@ -235,9 +235,9 @@ static int pdo_dblib_stmt_get_col(pdo_stmt_t *stmt, int colno, char **ptr,
|
||||
|
||||
/* uniqueidentifier is a 16-byte binary number, convert to 32 char hex string */
|
||||
#ifdef SQLUNIQUE
|
||||
*len = dbconvert(NULL, SQLUNIQUE, ptr, *len, SQLCHAR, tmp_ptr, *len);
|
||||
*len = dbconvert(NULL, SQLUNIQUE, *ptr, *len, SQLCHAR, tmp_ptr, *len);
|
||||
#else
|
||||
*len = dbconvert(NULL, 36, ptr, *len, SQLCHAR, tmp_ptr, *len);
|
||||
*len = dbconvert(NULL, 36, *ptr, *len, SQLCHAR, tmp_ptr, *len);
|
||||
#endif
|
||||
php_strtoupper(tmp_ptr, *len);
|
||||
*ptr = tmp_ptr;
|
||||
|
||||
Loaded 100 of 217 files, more files were not shown because too many files have changed in this diff.
Show more
Reference in new issue
Block a user