From: Siebrand Mazeland Date: Fri, 27 Dec 2013 17:02:40 +0000 (+0100) Subject: Throw exception for unknown field in SpecialListfiles::formatValue() X-Git-Tag: 1.31.0-rc.0~17430 X-Git-Url: https://git.cyclocoop.org/%242?a=commitdiff_plain;h=e6c7c85779c984f45eeab9375e7a64fddd4c40a0;p=lhc%2Fweb%2Fwiklou.git Throw exception for unknown field in SpecialListfiles::formatValue() Change-Id: I99fedfb28aaf9b09b5d9fee27020601f3c06e8d4 --- diff --git a/includes/specials/SpecialListfiles.php b/includes/specials/SpecialListfiles.php index b5181401c9..ba3e73f7cb 100644 --- a/includes/specials/SpecialListfiles.php +++ b/includes/specials/SpecialListfiles.php @@ -387,6 +387,20 @@ class ImageListPager extends TablePager { UserCache::singleton()->doQuery( $userIds, array( 'userpage' ), __METHOD__ ); } + /** + * @param string $field + * @param string $value + * @return Message|string|int The return type depends on the value of $field: + * - thumb: string + * - img_timestamp: string + * - img_name: string + * - img_user_text: string + * - img_size: string + * - img_description: string + * - count: int + * - top: Message + * @throws MWException + */ function formatValue( $field, $value ) { switch ( $field ) { case 'thumb': @@ -446,6 +460,8 @@ class ImageListPager extends TablePager { case 'top': // Messages: listfiles-latestversion-yes, listfiles-latestversion-no return $this->msg( 'listfiles-latestversion-' . $value ); + default: + throw new MWException( "Unknown field '$field'" ); } } diff --git a/tests/phpunit/includes/specials/SpecialListFilesTest.php b/tests/phpunit/includes/specials/SpecialListFilesTest.php new file mode 100644 index 0000000000..2689236b67 --- /dev/null +++ b/tests/phpunit/includes/specials/SpecialListFilesTest.php @@ -0,0 +1,21 @@ +formatValue( 'invalid_field', 'invalid_value' ); + } +}