[php-src] PHP-8.5: Merge branch 'PHP-8.4' into PHP-8.5

Weilin Du <[email protected]>
Newsgroups gmane.comp.php.cvs.general
Message-ID <[email protected]>
Author: Weilin Du (LamentXU123)
Date: 2026-08-19T13:43:56+08:00

Commit: https://github.com/php/php-src/commit/75e28802b4db9818d8baf3b130724116402f7ef1
Raw diff: https://github.com/php/php-src/commit/75e28802b4db9818d8baf3b130724116402f7ef1.diff

Merge branch 'PHP-8.4' into PHP-8.5

* PHP-8.4:
  ext/gd: Fix incorrect argument numbers in GD affine function errors (#23356)

Changed paths:
  A  ext/gd/tests/imageaffinematrixconcat_error.phpt
  M  NEWS
  M  ext/gd/gd.c
  M  ext/gd/tests/bug67248.phpt


Diff:

diff --git a/NEWS b/NEWS
index 185c4799343b..790e4ef21dad 100644
--- a/NEWS
+++ b/NEWS
@@ -16,6 +16,10 @@ PHP                                                                        NEWS
   . Fixed a use-after-free when Dom\Element::setAttributeNS() replaces the
     value of an attribute whose child still has a live wrapper. (iliaal)
 
+- GD:
+  . Fixed imageaffinematrixget() and imageaffinematrixconcat() reporting the
+    wrong argument in error messages. (Weilin Du)
+
 - Intl:
   . Fixed a double-free when IntlGregorianCalendar construction fails after
     the ICU constructor adopts the TimeZone. (iliaal)
diff --git a/ext/gd/gd.c b/ext/gd/gd.c
index 77fd1bdd31e6..3370dbd05403 100644
--- a/ext/gd/gd.c
+++ b/ext/gd/gd.c
@@ -4086,7 +4086,7 @@ PHP_FUNCTION(imageaffinematrixget)
 		case GD_AFFINE_SCALE: {
 			double x, y;
 			if (Z_TYPE_P(options) != IS_ARRAY) {
-				zend_argument_type_error(1, "must be of type array when using translate or scale");
+				zend_argument_type_error(2, "must be of type array when using translate or scale");
 				RETURN_THROWS();
 			}
 
@@ -4168,7 +4168,7 @@ PHP_FUNCTION(imageaffinematrixconcat)
 	}
 
 	if (zend_hash_num_elements(Z_ARRVAL_P(z_m2)) != 6) {
-		zend_argument_value_error(1, "must have 6 elements");
+		zend_argument_value_error(2, "must have 6 elements");
 		RETURN_THROWS();
 	}
 
diff --git a/ext/gd/tests/bug67248.phpt b/ext/gd/tests/bug67248.phpt
index a002f71c7fd3..5f00b94fadcd 100644
--- a/ext/gd/tests/bug67248.phpt
+++ b/ext/gd/tests/bug67248.phpt
@@ -17,8 +17,8 @@ for($i=0;$i<7;$i++) {
 }
 ?>
 --EXPECTF--
-!! [TypeError] imageaffinematrixget(): Argument #1 ($type) must be of type array when using translate or scale
-!! [TypeError] imageaffinematrixget(): Argument #1 ($type) must be of type array when using translate or scale
+!! [TypeError] imageaffinematrixget(): Argument #2 ($options) must be of type array when using translate or scale
+!! [TypeError] imageaffinematrixget(): Argument #2 ($options) must be of type array when using translate or scale
 
 Warning: Object of class stdClass could not be converted to float in %s on line %d
 array(6) {
diff --git a/ext/gd/tests/imageaffinematrixconcat_error.phpt b/ext/gd/tests/imageaffinematrixconcat_error.phpt
new file mode 100644
index 000000000000..91b355547f38
--- /dev/null
+++ b/ext/gd/tests/imageaffinematrixconcat_error.phpt
@@ -0,0 +1,14 @@
+--TEST--
+imageaffinematrixconcat() reports the correct argument for an invalid matrix size
+--EXTENSIONS--
+gd
+--FILE--
+<?php
+try {
+    imageaffinematrixconcat([1, 0, 0, 1, 0, 0], []);
+} catch (Throwable $e) {
+    echo $e::class, ': ', $e->getMessage(), "\n";
+}
+?>
+--EXPECT--
+ValueError: imageaffinematrixconcat(): Argument #2 ($matrix2) must have 6 elements
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.