Skip to content

Commit

Permalink
Deprecate $num_points parameter of image(open|filled)polygon
Browse files Browse the repository at this point in the history
Cf. <https://wiki.php.net/rfc/deprecations_php_8_1#num_points_parameter_of_image_open_filled_polygon>.

Co-authored-by: Máté Kocsis <kocsismate@woohoolabs.com>
Co-authored-by: George Peter Banyard <7906688+Girgias@users.noreply.github.com>

Closes GH-6789.
  • Loading branch information
cmb69 committed Jul 14, 2021
1 parent 4b3615a commit e1285c4
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 1 deletion.
3 changes: 3 additions & 0 deletions UPGRADING
Expand Up @@ -370,6 +370,9 @@ PHP 8.1 UPGRADE NOTES
. The filter.default ini setting is deprecated.
RFC: https://wiki.php.net/rfc/deprecations_php_8_1

- GD:
. The $num_points parameter of image(open|filled)polygon has been deprecated.

- Hash:
. The mhash(), mhash_keygen_s2k(), mhash_count(), mhash_get_block_size() and
mhash_get_hash_name() functions are deprecated. Use the hash_*() APIs
Expand Down
2 changes: 2 additions & 0 deletions ext/gd/gd.c
Expand Up @@ -2726,6 +2726,8 @@ static void php_imagepolygon(INTERNAL_FUNCTION_PARAMETERS, int filled)
RETURN_THROWS();
}
NPOINTS /= 2;
} else {
php_error_docref(NULL, E_DEPRECATED, "Using the $num_points parameter is deprecated");
}

im = php_gd_libgdimageptr_from_zval_p(IM);
Expand Down
5 changes: 4 additions & 1 deletion ext/gd/tests/bug55005.phpt
Expand Up @@ -14,6 +14,9 @@ trycatch_dump(
fn () => imagepolygon($g, array(200,10, 200,100, 280,100), 2, $fgnd)
);
?>
--EXPECT--
--EXPECTF--
Deprecated: imagefilledpolygon(): Using the $num_points parameter is deprecated in %s on line %d
!! [ValueError] imagefilledpolygon(): Argument #3 ($num_points_or_color) must be greater than or equal to 3

Deprecated: imagepolygon(): Using the $num_points parameter is deprecated in %s on line %d
!! [ValueError] imagepolygon(): Argument #3 ($num_points_or_color) must be greater than or equal to 3

0 comments on commit e1285c4

Please sign in to comment.