X-Git-Url: https://git.heureux-cyclage.org/?a=blobdiff_plain;f=includes%2FSpecialLog.php;h=409ca23beaedfafced2e8b2f67ff7b4e0b7d4338;hb=5fa40fe0fbfb379022430c24fcf66392e229d9a5;hp=65de257e33c701da782703b6e63c4fe0b63f74b2;hpb=6d0e491af0164d0e76b92fb3ee4f14e10b6e967d;p=lhc%2Fweb%2Fwiklou.git diff --git a/includes/SpecialLog.php b/includes/SpecialLog.php index 65de257e33..409ca23bea 100644 --- a/includes/SpecialLog.php +++ b/includes/SpecialLog.php @@ -14,13 +14,12 @@ # # You should have received a copy of the GNU General Public License along # with this program; if not, write to the Free Software Foundation, Inc., -# 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. +# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. # http://www.gnu.org/copyleft/gpl.html /** * - * @package MediaWiki - * @subpackage SpecialPage + * @addtogroup SpecialPage */ /** @@ -28,18 +27,17 @@ */ function wfSpecialLog( $par = '' ) { global $wgRequest; - $logReader =& new LogReader( $wgRequest ); + $logReader = new LogReader( $wgRequest ); if( $wgRequest->getVal( 'type' ) == '' && $par != '' ) { $logReader->limitType( $par ); } - $logViewer =& new LogViewer( $logReader ); + $logViewer = new LogViewer( $logReader ); $logViewer->show(); } /** * - * @package MediaWiki - * @subpackage SpecialPage + * @addtogroup SpecialPage */ class LogReader { var $db, $joinClauses, $whereClauses; @@ -49,7 +47,7 @@ class LogReader { * @param WebRequest $request For internal use use a FauxRequest object to pass arbitrary parameters. */ function LogReader( $request ) { - $this->db =& wfGetDB( DB_SLAVE ); + $this->db = wfGetDB( DB_SLAVE ); $this->setupQuery( $request ); } @@ -61,8 +59,10 @@ class LogReader { function setupQuery( $request ) { $page = $this->db->tableName( 'page' ); $user = $this->db->tableName( 'user' ); - $this->joinClauses = array( "LEFT OUTER JOIN $page ON log_namespace=page_namespace AND log_title=page_title" ); - $this->whereClauses = array( 'user_id=log_user' ); + $this->joinClauses = array( + "LEFT OUTER JOIN $page ON log_namespace=page_namespace AND log_title=page_title", + "INNER JOIN $user ON user_id=log_user" ); + $this->whereClauses = array(); $this->limitType( $request->getVal( 'type' ) ); $this->limitUser( $request->getText( 'user' ) ); @@ -95,13 +95,19 @@ class LogReader { function limitUser( $name ) { if ( $name == '' ) return false; - $title = Title::makeTitle( NS_USER, $name ); - if ( is_null( $title ) ) + $usertitle = Title::makeTitleSafe( NS_USER, $name ); + if ( is_null( $usertitle ) ) return false; - $this->user = $title->getText(); - $safename = $this->db->strencode( $this->user ); - $user = $this->db->tableName( 'user' ); - $this->whereClauses[] = "user_name='$safename'"; + $this->user = $usertitle->getText(); + + /* Fetch userid at first, if known, provides awesome query plan afterwards */ + $userid = $this->db->selectField('user','user_id',array('user_name'=>$this->user)); + if (!$userid) + /* It should be nicer to abort query at all, + but for now it won't pass anywhere behind the optimizer */ + $this->whereClauses[] = "NULL"; + else + $this->whereClauses[] = "log_user=$userid"; } /** @@ -143,13 +149,12 @@ class LogReader { */ function getQuery() { $logging = $this->db->tableName( "logging" ); - $user = $this->db->tableName( 'user' ); - $sql = "SELECT log_type, log_action, log_timestamp, + $sql = "SELECT /*! STRAIGHT_JOIN */ log_type, log_action, log_timestamp, log_user, user_name, log_namespace, log_title, page_id, - log_comment, log_params FROM $user, $logging "; + log_comment, log_params FROM $logging "; if( !empty( $this->joinClauses ) ) { - $sql .= implode( ',', $this->joinClauses ); + $sql .= implode( ' ', $this->joinClauses ); } if( !empty( $this->whereClauses ) ) { $sql .= " WHERE " . implode( ' AND ', $this->whereClauses ); @@ -164,7 +169,7 @@ class LogReader { * @return ResultWrapper result object to return the relevant rows */ function getRows() { - $res = $this->db->query( $this->getQuery() ); + $res = $this->db->query( $this->getQuery(), 'LogReader::getRows' ); return $this->db->resultObject( $res ); } @@ -196,8 +201,7 @@ class LogReader { /** * - * @package MediaWiki - * @subpackage SpecialPage + * @addtogroup SpecialPage */ class LogViewer { /** @@ -211,7 +215,7 @@ class LogViewer { */ function LogViewer( &$reader ) { global $wgUser; - $this->skin =& $wgUser->getSkin(); + $this->skin = $wgUser->getSkin(); $this->reader =& $reader; } @@ -238,7 +242,6 @@ class LogViewer { * @return object database result set */ function getLogRows() { - global $wgLinkCache; $result = $this->reader->getRows(); $this->numResults = 0; @@ -246,8 +249,8 @@ class LogViewer { $batch = new LinkBatch; while ( $s = $result->fetchObject() ) { // User link - $title = Title::makeTitleSafe( NS_USER, $s->user_name ); - $batch->addObj( $title ); + $batch->addObj( Title::makeTitleSafe( NS_USER, $s->user_name ) ); + $batch->addObj( Title::makeTitleSafe( NS_USER_TALK, $s->user_name ) ); // Move destination link if ( $s->log_type == 'move' ) { @@ -257,7 +260,7 @@ class LogViewer { } ++$this->numResults; } - $batch->execute( $wgLinkCache ); + $batch->execute(); return $result; } @@ -275,7 +278,6 @@ class LogViewer { function doShowList( &$out, $result ) { // Rewind result pointer and go through it again, making the HTML - $html=''; if ($this->numResults > 0) { $html = "\n