Commit Graph

248 Commits

Author SHA1 Message Date
Nikita Popov
14f599ea7d Use zend_long for resource ID
Currently, resource IDs are limited to 32-bits. As resource IDs
are not reused, this means that resource ID overflow for
long-running processes is very possible.

This patch switches resource IDs to use zend_long instead, which
means that on 64-bit systems, 64-bit resource IDs will be used.
This makes resource ID overflow practically impossible.

The tradeoff is an 8 byte increase in zend_resource size.

Closes GH-7436.
2021-08-31 14:58:59 +02:00
Joe Watkins
00c668a15d
Drop TsHashTable (#7351) 2021-08-08 10:45:44 +02:00
George Peter Banyard
fb52b3c915 [skip-ci] Fix comments and UPGRADING.INTERNALS for zend_type changes 2021-07-28 13:31:52 +02:00
Levi Morrison
ae8647d9d3
Remove leading underscore for _zend_hash_find_known_hash (#7260)
Convert zend_hash_find_ex(..., 1) to zend_hash_find_known_hash(...)
Convert zend_hash_find_ex(..., 0) to zend_hash_find(...)

Also add serializable changes to UPGRADING.INTERNALS summary
2021-07-20 17:07:17 -06:00
Joe Watkins
322864b569
Drop serial denier functions 2021-07-20 13:11:11 +02:00
Nikita Popov
814a932734 Add ZEND_ACC_NOT_SERIALIZABLE flag
This prevents serialization and unserialization of a class and its
children in a way that does not depend on the zend_class_serialize_deny
and zend_class_unserialize_deny handlers that will be going away
in PHP 9 together with the Serializable interface.

In stubs, `@not-serializable` can be used to set this flag.

This patch only uses the new flag for a handful of Zend classes,
converting the remainder is left for later.

Closes GH-7249.
Fixes bug #81111.
2021-07-19 15:59:11 +02:00
George Peter Banyard
453a5163ce [skip-ci] Fixup UPGRADING documents
Some entries were in the wrong section/wrong document.
2021-07-17 23:27:26 +02:00
Nikita Popov
a733b1ada7 Restore zend_atoi()
I dropped this in preparation for changes that I didn't end up
doing. Restore the function for now to avoid unnecessary churn for
extensions.
2021-07-16 14:46:56 +02:00
Nikita Popov
5f8489a11d Add upgrading note
I was originally planning more changes here, but then I realized
that zend_atol() is actually used to parse all numbers in inis,
not just those expecting sizes. I think I'll just leave it at
that.

[ci skip]
2021-07-13 11:03:12 +02:00
Nikita Popov
0d6358f2cf Drop support for printf p modifier
To be conservative, cause a fatal error if the p modifier is
encountered, in case this is still used by some extension.
2021-06-16 17:59:00 +02:00
Nikita Popov
e11468a79b Remove ZVAL_NEW_ARR() macro
This macro is a footgun because it creates an uninitialized array
(only an allocation). This macro is no longer used in php-src,
and we have better alternatives like array_init() or
ZVAL_ARR(arr, zend_new_array(size_hint)).
2021-06-07 12:49:58 +02:00
Anatol Belski
805b391d99
NEWS: UPGRADING.INTERNALS: Add PCRE2 10.37 info
[ci skip]

Signed-off-by: Anatol Belski <ab@php.net>
2021-05-30 13:06:16 +02:00
George Peter Banyard
612609e1bd
Refactor PGSQL extension to use zend_string*
* Prevents some unnecessary strlen() computation
 * Use interned "NULL"
 * Certain PGSQL_API functions now accept zend_string* instead of char*

Closes GH-6792
2021-04-19 20:33:40 +01:00
George Peter Banyard
fabcfd6d81
Formalize return type to zend_result for PGSQL_API functions 2021-04-19 20:33:05 +01:00
George Peter Banyard
dcdc5d9069 Drop -Wno-implicit-fallthrough compiler flag
And add it back to ext/date, ext/hash, and ext/opcache
2021-04-19 13:59:18 +01:00
twosee
cb8f39f247
Add zend_get_opcode_id() to get opcode id from name 2021-04-06 11:44:10 +08:00
George Peter Banyard
caaf2e9981 [skip-ci] Update UPGRADING documents for the new argument for fputcsv() 2021-03-29 13:55:18 +01:00
Dmitry Stogov
c732ab400a Change Zend Stream API to use zend_string* instead of char*.
This allows to eliminate re-calculation of string lenght and hash value.
See the detailed list of changes in UPGRADING.INTERNALS.
2021-03-16 20:31:36 +03:00
George Peter Banyard
0807c6cbb0 Remove php_pdo_str_tolower_dup() function 2021-03-15 14:48:33 +00:00
Máté Kocsis
91739b8c89
Fix bug #80816 Document the removal of alias class entries from ext/spl
Closes GH-6748 [skip-ci]
2021-03-03 09:43:55 +01:00
Anatol Belski
6055b72d0e UPGRADING: Add note about xxHash secret and fix a typo
[ci skip]

Signed-off-by: Anatol Belski <ab@php.net>
2021-02-21 13:36:28 +01:00
George Peter Banyard
a78aea8948 Refactor PDO's last inserted ID handler to use and return zend_string
Closes GH-6617
2021-01-19 11:54:25 +00:00
George Peter Banyard
94ea8e247b Refactor PDO doer handler to use zend_string 2021-01-19 11:42:39 +00:00
George Peter Banyard
63cda0fea8 Refactor PDO's quoter handler to return a zend_string
Closes GH-6547
2021-01-07 15:53:48 +00:00
George Peter Banyard
9052f3b7d2 Update UPGRADIN.INTERNALS 2021-01-06 10:26:37 +00:00
Nikita Popov
caa710037e Rewrite PDO result binding
Instead of requiring the type to be determined in advance by the
describer function and then requiring get_col to return a buffer
of appropriate type, allow get_col to return an arbitrary zval.
See UPGRADING.INTERNALS for a more detailed description of the
change.

This makes the result fetching simpler, more efficient and more
flexible. The general possibility already existed via the special
PDO_PARAM_ZVAL type, but the usage was very inconvenient and/or
inefficient. Now it's possible to easily implement behavior like
"return int if it fits, otherwise string" and to avoid any kind
of complex management of temporary buffers.

This also fixes bug #40913 (our second highest voted bug of all
time, for some reason). PARAM_LOB result bindings will now
consistently return a stream resource, independently of the used
database driver.

I've tried my best to update all PDO drivers for this change, but
some of the changes may be broken, as I cannot test or even build
some of these drivers (in particular PDO dblib and PDO oci).
Fixes are appreciated -- a working CI setup would be even more
appreciated ;)
2020-12-22 15:56:34 +01:00
Anatol Belski
ffcc93e3e5 UPGRADING.INTERNALS: Document hash init signature changes [ci skip]
Signed-off-by: Anatol Belski <ab@php.net>
2020-12-13 16:52:01 +01:00
Gabriel Caruso
14806e0824
Prepare for PHP 8.1
Closes GH-6305.
2020-10-09 11:37:27 +02:00
George Peter Banyard
07a2f30417 Extensions should have the final say on their compiler flags
Currently compiler flags passed by extensions using the standard
``PHP_NEW_EXTENSION`` and ``PHP_ADD_SOURCES`` m4 macros are prepended
before the ones defined by ``Zend/Zend.m4``.

This was not really an issue before as ``Zend.m4`` only included
``-Wall`` but since the addition of ``-Wextra`` various issue about
disabling flags have been brought up.

A preliminary attempt was done in commit 5c1cf7669b
but this turns out to be more or less irrelevant.

The root issue is that  ``PHP_NEW_EXTENSION`` and ``PHP_ADD_SOURCES`` call the
``PHP_ADD_SOURCES_X`` macro and pass their flags as the 3rd argument which prepends
the flags. There exists a 6th argument for this macro which appends them but from a
cursory look at https://heap.space/search?full=PHP_ADD_SOURCES_X&project=php-src
this is not used. Moreover, the comment describing this macro explicitly informs
that this macro should not be used directly.

As such we drop the 6th argument of ``PHP_ADD_SOURCES_X`` and move the `special-flags`
argument to be appended instead of prepended.

Closes GH-6204
2020-09-28 13:18:47 +01:00
Christoph M. Becker
3e33e1e86d Check linker compatibility directly from HMODULE
Checking the linker compatibility with extranous `ImageLoad()` calls is
possible, but unnecessary, since the modules are either already loaded
or loaded shortly afterwards, so that we can get the required
information directly from the module handles.  And actually, doing
`ImageLoad()` as well as `LoadLibrary()` leaves a tiny room for a race
condition, because both functions will lookup the module in the search
path, so there is no *guarantee* that both are dealing with the same
module.  Dropping the `ImageLoad()` calls also has the advantage to no
longer face the issue reported in bug #79557.  A very minor additional
advantage is that we no longer have to link against Imagehlp.dll.

Furthermore, there is no need to check for CRT compatibility multiple
times, so we can simplify the signature of `php_win32_crt_compatible`,
and at the same time clean up main.c a bit.

These changes require to change the signature of the exported
`php_win32_image_compatible` and `php_win32_crt_compatible` functions,
which now expect a `HMODULE` and nothing, respectively, instead of the
module name.
2020-09-21 16:25:31 +02:00
Sammy Kaye Powers
12306728c5
Add system ID entropy API
The `zend_system_id` is a (true global) system ID that fingerprints a process state. When extensions add engine hooks during MINIT/startup, entropy is added the system ID for each hook. This allows extensions to identify that changes have been made to the engine since the last PHP process restart.

Closes GH-5871
2020-09-18 14:26:44 -07:00
Nikita Popov
34bb5ba2ea Remove support for EXT_NOP
This is an annoying edge case that regularly gets broken. As we're
not aware of significant users of this API, and there are other
ways to hook this, remove support for EXT_NOP.
2020-09-18 11:03:08 +02:00
Benjamin Eberlei
1359a52d5b Rename zend_error_notify APIs to zend_observer_error* 2020-09-14 19:29:14 +02:00
George Peter Banyard
7b3ac296a5 Fix mismatch between macro and struct definition 2020-09-03 14:01:45 +02:00
George Peter Banyard
fa8d9b1183 Improve type declarations for Zend APIs
Voidification of Zend API which always succeeded
Use bool argument types instead of int for boolean arguments
Use bool return type for functions which return true/false (1/0)
Use zend_result return type for functions which return SUCCESS/FAILURE as they don't follow normal boolean semantics

Closes GH-6002
2020-08-28 15:41:27 +02:00
George Peter Banyard
1b2ec73c1d Drop various unused macros/APIs
Also convert_libmagic_pattern() to return a zend_string*

Closes GH-6029
2020-08-26 12:59:43 +02:00
Nikita Popov
45ece5bf19 Add UPGRADING.INTERNALS notes for zend_object* changes
Closes GH-5953.
2020-08-07 16:40:27 +02:00
Máté Kocsis
af80d8a14e
Add more argument types to stubs
Closes GH-5943
2020-08-07 12:35:30 +02:00
Nikita Popov
0d836a39a7 Revert "Prepare for PHP 8.1"
This reverts commit 1ab4d0e6b7.
This reverts commit a359635cb1.
2020-08-04 22:24:44 +02:00
Gabriel Caruso
a359635cb1
Prepare for PHP 8.1 2020-08-04 18:46:14 +02:00
Tyson Andre
650801ce45 [skip ci] Fix grammar/typo nits in docs
The PHP error message says "well-formed", not "well formed"

Fixes GH-5920
2020-08-01 18:03:45 -04:00
Máté Kocsis
02b03df91a
Document the signature change of zend_get_closure_method_def() 2020-07-31 10:04:49 +02:00
Nikita Popov
e2f39f84e2 Remove PHP_CHECK_GCC_ARG()
In favor of AX_CHECK_COMPILE_FLAG(), which we bundle since at least
PHP 7.

Closes GH-5904.
2020-07-29 15:07:53 +02:00
Benjamin Eberlei
4890bf19aa Add error notification callbacks to UPGRADING.INTERNALS 2020-07-17 15:51:15 +02:00
Nikita Popov
f60cf0cfe7 Remove type argument from zend_get_zval_ptr
As pointed out by Levi, this is unused, and we already changed
the signature of this function for PHP 8.
2020-07-15 09:51:51 +02:00
George Peter Banyard
4f3eccfd4d Use consistent types
uint32_t type for argument count
size_t for length of char*
zend_bool for a zval bool arg

Closes GH-5845
2020-07-13 13:30:54 +02:00
Nikita Popov
0280c64a2e Add upgrading note
[ci skip]
2020-07-13 11:47:25 +02:00
George Peter Banyard
9839752a9c Voidify some ZEND_API functions
Closes GH-5805
2020-07-09 14:15:57 +02:00
Nikita Popov
302933daea Remove no_separation flag 2020-07-07 09:30:24 +02:00
Remi Collet
8d1a1120bf [skip ci] add upgrade note
Closes GH-5798
2020-07-06 10:57:55 +02:00