1
0
mirror of https://github.com/php/php-src.git synced 2026-04-25 17:08:14 +02:00
Commit Graph

2349 Commits

Author SHA1 Message Date
Marco Pivetta 25cb9cdb79 Fix GH-8232 - always reference classes in var_export() via their FQCN
Closes GH-8233

This fix corrects a behavior of `var_export()` that was mostly "hidden" until PHP 8.1 introduced:

* properties with object initializers
* constants containing object references
* default values of class properties containing `enum`s

Since `var_export(..., true)` is mostly used in conjunction with code generation,
and we cannot make assumptions about the generated code being placed in the root
namespace, we must always provide the FQCN of a class in exported code.

For example:

```php
<?php

namespace MyNamespace { class Foo {} }

namespace { echo "<?php\n\nnamespace Example;\n\n" . var_export(new \MyNamespace\Foo(), true) . ';'; }
```

produces:

```php
<?php

namespace Example;

MyNamespace\Foo::__set_state(array(
));
```

This code snippet is invalid, because `Example\MyNamespace\Foo::__set_state()` (which
does not exist) is called.

With this patch applied, the code looks like following (valid):

```php
<?php

namespace Example;

\MyNamespace\Foo::__set_state(array(
));
```

Ref: https://github.com/php/php-src/issues/8232
Ref: https://github.com/Ocramius/ProxyManager/issues/754
Ref: https://externals.io/message/117466
2022-04-23 11:06:21 +02:00
Derick Rethans a690a56a86 Merge branch 'PHP-8.1' 2022-04-22 10:31:22 +01:00
Derick Rethans 15ee285f83 Merge branch 'PHP-8.0' into PHP-8.1 2022-04-22 10:31:14 +01:00
Derick Rethans c854bb2472 Fixed GH-8400: bug73837.phpt makes no sense
Replaces the indeed silly test with something that actually does the job,
albeit much slower.
2022-04-22 10:29:37 +01:00
Derick Rethans 731e3f6c96 Merge branch 'PHP-8.1' 2022-04-14 10:32:25 +01:00
Derick Rethans ec0771c03f Merge branch 'PHP-8.0' into PHP-8.1 2022-04-14 10:32:21 +01:00
Derick Rethans e38d300a70 Refactor code to avoid duplication 2022-04-14 10:32:10 +01:00
Cody Mann 24085d0192 style/readability updates 2022-04-14 10:22:00 +01:00
Cody Mann 287c8a86b4 GH-7979: iterator advances when checking if valid 2022-04-14 10:22:00 +01:00
Derick Rethans a4f4b96c91 Updated to version 2022.1 (2022a) 2022-04-07 10:45:21 +01:00
Derick Rethans 7e829d1536 Updated to version 2022.1 (2022a) 2022-04-07 10:45:20 +01:00
Derick Rethans 7aefee1613 Updated to version 2022.1 (2022a) 2022-04-07 10:45:19 +01:00
Derick Rethans cd6c338c89 Merge branch 'PHP-8.1' 2022-04-01 13:28:13 +01:00
Derick Rethans e6c4988187 Fixed #7752, #8101, #81660: DateTimeZone::getTransitions() returns insufficient data 2022-04-01 13:28:05 +01:00
Nikita Popov 902d64390e Deprecate implicit dynamic properties
Writing to a proprety that hasn't been declared is deprecated,
unless the class uses the #[AllowDynamicProperties] attribute or
defines __get()/__set().

RFC: https://wiki.php.net/rfc/deprecate_dynamic_properties
2021-11-26 14:10:11 +01:00
Derick Rethans f893b55123 Merge branch 'PHP-8.1' 2021-11-18 13:56:07 +00:00
Derick Rethans e4679ef0c2 Fixed date/diff where the difference in hour is less than 1 2021-11-18 13:55:51 +00:00
Derick Rethans 369ab3b53e Merge branch 'PHP-8.1' 2021-11-08 09:40:41 +00:00
Derick Rethans 904933e918 Fixed bug #81458: Regression: Incorrect difference after timezone change 2021-11-08 09:40:27 +00:00
Derick Rethans 64bd602b6a Updated to version 2021.5 (2021e) 2021-11-03 15:49:27 +00:00
Derick Rethans 456bfc7e9e Updated to version 2021.5 (2021e) 2021-11-03 15:49:27 +00:00
Derick Rethans 4ec9d07cc3 Updated to version 2021.5 (2021e) 2021-11-03 15:49:25 +00:00
Christoph M. Becker b7d90f09d4 Merge branch 'PHP-8.1'
* PHP-8.1:
  Fix #81500: Interval serialization regression since 7.3.14 / 7.4.2
2021-10-15 19:14:00 +02:00
Christoph M. Becker 2e65c8e581 Merge branch 'PHP-8.0' into PHP-8.1
* PHP-8.0:
  Fix #81500: Interval serialization regression since 7.3.14 / 7.4.2
2021-10-15 19:13:38 +02:00
Christoph M. Becker fc886694d3 Merge branch 'PHP-7.4' into PHP-8.0
* PHP-7.4:
  Fix #81500: Interval serialization regression since 7.3.14 / 7.4.2
2021-10-15 19:11:26 +02:00
Christoph M. Becker 866adb122a Fix #81500: Interval serialization regression since 7.3.14 / 7.4.2
While it may not be desired, `DateInterval::$f` supports negative
values, at least with regard to calculations.  We still need to guard
from assigning double values which are out of range for signed 64bit
integers (which would be undefined behavior).  zend_dval_to_lval() does
this by returning `0` instead of triggering UB.  This way we can avoid
setting the invalid marker, which doesn't work as expected anyway.

We must not do that only for unserialization, but also when the property
is set in the first place.

We need to adapt some of the existing tests wrt. this behavior.  In
particular, we check for an arbitrary value in bug79015.phpt, to cater
to differences between 32bit and 64bit architectures.

Closes GH-7575.
2021-10-15 19:08:07 +02:00
Hao Sun 2feecaf3f5 Merge branch 'PHP-8.1'
* PHP-8.1:
  Reduce threshold further in ext/date/tests/bug73837.phpt
2021-10-12 00:56:48 +00:00
Hao Sun 582e21fbda Reduce threshold further in ext/date/tests/bug73837.phpt
The threshold in test case ext/date/tests/bug73837.phpt has been reduced
several times, from the original 990 to current 400. However, this case
still failed on my local test with Mac Mini machine(macOS on Apple
silicon). Here is the diff result:

```
  $ cat ext/date/tests/bug73837.diff
     int(%d)
  002+ microseconds do not differ enough (268)
  002- microseconds differ
```

Hence this patch reduces the threshold further.

Note that this patch should be backported to PHP 8.1 branch as well.

Closes GH-7567.
2021-10-12 00:49:21 +00:00
Derick Rethans 21e8af8296 Merge branch 'PHP-8.1' 2021-10-08 13:52:47 +01:00
Derick Rethans 7af0bf4d07 Merge branch 'PHP-8.0' into PHP-8.1 2021-10-08 13:52:34 +01:00
Derick Rethans b230593b0e Merge branch 'PHP-7.4' into PHP-8.0 2021-10-08 13:52:18 +01:00
Derick Rethans 9733d49e14 Remove now superfluous tests due to changes in tzdata 2021-10-08 13:51:21 +01:00
Derick Rethans c8764870ae Updated to version 2021.3 (2021c) 2021-10-08 12:54:55 +01:00
Derick Rethans 7ad877ced1 Updated to version 2021.3 (2021c) 2021-10-08 12:54:54 +01:00
Derick Rethans c55b41d658 Updated to version 2021.3 (2021c) 2021-10-08 12:54:53 +01:00
Derick Rethans 8a61f1ece6 Updated to version 2021.3 (2021c) 2021-10-08 12:54:52 +01:00
Derick Rethans 8b55a84d00 Merge branch 'PHP-8.1' 2021-10-05 18:28:40 +01:00
Derick Rethans 6166ac51b7 Force UTC 2021-10-05 18:28:30 +01:00
Derick Rethans 0d6b8bbfcd Merge branch 'PHP-8.1' 2021-10-05 15:23:05 +01:00
Derick Rethans 68b874d10d Fixed bug #81504: Incorrect timezone transition details for POSIX data 2021-10-05 15:22:55 +01:00
Kamil Tekiela c3dda473cc Fix 'can not' in test data and in code comments 2021-10-05 09:51:58 +01:00
Christoph M. Becker f6ac832f0a [ci skip] Merge branch 'PHP-8.1'
* PHP-8.1:
  [ci skip] Remove erroneous XFAIL test
2021-10-01 18:59:54 +02:00
Christoph M. Becker c468e37858 [ci skip] Remove erroneous XFAIL test
Bug #66257 is actually not a bug, but rather a documentation issue.

Closes GH-7543.
2021-10-01 18:59:01 +02:00
Kamil Tekiela ca07cf3079 Merge branch 'PHP-8.1'
* PHP-8.1:
  getTimestamp does not return false
2021-09-30 09:16:25 +01:00
Kamil Tekiela 5fbba9b995 getTimestamp does not return false 2021-09-30 09:13:55 +01:00
George Peter Banyard 0663c64f41 Voidify php_date_interval_initialize_from_hash() 2021-09-29 17:15:50 +01:00
George Peter Banyard 492980c540 Use bool/zend_result instead of int in Date extension 2021-09-29 17:15:50 +01:00
Nikita Popov 9d8f97d58d Revert "Fix DATE_FORMAT_COOKIE definition"
This reverts commit ac34648cf6.

As pointed out on GH-6783, the new format doesn't match any of
the specified formats. Previously the constant generated

    Thursday, 14-Jul-2005 22:30:41 BST

which is obsolete. Now it generates

    Thu, 14-Jul-2005 22:30:41 BST

which is not specified at all. The correct version would be:

    Thu, 14 Jul 2005 22:30:41 BST

Reverting the change for now.
2021-09-29 09:26:40 +02:00
Mahmood Dhia ac34648cf6 Fix DATE_FORMAT_COOKIE definition
In all of http://curl.haxx.se/rfc/cookie_spec.html,
https://docs.microsoft.com/de-de/windows/win32/wininet/http-cookies
and https://tools.ietf.org/html/rfc7234#section-5.3 the cookie
datetime is specified as Mon, DD-Mon-YYYY HH:MM:SS GMT. However,
the current definition returns Monday, DD-Mon-YYY HH:MM:SS GMT.
Therefore, the "l" in "l, d-M-Y H:i:s T" must be changed to "D".

Closes GH-6783.
2021-09-23 16:01:04 +02:00
Christoph M. Becker fac3fbcb07 Fix OOB read due to timezone_open() with 5 digit offset
This has been reported as bug #78984, and is generally and properly
fixed as of timelib 2020.3 (PHP-8.0).  However, it is not fixed in
PHP-7.4, where the test results in an OOB read, and an unterminated
C string when calling `::getName()`.  Therefore, we apply a minimal
fix which just avoids this dangerous behavior.
2021-09-17 13:18:51 +02:00