mirror of
https://github.com/php/php-src.git
synced 2026-04-03 22:22:18 +02:00
make room for next UPGRADING notes
This commit is contained in:
727
UPGRADING
727
UPGRADING
@@ -1,4 +1,4 @@
|
||||
PHP 7.0 UPGRADE NOTES
|
||||
PHP 7.1 UPGRADE NOTES
|
||||
|
||||
1. Backward Incompatible Changes
|
||||
2. New Features
|
||||
@@ -19,776 +19,51 @@
|
||||
1. Backward Incompatible Changes
|
||||
========================================
|
||||
|
||||
Language changes
|
||||
================
|
||||
|
||||
Changes to variable handling
|
||||
----------------------------
|
||||
|
||||
* Indirect variable, property and method references are now interpreted with
|
||||
left-to-right semantics. Some examples:
|
||||
|
||||
$$foo['bar']['baz'] // interpreted as ($$foo)['bar']['baz']
|
||||
$foo->$bar['baz'] // interpreted as ($foo->$bar)['baz']
|
||||
$foo->$bar['baz']() // interpreted as ($foo->$bar)['baz']()
|
||||
Foo::$bar['baz']() // interpreted as (Foo::$bar)['baz']()
|
||||
|
||||
To restore the previous behavior add explicit curly braces:
|
||||
|
||||
${$foo['bar']['baz']}
|
||||
$foo->{$bar['baz']}
|
||||
$foo->{$bar['baz']}()
|
||||
Foo::{$bar['baz']}()
|
||||
|
||||
* The global keyword now only accepts simple variables. Instead of
|
||||
|
||||
global $$foo->bar;
|
||||
|
||||
it is now required to write the following:
|
||||
|
||||
global ${$foo->bar};
|
||||
|
||||
* Parentheses around variables or function calls no longer have any influence
|
||||
on behavior. For example the following code, where the result of a function
|
||||
call is passed to a by-reference function
|
||||
|
||||
function getArray() { return [1, 2, 3]; }
|
||||
|
||||
$last = array_pop(getArray());
|
||||
// Strict Standards: Only variables should be passed by reference
|
||||
$last = array_pop((getArray()));
|
||||
// Strict Standards: Only variables should be passed by reference
|
||||
|
||||
will now throw a strict standards error regardless of whether parentheses
|
||||
are used. Previously no notice was generated in the second case.
|
||||
|
||||
* Array elements or object properties that are automatically created during
|
||||
by-reference assignments will now result in a different order. For example
|
||||
|
||||
$array = [];
|
||||
$array["a"] =& $array["b"];
|
||||
$array["b"] = 1;
|
||||
var_dump($array);
|
||||
|
||||
now results in the array ["a" => 1, "b" => 1], while previously the result
|
||||
was ["b" => 1, "a" => 1];
|
||||
|
||||
Relevant RFCs:
|
||||
* https://wiki.php.net/rfc/uniform_variable_syntax
|
||||
* https://wiki.php.net/rfc/abstract_syntax_tree
|
||||
|
||||
Changes to list()
|
||||
-----------------
|
||||
|
||||
* list() will no longer assign variables in reverse order. For example
|
||||
|
||||
list($array[], $array[], $array[]) = [1, 2, 3];
|
||||
var_dump($array);
|
||||
|
||||
will now result in $array == [1, 2, 3] rather than [3, 2, 1]. Note that only
|
||||
the **order** of the assignments changed, but the assigned values stay the
|
||||
same. E.g. a normal usage like
|
||||
|
||||
list($a, $b, $c) = [1, 2, 3];
|
||||
// $a = 1; $b = 2; $c = 3;
|
||||
|
||||
will retain its current behavior.
|
||||
|
||||
* Empty list() assignments are no longer allowed. As such all of the following
|
||||
are invalid:
|
||||
|
||||
list() = $a;
|
||||
list(,,) = $a;
|
||||
list($x, list(), $y) = $a;
|
||||
|
||||
* list() no longer supports unpacking strings (while previously this was only
|
||||
supported in some cases). The code
|
||||
|
||||
$string = "xy";
|
||||
list($x, $y) = $string;
|
||||
|
||||
will now result in $x == null and $y == null (without notices) instead of
|
||||
$x == "x" and $y == "y". Furthermore list() is now always guaranteed to
|
||||
work with objects implementing ArrayAccess, e.g.
|
||||
|
||||
list($a, $b) = (object) new ArrayObject([0, 1]);
|
||||
|
||||
will now result in $a == 0 and $b == 1. Previously both $a and $b were null.
|
||||
|
||||
Relevant RFCs:
|
||||
* https://wiki.php.net/rfc/abstract_syntax_tree#changes_to_list
|
||||
* https://wiki.php.net/rfc/fix_list_behavior_inconsistency
|
||||
|
||||
Changes to foreach
|
||||
------------------
|
||||
|
||||
* Iteration with foreach() no longer has any effect on the internal array
|
||||
pointer, which can be accessed through the current()/next()/etc family of
|
||||
functions. For example
|
||||
|
||||
$array = [0, 1, 2];
|
||||
foreach ($array as &$val) {
|
||||
var_dump(current($array));
|
||||
}
|
||||
|
||||
will now print the value int(0) three times. Previously the output was int(1),
|
||||
int(2) and bool(false).
|
||||
|
||||
* When iterating arrays by-value, foreach will now always operate on a copy of
|
||||
the array, as such changes to the array during iteration will not influence
|
||||
iteration behavior. For example
|
||||
|
||||
$array = [0, 1, 2];
|
||||
$ref =& $array; // Necessary to trigger the old behavior
|
||||
foreach ($array as $val) {
|
||||
var_dump($val);
|
||||
unset($array[1]);
|
||||
}
|
||||
|
||||
will now print all three elements (0 1 2), while previously the second element
|
||||
1 was skipped (0 2).
|
||||
|
||||
* When iterating arrays by-reference, modifications to the array will continue
|
||||
to influence the iteration. However PHP will now do a better job of
|
||||
maintaining a correct position in a number of cases. E.g. appending to an
|
||||
array during by-reference iteration
|
||||
|
||||
$array = [0];
|
||||
foreach ($array as &$val) {
|
||||
var_dump($val);
|
||||
$array[1] = 1;
|
||||
}
|
||||
|
||||
will now iterate over the appended element as well. As such the output of this
|
||||
example will now be "int(0) int(1)", while previously it was only "int(0)".
|
||||
|
||||
* Iteration of plain (non-Traversable) objects by-value or by-reference will
|
||||
behave like by-reference iteration of arrays. This matches the previous
|
||||
behavior apart from the more accurate position management mentioned in the
|
||||
previous point.
|
||||
|
||||
* Iteration of Traversable objects remains unchanged.
|
||||
|
||||
Relevant RFC: https://wiki.php.net/rfc/php7_foreach
|
||||
|
||||
Changes to parameter handling
|
||||
-----------------------------
|
||||
|
||||
* It is no longer possible to define two function parameters with the same name.
|
||||
For example, the following method will trigger a compile-time error:
|
||||
|
||||
public function foo($a, $b, $unused, $unused) {
|
||||
// ...
|
||||
}
|
||||
|
||||
Code like this should be changed to use distinct parameter names, for example:
|
||||
|
||||
public function foo($a, $b, $unused1, $unused2) {
|
||||
// ...
|
||||
}
|
||||
|
||||
* The func_get_arg() and func_get_args() functions will no longer return the
|
||||
original value that was passed to a parameter and will instead provide the
|
||||
current value (which might have been modified). For example
|
||||
|
||||
function foo($x) {
|
||||
$x++;
|
||||
var_dump(func_get_arg(0));
|
||||
}
|
||||
foo(1);
|
||||
|
||||
will now print "2" instead of "1". This code should be changed to either
|
||||
perform modifications only after calling func_get_arg(s)
|
||||
|
||||
function foo($x) {
|
||||
var_dump(func_get_arg(0));
|
||||
$x++;
|
||||
}
|
||||
|
||||
or avoid modifying the parameters altogether:
|
||||
|
||||
function foo($x) {
|
||||
$newX = $x + 1;
|
||||
var_dump(func_get_arg(0));
|
||||
}
|
||||
|
||||
* Similarly exception backtraces will no longer display the original value that
|
||||
was passed to a function and show the modified value instead. For example
|
||||
|
||||
function foo($x) {
|
||||
$x = 42;
|
||||
throw new Exception;
|
||||
}
|
||||
foo("string");
|
||||
|
||||
will now result in the stack trace
|
||||
|
||||
Stack trace:
|
||||
#0 file.php(4): foo(42)
|
||||
#1 {main}
|
||||
|
||||
while previously it was:
|
||||
|
||||
Stack trace:
|
||||
#0 file.php(4): foo('string')
|
||||
#1 {main}
|
||||
|
||||
While this should not impact runtime behavior of your code, it is worthwhile
|
||||
to be aware of this difference for debugging purposes.
|
||||
|
||||
The same limitation also applies to debug_backtrace() and other functions
|
||||
inspecting function arguments.
|
||||
|
||||
Relevant RFC: https://wiki.php.net/phpng
|
||||
|
||||
Changes to integer handling
|
||||
---------------------------
|
||||
|
||||
* Invalid octal literals (containing digits larger than 7) now produce compile
|
||||
errors. For example, the following is no longer valid:
|
||||
|
||||
$i = 0781; // 8 is not a valid octal digit!
|
||||
|
||||
Previously the invalid digits (and any following valid digits) were simply
|
||||
ignored. As such $i previously held the value 7, because the last two digits
|
||||
were silently discarded.
|
||||
|
||||
* Bitwise shifts by negative numbers will now throw an ArithmeticError:
|
||||
|
||||
var_dump(1 >> -1);
|
||||
// ArithmeticError: Bit shift by negative number
|
||||
|
||||
* Left bitwise shifts by a number of bits beyond the bit width of an integer
|
||||
will always result in 0:
|
||||
|
||||
var_dump(1 << 64); // int(0)
|
||||
|
||||
Previously the behavior of this code was dependent on the used CPU
|
||||
architecture. For example on x86 (including x86-64) the result was int(1),
|
||||
because the shift operand was wrapped.
|
||||
|
||||
* Similarly right bitwise shifts by a number of bits beyond the bit width of an
|
||||
integer will always result in 0 or -1 (depending on sign):
|
||||
|
||||
var_dump(1 >> 64); // int(0)
|
||||
var_dump(-1 >> 64); // int(-1)
|
||||
|
||||
Relevant RFC: https://wiki.php.net/rfc/integer_semantics
|
||||
|
||||
Changes to string handling
|
||||
--------------------------
|
||||
|
||||
* Strings that contain hexadecimal numbers are no longer considered to be
|
||||
numeric and don't receive special treatment anymore. Some examples of the
|
||||
new behavior:
|
||||
|
||||
var_dump("0x123" == "291"); // bool(false) (previously true)
|
||||
var_dump(is_numeric("0x123")); // bool(false) (previously true)
|
||||
var_dump("0xe" + "0x1"); // int(0) (previously 16)
|
||||
|
||||
var_dump(substr("foo", "0x1")); // string(3) "foo" (previously "oo")
|
||||
// Notice: A non well formed numeric value encountered
|
||||
|
||||
filter_var() can be used to check if a string contains a hexadecimal number
|
||||
or convert such a string into an integer:
|
||||
|
||||
$str = "0xffff";
|
||||
$int = filter_var($str, FILTER_VALIDATE_INT, FILTER_FLAG_ALLOW_HEX);
|
||||
if (false === $int) {
|
||||
throw new Exception("Invalid integer!");
|
||||
}
|
||||
var_dump($int); // int(65535)
|
||||
|
||||
* Due to the addition of the Unicode Codepoint Escape Syntax for double-quoted
|
||||
strings and heredocs, "\u{" followed by an invalid sequence will now result in
|
||||
an error:
|
||||
|
||||
$str = "\u{xyz}"; // Fatal error: Invalid UTF-8 codepoint escape sequence
|
||||
|
||||
To avoid this the leading backslash should be escaped:
|
||||
|
||||
$str = "\\u{xyz}"; // Works fine
|
||||
|
||||
However, "\u" without a following { is unaffected. As such the following code
|
||||
won't error and will work the same as before:
|
||||
|
||||
$str = "\u202e"; // Works fine
|
||||
|
||||
Relevant RFCs:
|
||||
* https://wiki.php.net/rfc/remove_hex_support_in_numeric_strings
|
||||
* https://wiki.php.net/rfc/unicode_escape
|
||||
|
||||
Changes to error handling
|
||||
-------------------------
|
||||
|
||||
* There are now two exception classes: Exception and Error. Both classes
|
||||
implement a new interface Throwable. Type hints in exception handling code
|
||||
may need to be changed to account for this.
|
||||
|
||||
* Some fatal errors and recoverable fatal errors now throw an Error instead.
|
||||
As Error is a separate class from Exception, these exceptions will not be
|
||||
caught by existing try/catch blocks.
|
||||
|
||||
For the recoverable fatal errors which have been converted into an exception,
|
||||
it is no longer possible to silently ignore the error from an error handler.
|
||||
In particular, it is no longer possible to ignore type hint failures.
|
||||
|
||||
* Parser errors now generate a ParseError that extends Error. Error
|
||||
handling for eval()s on potentially invalid code should be changed to catch
|
||||
ParseError in addition to the previous return value / error_get_last()
|
||||
based handling.
|
||||
|
||||
* Constructors of internal classes will now always throw an exception on
|
||||
failure. Previously some constructors returned NULL or an unusable object.
|
||||
|
||||
* The error level of some E_STRICT notices has been changed.
|
||||
|
||||
Relevant RFCs:
|
||||
* https://wiki.php.net/rfc/engine_exceptions_for_php7
|
||||
* https://wiki.php.net/rfc/throwable-interface
|
||||
* https://wiki.php.net/rfc/internal_constructor_behaviour
|
||||
* https://wiki.php.net/rfc/reclassify_e_strict
|
||||
|
||||
Other language changes
|
||||
----------------------
|
||||
|
||||
* Removed support for static calls to non-static calls form an incompatible
|
||||
$this context. In this case $this will not be defined, but the call will be
|
||||
allowed with a deprecation notice. An example:
|
||||
|
||||
class A {
|
||||
public function test() { var_dump($this); }
|
||||
}
|
||||
|
||||
// Note: Does NOT extend A
|
||||
class B {
|
||||
public function callNonStaticMethodOfA() { A::test(); }
|
||||
}
|
||||
|
||||
(new B)->callNonStaticMethodOfA();
|
||||
|
||||
// Deprecated: Non-static method A::test() should not be called statically
|
||||
// Notice: Undefined variable $this
|
||||
NULL
|
||||
|
||||
Note that this only applies to calls from an incompatible context. If class B
|
||||
extended from A the call would be allowed without any notices.
|
||||
|
||||
* It is no longer possible to use the following class, interface and trait names
|
||||
(case-insensitive):
|
||||
|
||||
bool
|
||||
int
|
||||
float
|
||||
string
|
||||
null
|
||||
false
|
||||
true
|
||||
|
||||
This applies to class/interface/trait declarations, class_alias() and use
|
||||
statements.
|
||||
|
||||
Furthermore the following class, interface and trait names are now reserved
|
||||
for future use, but do not yet throw an error when used:
|
||||
|
||||
resource
|
||||
object
|
||||
mixed
|
||||
numeric
|
||||
|
||||
* The yield language construct no longer requires parentheses when used in an
|
||||
expression context. It is now a right-associative operator with precedence
|
||||
between the "print" and "=>" operators. This can result in different behavior
|
||||
in some cases, for example:
|
||||
|
||||
echo yield -1;
|
||||
// Was previously interpreted as
|
||||
echo (yield) - 1;
|
||||
// And is now interpreted as
|
||||
echo yield (-1);
|
||||
|
||||
yield $foo or die;
|
||||
// Was previously interpreted as
|
||||
yield ($foo or die);
|
||||
// And is now interpreted as
|
||||
(yield $foo) or die;
|
||||
|
||||
Such cases can always be resolved by adding additional parentheses.
|
||||
|
||||
. Removed ASP (<%) and script (<script language=php>) tags.
|
||||
(RFC: https://wiki.php.net/rfc/remove_alternative_php_tags)
|
||||
. Removed support for assigning the result of new by reference.
|
||||
. Removed support for scoped calls to non-static methods from an incompatible
|
||||
$this context. See details in https://wiki.php.net/rfc/incompat_ctx.
|
||||
. Removed support for #-style comments in ini files. Use ;-style comments
|
||||
instead.
|
||||
. $HTTP_RAW_POST_DATA is no longer available. Use the php://input stream instead.
|
||||
|
||||
Standard library changes
|
||||
========================
|
||||
|
||||
. substr() now returns an empty string instead of FALSE when the truncation happens on boundaries.
|
||||
. call_user_method() and call_user_method_array() no longer exists.
|
||||
. ob_start() no longer issues an E_ERROR, but instead an E_RECOVERABLE_ERROR in case an
|
||||
output buffer is created in an output buffer handler.
|
||||
. The internal sorting algorithm has been improved, what may result in
|
||||
different sort order of elements that compare as equal.
|
||||
. Removed dl() function on fpm-fcgi.
|
||||
. setcookie() with an empty cookie name now issues a WARNING and doesn't send an empty set-cookie header line anymore.
|
||||
|
||||
Other
|
||||
=====
|
||||
|
||||
- Curl:
|
||||
. Removed support for disabling the CURLOPT_SAFE_UPLOAD option. All curl file
|
||||
uploads must use the curl_file / CURLFile APIs.
|
||||
|
||||
- Date:
|
||||
. Removed $is_dst parameter from mktime() and gmmktime().
|
||||
|
||||
- DBA
|
||||
. dba_delete() now returns false if the key was not found for the inifile
|
||||
handler, too.
|
||||
|
||||
- GMP
|
||||
. Requires libgmp version 4.2 or newer now.
|
||||
. gmp_setbit() and gmp_clrbit() now return FALSE for negative indices, making
|
||||
them consistent with other GMP functions.
|
||||
|
||||
- Intl:
|
||||
. Removed deprecated aliases datefmt_set_timezone_id() and
|
||||
IntlDateFormatter::setTimeZoneID(). Use datefmt_set_timezone() and
|
||||
IntlDateFormatter::setTimeZone() instead.
|
||||
|
||||
- libxml:
|
||||
. Added LIBXML_BIGLINES parser option. It's available starting with libxml 2.9.0
|
||||
and adds suppport for line numbers >16-bit in the error reporting.
|
||||
|
||||
- Mcrypt
|
||||
. Removed deprecated mcrypt_generic_end() alias in favor of
|
||||
mcrypt_generic_deinit().
|
||||
. Removed deprecated mcrypt_ecb(), mcrypt_cbc(), mcrypt_cfb() and mcrypt_ofb()
|
||||
functions in favor of mcrypt_encrypt() and mcrypt_decrypt() with an
|
||||
MCRYPT_MODE_* flag.
|
||||
|
||||
- Session
|
||||
. session_start() accepts all INI settings as array. e.g. ['cache_limiter'=>'private']
|
||||
sets session.cache_limiter=private. It also supports 'read_and_close' which closes
|
||||
session data immediately after read data.
|
||||
. Save handler accepts validate_sid(), update_timestamp() which validates session
|
||||
ID existence, updates timestamp of session data. Compatibility of old user defined
|
||||
save handler is retained.
|
||||
. SessionUpdateTimestampHandlerInterface is added. validateSid(), updateTimestamp()
|
||||
is defined in the interface.
|
||||
. session.lazy_write(default=On) INI setting enables only write session data when
|
||||
session data is updated.
|
||||
|
||||
- Opcache
|
||||
. Removed opcache.load_comments configuration directive. Now doc comments
|
||||
loading costs nothing and always enabled.
|
||||
|
||||
- OpenSSL:
|
||||
. Removed the "rsa_key_size" SSL context option in favor of automatically
|
||||
setting the appropriate size given the negotiated crypto algorithm.
|
||||
. Removed "CN_match" and "SNI_server_name" SSL context options. Use automatic
|
||||
detection or the "peer_name" option instead.
|
||||
|
||||
- PCRE:
|
||||
. Removed support for /e (PREG_REPLACE_EVAL) modifier. Use
|
||||
preg_replace_callback() instead.
|
||||
|
||||
- PDO_pgsql:
|
||||
. Removed PGSQL_ATTR_DISABLE_NATIVE_PREPARED_STATEMENT attribute in favor of
|
||||
ATTR_EMULATE_PREPARES.
|
||||
|
||||
- Standard:
|
||||
. Removed string category support in setlocale(). Use the LC_* constants
|
||||
instead.
|
||||
. Removed set_magic_quotes_runtime() and its alias magic_quotes_runtime().
|
||||
|
||||
- JSON:
|
||||
. Rejected RFC 7159 incompatible number formats in json_decode string -
|
||||
top level (07, 0xff, .1, -.1) and all levels ([1.], [1.e1])
|
||||
. Calling json_decode with 1st argument equal to empty PHP string or value that
|
||||
after casting to string is empty string (NULL, FALSE) results in JSON syntax error.
|
||||
|
||||
- Stream:
|
||||
. Removed set_socket_blocking() in favor of its alias stream_set_blocking().
|
||||
|
||||
- XSL:
|
||||
. Removed xsl.security_prefs ini option. Use XsltProcessor::setSecurityPrefs()
|
||||
instead.
|
||||
|
||||
========================================
|
||||
2. New Features
|
||||
========================================
|
||||
|
||||
- Core
|
||||
. Added group use declarations.
|
||||
(RFC: https://wiki.php.net/rfc/group_use_declarations)
|
||||
. Added null coalesce operator (??).
|
||||
(RFC: https://wiki.php.net/rfc/isset_ternary)
|
||||
. Support for strings with length >= 2^31 bytes in 64 bit builds.
|
||||
. Closure::call() method added (works only with userland classes).
|
||||
. Added \u{xxxxxx} Unicode Codepoint Escape Syntax for double-quoted strings
|
||||
and heredocs.
|
||||
. define() now supports arrays as constant values, fixing an oversight where
|
||||
define() did not support arrays yet const syntax did.
|
||||
. Added the comparison operator (<=>), aka the spaceship operator.
|
||||
(RFC: https://wiki.php.net/rfc/combined-comparison-operator)
|
||||
. Added the yield from operator for delegating Generators like coroutines.
|
||||
(RFC: https://wiki.php.net/rfc/generator-delegation)
|
||||
. Reserved keywords can now be used in various new contexts.
|
||||
(RFC: https://wiki.php.net/rfc/context_sensitive_lexer)
|
||||
. Added support for scalar type declarations and strict mode using
|
||||
declare(strict_types=1) (RFC: https://wiki.php.net/rfc/scalar_type_hints_v5)
|
||||
. Added support for cryptographically secure user land RNG
|
||||
(RFC: https://wiki.php.net/rfc/easy_userland_csprng)
|
||||
|
||||
- Opcache
|
||||
. Added second level file based opcode cache. It may be enabled by setting
|
||||
opcache.file_cache=<DIR> configuration directive in php.ini. The second
|
||||
level cache may improve performance when SHM is full, at server restart or
|
||||
SHM reset. In addition, it's possibe to use file cache without SHM at all,
|
||||
using opcache.file_cache_only=1 (this may be useful for sharing hosting),
|
||||
and disable file cache consistency check, to speedup loading at the cost of
|
||||
safety, using opcache.file_cache_consistency_checks=0.
|
||||
. Added ability to move PHP code pages (PHP TEXT segment) into HUGE pages.
|
||||
It's possible to enable/disable this feature in php.ini through
|
||||
opcache.huge_code_pages=0/1. OS should be configured to provide huge pages.
|
||||
|
||||
- OpenSSL
|
||||
. Added "alpn_protocols" SSL context option allowing encrypted client/server
|
||||
streams to negotiate alternative protocols using the ALPN TLS extension when
|
||||
built against OpenSSL 1.0.2 or newer. Negotiated protocol information is
|
||||
accessible through stream_get_meta_data() output.
|
||||
|
||||
- Reflection
|
||||
. Added a ReflectionGenerator class (yield from Traces, current file/line,
|
||||
etc.)
|
||||
. Added a ReflectionType class to better support the new return type and
|
||||
scalar type declarations features. The new ReflectionParameter::getType()
|
||||
and ReflectionFunctionAbstract::getReturnType() methods both return an
|
||||
instance of ReflectionType.
|
||||
|
||||
- Stream:
|
||||
. New Windows only stream context options was added to allow blocking reads
|
||||
on pipes. To enable it, pass array("pipe" => array("blocking" => true))
|
||||
when creating the stream context. Be aware, that this option can under
|
||||
circumstances cause dead locks on the pipe buffer. However it can be useful
|
||||
in several CLI use case scenarios.
|
||||
|
||||
========================================
|
||||
3. Changes in SAPI modules
|
||||
========================================
|
||||
|
||||
- FPM
|
||||
. Fixed bug #65933 (Cannot specify config lines longer than 1024 bytes).
|
||||
. Listen = port now listen on all addresses (IPv6 and IPv4-mapped).
|
||||
|
||||
========================================
|
||||
4. Deprecated Functionality
|
||||
========================================
|
||||
|
||||
- Core
|
||||
. PHP 4 style constructors, where the constructor name is the same as the
|
||||
class name, are now deprecated.
|
||||
. Static calls to non-static methods are now deprecated.
|
||||
|
||||
- OpenSSL
|
||||
. The "capture_session_meta" SSL context option is now deprecated. Meta
|
||||
data concerning active crypto on a stream resource is now accessible
|
||||
through the return result from stream_get_meta_data().
|
||||
|
||||
========================================
|
||||
5. Changed Functions
|
||||
========================================
|
||||
|
||||
- parse_ini_file():
|
||||
- parse_ini_string():
|
||||
. Added scanner mode INI_SCANNER_TYPED to yield typed .ini values.
|
||||
- unserialize():
|
||||
. Added second parameter for unserialize function
|
||||
(RFC: https://wiki.php.net/rfc/secure_unserialize) allowing to specify
|
||||
acceptable classes:
|
||||
unserialize($foo, ["allowed_classes" => ["MyClass", "MyClass2"]]);
|
||||
|
||||
- proc_open():
|
||||
. The maximum number of pipes used by proc_open() was previously limited by
|
||||
hardcoded value of 16. This limit is now removed and the number of pipes is
|
||||
effectively limited by the amount of memory available to PHP.
|
||||
. New Windows only configuration option "blocking_pipes" can be used to
|
||||
force blocking reads on child process pipes. This covers several
|
||||
edge cases in CLI usage however can lead to dead locks. Also, this
|
||||
correlates with the new stream context options for pipes.
|
||||
|
||||
- array_column():
|
||||
The function now supports an array of objects as well as two-dimensional
|
||||
arrays. Only public properties are considered, and objects that make use of
|
||||
__get() for dynamic properties must also implement __isset().
|
||||
|
||||
- stream_context_create()
|
||||
It accepts now a Windows only configuration
|
||||
array("pipe" => array("blocking" => <boolean>)) which forces blocking reads
|
||||
on pipes. This option should be used carefully because due to the
|
||||
platform restrictions dead locks on pipe buffers are possible.
|
||||
|
||||
- dirname()
|
||||
A new optional argument ($levels) allow to go up various times
|
||||
dirname(dirname($foo)) => dirname($foo, 2);
|
||||
|
||||
- debug_zval_dump
|
||||
It prints now "int" instead of "long", and "float" instead of "double".
|
||||
|
||||
========================================
|
||||
6. New Functions
|
||||
========================================
|
||||
- GMP
|
||||
. Added gmp_random_seed().
|
||||
|
||||
- PCRE:
|
||||
. Added preg_replace_callback_array function
|
||||
(RFC: https://wiki.php.net/rfc/preg_replace_callback_array)
|
||||
|
||||
- Standard
|
||||
. Added intdiv() function for integer division.
|
||||
. Added error_clear_last() function to reset error state.
|
||||
|
||||
- Zip:
|
||||
. Added ZipArchive::setCompressionIndex() and ZipArchive::setCompressionName()
|
||||
for setting the compression method.
|
||||
|
||||
- Zlib:
|
||||
. Added deflate_init(), deflate_add(), inflate_init(), inflate_add()
|
||||
functions allowing incremental/streaming compression/decompression.
|
||||
|
||||
========================================
|
||||
7. New Classes and Interfaces
|
||||
========================================
|
||||
|
||||
|
||||
========================================
|
||||
8. Removed Extensions and SAPIs
|
||||
========================================
|
||||
|
||||
- sapi/aolserver
|
||||
- sapi/apache
|
||||
- sapi/apache_hooks
|
||||
- sapi/apache2filter
|
||||
- sapi/caudium
|
||||
- sapi/continuity
|
||||
- sapi/isapi
|
||||
- sapi/milter
|
||||
- sapi/nsapi
|
||||
- sapi/phttpd
|
||||
- sapi/pi3web
|
||||
- sapi/roxen
|
||||
- sapi/thttpd
|
||||
- sapi/tux
|
||||
- sapi/webjames
|
||||
- ext/mssql
|
||||
- ext/mysql
|
||||
- ext/sybase_ct
|
||||
- ext/ereg
|
||||
|
||||
For more details see
|
||||
|
||||
https://wiki.php.net/rfc/removal_of_dead_sapis_and_exts
|
||||
https://wiki.php.net/rfc/remove_deprecated_functionality_in_php7
|
||||
|
||||
NOTE: NSAPI was not voted in the RFC, however it was removed afterwards. It turned
|
||||
out, that the corresponding SDK isn't available anymore.
|
||||
|
||||
========================================
|
||||
9. Other Changes to Extensions
|
||||
========================================
|
||||
|
||||
- Mhash
|
||||
Mhash is not an extension anymore, use function_exists("mhash") to check whether
|
||||
it is avaliable.
|
||||
|
||||
- GD
|
||||
The bundled libgd requires libwebp instead of libvpx for the WebP functionality.
|
||||
|
||||
========================================
|
||||
10. New Global Constants
|
||||
========================================
|
||||
|
||||
- Core
|
||||
. PHP_INT_MIN added.
|
||||
|
||||
- PCRE
|
||||
. This error constant is added to signal errors due to stack size limitations
|
||||
when PCRE JIT support is enabled:
|
||||
. PREG_JIT_STACKLIMIT_ERROR
|
||||
|
||||
- Zlib
|
||||
. These constants are added to control flush behavior with the new
|
||||
incremental deflate_add() and inflate_add() functions:
|
||||
. ZLIB_NO_FLUSH
|
||||
. ZLIB_PARTIAL_FLUSH
|
||||
. ZLIB_SYNC_FLUSH
|
||||
. ZLIB_FULL_FLUSH
|
||||
. ZLIB_BLOCK
|
||||
. ZLIB_FINISH
|
||||
|
||||
- GD
|
||||
. T1Lib support removed, thus lifting the optional dependency on T1Lib, the
|
||||
following is therefore not available anymore:
|
||||
|
||||
Functions:
|
||||
- imagepsbbox()
|
||||
- imagepsencodefont()
|
||||
- imagepsextendedfont()
|
||||
- imagepsfreefont()
|
||||
- imagepsloadfont()
|
||||
- imagepsslantfont()
|
||||
- imagepstext()
|
||||
|
||||
Resources:
|
||||
- 'gd PS font'
|
||||
- 'gd PS encoding'
|
||||
|
||||
========================================
|
||||
11. Changes to INI File Handling
|
||||
========================================
|
||||
|
||||
- Core
|
||||
. Removed asp_tags ini directive. Trying to enable it will result in a fatal
|
||||
error.
|
||||
. Removed always_populate_raw_post_data ini directive.
|
||||
|
||||
========================================
|
||||
12. Windows Support
|
||||
========================================
|
||||
|
||||
- Core
|
||||
. Support for native 64 bit integers in 64 bit builds.
|
||||
. Support for large files in 64 bit builds.
|
||||
. Support for getrusage()
|
||||
|
||||
- ftp
|
||||
. The ftp extension is always shipped shared
|
||||
. For SSL support, the dependency on the openssl extension was abolished. Instead
|
||||
it depends alone on the openssl library. If it's present at the compile time,
|
||||
ftp_ssl_connect() is enabled automatically.
|
||||
|
||||
- imap
|
||||
. Static building of ext/imap is disabled
|
||||
|
||||
- odbc
|
||||
. The odbc extension is always shipped shared
|
||||
|
||||
========================================
|
||||
13. Other Changes
|
||||
========================================
|
||||
|
||||
- Core
|
||||
. Instead of being undefined and platform-dependent, NaN and Infinity will
|
||||
always be zero when cast to integer.
|
||||
. Calling a method on a non-object now raises a catchable error instead of a
|
||||
fatal error; see: https://wiki.php.net/rfc/catchable-call-to-member-of-non-object
|
||||
. Error messages for zend_parse_parameters, type hints and conversions now
|
||||
always say "integer" and "float" instead of "long" and "double".
|
||||
. Output buffering now continues to work for an aborted connection if
|
||||
ignore_user_abort is set to true.
|
||||
|
||||
@@ -1,25 +1,7 @@
|
||||
PHP 7.0 INTERNALS UPGRADE NOTES
|
||||
PHP 7.1 INTERNALS UPGRADE NOTES
|
||||
|
||||
0. Wiki Examples
|
||||
1. Internal API changes
|
||||
e. New data types
|
||||
f. zend_parse_parameters() specs
|
||||
g. sprintf() formats
|
||||
h. HashTable API
|
||||
i. New portable macros for large file support
|
||||
j. New portable macros for integers
|
||||
k. get_class_entry object handler info
|
||||
l. get_class_name object handler info
|
||||
m. Other portable macros info
|
||||
n. ZEND_ENGINE_2 removal
|
||||
o. Updated final class modifier
|
||||
p. TSRM changes
|
||||
q. gc_collect_cycles() is now hookable
|
||||
r. PDO uses size_t for lengths
|
||||
s. Resource API changes
|
||||
t. Optimized strings concatenation.
|
||||
u. Streams changes
|
||||
v. Sort algorithm changes
|
||||
|
||||
2. Build system changes
|
||||
a. Unix build system changes
|
||||
@@ -39,213 +21,6 @@ changes. See: https://wiki.php.net/phpng-upgrading
|
||||
1. Internal API changes
|
||||
========================
|
||||
|
||||
e. New data types
|
||||
|
||||
String
|
||||
|
||||
Besides the old way of accepting the strings with 's', the new 'S' ZPP spec
|
||||
was introduced. It expects an argument of the type zend_string *. String lengths
|
||||
in it are bound to the size_t datatype.
|
||||
|
||||
Integer types
|
||||
|
||||
Integers do no more depend on the firm 'long' type. Instead a platform
|
||||
dependent integer type is used, it is called zend_long. That datatype is
|
||||
defined dynamically to guarantee the consistent 64 bit support. The zval
|
||||
field representing user land integer it bound to zend_long.
|
||||
|
||||
Signed integer is defined as zend_long, unsigned integer as zend_ulong
|
||||
inside Zend.
|
||||
|
||||
Other datatypes
|
||||
|
||||
zend_off_t - portable off_t analogue
|
||||
zend_stat_t - portable 'struct stat' analogue
|
||||
|
||||
These datatypes are declared to be portable across platforms. Thus, direct
|
||||
usage of the functions like fseek, stat, etc. as well as direct usage of
|
||||
off_t and struct stat is strongly not recommended. Instead the portable
|
||||
macros should be used.
|
||||
|
||||
zend_fseek - portable fseek equivalent
|
||||
zend_ftell - portable ftell equivalent
|
||||
zend_lseek - portable lseek equivalent
|
||||
zend_fstat - portable fstat equivalent
|
||||
zend_stat - portable stat equivalent
|
||||
|
||||
f. zend_parse_parameters() specs
|
||||
|
||||
The new spec 'S' introduced, which expects an argument of type zend_string *.
|
||||
The 'l' spec expects a parameter of the type zend_long, not long anymore.
|
||||
The 's' spec expects parameters of the type char * and size_t, no int anymore.
|
||||
|
||||
g. sprintf() formats
|
||||
|
||||
New printf modifier 'p' was implemented to platform independently output zend_long,
|
||||
zend_ulong and php_size_t datatypes. That modifier can be used with 'd', 'u', 'x' and 'o'
|
||||
printf format specs with spprintf, snprintf and the wrapping printf implementations.
|
||||
%pu is sufficient for both zend_ulong and php_size_t. the code using %p spec to output
|
||||
pointer address might need to be enclosed into #ifdef when it unlickily followed by 'd',
|
||||
'u', 'x' or 'o'.
|
||||
|
||||
The only exceptions are the snprintf and zend_sprintf functions yet, because in some cases
|
||||
they can use the implemenations available on the system, not the PHP one. With snprintf the
|
||||
macros ZEND_INT_FMT and ZEND_UINT_FMT should be used.
|
||||
|
||||
h. HashTable API
|
||||
|
||||
Datatype for array indexes was changed to zend_ulong, for string keys to zend_string *.
|
||||
|
||||
i. New portable macros for large file support
|
||||
|
||||
Function(s) Alias Comment
|
||||
stat, _stat64 zend_stat for use with zend_stat_t
|
||||
fstat, _fstat64 zend_fstat for use with zend_stat_t
|
||||
lseek, _lseeki64 zend_lseek for use with zend_off_t
|
||||
ftell, _ftelli64 zend_ftell for use with zend_off_t
|
||||
fseek, _fseeki64 zend_fseek for use with zend_off_t
|
||||
|
||||
j. New portable macros for integers
|
||||
|
||||
Function(s) Alias Comment
|
||||
snprintf with "%ld" or "%lld", _ltoa_s, _i64toa_s ZEND_LTOA for use with zend_long
|
||||
atol, atoll, _atoi64 ZEND_ATOL for use with zend_long
|
||||
strtol, strtoll, _strtoi64 ZEND_STRTOL for use with zend_long
|
||||
strtoul, strtoull, _strtoui64 ZEND_STRTOUL for use with zend_long
|
||||
abs, llabs, _abs64 ZEND_ABS for use with zend_long
|
||||
- ZEND_LONG_MAX replaces LONG_MAX where appropriate
|
||||
- ZEND_LONG_MIN replaces LONG_MIN where appropriate
|
||||
- ZEND_ULONG_MAX replaces ULONG_MAX where appropriate
|
||||
- SIZEOF_ZEND_LONG reworked SIZEOF_ZEND_LONG representing the size of zend_long datatype
|
||||
- ZEND_SIZE_MAX Max value of size_t
|
||||
- Z_L casts an integral constant to zend_long
|
||||
- Z_UL casts an integral constant to zend_ulong
|
||||
|
||||
The macro ZEND_ENABLE_ZVAL_LONG64 reveals whether zval operates on 64 or 32 bit integer.
|
||||
|
||||
k. The get_class_entry object handler is no longer available. Instead
|
||||
zend_object.ce is always used.
|
||||
|
||||
l. The get_class_name object handler is now only used for displaying class
|
||||
names in debugging functions like var_dump(). It is no longer used in
|
||||
get_class(), get_parent_class() or similar.
|
||||
|
||||
The handler is now obligatory, no longer accepts a `parent` argument and
|
||||
must return a non-NULL zend_string*, which will be released by the caller.
|
||||
|
||||
m. Other portable macros info
|
||||
|
||||
ZEND_SECURE_ZERO - zeroes chunk of memory
|
||||
ZEND_VALID_SOCKET - validates a php_socket_t variable
|
||||
|
||||
ZEND_FASTCALL is defined to use __vectorcall convention on VS2013 and above
|
||||
ZEND_NORETURN is defined as __declspec(noreturn) on VS
|
||||
|
||||
n. The ZEND_ENGINE_2 macro has been removed. A ZEND_ENGINE_3 macro has been added.
|
||||
|
||||
o. Removed ZEND_ACC_FINAL_CLASS in favour of ZEND_ACC_FINAL, turning final class
|
||||
modifier now a different class entry flag. Update your extensions.
|
||||
|
||||
p. TSRM changes
|
||||
|
||||
The TSRM layer undergone significant changes. It is not necessary anymore to
|
||||
pass the tsrm_ls pointer explicitly. The TSRMLS_* macros should not be used
|
||||
in any new developments.
|
||||
|
||||
The recommended way accessing globals in TS builds is by implementing it
|
||||
to use a local thread unique pointer to the corresponding data pool. These
|
||||
are the new macros that serve to achieve this goal:
|
||||
|
||||
- ZEND_TSRMG - based on TSRMG and if static pointer for data pool access is
|
||||
implemented, will use it
|
||||
- ZEND_TSRMLS_CACHE_EXTERN - to be used in a header shared across multiple
|
||||
C/C++ files
|
||||
- ZEND_TSRMLS_CACHE_DEFINE - to be used in the main extension C/C++ file
|
||||
- ZEND_TSRMLS_CACHE_UPDATE - to be integrated at the top of the globals
|
||||
ctor or RINIT function
|
||||
- ZEND_ENABLE_STATIC_TSRMLS_CACHE - to be used in the config.[m4|w32] for
|
||||
enabling the globals access per thread unique pointer
|
||||
- TSRMLS_CACHE - expands to the variable name which links to the thread
|
||||
unique data pool
|
||||
|
||||
Note that usually it will work without implementing the globals access per
|
||||
a thread unique pointer, however it might cause a slowdown. The reason is
|
||||
that the access model to the extension/SAPI own globals as well as the
|
||||
access to the core globals is determined in the compilation phase depending
|
||||
on whether ZEND_ENABLE_STATIC_TSRMLS_CACHE macro is defined.
|
||||
|
||||
Due to the current compiler evolution state, the TSRMLS_CACHE pointer
|
||||
(when implemented) has to be present and updated in every binary unit which
|
||||
is not compiled statically into PHP. So any DLL, DSO, EXE, etc. has to take
|
||||
care about defining and updating it's TSRMLS cache. An update should happen
|
||||
before any globals was accessed.
|
||||
|
||||
Porting an extension or SAPI is usually as easy as removing all the TSRMLS_*
|
||||
occurrences and integrating the macros mentioned above. However if tsrm_ls
|
||||
is used explicitly, its usage can be considered obsolete in most cases.
|
||||
Additionally, if an extension triggers its own threads, TSRMLS_CACHE shouldn't
|
||||
be passed to that threads directly.
|
||||
|
||||
When working with CTOR/DTOR for the extension globals, only the data passed
|
||||
as parameters should be touched. For example, don't use code like
|
||||
free(MYEXT_G(vars)); inside globals destructor, as it possibly can destroy
|
||||
the data from a wrong thread. Instead use the pointer to the data delivered
|
||||
into the destructor. So the previous example could look like
|
||||
free(my_struct->vars); given the income was casted to (struct my_struct *).
|
||||
|
||||
A new macro was introduced to simplify the declaration to the extension
|
||||
globals. A simplified declaration looks as follows
|
||||
|
||||
#define MYEXT_G(v) ZEND_MODULE_GLOBALS_ACCESSOR(myext, v)
|
||||
|
||||
Another new macro ZEND_MODULE_GLOBALS_BULK(myext) delivers the corresponding
|
||||
globals struct as a whole.
|
||||
|
||||
Two new storage specifiers was introduced.
|
||||
|
||||
ZEND_EXT_TLS - expand to an appropriate thread specific storage specifier in
|
||||
the thread safe build, expands to empty in a non thread safe
|
||||
build.
|
||||
ZEND_TLS - expands to an appropriate thread specific storage specifier
|
||||
with static visibility in the thread safe build, expands to
|
||||
static specifier in a non thread safe build.
|
||||
|
||||
Variables declared with these storage specifiers can not be shared across
|
||||
threads. While ZEND_TLS enforces the local scope visibility, ZEND_EXT_TLS
|
||||
pertains to the visiblity across several compilation units. In both cases,
|
||||
there's no portable way to achieve the visibility across shared objects.
|
||||
Thus, these specifiers are not compatible with ZEND_API and PHPAPI specifiers.
|
||||
|
||||
q. gc_collect_cycles() is now a function pointer, and can be replaced in the
|
||||
same manner as zend_execute_ex() if needed (for example, to include the
|
||||
time spent in the garbage collector in a profiler). The default
|
||||
implementation has been renamed to zend_gc_collect_cycles(), and is
|
||||
exported with ZEND_API.
|
||||
|
||||
r. In accordance with general use of size_t as string length, all PDO API
|
||||
functions now use size_t for string length.
|
||||
|
||||
s. Removed ZEND_REGISTER/FETCH_RESOURCE, use zend_fetch_resource and
|
||||
and zend_register_resource instead, zend_fetch_resource accepts a zend_resource *
|
||||
as first argument, if you still need to fetch a resource from zval, use
|
||||
zend_fetch_resource_ex. More details can be found in Zend/zend_list.c.
|
||||
|
||||
t. Optimized strings concatenation.
|
||||
ZEND_ADD_STRING/VAR/CHAR are replaced with ZEND_ROPE_INIT, ZEND_ROPE_ADD,
|
||||
ZEND_ROPE_END.
|
||||
Instead of reallocation and copying string on each ZEND_ADD_STRING/VAR/CAHR,
|
||||
collect all the strings and then allocate and construct the resulting string once.
|
||||
|
||||
u. Streams changes
|
||||
- It is possible to do blocking reads on Windows pipes. It can be done either
|
||||
using context stream option PHP_STREAM_OPTION_PIPE_BLOCKING or
|
||||
adding STREAM_USE_BLOCKING_PIPE when opening the stream.
|
||||
|
||||
v. Sort algorithm changes
|
||||
- Improved zend_qsort(using hybrid sorting algo) for better performance,
|
||||
and also renamed zend_qsort to zend_sort.
|
||||
- Added stable sorting algo zend_insert_sort.
|
||||
|
||||
========================
|
||||
2. Build system changes
|
||||
========================
|
||||
@@ -254,65 +29,7 @@ changes. See: https://wiki.php.net/phpng-upgrading
|
||||
|
||||
b. Windows build system changes
|
||||
|
||||
- Besides Visual Studio, building with Clang or Intel Composer is now
|
||||
possible. To enable an alternative toolset, add the option
|
||||
--with-toolset=[vs,clang,icc] to the configure line. The default
|
||||
toolset is vs. Still clang or icc need the correct environment
|
||||
which involves many tools from the vs toolset.
|
||||
|
||||
The toolset option is supported by phpize as well.
|
||||
|
||||
AWARENESS The only recommended and supported toolset to produce production
|
||||
ready binaries is Visual Studio. Still other compilers can be used now for
|
||||
testing and analyzing purposes.
|
||||
|
||||
- configure.js now produces response files which are passed to the linker
|
||||
and library manager. This solves the issues with the long command lines
|
||||
which can exceed the OS limit.
|
||||
|
||||
- with clang toolset, an option --with-uncritical-warn-choke is available,
|
||||
which suppresses the most frequent false positive warnings
|
||||
|
||||
- the --with-mp option will by default utilize all the available cores. It's
|
||||
enabled by default for release builds and can be disabled with the special
|
||||
"disable" keyword.
|
||||
|
||||
========================
|
||||
3. Module changes
|
||||
========================
|
||||
|
||||
Session:
|
||||
|
||||
- PS_MOD_UPDATE_TIMESTAMP() session save handler definition is added. New
|
||||
save handler should use PS_MOD_UPDATE_TIMESTAMP() definition. Save handler
|
||||
must not refer/change PS() variables directly from save handler. Use
|
||||
parameters.
|
||||
- PS_MOD()/PS_MOD_SID() macro exist only for transition. Beware these
|
||||
save handlers are less secure and slower than PS_MOD_UPDATE_TIMESTAMP().
|
||||
- PS(invalid_session_id) was removed. It was never worked as it supposed.
|
||||
To report invalid session ID, use PS_VALIDATE_SID() handler.
|
||||
- PS_VALIDATE_SID() defines session ID validation handler. This handler
|
||||
must validate if requested session ID exists in session data storage or not.
|
||||
Do not access PS(id) directly, but use this handler and it's parameter.
|
||||
- PS_UPDATE_TIMESTAMP() defines timestamp updating handler. This handler
|
||||
must update session data timestamp for GC if it is needed. e.g. Memcache
|
||||
updates timestamp on read, so it does not need to update timestamp. Return
|
||||
SUCCESS simply for this case.
|
||||
- PS_CREATE_SID() should check session ID collision. Return NULL for failure.
|
||||
- More documentation can be found in ext/session/mod_files.c as comments.
|
||||
mod_files.c may be used as reference implementation.
|
||||
|
||||
Openssl:
|
||||
- several ext/openssl functions require the inclusion of the applink shim
|
||||
as documented in the OpenSSL FAQ https://www.openssl.org/support/faq.html#PROG2
|
||||
to properly work on Windows. While this primarily affects the OpenSSL
|
||||
functionality, the shim needs to be included into the executable file
|
||||
which loads the extension DLL, not into the extension DLL itself. Alternatively
|
||||
it can be compiled and linked with the main program as a separate object file.
|
||||
More information and explanation in the linked OpenSSL FAQ.
|
||||
|
||||
Thus, this primarily affects any WAMP or other redistributions bundling the
|
||||
official PHP release zipballs or building from sources. The applink shim is
|
||||
already integrated with all the PHP executables from the official distribution
|
||||
starting with 7.0.0beta1.
|
||||
|
||||
|
||||
Reference in New Issue
Block a user