Commit Graph

2856 Commits

Author SHA1 Message Date
Niels Dossche
1b171bb6b4
Merge branch 'PHP-8.3'
* PHP-8.3:
  Fix GH-15918: Assertion failure in ext/spl/spl_fixedarray.c
2024-09-20 17:34:54 +02:00
Niels Dossche
9774cedb01
Fix GH-15918: Assertion failure in ext/spl/spl_fixedarray.c
SplFixedArray should've never get supported in ArrayObject because it's
overloaded, and so that breaks assumptions. This regressed in c4ecd82f.

Closes GH-15947.
2024-09-20 17:34:23 +02:00
Gina Peter Banyard
f756b96e06
Make CSV deprecation less annoying to deal with (#15569) 2024-09-13 15:07:26 +01:00
DanielEScherzer
db545767e5
Rename ZEND_STR_DEPRECATED to ZEND_STR_DEPRECATED_CAPITALIZED (#15831)
To match other capitalized strings like `ZEND_STR_UNKNOWN_CAPITALIZED` and
`ZEND_STR_ARRAY_CAPITALIZED`. Since this known string was only added in PHP
8.4, no backwards compatibility alias is needed.
2024-09-10 22:45:23 +01:00
DanielEScherzer
5dd0575698
Generated arginfo header files: combine preprocessor conditional blocks (#15736)
When functions' or class methods' availability is based on some preprocessor
condition, the generated arginfo header files wrap the declarations in the
preprocessor `#if` conditional blocks, one per declaration, even if they are in
the same conditional block based on comments in the stub file. Instead of
having multiple conditional blocks one after the other with the same condition,
combine them into a single conditional block.
2024-09-04 13:04:22 +02:00
DanielEScherzer
53cb89670c
Generated arginfo header files: remove empty zend_function_entry arrays (#15705)
When a class (or enum) has no methods, rather than using an array that only
contains `ZEND_FE_END`, use `NULL` for the functions. The implementation of
class registration for internal classes, `do_register_internal_class()` in
zend_API.c, already skips classes where the functions are `NULL`. By removing
these unneeded arrays, we can reduce the size of the header files, while also
removing an unneeded call to zend_register_functions() for each internal class
with no extra methods.
2024-09-03 23:19:53 +02:00
Christoph M. Becker
6d5962074f
Dynamically xfail test cases which fail on CI (GH-15710)
This is a stop-gap measure for GH-15709 to keep CI green.
2024-09-02 18:23:52 +02:00
Máté Kocsis
8d12f666ae
Fix registration of internal readonly child classes (#15459)
Currently, internal classes are registered with the following code:

INIT_CLASS_ENTRY(ce, "InternalClass", class_InternalClass_methods);
class_entry = zend_register_internal_class_ex(&ce, NULL);
class_entry->ce_flags |= ...;

This has worked well so far, except if InternalClass is readonly. It is because some inheritance checks are run by zend_register_internal_class_ex before ZEND_ACC_READONLY_CLASS is added to ce_flags.

The issue is fixed by adding a zend_register_internal_class_with_flags() zend API function that stubs can use from now on. This function makes sure to add the flags before running any checks. Since the new API is not available in lower PHP versions, gen_stub.php has to keep support for the existing API for PHP 8.3 and below.
2024-08-24 12:36:54 +02:00
Gina Peter Bnayard
5853cdb73d Use "must not" instead of "cannot" wording 2024-08-21 21:12:17 +01:00
Gina Peter Bnayard
e7c4d54d65 Use new helper function for "cannot be empty" ValueErrors 2024-08-21 21:12:17 +01:00
Gina Peter Banyard
02177848e4
Replace uses of php_dirname() with zend_dirname() (#15393)
This removes some needs to include the php_string.h header
2024-08-14 12:35:47 +01:00
Gina Peter Banyard
c818d944cf
ext/(standard|spl): Deprecate passing a non-empty string as the $enclosure parameter (#15362) 2024-08-12 16:09:56 +01:00
Kamil Tekiela
e6ecd83ea5
Update arginfo for mysqli and spl_fixedarray (#15356) 2024-08-12 13:37:30 +02:00
Gina Peter Banyard
c8b45aa59a
ext/spl: Follow-up on GH-9704 (#15295)
Co-authored-by: Tim Düsterhus <timwolla@googlemail.com>
2024-08-08 19:31:51 +01:00
Tyson Andre
43def0af46
Deprecate SplFixedArray::__wakeup() (#9704)
GH-9354 added the `__serialize` and `__unserialize` method,
so unserialize() and other unserializers will call `__unserialize`
instead of `__wakeup` for SplFixedArray and userland subclasses.

RFC: https://wiki.php.net/rfc/deprecations_php_8_4#deprecate_splfixedarraywakeup
2024-08-08 16:16:42 +01:00
Peter Kokot
9cc63e1de9
Autotools: Normalize headers arguments (#15149)
Refactor all "long" arguments into blank-or-newline-separated list of
files with m4_normalize.
2024-07-29 10:08:17 +02:00
Peter Kokot
1ceadaed52
Autotools: Normalize and quote all PHP_NEW_EXTENSION arguments (#15144)
This adds Autoconf quote characters to all PHP_NEW_EXTENSION arguments
and syncs the CS across the php-src Autotools build system.
2024-07-29 00:14:59 +02:00
Levi Morrison
9d25296723
Merge branch 'PHP-8.3' 2024-07-23 16:34:16 -06:00
Levi Morrison
e43d9c7469
Merge branch 'PHP-8.2' into PHP-8.3 2024-07-23 16:33:40 -06:00
Levi Morrison
0956267c08
Fix warnings in session/spl
This fixes -Winline errors where the functions are not ever inlined.

Also fixes some signature mismatches which were fixed previously but
for whatever reason were not ported to all maintained branches:

/usr/local/src/php/ext/session/session.c:1299:20:
warning:conflicting types for 'php_session_send_cookie' due to enum/integer mismatch;
have 'zend_result(void)' {aka 'ZEND_RESULT_CODE(void)'} [-Wenum-int-mismatch]
 1299 | static zend_result php_session_send_cookie(void) /* {{{ */
      |                    ^~~~~~~~~~~~~~~~~~~~~~~
/usr/local/src/php/ext/session/session.c💯12:
note: previous declaration of 'php_session_send_cookie' with type 'int(void)'
  100 | static int php_session_send_cookie(void);
      |            ^~~~~~~~~~~~~~~~~~~~~~~
2024-07-23 16:25:11 -06:00
Arnaud Le Blanc
1fbb666545
Use zend_std_build_properties() to access zend_object.properties
The zend_object.properties HashTable needs to be built just in time by calling
rebuild_object_properties() on the object before accessing it. Normally this is
done automatically in zend_std_get_properties(), but we do it manually in a few
places.

In this change I introduce an inline variant of zend_std_build_properties(), and
refactor these places to use it instead of calling rebuild_object_properties()
manually.

rebuild_object_properties() renamed as rebuild_object_properties_internal(), to
enforce usage of zend_std_get_properties() or zend_std_build_properties_ex().

Closes GH-14996
2024-07-18 22:18:38 +02:00
Gina Peter Banyard
efe4e6d38e
ext/spl: Add ArrayObject test with property hooks (#15005)
As expected, ArrayObject is cursed
2024-07-18 13:10:00 +01:00
Tim Düsterhus
29f98e7485
Replace @deprecated by #[\Deprecated] for internal functions / class constants (#14750)
Co-authored-by: Gina Peter Banyard <girgias@php.net>
Co-authored-by: Niels Dossche <7771979+nielsdos@users.noreply.github.com>
2024-07-10 16:47:31 +02:00
Niels Dossche
e2189beaca
Merge branch 'PHP-8.3'
* PHP-8.3:
  Fix GH-14639: Member access within null pointer in ext/spl/spl_observer.c
2024-07-06 23:58:37 +02:00
Niels Dossche
8ea3f154be
Merge branch 'PHP-8.2' into PHP-8.3
* PHP-8.2:
  Fix GH-14639: Member access within null pointer in ext/spl/spl_observer.c
2024-07-06 23:58:20 +02:00
Niels Dossche
0d4e0c013e
Fix GH-14639: Member access within null pointer in ext/spl/spl_observer.c
`spl_object_storage_attach_handle` creates an entry already, but only
fills it in at the end with `spl_object_storage_create_element` which
allocates memory. In this case the allocation fails and we're left with
a NULL slot. Doing the allocation first isn't an option because we want
to check whether the slot is occupied before allocating memory.
The simplest solution is to set the entry to NULL and check for a NULL
pointer upon destruction.

Closes GH-14849.
2024-07-06 23:57:46 +02:00
Arnaud Le Blanc
11accb5cdf
Preferably include from build dir (#13516)
* Include from build dir first

This fixes out of tree builds by ensuring that configure artifacts are included
from the build dir.

Before, out of tree builds would preferably include files from the src dir, as
the include path was defined as follows (ignoring includes from ext/ and sapi/) :

    -I$(top_builddir)/main
    -I$(top_srcdir)
    -I$(top_builddir)/TSRM
    -I$(top_builddir)/Zend
    -I$(top_srcdir)/main
    -I$(top_srcdir)/Zend
    -I$(top_srcdir)/TSRM
    -I$(top_builddir)/

As a result, an out of tree build would include configure artifacts such as
`main/php_config.h` from the src dir.

After this change, the include path is defined as follows:

    -I$(top_builddir)/main
    -I$(top_builddir)
    -I$(top_srcdir)/main
    -I$(top_srcdir)
    -I$(top_builddir)/TSRM
    -I$(top_builddir)/Zend
    -I$(top_srcdir)/Zend
    -I$(top_srcdir)/TSRM

* Fix extension include path for out of tree builds

* Include config.h with the brackets form

`#include "config.h"` searches in the directory containing the including-file
before any other include path. This can include the wrong config.h when building
out of tree and a config.h exists in the source tree.

Using `#include <config.h>` uses exclusively the include path, and gives
priority to the build dir.
2024-06-26 00:26:43 +02:00
Gina Peter Banyard
f0fb9e34a5 ext/spl: use ecalloc instead of complicate memset to 0 2024-06-15 01:33:09 +01:00
Gina Peter Banyard
5337172508 ext/spl: Use ArrayObject object handlers for ArrayIterator
They are the same
2024-06-15 01:33:09 +01:00
Gina Peter Banyard
446b7fbab9 ext/spl: Remove unused typedef 2024-06-15 01:33:09 +01:00
Gina Peter Banyard
809410423f ext/spl: Refactor debug handlers
Mainly to use zend_mangle_property_name() directly instead of spl_gen_private_prop_name()
2024-06-15 01:33:09 +01:00
Gina Peter Banyard
54047c1090 ext/spl: Remove some useless header includes and clarify usages 2024-06-15 01:33:09 +01:00
Gina Peter Banyard
3fd60d33ca ext/spl: Refactor SplFileObject::fgetc() 2024-06-15 01:33:09 +01:00
Gina Peter Banyard
f296cba58c ext/spl: Convert current_line to a zend_string* 2024-06-15 01:33:09 +01:00
Gina Peter Banyard
bb4491af88 ext/spl: Adding a const modifier 2024-06-15 01:33:09 +01:00
Gina Peter Banyard
35c5cf9760 ext/spl: Remove useless wrapper 2024-06-15 01:33:09 +01:00
Gina Peter Banyard
90b8db49ac ext/spl: Refactor SplFileInfo::getPathInfo() implementation 2024-06-15 01:33:09 +01:00
Gina Peter Banyard
a5cacba6d8
ext/spl: Remove spl_engine.h header (#14418)
And convert calls to spl_instantiate_arg_* to the new object_init_with_constructor() API
2024-06-08 23:46:34 +01:00
Gina Peter Banyard
fd2d869642
Clean-up some more headers (#14416)
Remove unused headers (such as php_ini.h for extensions that don't define INI settings)
Use more specific headers when possible
2024-06-08 17:15:36 +01:00
Levi Morrison
07a1921a8c
refactor: use ZEND_PARSE_PARAMETERS_NONE() (#14442)
Prefer:

	ZEND_PARSE_PARAMETERS_NONE();

Over:

	if (zend_parse_parameters_none() == FAILURE) {
		RETURN_THROWS();
	}

It's shorter, more modern, and they do the same thing. Technically,
ZEND_PARSE_PARAMETERS_NONE doesn't check that there's an exception,
but it generates one, so it's still cohesive.
2024-06-02 23:58:24 +01:00
Levi Morrison
c461b60060
refactor: change zend_is_true to return bool (#14301)
Previously this returned `int`. Many functions actually take advantage
of the fact this returns exactly 0 or 1. For instance,
`main/streams/xp_socket.c` does:

    sockopts |= STREAM_SOCKOP_IPV6_V6ONLY_ENABLED * zend_is_true(tmpzval);

And `Zend/zend_compile.c` does:

    child = &ast->child[2 - zend_is_true(zend_ast_get_zval(ast->child[0]))];

I changed a few places trivially from `int` to `bool`, but there are
still many places such as the object handlers which return `int` that
should eventually be `bool`.
2024-05-24 15:16:36 -06:00
Cristian Rodríguez
8e62e2b829
Mark multple functions as static (#13864)
* Mark many functions as static

Multiple functions are missing the static qualifier.

* remove unused struct sigactions

struct sigaction act, old_term, old_quit, old_int;
all unused.

* optimizer: minXOR and maxXOR are unused
2024-05-22 13:11:46 +02:00
Niels Dossche
e16bc4b28e
Merge branch 'PHP-8.3'
* PHP-8.3:
  Fix GH-14290: Member access within null pointer in extension spl
2024-05-21 23:24:28 +02:00
Niels Dossche
88af09193d
Merge branch 'PHP-8.2' into PHP-8.3
* PHP-8.2:
  Fix GH-14290: Member access within null pointer in extension spl
2024-05-21 23:24:15 +02:00
Niels Dossche
b3a56bd558
Fix GH-14290: Member access within null pointer in extension spl
php_pcre_replace_impl() can fail and return NULL. We should take that
error condition into account. Because other failures return false, we
return false here as well.

At first, I also thought there was a potential memory leak in the error
check of replacement_str, but found that the error condition can never
trigger, so replace that with an assertion.

Closes GH-14292.
2024-05-21 23:20:32 +02:00
Niels Dossche
f97bd071d5
Implement SeekableIterator for SplObjectStorage (#13665) 2024-05-05 13:26:54 +02:00
Peter Kokot
e93d23a9cb
Remove unused ext/spl SPL_API code (#13985)
The ext/spl is always enabled and building it as shared is no longer
relevant.
2024-04-19 22:50:36 +02:00
Tim Düsterhus
08b2ab22f4
Include the source location in Closure names (#13550)
* Include the source location in Closure names

This change makes stack traces involving Closures, especially multiple
different Closures, much more useful, because it's more easily visible *which*
closure was called for a given stack frame.

The implementation is similar to that of anonymous classes which already
include the file name and line number within their generated classname.

* Update scripts/dev/bless_tests.php for closure naming

* Adjust existing tests for closure naming

* Adjust tests for closure naming that were not caught locally

* Drop the namespace from closure names

This is redundant with the included filename.

* Include filename and line number as separate keys in Closure debug info

* Fix test

* Fix test

* Include the surrounding class and function name in closure names

* Fix test

* Relax test expecations

* Fix tests after merge

* NEWS / UPGRADING
2024-04-12 18:21:13 +02:00
Gina Peter Banyard
a648365fc0
ext/spl: Throw TypeError when overloaded SplObjectStorage::getHash() method does not return a string 2024-03-17 23:08:58 +00:00
Gina Peter Banyard
610c7a07b1
Move SplObjectStorage test to a folder 2024-03-17 23:08:47 +00:00