- Scattered if blocks moved together as PDO_MYSQL_UNIX_ADDR is defined
only when mysql_config is available
- Obsolete backticks command substitutions `...` replaced with the
recommended $(...)
When this function has been added to our bundled GD[1], it had been
overlooked to also declare it in gd.h, like it's done in libgd. While
MSVC doesn't have any issues with this, clang reports an error.
[1] <03bd4333f6>
While clang is picky about these, MSVC doesn't seem to care and would
only report the calls to undeclared functions as errors during link
time. Still, obviously, MSVC is fine with having the declarations
during compile time.
YIELD and YIELD_FROM increment opline before returning, but in most places
we need the opline to point to the YIELD and YIELD_FROM.
Here I change YIELD / YIELD_FROM to not increment opline. This simplifies the
code and fixes GH-15275 in a better way.
Closes GH-15328
The logic was very weird as it just should check whether the boolean is
true or not. And in fact the code is equivalent because zval_get_long()
will only return 0/1 because the type is a bool, and ZEND_NORMALIZE_BOOL
won't change that value.
The definition of the class entries in the internal header file is not
correct, since that file is included several times, and even the
comment above the definition hints at com_extension.c where the actual
definition is. We fix this by declaring these variables as `extern`.
- AS_* macros used
- s/UNIX/Unix
- The --with-mysql result value moved into the check when extension is
enabled
- List of source files normalized with m4_normalize
- Redundant variables omitted
- CS synced
This is a follow-up of GH-15242
(0b25e26b4e)
because the usmHMAC192SHA256AuthProtocol and usmHMAC384SHA512AuthProtocol
are not functions but arrays. The AC_CHECK_DECL might be more
appropriate and portable way to find these.
NET-SNMP has pkg-config support since 5.8.1
This optionally finds the NET-SNMP library using pkg-config or falls
back to find library on the system with net-snmp-config. The configure
option argument (--with-snmp=DIR) works like before (path to the
net-snmp-config).
When explicitly using the DIR argument, the pkg-config check is silently
skipped.
When not using DIR argument, the SNMP_CFLAGS and SNMP_LIBS can be also
used to find the NET-SNMP library:
./configure --with-snmp \
SNMP_CFLAGS=-I/path/to/net-snmp/include \
SNMP_LIBS="-L/path/to/net-snmp -lnetsnmp"
Co-authored-by: Calvin Buckley <calvin@cmpct.info>
readonly properties will usually be IS_UNDEF on assignment, dodging the fast
path anyway. The fast path does not handle the readonly scope check. The
alternative would be handling scope there, but since there are some many
variants that might be more trouble than it's worth.
* hash: Add SSE2 implementation of SHA-256
Implementation taken from
tarsnap/libcperciva@661752aee8.
Co-authored-by: Christoph M. Becker <cmbecker69@gmx.de>
Co-authored-by: Niels Dossche <7771979+nielsdos@users.noreply.github.com>
* zend_cpuinfo: Add ZEND_CPU_FEATURE_SHA
* hash: Add SHA-NI implementation of SHA-256
Implementation taken from
tarsnap/libcperciva@661752aee8.
Co-authored-by: Christoph M. Becker <cmbecker69@gmx.de>
* NEWS / UPGRADING
---------
Co-authored-by: Christoph M. Becker <cmbecker69@gmx.de>
Co-authored-by: Niels Dossche <7771979+nielsdos@users.noreply.github.com>
Because the signature is checked at compile time, we know that the only
possible return value (if there is no exception) is IS_LONG. So we can
avoid some work.
The sodium extension was initially named "libsodium" in PECL and was
renamed to sodium when it was bundled to php-src. The HAVE_LIBSODIUMLIB
symbol here could indicate that PHP extension sodium is available.
Otherwise the macro is not used in the current code base. Header
php_libsodium.h became "installed"/public as of PHP-8.4.
[skip ci]
These diagnostics can be useful, and if not for users, at least for the
ext/odbc maintainers. We only call `odbc_sql_error()` if the previous
`SQLFetch()` or `SQLFetchExtended()` return `SQL_ERROR`, because
otherwise the diagnostic would be unhelpful ("Failed to fetch error
message, SQL state HY000").
Note that the diagnostic is emitted as `E_WARNING` so technically this
is a small BC break.
Closes GH-15256.
As of PHP 8.1.0, passing `null` to an `int` parameter is deprecated,
and as such the deprecation notice breaks the test. So we instead pass
an integer, and to avoid hard-coding a value we just add the two
supported constants (which are supposed to have the values `1` and `2`,
respectively).
Closes GH-15254.
GMP has pkg-config integration since 2019-08-22 (version ~6.2.0).
This optionally finds the GMP library using pkg-config or falls back to
find library on the system or with the provided configure option
argument (--with-gmp=DIR).
When using DIR argument, the pkg-config check is silently skipped.
When not using DIR argument, the GMP_CFLAGS and GMP_LIBS can be also
used to find the GMP library:
./configure --with-gmp \
GMP_CFLAGS=-I/path/to/gmp/include \
GMP_LIBS="-L/path/to/gmp -lgmp"
This adds the missing macros help texts for easier understanding. The
AC_DEFINE can be called with only 2 arguments if there is another
definition in the code where template (see AH_TEMPLATE Autoconf macro)
is read by autoheader (the 2nd AC_DEFINE sets the template for all other
definitions with the same name).
Two issues:
1) We should not modify the object when we pass invalid values
2) We should reset the properties to their default value otherwise we
get a UAF.
Regressed in df219ccf9d
Closes GH-15248.
This patch greatly improves the performance for the common case of using a
64-bit engine and requesting a length that is a multiple of 8.
It does so by providing a fast path that will just `memcpy()` (which will be
optimized out) the returned uint64_t directly into the output buffer,
byteswapping it for big endian architectures.
The existing byte-wise copying logic was mostly left alone. It only received an
optimization of the shifting and masking that was previously applied to
`Randomizer::getBytesFromString()` in 1fc2ddc996.
Co-authored-by: Saki Takamachi <saki@php.net>
The 'rl_pending_input' is a variable in Readline library and checking it
with PHP_CHECK_LIBRARY wouldn't find it on some systems.
Library check works on most systems but not on the mentioned AIX in the
bug as it exports variables and functions differently whereas the linker
couldn't resolve the variable as a function.
This should fix the build on systems where this caused issues, such as
AIX.
The <readline/readline.h> is not self-contained header and needs to also
have <stdio.h> included before to have FILE type available. This fixes
the issue on unpatched default readline installations, such as macOS.
Checking this variable ensures that the found library is the correct
library and also that it is of minimum version needed by current PHP
code (https://bugs.php.net/48608).
The library check:
```c
| char rl_pending_input ();
| int main (void) {
| return rl_pending_input ();
| }
```
The declaration check:
```c
| #include <stdio.h>
| #include <readline/readline.h>
| int main (void) {
| #ifndef rl_pending_input
| #ifdef __cplusplus
| (void) rl_pending_input;
| #else
| (void) rl_pending_input;
| #endif
| #endif
| ;
| return 0;
| }
```
Closes https://bugs.php.net/51558
When PHP gd extension uses the external system GD library, the
HAVE_LIBGD preprocessor macro gets defined in Autotools. On Windows it
was previously always defined when bundled library is used. This fixes
the usage and adds help texts.
The cross_compiling variable can initially be "yes", "no", or
"maybe" (when only --host option is added). Autoconf otherwise after
AC_PROG_CC resets it to "no" in such case but to be sure, this
checks for value "yes" instead. The HAVE_FNMATCH template can be also
set after the AC_DEFINE as autoheader scans the templates overall the
source code.
The mm check code block needs to done only when session is enabled to
prevent redundant mm library linkage in edge case mistakes like:
./configure --disable-session --with-mm
CS is synced with AC_* macros. The 'm4_text_wrap' macro joins the given
text with single space characters and limits it to 79 characters width.
Co-authored-by: Gina Peter Banyard <girgias@php.net>
This replaces the AC_MSG_ERROR with AC_MSG_FAILURE, where appropriate.
The AC_MSG_ERROR outputs given message and exits the configure step. The
AC_MSG_FAILURE does the same but also automatically outputs additional
message "See 'config.log' for more details." which might help directing
the user where to look further.
The AC_MSG_ERROR is used for errors where current test step isn't logged
in the config.log and wouldn't make sense, and AC_MSG_FAILURE is mostly
used in cases of library checks, compilation tests, headers checked with
AC_CHECK_HEADER* and similar tests that are also logged in the
config.log.
AC_MSG_ERROR([Sanity check failed.]) output:
```
configure: error: Sanity check failed.
```
AC_MSG_FAILURE([Sanity check failed.]) output:
```
configure: error: in '/path/to/php-src':
configure: error: Sanity check failed.
See 'config.log' for more details
```
This is a follow-up of GH-15177
(c96f08aa70)
and GH-15185
(9467ffb43c)
The PHP_OUTPUT macro was introduced in the very early phase of the build
system due to AC_OUTPUT handling issues in the old Autoconf versions
before the AC_CONFIG_FILES, AC_CONFIG_COMMANDS etc were introduced with
the AC_OUTPUT signature without arguments. The PHP_OUTPUT was also
helping Makefile.in back then being properly generated based on whether
all files were generated or only some (when using the obsolete
CONFIG_FILES=... ./config.status invocation instead of the new
./config.status --file=...). Another issue is that PHP_OUTPUT can't be
used by extensions when using phpize.
This replaces the PHP_OUTPUT invocations with default AC_CONFIG_FILES.
The obsolete "REDO_ALL" feature at the config.status invocation is also
removed with a simpler unconditional generation.
In phar extension the "ext/phar" is replaced with $ext_dir variable to
be able to use phpize.
When cloning a document, doc will not be equal to the actual new
document clone->doc. clone->doc will always point to the correct
document so use that instead when comparing document nodes.
Closes GH-15198.
* Allow optimizer to depend on preloaded symbols
It is safe for the optimizer to rely on preloaded symbols. This can occur when
compiling non-preloaded files, referencing preloaded ones.
* Disable inline pass for observer test
* Move duplicated code into functions
* Add comment to specific optimization value
* Optimizer should only rely on preloaded symbols in the symbol table
* Fix skipif for windows
When libffi is installed on non-default places, also the calling
convention checks need adjusted compilation flags to be able to find the
ffi.h header file.
* Improve link styling in PHPInfo
The previous styling with the fixed background color didn't work well in dark
mode. Remove the background and make links inherit the regular text color. To
make them visually detectable the underlining behavior is reversed. The
underline is now shown when not hovering and hidden when hovering.
* Preserve the headline linking behavior
This is an old bug, but this is pretty easy to fix.
It's basically applying the same fix as I did for e878b9f.
Reported by YuanchengJiang.
Closes GH-15143.
The PHP_ADD_EXTENSION_DEP Autoconf macro needs to be called after
PHP_NEW_EXTENSION to be fully effective. This simplifies the code and
checks. Also, due to the current order_by_dep.awk script implementation
it needs to be on its own line with arguments unquoted so that awk can
parse the config.m4 file. Until order_by_dep.awk script is fixed.
- Comments refactored to a bit more guide way
- Basic help text added to the HAVE_<EXTENSION>* preprocessor macro definitions
- Raw shell ifs replaced with AS_VAR_IF M4 macros
- Code wrapped inside the line length of 80 characters
- pkg-config functionality added on top
- non-pkg-config functionality added afterwards
- The loop refactored a bit with a break and check message done
afterwards
[skip ci]
The 3rd argument of the PHP_NEW_EXTENSION can be "shared" or "yes" to
mark the extension as shared, or anything else to mark that extension as
not shared. This syncs the argument values across the build system to be
"no" as in other always-enabled extensions.
When building in out-of-source directory, instead of creating these
build directories right away, this appends them to the list and creates
them at the end of configure phase. These don't need to be created
immediately as no files are generated in these extensions before the
configure phase is finished.
Also, the PHP_ADD_BUILD_DIR is moved after the PHP_NEW_EXTENSION when
the more common $ext_builddir variable is available (the ext/<extension>
isn't available when building with phpize).
* ext/gmp: Make GMP class final
RFC: https://wiki.php.net/rfc/gmp-final
* Update UPGRADING
Co-authored-by: Peter Kokot <peterkokot@gmail.com>
---------
Co-authored-by: Peter Kokot <peterkokot@gmail.com>
This regressed when I optimized $wholeText. The previous code used xmlStrcat
which implicitly checked for a NULL argument, but now it's a direct memcpy
which you shouldn't pass null pointers to, although it won't result in a
crash because memcpy doesn't do anything if the length is 0.
This appends source files to the PHP_NEW_EXTENSION call and adds the
possible compilation flag -DZEND_ENABLE_STATIC_TSRMLS_CACHE when
building objects as done on all ext/standard sources already. Also, the
PHP_EXT_DIR Autoconf macro doesn't accept any argument.
- Sync Autoconf syntax
- The PHP_EXT_DIR macro doesn't accept any arguments and since this is
called after PHP_NEW_EXTENSION, the $ext_dir variable can be used
instead.
- PHP_SETUP_LIBXML arguments quoted
- Help texts updated for HAVE_LIBXML, HAVE_DOM, HAVE_XMLREADER,
HAVE_XMLWRITER, HAVE_SOAP, HAVE_SIMPLEXML, and HAVE_XML CPP macros
- Duplicate HAVE_LIBXML symbol definition in PHP_SETUP_LIBXML M4 macro
removed (the HAVE_LIBXML marks that PHP libxml extension is available and
not only that libxml2 library is available)
simplifying the workflow by just using PQreset which force a new
connection internally, connection process ids ought to be different,
and let the existing checks do the rest.
When building with readline/libedit installed at non-standard or
non-system paths the check flags also need to be adjusted a bit to be
able to check for the declared variable.
This partially reverts 0956267c08, which
introduced a type incompatibility where an `int` function is assigned
to a `zend_result` function. That yields a level 1 C4133 warning on
MSVC, and usually (e.g. in CI) level 1 warnings are elevated to errors,
so the build fails.[1]
The PHP-8.3 branch and up are uneffected by this, so the upward merges
should be empty.
[1] <0956267c08 (r144587696)>
* ext/dba/tests/setup/setup_dba_tests.inc: sort test output
Iterating through a database with firstkey() and nextkey() is
guaranteed to retrieve all rows, but apparently not in any particular
order. This is causing a test failure for at least one user, so we
steal the sort() approach from GDBM to ensure that the output is
predictable.
* ext/dba/tests/dba_*.phpt: sort expected test output
The actual output is now sorted for consistency, so we need to update
the expected output as well. As a nice side effect, some differences
in the expected outputs for the various engines have been eliminated.
Closes GH-14786
* ext/pgsql/tests/80_bug14383.phpt: sort expected test output
This test uses a routine from ext/dba that now sorts its (actual)
output, so we have to sort the expected output here as well.
* ext/dba/tests/setup/setup_dba_tests.inc: update comment
After doing some more digging, it looks like GDBM isn't the only
engine where the iteration order with firstkey() and nextkey()
might change unexpectedly.
These get the next and previous sibling nodes, respectively.
We can already kind of do this by using the $child array, but that's
inconvenient when actually walking the tree by only using node
instances. Since the class is final, there is no BC break here.
Closes GH-15047.
Using compound literals is conforming to C99 (and up), but not with any
C++ standard. Since the code is in a public header, it might be used
by C++ extensions. Unfortunately, we cannot even used designated
initializers, because these are a C++20 feature, so we stick with
classic C/C++ code.
Closes GH-15100.
- Added Capstone check message in configure log
- PKG_CHECK_MODULES already errors out by default if Capstone is not
found with a bit more informative message
- Autoconf syntax used
- HAVE_CAPSTONE help text synced and updated
We port this modification[1] from libgd into our bundled libgd, because
the change makes sense, and we want the code bases to stay in sync as
close as possible.
We also apply a quick fix to the respective test.
[1] <f0a059be6c>
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);
| ^~~~~~~~~~~~~~~~~~~~~~~
This checks if crypt and crypt_r functions are available on the system
in default libraries or in the crypt library with the AC_SEARCH_LIBS.
The redundant HAVE_LIBCRYPT symbol is removed.
* PHP-8.3:
[ci skip] NEWS
Hint the opcache shm mapping location only when JIT is enabled
Fix the JIT buffer relocation failure at the corner case (#11266)
Avoid missing possible candidates due to the large address range of the free segment.
Eg,
48000000-49400000 r-xs 08000000 00:0f 39322841 segment1
7ffff2ec8000-7ffff2f49000 rw-p 00000000 00:00 0 segment2
7ffff6fae000-7ffff735c000 r-xp 00200000 08:02 11538515 /usr/local/sbin/php-fpm
original code will miss the opportunity between [7ffff2ec** - 7ffff2ec8000].
Fix issue #11265.
Signed-off-by: Long, Tao <tao.long@intel.com>
Signed-off-by: Dmitry Stogov <dmitrystogov@gmail.com>
Instead of fixing up temporaries count in between observer steps, just apply the additional temporary in the two affected observer steps.
Closes GH-14018.
For top-level anonymous type definition we never store the declaration anywhere
else nor the type anywhere else.
The declaration keeps owning the type and it goes out of scope.
For anonymous fields this gets handled by the add_anonymous_field code that
removes the type from the declaration.
This patch does something similar in the parsing code when it is
detected we're dealing with an anonymous enum in a top-level declaration.
Closes GH-14839.
- exit() replaced with regular return since these two behave the same in
main()
- main(void) used as argc and argv aren't used
- if sentences wrapped in curly brackets for readability
- fgets wrapped in if to check for the return result and omit the
"ignoring return value of 'fgets' declared with attribute
'warn_unused_result'..." warnings in the config.log
- fclose(fp) added before returning
Older GCC versions (< 7.0) don't support the -Wno-implicit-fallthrough
compiler flag. This adds the flag conditionally in case some other
compiler will run into same issue.
Fixes GH-13330
We were using atoi, which is only for integers. When the size does not
fit in an integer this breaks. Use ZEND_STRTOUL instead. Also make sure
invalid data isn't accidentally parsed into a file size.
Closes GH-15035.
Lower branches suffer from this as well but we cannot change the
behaviour there.
We also add NULL checks to check for allocation failure.
Closes GH-15014.
TIDY_APPLY_CONFIG can early return because it's a macro, but then the
cleanup paths are not executed. Transform this to a real function and
handle the cleanups correctly at the callsites.
Closes GH-15046.
I don't know why this code was here in the first place, it is present
since the initial implementation. It doesn't make sense because:
1. It would require updating the refcounts if the document wasn't
actually already set.
2. We enforce that the document is the same as the target document by
this point, so setting the tree is pointless.
AIX 7.1 has SOCK_CONN_DGRAM, but not SOCK_DCCP; the previous change
conflated the availability between the two definitions. Add an
additional #ifdef for this.
Quoted m4_normalize will expand and change its argument later in the
macro call when M4 is processing the *.m4 sources. Without quotes the
already normalized string is passed to the macro directly. In these
specific cases generated configure script is the same. This is more for
consistency to have this synced and not repeat the pattern too much
in the future when copy/pasting. Note, that many AC_* macros require
similar behavior already (for example, AC_CHECK_FUNCS.)
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
This introduces a new helper php_dom_create_nullable_object() that does
the NULL check and puts NULL in return_value. Otherwise it runs
php_dom_create_object(). This deduplicates a bit of code.
Use our own string builder instead of using libxml's and then having to
copy over.
For the following test:
```
$dom = Dom\HTMLDocument::createEmpty();
$root = $dom->appendChild($dom->createElement('root'));
$root->append('abc', 'def', 'ghi');
$f = $root->firstChild;
for ($i = 0; $i < 1000000; $i++)
$f->wholeText;
```
The following results were obtained on an i7-4790:
```
Benchmark 1: ./sapi/cli/php x.php
Time (mean ± σ): 57.2 ms ± 2.3 ms [User: 53.2 ms, System: 3.4 ms]
Range (min … max): 54.7 ms … 69.3 ms 52 runs
Benchmark 2: ./sapi/cli/php_old x.php
Time (mean ± σ): 89.4 ms ± 3.4 ms [User: 85.6 ms, System: 3.0 ms]
Range (min … max): 86.1 ms … 105.8 ms 32 runs
Summary
./sapi/cli/php x.php ran
1.56 ± 0.09 times faster than ./sapi/cli/php_old x.php
```