From f7ac35d5c63d736e83e2a65f01e4daf01676a1d3 Mon Sep 17 00:00:00 2001 From: Daimona Eaytoy Date: Mon, 16 Sep 2019 16:02:33 +0200 Subject: [PATCH] Hard-deprecate too many params Bug: T230803 Change-Id: Icec8bcb8ab23956654857acc8b3d235889f587a9 --- includes/parser/AFPTreeParser.php | 18 ++++++++++++++---- includes/parser/AbuseFilterParser.php | 18 ++++++++++++++---- 2 files changed, 28 insertions(+), 8 deletions(-) diff --git a/includes/parser/AFPTreeParser.php b/includes/parser/AFPTreeParser.php index e9cf89a22..66345786e 100644 --- a/includes/parser/AFPTreeParser.php +++ b/includes/parser/AFPTreeParser.php @@ -758,11 +758,21 @@ class AFPTreeParser { [ $func, $min, count( $args ) ] ); } elseif ( count( $args ) > $max ) { - $this->logger->warning( - "Too many params to $func for filter: " . ( $this->mFilter ?? 'unavailable' ) - ); + if ( $this->mFilter !== null ) { + $this->logger->warning( + 'DEPRECATED! Too many params passed to function `{func}`: got {actual_count}, ' . + 'expected {max_count} when parsing filter: {filter}. This is deprecated since ' . + '1.34 and support will cease as of 1.35. Please fix the affected filter!', + [ + 'func' => $func, + 'actual_count' => count( $args ), + 'max_count' => $max, + 'filter' => $this->mFilter + ] + ); + } /* - @todo Uncomment after fixing filters in WMF production + @todo Uncomment in 1.35/36 throw new AFPUserVisibleException( 'toomanyargs', $this->mCur->pos, diff --git a/includes/parser/AbuseFilterParser.php b/includes/parser/AbuseFilterParser.php index a0b4ff96c..4622ccc9d 100644 --- a/includes/parser/AbuseFilterParser.php +++ b/includes/parser/AbuseFilterParser.php @@ -1213,11 +1213,21 @@ class AbuseFilterParser { [ $func, $min, count( $args ) ] ); } elseif ( count( $args ) > $max ) { - $this->logger->warning( - "Too many params to $func for filter: " . ( $this->mFilter ?? 'unavailable' ) - ); + if ( $this->mFilter !== null ) { + $this->logger->warning( + 'DEPRECATED! Too many params passed to function `{func}`: got {actual_count}, ' . + 'expected {max_count} when parsing filter: {filter}. This is deprecated since ' . + '1.34 and support will cease as of 1.35. Please fix the affected filter!', + [ + 'func' => $func, + 'actual_count' => count( $args ), + 'max_count' => $max, + 'filter' => $this->mFilter + ] + ); + } /* - @todo Uncomment after fixing filters in WMF production + @todo Uncomment in 1.35/36 throw new AFPUserVisibleException( 'toomanyargs', $this->mCur->pos,