Commit Graph

2367 Commits

Author SHA1 Message Date
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
Peter Kokot
8c4f019cc6
Autotools: Sync CS in gd extension (#15364)
- Obsolete PHP_* variables checks removed (there was once the 'pdf'
  extension bundled in PHP that also had the same --with-*-dir configure
  options (3be17e3f26). When combined with
  the gd extension, options need to be executed conditionally; first one
  won), this is no longer relevant neither recommended practice to
  duplicate configure options inside the php-src context. Ideally,
  all configure options should be prefixed with an extension namespace
  --with-<extension-name>-<option> to be unique.
- AS_* macros used
2024-08-12 21:38:30 +02:00
Christoph M. Becker
9b41c8b1b5
Declare gdImageGetInterpolationMethod() for bundled GD (GH-15329)
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>
2024-08-10 16:57:48 +02:00
Peter Kokot
72fb00b644
Update gd extension preprocessor macros help texts (#15296)
PHP_GD_CHECK_FORMAT macro 2nd argument is changed from automatic
AC_DEFINE_UNQUOTED to manual action for easier usage.
2024-08-09 18:06:02 +02:00
Peter Kokot
11094d5f24
[skip ci] Fix typo in ext/gd 2024-08-05 16:23:38 +02:00
Peter Kokot
9049d86a78
[skip ci] Fix typo in ext/gd 2024-08-05 16:22:36 +02:00
Peter Kokot
8bfcbdc5ee
Fix HAVE_LIBGD usage (#15226)
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.
2024-08-05 09:35:13 +02:00
Peter Kokot
dcdcb3cbfe
Autotools: Replace AC_MSG_ERROR with AC_MSG_FAILURE (#15209)
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
```
2024-08-04 07:36:37 +02:00
Peter Kokot
79af1b5280
Autotools: Remove unused variable FREETYPE2_FOUND
Follow-up of 19d8a6b771.
2024-07-30 11:25:24 +02:00
Peter Kokot
2b97c84d4c
Autotools: Quote PHP_CHECK_LIBRARY arguments (#15136)
This syncs the quotes across the PHP_CHECK_LIBRARY macro arguments.
2024-07-28 18:39:14 +02:00
Christoph M. Becker
6727f548b0
Port "gd2: use existing overflow2() rather than ad-hoc version" (#15090)
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>
2024-07-24 14:18:36 +02:00
Peter Kokot
6cdff7573a
Autotools: Normalize ext/gd sources (#15086) 2024-07-24 01:52:51 +02:00
Peter Kokot
68ae477796
Autotools: Quote M4 arguments (#15033)
- PHP_ADD_INCLUDE
- PHP_EVAL_INCLINE
- PHP_EVAL_LIBLINE
2024-07-20 07:21:44 +02:00
Peter Kokot
0e2e8e0f13
Autotools: Quote all PHP_ADD_BUILD_DIR arguments (#14947)
- All arguments quoted for consistency
- m4_normalize used where list of directories becomes a bit simpler to
  read and see the diff
2024-07-14 16:58:43 +02:00
Christoph M. Becker
82fe4a2d48
Merge branch 'PHP-8.3'
* PHP-8.3:
  Fix skip condition of gh13082.phpt
2024-07-14 13:40:38 +02:00
Christoph M. Becker
02a60be24d
Fix skip condition of gh13082.phpt
The test failure is not particularly related to Travis, but rather is
caused by the GD font file to only be suitable for platforms where
`int` stores 32bit values in little endian byte order.  This platform
dependence is documented in the source code[1].  Thus we fix the skip
condition and skip reason accordingly.

An alternative would be to dynamically create the font file just before
running the test, but that appears to be overkill.

[1] <d59691c02f/ext/gd/gd.c (L545-L556)>

Closes GH-14922.
2024-07-14 13:39:49 +02:00
Christoph M. Becker
a6d1844446
Merge branch 'PHP-8.3'
* PHP-8.3:
  Add test case for GH-13774
2024-07-14 12:48:22 +02:00
Christoph M. Becker
0ed956dc69
Merge branch 'PHP-8.2' into PHP-8.3
* PHP-8.2:
  Add test case for GH-13774
2024-07-14 12:47:25 +02:00
Christoph M. Becker
6d0db52896
Add test case for GH-13774
Besides demonstrating the new behavior, this test also ensures that the
bundled and external libgd now behave the same.  It has to be noted,
though, that we only test one of the five code paths.

Closes GH-14945.
2024-07-14 12:46:37 +02:00
David Carlier
79c134a6e8
Merge branch 'PHP-8.3' 2024-07-13 17:00:53 +01:00
David Carlier
10a94f846d
Merge branch 'PHP-8.2' into PHP-8.3 2024-07-13 16:59:30 +01:00
Denis Ryabov
b456ae8d34
Restore Warning instead of Fatal Error in gd_webp.c
According to the docs (https://www.php.net/manual/en/function.imagecreatefromwebp.php and https://www.php.net/manual/en/function.imagewebp.php), `false` should be returned on errors (similar to other functions of the `gd` extension), but actually all errors result in a `Fatal Error`. It doesn't look normal when trying to read an empty file or a file in the wrong format causes the program to stop. The problem seems to be related to a mega-patch that replaced `zend_error` with `zend_error_noreturn` almost everywhere. My patch fixes this behavior by switching from `zend_error_noerror` to `gd_error` (i.e. to `E_WARNING` level). All necessary memory cleanup is already in the code (as it was before the "zend_error_noreturn" patch).

Close GH-13774
2024-07-13 16:58:54 +01:00
Niels Dossche
71defce4be
Merge branch 'PHP-8.3'
* PHP-8.3:
  ext/gd/tests/gh10614.phpt: skip if no PNG support
2024-07-10 19:51:17 +02:00
Niels Dossche
361644b78d
Merge branch 'PHP-8.2' into PHP-8.3
* PHP-8.2:
  ext/gd/tests/gh10614.phpt: skip if no PNG support
2024-07-10 19:51:11 +02:00
Michael Orlitzky
09957ab9a8
ext/gd/tests/gh10614.phpt: skip if no PNG support
This test uses imagecreatefrompng(), which won't be there if libgd was
built without PNG support.

Closes GH-14905.
2024-07-10 19:50:48 +02:00
David CARLIER
93c3ebd209
ext/gd minor corrections concerning image format id for errors. (#14887) 2024-07-09 20:07:07 +01:00
David Carlier
23a55babb4
ext/gd: checking imagescale/imagefilter invalid values.
close GH-14598
2024-07-08 16:59:40 +01:00
Peter Kokot
034621760d
Autotools: Sync PHP_SUBST in ext/gd (#14751)
- Argument quoted
- CFLAGS variable changed into normal shell variable
- GDLIB_CFLAGS and GDLIB_LIBS are not used in the generated Makefile
2024-07-01 20:57:43 +02:00
Peter Kokot
c44834d8ad
Trim trailing whitespace (#14721) 2024-06-29 18:41:45 +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
Peter Kokot
b12ccb319f
Add PHP_SETUP_ZLIB M4 macro (#14591)
This enables the zlib library (https://zlib.net/) from a single place to
match the minimum required version across the php-src. This provides a
possible simpler version bump in the future. Macro's 2nd and 3rd
arguments can pass additional actions whether zlib library is found or
not for the possible future adjustments in the ext/standard where also
zlib might be required.

Support for pkg-config was introduced in 1.2.3.1.
The minimum zlib version has been bumped to 1.2.3.1



* Bump minimum zlib version to 1.2.11

This is aligned with CentOS 8, which has 1.2.11 in the default packages.

* [skip ci] Move zlib version change to UPGRADING

This matches the OpenSSL style version change notice already done in
this file.
2024-06-21 15:05:34 +02:00
David CARLIER
1fc083e526
ext/gd: iamgeresolution checks overflow. (#14585) 2024-06-16 23:28:04 +01:00
Niels Dossche
934e385640 gd: change uses of sprintf into snprintf 2024-06-14 08:12:03 -07:00
Giovanni Giacobbi
592d899462
ext/gd: de-factorize image output functions (#14523)
The image output functions imagegif/imagepng/imagewebp/imageavif/imagejpeg
were all calling the static function _php_image_output_ctx which was basically
a big switch statement between each image type which also have different
parameters.

The only identical part was the call to create_stream_context_from_zval that
is now merged with create_output_context.
2024-06-13 09:46:47 +01:00
David CARLIER
1ae544330c
ext/gd using fast ZPP. (#14534) 2024-06-11 09:01:54 +01:00
Peter Kokot
a82d86479c
Replace WIN32 conditions with _WIN32 or PHP_WIN32 (#14462)
* Replace WIN32 conditions with _WIN32 or PHP_WIN32

WIN32 is defined by the SDK and not defined all the time on Windows by
compilers or the environment. _WIN32 is defined as 1 when the
compilation target is 32-bit ARM, 64-bit ARM, x86, or x64. Otherwise,
undefined.

This syncs these usages one step further.

Upstream libgd has replaced WIN32 with _WIN32 via
c60d9fe577

PHP_WIN32 is added to ext/sockets/sockets.stub.php as done in other
*.stub.php files at this point.

* Use PHP_WIN32 in ext/random

* Use PHP_WIN32 in ext/sockets

* Use _WIN32 in xxhash.h as done upstream

See https://github.com/Cyan4973/xxHash/pull/931

* Update end comment with PHP_WIN32
2024-06-10 21:59:41 +02:00
David Carlier
7b2ca071c5
ext/gd: imagewebp/imageavif/imagepng/imagejpeg stricter checks quality/speed.
close GH-14485
2024-06-05 23:07:57 +01:00
Niels Dossche
7fe03e1a1b
Merge branch 'PHP-8.2' into PHP-8.3
* PHP-8.2:
  Fix parameter numbers for imagecolorset()
2024-06-05 18:04:53 +02:00
Giovanni Giacobbi
da769be7c9
Fix parameter numbers for imagecolorset()
This is the 8.2 & 8.3 version of GH-14477.
2024-06-05 18:01:59 +02:00
Giovanni Giacobbi
44cbdb107e
Fix parameter numbers and missing alpha check for imagecolorset()
The check for the alpha parameter existed in PHP 7.4 but was lost in PHP 8.0.

Fixes: 50765075db

Closes GH-14477.
2024-06-05 17:54:42 +02:00
Peter Kokot
6c034ee7e3
Wrap gdImageCreateFrom* checks in AC_CACHE_CHECK (#14443)
This enables cross-compiling edge cases to manually override the checks
with the php_cv_lib_gd_gdImageCreateFrom* cache variables.
2024-06-03 00:00:44 +01:00
Gina Peter Banyard
07a48517ac
Merge branch 'PHP-8.3'
* PHP-8.3:
  ext/readline: Fix [-Wcalloc-transposed-args] compiler warning
  ext/pdo_mysql: Fix [-Wcalloc-transposed-args] compiler warning
  ext/gd: Fix [-Wcalloc-transposed-args] compiler warning
  ext/ffi: Fix [-Wenum-int-mismatch] compiler warning
  ext/bcmath: Fix [-Wenum-int-mismatch] compiler warning
2024-05-21 12:23:45 +01:00
Gina Peter Banyard
b2c0db1f89
Merge branch 'PHP-8.2' into PHP-8.3
* PHP-8.2:
  ext/readline: Fix [-Wcalloc-transposed-args] compiler warning
  ext/pdo_mysql: Fix [-Wcalloc-transposed-args] compiler warning
  ext/gd: Fix [-Wcalloc-transposed-args] compiler warning
  ext/ffi: Fix [-Wenum-int-mismatch] compiler warning
  ext/bcmath: Fix [-Wenum-int-mismatch] compiler warning
2024-05-21 12:21:46 +01:00
Gina Peter Banyard
3c45152798
ext/gd: Fix [-Wcalloc-transposed-args] compiler warning 2024-05-21 12:17:25 +01:00
Peter Kokot
4f7a3d9053
Merge branch 'PHP-8.3'
* PHP-8.3:
  Fix GH-12019: ext/gd/config.m4: don't forget GDLIB_CFLAGS in feature tests
2024-03-18 11:59:34 +01:00
Peter Kokot
f66696548b
Merge branch 'PHP-8.2' into PHP-8.3
* PHP-8.2:
  Fix GH-12019: ext/gd/config.m4: don't forget GDLIB_CFLAGS in feature tests
2024-03-18 11:58:56 +01:00
Michael Orlitzky
00799320ec
Fix GH-12019: ext/gd/config.m4: don't forget GDLIB_CFLAGS in feature tests
In commit 85e5635a, a feature test for the various libgd image formats
was added. That test however erroneously omits the GDLIB_CFLAGS (from
pkg-config) during compilation. This can lead to build failures and
therefore false negatives from the test.

Here, we add $GDLIB_CFLAGS to $CFLAGS for the duration of the test.

Closes GH-12019
2024-03-18 11:57:20 +01:00
David Carlier
868257a3de Fix GH-13727: macro generating invalid call test prototypes fixes.
autoconf/libtool generating code to test features missed `void` for
C calls prototypes w/o arguments.
Note that specific changes related to libtool have to be upstreamed.

Co-authored-by: Peter Kokot <petk@php.net>

close GH-13732
2024-03-18 06:53:39 +00:00
Peter Kokot
ba8633a9ce
Use fabsf() and floorf() unconditionally in bundled libgd (#13624)
These are available since C99 with math.h also on Windows, without
requiring checking. Upstream libgd uses floorf() unconditionally and
doesn't use fabsf().
2024-03-08 19:28:52 +01:00