+ /**
+ * Get the last N authors
+ * @param int $num Number of revisions to get
+ * @param string $revLatest The latest rev_id, selected from the master (optional)
+ * @return array Array of authors, duplicates not removed
+ */
+ function getLastNAuthors( $num, $revLatest = 0 ) {
+ $fname = 'Article::getLastNAuthors';
+ wfProfileIn( $fname );
+
+ // First try the slave
+ // If that doesn't have the latest revision, try the master
+ $continue = 2;
+ $db =& wfGetDB( DB_SLAVE );
+ do {
+ $res = $db->select( array( 'page', 'revision' ),
+ array( 'rev_id', 'rev_user_text' ),
+ array(
+ 'page_namespace' => $this->mTitle->getNamespace(),
+ 'page_title' => $this->mTitle->getDBkey(),
+ 'rev_page = page_id'
+ ), $fname, $this->getSelectOptions( array(
+ 'ORDER BY' => 'rev_timestamp DESC',
+ 'LIMIT' => $num
+ ) )
+ );
+ if ( !$res ) {
+ wfProfileOut( $fname );
+ return array();
+ }
+ $row = $db->fetchObject( $res );
+ if ( $continue == 2 && $revLatest && $row->rev_id != $revLatest ) {
+ $db =& wfGetDB( DB_MASTER );
+ $continue--;
+ } else {
+ $continue = 0;
+ }
+ } while ( $continue );
+
+ $authors = array( $row->rev_user_text );
+ while ( $row = $db->fetchObject( $res ) ) {
+ $authors[] = $row->rev_user_text;
+ }
+ wfProfileOut( $fname );
+ return $authors;
+ }
+