Merge "Adjusting badge size per Vibha"
[lhc/web/wiklou.git] / includes / cache / GenderCache.php
index 6a9ecd2..63e4226 100644 (file)
@@ -59,8 +59,8 @@ class GenderCache {
 
        /**
         * Returns the gender for given username.
-        * @param $username String or User: username
-        * @param $caller String: the calling method
+        * @param string $username or User: username
+        * @param string $caller the calling method
         * @return String
         */
        public function getGenderOf( $username, $caller = '' ) {
@@ -111,10 +111,33 @@ class GenderCache {
                $this->doQuery( array_keys( $users ), $caller );
        }
 
+       /**
+        * Wrapper for doQuery that processes a title or string array.
+        *
+        * @since 1.20
+        * @param $titles List: array of Title objects or strings
+        * @param string $caller the calling method
+        */
+       public function doTitlesArray( $titles, $caller = '' ) {
+               $users = array();
+               foreach ( $titles as $title ) {
+                       $titleObj = is_string( $title ) ? Title::newFromText( $title ) : $title;
+                       if ( !$titleObj ) {
+                               continue;
+                       }
+                       if ( !MWNamespace::hasGenderDistinction( $titleObj->getNamespace() ) ) {
+                               continue;
+                       }
+                       $users[] = $titleObj->getText();
+               }
+
+               $this->doQuery( $users, $caller );
+       }
+
        /**
         * Preloads genders for given list of users.
         * @param $users List|String: usernames
-        * @param $caller String: the calling method
+        * @param string $caller the calling method
         */
        public function doQuery( $users, $caller = '' ) {
                $default = $this->getDefault();