Exception on Special:NewFiles, when no bot group is defined
authorumherirrender <umherirrender_de.wp@web.de>
Fri, 13 Jul 2012 13:40:18 +0000 (15:40 +0200)
committerumherirrender <umherirrender_de.wp@web.de>
Fri, 13 Jul 2012 13:40:18 +0000 (15:40 +0200)
When no user group has the permission 'bot', the list is empty and
Database::makeList throws an exception

Change-Id: I7ac5863ef22b1454857399b0cff52850eca7d3b8

includes/specials/SpecialNewimages.php

index 45dbd36..35f39ce 100644 (file)
@@ -68,15 +68,18 @@ class NewFilesPager extends ReverseChronologicalPager {
                $tables = array( 'image' );
 
                if( !$this->showbots ) {
-                       $tables[] = 'user_groups';
-                       $conds[] = 'ug_group IS NULL';
-                       $jconds['user_groups'] = array(
-                               'LEFT JOIN',
-                               array(
-                                       'ug_group' => User::getGroupsWithPermission( 'bot' ),
-                                       'ug_user = img_user'
-                               )
-                       );
+                       $groupsWithBotPermission = User::getGroupsWithPermission( 'bot' );
+                       if( count( $groupsWithBotPermission ) ) {
+                               $tables[] = 'user_groups';
+                               $conds[] = 'ug_group IS NULL';
+                               $jconds['user_groups'] = array(
+                                       'LEFT JOIN',
+                                       array(
+                                               'ug_group' => $groupsWithBotPermission,
+                                               'ug_user = img_user'
+                                       )
+                               );
+                       }
                }
 
                if( !$wgMiserMode && $this->like !== null ){