-<?
+<?php
# Class to simplify the use of log pages
class LogPage {
$sql = "SELECT cur_id,cur_text,cur_timestamp FROM cur " .
"WHERE cur_namespace=" . Namespace::getWikipedia() . " AND " .
"cur_title='" . wfStrencode($this->mTitle ) . "'";
- $res = wfQuery( $sql, "LogPage::getContent" );
+ $res = wfQuery( $sql, DB_READ, "LogPage::getContent" );
if( wfNumRows( $res ) > 0 ) {
$s = wfFetchObject( $res );
$won = wfInvertTimestamp( $now );
if($this->mId == 0) {
$sql = "INSERT INTO cur (cur_timestamp,cur_user,cur_user_text,
- cur_namespace,cur_title,cur_text,cur_comment,cur_restrictions,inverse_timestamp)
+ cur_namespace,cur_title,cur_text,cur_comment,cur_restrictions,
+ inverse_timestamp,cur_touched)
VALUES ('{$now}', {$uid}, '{$ut}', " .
Namespace::getWikipedia() . ", '" .
wfStrencode( $this->mTitle ) . "', '" .
wfStrencode( $this->mContent ) . "', '" .
- wfStrencode( $this->mComment ) . "', 'sysop', '{$won}')";
- wfQuery( $sql, $fname );
+ wfStrencode( $this->mComment ) . "', 'sysop', '{$won}','{$now}')";
+ wfQuery( $sql, DB_WRITE, $fname );
$this->mId = wfInsertId();
} else {
$sql = "UPDATE cur SET cur_timestamp='{$now}', " .
"cur_user={$uid}, cur_user_text='{$ut}', " .
"cur_text='" . wfStrencode( $this->mContent ) . "', " .
"cur_comment='" . wfStrencode( $this->mComment ) . "', " .
- "cur_restrictions='sysop', inverse_timestamp='{$won}' " .
+ "cur_restrictions='sysop', inverse_timestamp='{$won}', cur_touched='{$now}' " .
"WHERE cur_id={$this->mId}";
- wfQuery( $sql, $fname );
+ wfQuery( $sql, DB_WRITE, $fname );
}
# And update recentchanges
if ( $this->mUpdateRecentChanges ) {
- $sql = "INSERT INTO recentchanges (rc_timestamp,rc_cur_time,
- rc_user,rc_user_text,rc_namespace,rc_title,rc_comment,
- rc_cur_id) VALUES ('{$now}','{$now}',{$uid},'{$ut}',4,'" .
- wfStrencode( $this->mTitle ) . "','" .
- wfStrencode( $this->mComment ) . "',{$this->mId})";
- wfQuery( $sql, $fname );
- }
+ $titleObj = Title::makeTitle( Namespace::getWikipedia(), $this->mTitle );
+ RecentChange::notifyLog( $now, $titleObj, $wgUser, $this->mComment );
+ }
return true;
}
function addEntry( $action, $comment, $textaction = "" )
{
global $wgLang, $wgUser;
+
+ $comment_esc = wfEscapeWikiText( $comment );
+
$this->getContent();
$ut = $wgUser->getName();
}
$d = $wgLang->timeanddate( wfTimestampNow(), false );
- preg_match( "/^(.*?)<ul>(.*)$/sD", $this->mContent, $m );
-
+ if( preg_match( "/^(.*?)<ul>(.*)$/sD", $this->mContent, $m ) ) {
+ $before = $m[1];
+ $after = $m[2];
+ } else {
+ $before = "";
+ $after = "";
+ }
+
if($textaction)
$this->mComment = $textaction;
else
if ( "" == $comment ) {
$inline = "";
} else {
- $inline = " <em>({$comment})</em>";
+ $inline = " <em>({$comment_esc})</em>";
+ # comment gets escaped again, so we use the unescaped version
$this->mComment .= ": {$comment}";
}
- $this->mContent = "{$m[1]}<ul><li>{$d} {$ul} {$action}{$inline}</li>\n{$m[2]}";
+ $this->mContent = "{$before}<ul><li>{$d} {$ul} {$action}{$inline}</li>\n{$after}";
# TODO: automatic log rotation...
function showAsDisabledPage( $rawhtml = true )
{
global $wgLang, $wgOut;
- $wgOut->checkLastModified( $this->getTimestamp() );
+ if( $wgOut->checkLastModified( $this->getTimestamp() ) ){
+ # Client cache fresh and headers sent, nothing more to do.
+ return;
+ }
$func = ( $rawhtml ? "addHTML" : "addWikiText" );
$wgOut->$func(
"<p>" . wfMsg( "perfdisabled" ) . "</p>\n\n" .