From df04529010c65074f61373ad6cf80051a34f614d Mon Sep 17 00:00:00 2001 From: Scott Taylor Date: Thu, 26 Jun 2014 17:51:52 +0000 Subject: [PATCH] Add a second optional parameter to `absint()` to limit the result to `PHP_INT_MAX`. See #23383. git-svn-id: https://develop.svn.wordpress.org/trunk@28855 602fd350-edb4-49c9-b593-d223f7449a82 --- src/wp-includes/functions.php | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/src/wp-includes/functions.php b/src/wp-includes/functions.php index bc8135a1b4..7714c72218 100644 --- a/src/wp-includes/functions.php +++ b/src/wp-includes/functions.php @@ -3000,10 +3000,15 @@ function dead_db() { * @since 2.5.0 * * @param mixed $maybeint Data you wish to have converted to a nonnegative integer + * @param bool $limit Whether to only return up to PHP_INT_MAX. * @return int An nonnegative integer */ -function absint( $maybeint ) { - return abs( intval( $maybeint ) ); +function absint( $maybeint, $limit = false ) { + $int = abs( intval( $maybeint ) ); + if ( $limit && $int > PHP_INT_MAX ) { + $int = PHP_INT_MAX; + } + return $int; } /**