2004-02-18 02:15:00 +00:00
|
|
|
<?php
|
2012-05-11 08:34:29 +00:00
|
|
|
/**
|
|
|
|
|
* Utility class for creating and accessing recent change entries.
|
|
|
|
|
*
|
|
|
|
|
* This program is free software; you can redistribute it and/or modify
|
|
|
|
|
* it under the terms of the GNU General Public License as published by
|
|
|
|
|
* the Free Software Foundation; either version 2 of the License, or
|
|
|
|
|
* (at your option) any later version.
|
|
|
|
|
*
|
|
|
|
|
* This program is distributed in the hope that it will be useful,
|
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
|
* GNU General Public License for more details.
|
|
|
|
|
*
|
|
|
|
|
* 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.,
|
|
|
|
|
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
|
|
|
|
* http://www.gnu.org/copyleft/gpl.html
|
|
|
|
|
*
|
|
|
|
|
* @file
|
|
|
|
|
*/
|
|
|
|
|
|
2004-09-02 23:28:24 +00:00
|
|
|
/**
|
|
|
|
|
* Utility class for creating new RC entries
|
2010-08-08 14:23:14 +00:00
|
|
|
*
|
2005-06-29 07:01:24 +00:00
|
|
|
* mAttribs:
|
2010-01-21 22:01:38 +00:00
|
|
|
* rc_id id of the row in the recentchanges table
|
|
|
|
|
* rc_timestamp time the entry was made
|
|
|
|
|
* rc_cur_time timestamp on the cur row
|
|
|
|
|
* rc_namespace namespace #
|
|
|
|
|
* rc_title non-prefixed db key
|
|
|
|
|
* rc_type is new entry, used to determine whether updating is necessary
|
|
|
|
|
* rc_minor is minor
|
|
|
|
|
* rc_cur_id page_id of associated page entry
|
|
|
|
|
* rc_user user id who made the entry
|
|
|
|
|
* rc_user_text user name who made the entry
|
|
|
|
|
* rc_comment edit summary
|
|
|
|
|
* rc_this_oldid rev_id associated with this entry (or zero)
|
|
|
|
|
* rc_last_oldid rev_id associated with the entry before this one (or zero)
|
|
|
|
|
* rc_bot is bot, hidden
|
|
|
|
|
* rc_ip IP address of the user in dotted quad notation
|
|
|
|
|
* rc_new obsolete, use rc_type==RC_NEW
|
|
|
|
|
* rc_patrolled boolean whether or not someone has marked this edit as patrolled
|
|
|
|
|
* rc_old_len integer byte length of the text before the edit
|
|
|
|
|
* rc_new_len the same after the edit
|
|
|
|
|
* rc_deleted partial deletion
|
|
|
|
|
* rc_logid the log_id value for this log entry (or zero)
|
|
|
|
|
* rc_log_type the log type (or null)
|
|
|
|
|
* rc_log_action the log action (or null)
|
|
|
|
|
* rc_params log params
|
2005-07-01 10:44:48 +00:00
|
|
|
*
|
2004-09-02 23:28:24 +00:00
|
|
|
* mExtra:
|
2010-01-21 22:01:38 +00:00
|
|
|
* prefixedDBkey prefixed db key, used by external app via msg queue
|
|
|
|
|
* lastTimestamp timestamp of previous entry, used in WHERE clause during update
|
|
|
|
|
* lang the interwiki prefix, automatically set in save()
|
2005-06-29 07:01:24 +00:00
|
|
|
* oldSize text size before the change
|
|
|
|
|
* newSize text size after the change
|
2005-07-01 10:44:48 +00:00
|
|
|
*
|
2010-01-21 22:01:38 +00:00
|
|
|
* temporary: not stored in the database
|
2004-12-18 03:47:11 +00:00
|
|
|
* notificationtimestamp
|
|
|
|
|
* numberofWatchingusers
|
|
|
|
|
*
|
2004-09-02 23:28:24 +00:00
|
|
|
* @todo document functions and variables
|
|
|
|
|
*/
|
2010-01-21 22:01:38 +00:00
|
|
|
class RecentChange {
|
2006-05-11 22:40:38 +00:00
|
|
|
var $mAttribs = array(), $mExtra = array();
|
2011-04-11 12:47:55 +00:00
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* @var Title
|
|
|
|
|
*/
|
|
|
|
|
var $mTitle = false;
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* @var Title
|
|
|
|
|
*/
|
|
|
|
|
var $mMovedToTitle = false;
|
2006-05-11 22:40:38 +00:00
|
|
|
var $numberofWatchingusers = 0 ; # Dummy to prevent error message in SpecialRecentchangeslinked
|
2012-01-14 15:27:30 +00:00
|
|
|
var $notificationtimestamp;
|
2004-01-17 05:49:39 +00:00
|
|
|
|
|
|
|
|
# Factory methods
|
2004-08-09 05:38:11 +00:00
|
|
|
|
2011-10-29 01:17:26 +00:00
|
|
|
/**
|
|
|
|
|
* @param $row
|
|
|
|
|
* @return RecentChange
|
|
|
|
|
*/
|
2008-10-17 23:52:57 +00:00
|
|
|
public static function newFromRow( $row ) {
|
2004-01-17 05:49:39 +00:00
|
|
|
$rc = new RecentChange;
|
|
|
|
|
$rc->loadFromRow( $row );
|
|
|
|
|
return $rc;
|
|
|
|
|
}
|
2004-08-09 05:38:11 +00:00
|
|
|
|
2011-10-29 01:17:26 +00:00
|
|
|
/**
|
2012-01-14 15:27:30 +00:00
|
|
|
* @param $row
|
2011-10-29 01:17:26 +00:00
|
|
|
* @return RecentChange
|
|
|
|
|
*/
|
2008-10-17 23:52:57 +00:00
|
|
|
public static function newFromCurRow( $row ) {
|
2004-01-17 09:49:43 +00:00
|
|
|
$rc = new RecentChange;
|
2008-06-16 02:39:43 +00:00
|
|
|
$rc->loadFromCurRow( $row );
|
2004-12-18 03:47:11 +00:00
|
|
|
$rc->notificationtimestamp = false;
|
|
|
|
|
$rc->numberofWatchingusers = false;
|
2004-01-17 09:49:43 +00:00
|
|
|
return $rc;
|
|
|
|
|
}
|
2008-04-14 07:45:50 +00:00
|
|
|
|
2006-12-22 19:43:20 +00:00
|
|
|
/**
|
|
|
|
|
* Obtain the recent change with a given rc_id value
|
|
|
|
|
*
|
2011-01-05 23:08:13 +00:00
|
|
|
* @param $rcid Int rc_id value to retrieve
|
2006-12-22 19:43:20 +00:00
|
|
|
* @return RecentChange
|
|
|
|
|
*/
|
|
|
|
|
public static function newFromId( $rcid ) {
|
2007-01-22 23:50:42 +00:00
|
|
|
$dbr = wfGetDB( DB_SLAVE );
|
2012-03-14 16:18:27 +00:00
|
|
|
$row = $dbr->selectRow( 'recentchanges', '*', array( 'rc_id' => $rcid ), __METHOD__ );
|
|
|
|
|
if( $row !== false ) {
|
2006-12-22 19:43:20 +00:00
|
|
|
return self::newFromRow( $row );
|
|
|
|
|
} else {
|
2009-12-11 21:07:27 +00:00
|
|
|
return null;
|
2006-12-22 19:43:20 +00:00
|
|
|
}
|
|
|
|
|
}
|
2008-04-14 07:45:50 +00:00
|
|
|
|
2007-08-06 03:29:40 +00:00
|
|
|
/**
|
|
|
|
|
* Find the first recent change matching some specific conditions
|
|
|
|
|
*
|
2010-01-21 22:01:38 +00:00
|
|
|
* @param $conds Array of conditions
|
|
|
|
|
* @param $fname Mixed: override the method name in profiling/logs
|
2007-08-06 03:29:40 +00:00
|
|
|
* @return RecentChange
|
|
|
|
|
*/
|
2012-01-14 15:27:30 +00:00
|
|
|
public static function newFromConds( $conds, $fname = __METHOD__ ) {
|
2007-08-06 03:29:40 +00:00
|
|
|
$dbr = wfGetDB( DB_SLAVE );
|
|
|
|
|
$res = $dbr->select(
|
|
|
|
|
'recentchanges',
|
|
|
|
|
'*',
|
|
|
|
|
$conds,
|
|
|
|
|
$fname
|
|
|
|
|
);
|
|
|
|
|
if( $res instanceof ResultWrapper && $res->numRows() > 0 ) {
|
|
|
|
|
$row = $res->fetchObject();
|
|
|
|
|
$res->free();
|
|
|
|
|
return self::newFromRow( $row );
|
|
|
|
|
}
|
|
|
|
|
return null;
|
|
|
|
|
}
|
2004-01-17 09:49:43 +00:00
|
|
|
|
2004-01-17 05:49:39 +00:00
|
|
|
# Accessors
|
2004-08-09 05:38:11 +00:00
|
|
|
|
2012-01-14 15:27:30 +00:00
|
|
|
/**
|
|
|
|
|
* @param $attribs array
|
|
|
|
|
*/
|
2008-10-17 23:52:57 +00:00
|
|
|
public function setAttribs( $attribs ) {
|
2004-01-17 05:49:39 +00:00
|
|
|
$this->mAttribs = $attribs;
|
|
|
|
|
}
|
2004-08-09 05:38:11 +00:00
|
|
|
|
2012-01-14 15:27:30 +00:00
|
|
|
/**
|
|
|
|
|
* @param $extra array
|
|
|
|
|
*/
|
2008-10-17 23:52:57 +00:00
|
|
|
public function setExtra( $extra ) {
|
2004-01-17 05:49:39 +00:00
|
|
|
$this->mExtra = $extra;
|
|
|
|
|
}
|
2004-08-09 05:38:11 +00:00
|
|
|
|
2010-09-28 02:18:35 +00:00
|
|
|
/**
|
|
|
|
|
*
|
|
|
|
|
* @return Title
|
|
|
|
|
*/
|
2008-10-17 23:52:57 +00:00
|
|
|
public function &getTitle() {
|
|
|
|
|
if( $this->mTitle === false ) {
|
2004-01-17 05:49:39 +00:00
|
|
|
$this->mTitle = Title::makeTitle( $this->mAttribs['rc_namespace'], $this->mAttribs['rc_title'] );
|
2009-06-17 21:11:29 +00:00
|
|
|
# Make sure the correct page ID is process cached
|
|
|
|
|
$this->mTitle->resetArticleID( $this->mAttribs['rc_cur_id'] );
|
2004-01-17 05:49:39 +00:00
|
|
|
}
|
|
|
|
|
return $this->mTitle;
|
|
|
|
|
}
|
|
|
|
|
|
2011-10-29 01:17:26 +00:00
|
|
|
/**
|
|
|
|
|
* @return bool|\Title
|
|
|
|
|
*/
|
2008-10-17 23:52:57 +00:00
|
|
|
public function getMovedToTitle() {
|
|
|
|
|
if( $this->mMovedToTitle === false ) {
|
2004-08-09 05:38:11 +00:00
|
|
|
$this->mMovedToTitle = Title::makeTitle( $this->mAttribs['rc_moved_to_ns'],
|
2004-01-17 05:49:39 +00:00
|
|
|
$this->mAttribs['rc_moved_to_title'] );
|
|
|
|
|
}
|
|
|
|
|
return $this->mMovedToTitle;
|
|
|
|
|
}
|
|
|
|
|
|
2011-10-29 01:17:26 +00:00
|
|
|
/**
|
|
|
|
|
* Writes the data in this object to the database
|
2012-01-06 21:25:09 +00:00
|
|
|
* @param $noudp bool
|
2011-10-29 01:17:26 +00:00
|
|
|
*/
|
2011-11-03 17:07:29 +00:00
|
|
|
public function save( $noudp = false ) {
|
2012-03-06 19:38:17 +00:00
|
|
|
global $wgLocalInterwiki, $wgPutIPinRC, $wgContLang;
|
2004-08-09 05:38:11 +00:00
|
|
|
|
2007-01-22 23:50:42 +00:00
|
|
|
$dbw = wfGetDB( DB_MASTER );
|
2008-10-17 23:52:57 +00:00
|
|
|
if( !is_array($this->mExtra) ) {
|
2004-01-17 05:49:39 +00:00
|
|
|
$this->mExtra = array();
|
|
|
|
|
}
|
|
|
|
|
$this->mExtra['lang'] = $wgLocalInterwiki;
|
2004-08-09 05:38:11 +00:00
|
|
|
|
2008-10-17 23:52:57 +00:00
|
|
|
if( !$wgPutIPinRC ) {
|
2004-06-14 10:40:24 +00:00
|
|
|
$this->mAttribs['rc_ip'] = '';
|
|
|
|
|
}
|
2004-08-09 05:38:11 +00:00
|
|
|
|
2008-09-22 12:22:18 +00:00
|
|
|
# If our database is strict about IP addresses, use NULL instead of an empty string
|
2008-10-17 23:52:57 +00:00
|
|
|
if( $dbw->strictIPs() and $this->mAttribs['rc_ip'] == '' ) {
|
2006-08-16 00:59:34 +00:00
|
|
|
unset( $this->mAttribs['rc_ip'] );
|
|
|
|
|
}
|
|
|
|
|
|
2012-03-06 19:38:17 +00:00
|
|
|
# Make sure summary is truncated (whole multibyte characters)
|
|
|
|
|
$this->mAttribs['rc_comment'] = $wgContLang->truncate( $this->mAttribs['rc_comment'], 255 );
|
|
|
|
|
|
2004-08-19 12:59:57 +00:00
|
|
|
# Fixup database timestamps
|
2005-08-02 13:35:19 +00:00
|
|
|
$this->mAttribs['rc_timestamp'] = $dbw->timestamp($this->mAttribs['rc_timestamp']);
|
|
|
|
|
$this->mAttribs['rc_cur_time'] = $dbw->timestamp($this->mAttribs['rc_cur_time']);
|
2009-10-28 16:17:16 +00:00
|
|
|
$this->mAttribs['rc_id'] = $dbw->nextSequenceValue( 'recentchanges_rc_id_seq' );
|
2004-08-19 12:59:57 +00:00
|
|
|
|
2006-07-23 01:13:56 +00:00
|
|
|
## If we are using foreign keys, an entry of 0 for the page_id will fail, so use NULL
|
2008-10-17 23:52:57 +00:00
|
|
|
if( $dbw->cascadingDeletes() and $this->mAttribs['rc_cur_id']==0 ) {
|
2009-06-17 21:11:29 +00:00
|
|
|
unset( $this->mAttribs['rc_cur_id'] );
|
2006-07-23 01:13:56 +00:00
|
|
|
}
|
|
|
|
|
|
2004-01-17 05:49:39 +00:00
|
|
|
# Insert new row
|
2011-11-03 17:07:29 +00:00
|
|
|
$dbw->insert( 'recentchanges', $this->mAttribs, __METHOD__ );
|
2004-08-09 05:38:11 +00:00
|
|
|
|
2006-03-18 22:47:40 +00:00
|
|
|
# Set the ID
|
|
|
|
|
$this->mAttribs['rc_id'] = $dbw->insertId();
|
2011-10-29 01:17:26 +00:00
|
|
|
|
2009-01-09 18:05:58 +00:00
|
|
|
# Notify extensions
|
|
|
|
|
wfRunHooks( 'RecentChange_save', array( &$this ) );
|
2005-11-03 11:27:10 +00:00
|
|
|
|
2005-06-29 07:01:24 +00:00
|
|
|
# Notify external application via UDP
|
2011-11-03 17:07:29 +00:00
|
|
|
if ( !$noudp ) {
|
2011-11-03 17:09:29 +00:00
|
|
|
$this->notifyRC2UDP();
|
2004-01-17 05:49:39 +00:00
|
|
|
}
|
2006-01-07 13:31:29 +00:00
|
|
|
|
2006-09-30 12:34:53 +00:00
|
|
|
# E-mail notifications
|
2008-05-17 23:34:28 +00:00
|
|
|
global $wgUseEnotif, $wgShowUpdatedMarker, $wgUser;
|
|
|
|
|
if( $wgUseEnotif || $wgShowUpdatedMarker ) {
|
2008-05-17 22:57:46 +00:00
|
|
|
// Users
|
|
|
|
|
if( $this->mAttribs['rc_user'] ) {
|
2011-10-29 01:17:26 +00:00
|
|
|
$editor = ($wgUser->getId() == $this->mAttribs['rc_user']) ?
|
2008-05-17 22:57:46 +00:00
|
|
|
$wgUser : User::newFromID( $this->mAttribs['rc_user'] );
|
|
|
|
|
// Anons
|
|
|
|
|
} else {
|
2011-10-29 01:17:26 +00:00
|
|
|
$editor = ($wgUser->getName() == $this->mAttribs['rc_user_text']) ?
|
2008-05-17 22:57:46 +00:00
|
|
|
$wgUser : User::newFromName( $this->mAttribs['rc_user_text'], false );
|
|
|
|
|
}
|
2012-01-06 21:25:09 +00:00
|
|
|
$title = Title::makeTitle( $this->mAttribs['rc_namespace'], $this->mAttribs['rc_title'] );
|
|
|
|
|
|
2011-05-17 22:03:20 +00:00
|
|
|
# @todo FIXME: This would be better as an extension hook
|
2008-12-23 18:08:43 +00:00
|
|
|
$enotif = new EmailNotification();
|
2012-01-06 21:25:09 +00:00
|
|
|
$status = $enotif->notifyOnPageChange( $editor, $title,
|
2005-12-08 01:36:33 +00:00
|
|
|
$this->mAttribs['rc_timestamp'],
|
|
|
|
|
$this->mAttribs['rc_comment'],
|
|
|
|
|
$this->mAttribs['rc_minor'],
|
2009-09-11 01:04:00 +00:00
|
|
|
$this->mAttribs['rc_last_oldid'] );
|
2005-12-08 01:36:33 +00:00
|
|
|
}
|
2004-01-17 05:49:39 +00:00
|
|
|
}
|
2011-10-29 01:17:26 +00:00
|
|
|
|
2009-01-14 01:45:52 +00:00
|
|
|
public function notifyRC2UDP() {
|
|
|
|
|
global $wgRC2UDPAddress, $wgRC2UDPOmitBots;
|
|
|
|
|
# Notify external application via UDP
|
|
|
|
|
if( $wgRC2UDPAddress && ( !$this->mAttribs['rc_bot'] || !$wgRC2UDPOmitBots ) ) {
|
|
|
|
|
self::sendToUDP( $this->getIRCLine() );
|
|
|
|
|
}
|
|
|
|
|
}
|
2004-08-09 05:38:11 +00:00
|
|
|
|
2008-10-19 23:59:39 +00:00
|
|
|
/**
|
2010-06-24 06:20:11 +00:00
|
|
|
* Send some text to UDP.
|
|
|
|
|
* @see RecentChange::cleanupForIRC
|
2010-01-21 22:01:38 +00:00
|
|
|
* @param $line String: text to send
|
2010-06-24 06:20:11 +00:00
|
|
|
* @param $address String: defaults to $wgRC2UDPAddress.
|
|
|
|
|
* @param $prefix String: defaults to $wgRC2UDPPrefix.
|
|
|
|
|
* @param $port Int: defaults to $wgRC2UDPPort. (Since 1.17)
|
2010-01-21 22:01:38 +00:00
|
|
|
* @return Boolean: success
|
2008-10-19 23:59:39 +00:00
|
|
|
*/
|
2010-06-24 06:20:11 +00:00
|
|
|
public static function sendToUDP( $line, $address = '', $prefix = '', $port = '' ) {
|
2008-10-19 23:59:39 +00:00
|
|
|
global $wgRC2UDPAddress, $wgRC2UDPPrefix, $wgRC2UDPPort;
|
|
|
|
|
# Assume default for standard RC case
|
|
|
|
|
$address = $address ? $address : $wgRC2UDPAddress;
|
|
|
|
|
$prefix = $prefix ? $prefix : $wgRC2UDPPrefix;
|
2010-06-24 06:20:11 +00:00
|
|
|
$port = $port ? $port : $wgRC2UDPPort;
|
2008-10-19 23:59:39 +00:00
|
|
|
# Notify external application via UDP
|
|
|
|
|
if( $address ) {
|
|
|
|
|
$conn = socket_create( AF_INET, SOCK_DGRAM, SOL_UDP );
|
|
|
|
|
if( $conn ) {
|
|
|
|
|
$line = $prefix . $line;
|
2008-12-10 18:49:16 +00:00
|
|
|
wfDebug( __METHOD__ . ": sending UDP line: $line\n" );
|
2010-06-24 06:20:11 +00:00
|
|
|
socket_sendto( $conn, $line, strlen($line), 0, $address, $port );
|
2008-10-19 23:59:39 +00:00
|
|
|
socket_close( $conn );
|
|
|
|
|
return true;
|
2008-12-10 18:49:16 +00:00
|
|
|
} else {
|
|
|
|
|
wfDebug( __METHOD__ . ": failed to create UDP socket\n" );
|
2008-10-19 23:59:39 +00:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
return false;
|
|
|
|
|
}
|
2011-10-29 01:17:26 +00:00
|
|
|
|
2008-10-19 23:59:39 +00:00
|
|
|
/**
|
2009-01-25 19:00:11 +00:00
|
|
|
* Remove newlines, carriage returns and decode html entites
|
2010-01-21 22:01:38 +00:00
|
|
|
* @param $text String
|
|
|
|
|
* @return String
|
2008-10-19 23:59:39 +00:00
|
|
|
*/
|
|
|
|
|
public static function cleanupForIRC( $text ) {
|
2009-01-25 19:00:11 +00:00
|
|
|
return Sanitizer::decodeCharReferences( str_replace( array( "\n", "\r" ), array( "", "" ), $text ) );
|
2008-10-19 23:59:39 +00:00
|
|
|
}
|
|
|
|
|
|
2007-08-06 03:29:40 +00:00
|
|
|
/**
|
|
|
|
|
* Mark a given change as patrolled
|
|
|
|
|
*
|
2010-01-21 22:01:38 +00:00
|
|
|
* @param $change Mixed: RecentChange or corresponding rc_id
|
|
|
|
|
* @param $auto Boolean: for automatic patrol
|
2010-10-09 00:01:45 +00:00
|
|
|
* @return Array See doMarkPatrolled(), or null if $change is not an existing rc_id
|
2007-08-06 03:29:40 +00:00
|
|
|
*/
|
2008-09-19 00:11:41 +00:00
|
|
|
public static function markPatrolled( $change, $auto = false ) {
|
2011-07-09 09:17:35 +00:00
|
|
|
global $wgUser;
|
|
|
|
|
|
2008-09-04 15:17:51 +00:00
|
|
|
$change = $change instanceof RecentChange
|
|
|
|
|
? $change
|
|
|
|
|
: RecentChange::newFromId($change);
|
2011-07-09 09:17:35 +00:00
|
|
|
|
2008-09-20 07:55:14 +00:00
|
|
|
if( !$change instanceof RecentChange ) {
|
2008-09-04 15:17:51 +00:00
|
|
|
return null;
|
2008-09-20 07:55:14 +00:00
|
|
|
}
|
2011-07-09 09:17:35 +00:00
|
|
|
return $change->doMarkPatrolled( $wgUser, $auto );
|
2008-09-04 15:17:51 +00:00
|
|
|
}
|
2011-10-29 01:17:26 +00:00
|
|
|
|
2008-09-04 15:17:51 +00:00
|
|
|
/**
|
|
|
|
|
* Mark this RecentChange as patrolled
|
|
|
|
|
*
|
|
|
|
|
* NOTE: Can also return 'rcpatroldisabled', 'hookaborted' and 'markedaspatrollederror-noautopatrol' as errors
|
2011-07-09 09:17:35 +00:00
|
|
|
* @param $user User object doing the action
|
2010-01-21 22:01:38 +00:00
|
|
|
* @param $auto Boolean: for automatic patrol
|
2008-09-04 15:17:51 +00:00
|
|
|
* @return array of permissions errors, see Title::getUserPermissionsErrors()
|
|
|
|
|
*/
|
2011-07-09 09:17:35 +00:00
|
|
|
public function doMarkPatrolled( User $user, $auto = false ) {
|
|
|
|
|
global $wgUseRCPatrol, $wgUseNPPatrol;
|
2008-09-04 15:17:51 +00:00
|
|
|
$errors = array();
|
|
|
|
|
// If recentchanges patrol is disabled, only new pages
|
|
|
|
|
// can be patrolled
|
2008-10-17 23:52:57 +00:00
|
|
|
if( !$wgUseRCPatrol && ( !$wgUseNPPatrol || $this->getAttribute('rc_type') != RC_NEW ) ) {
|
2008-09-04 15:17:51 +00:00
|
|
|
$errors[] = array('rcpatroldisabled');
|
2008-09-20 07:55:14 +00:00
|
|
|
}
|
|
|
|
|
// Automatic patrol needs "autopatrol", ordinary patrol needs "patrol"
|
|
|
|
|
$right = $auto ? 'autopatrol' : 'patrol';
|
2011-07-09 09:17:35 +00:00
|
|
|
$errors = array_merge( $errors, $this->getTitle()->getUserPermissionsErrors( $right, $user ) );
|
2011-07-19 20:21:11 +00:00
|
|
|
if( !wfRunHooks('MarkPatrolled', array($this->getAttribute('rc_id'), &$user, false)) ) {
|
2008-09-20 07:55:14 +00:00
|
|
|
$errors[] = array('hookaborted');
|
2008-10-17 23:52:57 +00:00
|
|
|
}
|
2008-09-04 15:17:51 +00:00
|
|
|
// Users without the 'autopatrol' right can't patrol their
|
|
|
|
|
// own revisions
|
2011-07-09 09:17:35 +00:00
|
|
|
if( $user->getName() == $this->getAttribute('rc_user_text') && !$user->isAllowed('autopatrol') ) {
|
2008-09-04 15:17:51 +00:00
|
|
|
$errors[] = array('markedaspatrollederror-noautopatrol');
|
2008-10-17 23:52:57 +00:00
|
|
|
}
|
2008-09-20 07:55:14 +00:00
|
|
|
if( $errors ) {
|
2008-09-04 15:17:51 +00:00
|
|
|
return $errors;
|
2008-09-20 07:55:14 +00:00
|
|
|
}
|
2008-09-04 15:17:51 +00:00
|
|
|
// If the change was patrolled already, do nothing
|
2008-10-17 23:52:57 +00:00
|
|
|
if( $this->getAttribute('rc_patrolled') ) {
|
2008-09-04 15:17:51 +00:00
|
|
|
return array();
|
2008-10-17 23:52:57 +00:00
|
|
|
}
|
2008-09-19 00:11:41 +00:00
|
|
|
// Actually set the 'patrolled' flag in RC
|
2008-09-04 15:17:51 +00:00
|
|
|
$this->reallyMarkPatrolled();
|
2008-09-19 00:11:41 +00:00
|
|
|
// Log this patrol event
|
2012-02-21 22:27:33 +00:00
|
|
|
PatrolLog::record( $this, $auto, $user );
|
2011-07-09 09:17:35 +00:00
|
|
|
wfRunHooks( 'MarkPatrolledComplete', array($this->getAttribute('rc_id'), &$user, false) );
|
2008-09-04 15:17:51 +00:00
|
|
|
return array();
|
|
|
|
|
}
|
2011-10-29 01:17:26 +00:00
|
|
|
|
2008-09-04 15:17:51 +00:00
|
|
|
/**
|
|
|
|
|
* Mark this RecentChange patrolled, without error checking
|
2010-01-21 22:01:38 +00:00
|
|
|
* @return Integer: number of affected rows
|
2008-09-04 15:17:51 +00:00
|
|
|
*/
|
|
|
|
|
public function reallyMarkPatrolled() {
|
2007-01-22 23:50:42 +00:00
|
|
|
$dbw = wfGetDB( DB_MASTER );
|
2007-08-06 03:29:40 +00:00
|
|
|
$dbw->update(
|
|
|
|
|
'recentchanges',
|
|
|
|
|
array(
|
2004-08-09 05:38:11 +00:00
|
|
|
'rc_patrolled' => 1
|
2007-08-06 03:29:40 +00:00
|
|
|
),
|
|
|
|
|
array(
|
2008-09-04 15:17:51 +00:00
|
|
|
'rc_id' => $this->getAttribute('rc_id')
|
2007-08-06 03:29:40 +00:00
|
|
|
),
|
|
|
|
|
__METHOD__
|
2004-08-09 05:38:11 +00:00
|
|
|
);
|
2008-02-25 05:58:10 +00:00
|
|
|
return $dbw->affectedRows();
|
2004-08-09 05:38:11 +00:00
|
|
|
}
|
|
|
|
|
|
2011-04-11 12:47:55 +00:00
|
|
|
/**
|
|
|
|
|
* Makes an entry in the database corresponding to an edit
|
|
|
|
|
*
|
|
|
|
|
* @param $timestamp
|
|
|
|
|
* @param $title Title
|
|
|
|
|
* @param $minor
|
|
|
|
|
* @param $user User
|
|
|
|
|
* @param $comment
|
|
|
|
|
* @param $oldId
|
|
|
|
|
* @param $lastTimestamp
|
|
|
|
|
* @param $bot
|
|
|
|
|
* @param $ip string
|
|
|
|
|
* @param $oldSize int
|
|
|
|
|
* @param $newSize int
|
|
|
|
|
* @param $newId int
|
|
|
|
|
* @param $patrol int
|
|
|
|
|
* @return RecentChange
|
|
|
|
|
*/
|
2008-11-27 18:55:47 +00:00
|
|
|
public static function notifyEdit( $timestamp, &$title, $minor, &$user, $comment, $oldId,
|
2011-04-11 12:47:55 +00:00
|
|
|
$lastTimestamp, $bot, $ip='', $oldSize=0, $newSize=0, $newId=0, $patrol=0 ) {
|
2004-01-17 05:49:39 +00:00
|
|
|
$rc = new RecentChange;
|
|
|
|
|
$rc->mAttribs = array(
|
2010-01-21 22:01:38 +00:00
|
|
|
'rc_timestamp' => $timestamp,
|
|
|
|
|
'rc_cur_time' => $timestamp,
|
|
|
|
|
'rc_namespace' => $title->getNamespace(),
|
|
|
|
|
'rc_title' => $title->getDBkey(),
|
|
|
|
|
'rc_type' => RC_EDIT,
|
|
|
|
|
'rc_minor' => $minor ? 1 : 0,
|
|
|
|
|
'rc_cur_id' => $title->getArticleID(),
|
|
|
|
|
'rc_user' => $user->getId(),
|
|
|
|
|
'rc_user_text' => $user->getName(),
|
|
|
|
|
'rc_comment' => $comment,
|
|
|
|
|
'rc_this_oldid' => $newId,
|
|
|
|
|
'rc_last_oldid' => $oldId,
|
|
|
|
|
'rc_bot' => $bot ? 1 : 0,
|
|
|
|
|
'rc_moved_to_ns' => 0,
|
|
|
|
|
'rc_moved_to_title' => '',
|
Unbreak maintenance/deleteDefaultMessages.php for PostgreSQL
deleteDefaultMessages.php was failing during upgrade
from MediaWiki 1.7.3 with a databaser error.
A stub user:
$user = User::newFromName( 'MediaWiki default' );
has user ID 0, so that $user->isAnon() is true.
Unfortunately, ManualLogEntry::publish() from r96441
tries to insert $user->getName() ("MediaWiki default")
into rc_ip.
PostgreSQL won't allow this, because rc_ip is of
Postgres-specific CIDR type.
Traceback:
Checking existence of old default messages...
...deleting old default messages (this may take a long time!)...A database query syntax error has occurred.
The last attempted database query was:
"INSERT INTO "recentchanges" (rc_timestamp,rc_cur_time,rc_namespace,rc_title,rc_type,rc_minor,rc_user,rc_user_text,rc_comment,rc_this_oldid,rc_last_oldid,rc_bot,rc_moved_to_ns,rc_moved_to_title,rc_ip,rc_patrolled,rc_new,rc_old_len,rc_new_len,rc_deleted,rc_logid,rc_log_type,rc_log_action,rc_params,rc_id) VALUES ('2012-03-14 21:51:05 GMT','2012-03-14 21:51:05 GMT','8','1movedto2','3','0','0','MediaWiki default','No longer required','0','0',1,'0','','MediaWiki default','1','0',NULL,NULL,'0','1','delete','delete','a:0:{}','1')"
from within function "RecentChange::save".
MySQL returned error "1: ERROR: invalid input syntax for type cidr: "MediaWiki default"
LINE 1: ...ki default','No longer required','0','0',1,'0','','MediaWiki...
^"
Backtrace:
#0 /usr/home/saper/public_html/pg/w/includes/db/DatabasePostgres.php(332): DatabaseBase->reportQueryError('ERROR: invalid...', 1, 'INSERT INTO "re...', 'RecentChange::s...', '')
#1 /usr/home/saper/public_html/pg/w/includes/db/Database.php(904): DatabasePostgres->reportQueryError('ERROR: invalid...', 1, 'INSERT INTO "re...', 'RecentChange::s...', '')
#2 /usr/home/saper/public_html/pg/w/includes/db/DatabasePostgres.php(604): DatabaseBase->query('INSERT INTO "re...', 'RecentChange::s...', '')
#3 /usr/home/saper/public_html/pg/w/includes/RecentChange.php(199): DatabasePostgres->insert('recentchanges', Array, 'RecentChange::s...')
#4 /usr/home/saper/public_html/pg/w/includes/logging/LogEntry.php(479): RecentChange->save('pleasedontudp')
#5 /usr/home/saper/public_html/pg/w/includes/WikiPage.php(2042): ManualLogEntry->publish('1')
#6 /usr/home/saper/public_html/pg/w/includes/WikiPage.php(1937): WikiPage->doDeleteArticleReal('No longer requi...', false, 0, false, '', Object(User))
#7 /usr/home/saper/public_html/pg/w/maintenance/deleteDefaultMessages.php(73): WikiPage->doDeleteArticle('No longer requi...', false, 0, false, '', Object(User))
#8 /usr/home/saper/public_html/pg/w/maintenance/update.php(128): DeleteDefaultMessages->execute()
#9 /usr/home/saper/public_html/pg/w/maintenance/doMaintenance.php(105): UpdateMediaWiki->execute()
#10 /usr/home/saper/public_html/pg/w/maintenance/update.php(151): require_once('/usr/home/saper...')
#11 {main}
2012-03-15 01:52:38 +00:00
|
|
|
'rc_ip' => self::checkIPAddress( $ip ),
|
2010-01-21 22:01:38 +00:00
|
|
|
'rc_patrolled' => intval($patrol),
|
|
|
|
|
'rc_new' => 0, # obsolete
|
|
|
|
|
'rc_old_len' => $oldSize,
|
|
|
|
|
'rc_new_len' => $newSize,
|
|
|
|
|
'rc_deleted' => 0,
|
|
|
|
|
'rc_logid' => 0,
|
|
|
|
|
'rc_log_type' => null,
|
|
|
|
|
'rc_log_action' => '',
|
|
|
|
|
'rc_params' => ''
|
2004-01-17 05:49:39 +00:00
|
|
|
);
|
2004-08-09 05:38:11 +00:00
|
|
|
|
2004-01-17 05:49:39 +00:00
|
|
|
$rc->mExtra = array(
|
2010-01-21 22:01:38 +00:00
|
|
|
'prefixedDBkey' => $title->getPrefixedDBkey(),
|
2005-06-29 07:01:24 +00:00
|
|
|
'lastTimestamp' => $lastTimestamp,
|
|
|
|
|
'oldSize' => $oldSize,
|
|
|
|
|
'newSize' => $newSize,
|
2004-01-17 05:49:39 +00:00
|
|
|
);
|
|
|
|
|
$rc->save();
|
2008-09-19 00:11:41 +00:00
|
|
|
return $rc;
|
2004-01-17 05:49:39 +00:00
|
|
|
}
|
2004-08-09 05:38:11 +00:00
|
|
|
|
2006-07-10 15:41:30 +00:00
|
|
|
/**
|
|
|
|
|
* Makes an entry in the database corresponding to page creation
|
|
|
|
|
* Note: the title object must be loaded with the new id using resetArticleID()
|
|
|
|
|
* @todo Document parameters and return
|
2011-04-11 12:47:55 +00:00
|
|
|
*
|
|
|
|
|
* @param $timestamp
|
|
|
|
|
* @param $title Title
|
|
|
|
|
* @param $minor
|
|
|
|
|
* @param $user User
|
|
|
|
|
* @param $comment
|
|
|
|
|
* @param $bot
|
|
|
|
|
* @param $ip string
|
|
|
|
|
* @param $size int
|
|
|
|
|
* @param $newId int
|
|
|
|
|
* @param $patrol int
|
|
|
|
|
* @return RecentChange
|
2006-07-10 15:41:30 +00:00
|
|
|
*/
|
2008-01-10 13:33:23 +00:00
|
|
|
public static function notifyNew( $timestamp, &$title, $minor, &$user, $comment, $bot,
|
2011-04-11 12:47:55 +00:00
|
|
|
$ip='', $size=0, $newId=0, $patrol=0 ) {
|
2004-01-17 05:49:39 +00:00
|
|
|
$rc = new RecentChange;
|
|
|
|
|
$rc->mAttribs = array(
|
2004-06-14 10:40:24 +00:00
|
|
|
'rc_timestamp' => $timestamp,
|
|
|
|
|
'rc_cur_time' => $timestamp,
|
|
|
|
|
'rc_namespace' => $title->getNamespace(),
|
|
|
|
|
'rc_title' => $title->getDBkey(),
|
|
|
|
|
'rc_type' => RC_NEW,
|
|
|
|
|
'rc_minor' => $minor ? 1 : 0,
|
|
|
|
|
'rc_cur_id' => $title->getArticleID(),
|
2008-05-22 16:39:43 +00:00
|
|
|
'rc_user' => $user->getId(),
|
2004-06-14 10:40:24 +00:00
|
|
|
'rc_user_text' => $user->getName(),
|
|
|
|
|
'rc_comment' => $comment,
|
2005-07-01 20:36:04 +00:00
|
|
|
'rc_this_oldid' => $newId,
|
2004-06-14 10:40:24 +00:00
|
|
|
'rc_last_oldid' => 0,
|
|
|
|
|
'rc_bot' => $bot ? 1 : 0,
|
|
|
|
|
'rc_moved_to_ns' => 0,
|
|
|
|
|
'rc_moved_to_title' => '',
|
Unbreak maintenance/deleteDefaultMessages.php for PostgreSQL
deleteDefaultMessages.php was failing during upgrade
from MediaWiki 1.7.3 with a databaser error.
A stub user:
$user = User::newFromName( 'MediaWiki default' );
has user ID 0, so that $user->isAnon() is true.
Unfortunately, ManualLogEntry::publish() from r96441
tries to insert $user->getName() ("MediaWiki default")
into rc_ip.
PostgreSQL won't allow this, because rc_ip is of
Postgres-specific CIDR type.
Traceback:
Checking existence of old default messages...
...deleting old default messages (this may take a long time!)...A database query syntax error has occurred.
The last attempted database query was:
"INSERT INTO "recentchanges" (rc_timestamp,rc_cur_time,rc_namespace,rc_title,rc_type,rc_minor,rc_user,rc_user_text,rc_comment,rc_this_oldid,rc_last_oldid,rc_bot,rc_moved_to_ns,rc_moved_to_title,rc_ip,rc_patrolled,rc_new,rc_old_len,rc_new_len,rc_deleted,rc_logid,rc_log_type,rc_log_action,rc_params,rc_id) VALUES ('2012-03-14 21:51:05 GMT','2012-03-14 21:51:05 GMT','8','1movedto2','3','0','0','MediaWiki default','No longer required','0','0',1,'0','','MediaWiki default','1','0',NULL,NULL,'0','1','delete','delete','a:0:{}','1')"
from within function "RecentChange::save".
MySQL returned error "1: ERROR: invalid input syntax for type cidr: "MediaWiki default"
LINE 1: ...ki default','No longer required','0','0',1,'0','','MediaWiki...
^"
Backtrace:
#0 /usr/home/saper/public_html/pg/w/includes/db/DatabasePostgres.php(332): DatabaseBase->reportQueryError('ERROR: invalid...', 1, 'INSERT INTO "re...', 'RecentChange::s...', '')
#1 /usr/home/saper/public_html/pg/w/includes/db/Database.php(904): DatabasePostgres->reportQueryError('ERROR: invalid...', 1, 'INSERT INTO "re...', 'RecentChange::s...', '')
#2 /usr/home/saper/public_html/pg/w/includes/db/DatabasePostgres.php(604): DatabaseBase->query('INSERT INTO "re...', 'RecentChange::s...', '')
#3 /usr/home/saper/public_html/pg/w/includes/RecentChange.php(199): DatabasePostgres->insert('recentchanges', Array, 'RecentChange::s...')
#4 /usr/home/saper/public_html/pg/w/includes/logging/LogEntry.php(479): RecentChange->save('pleasedontudp')
#5 /usr/home/saper/public_html/pg/w/includes/WikiPage.php(2042): ManualLogEntry->publish('1')
#6 /usr/home/saper/public_html/pg/w/includes/WikiPage.php(1937): WikiPage->doDeleteArticleReal('No longer requi...', false, 0, false, '', Object(User))
#7 /usr/home/saper/public_html/pg/w/maintenance/deleteDefaultMessages.php(73): WikiPage->doDeleteArticle('No longer requi...', false, 0, false, '', Object(User))
#8 /usr/home/saper/public_html/pg/w/maintenance/update.php(128): DeleteDefaultMessages->execute()
#9 /usr/home/saper/public_html/pg/w/maintenance/doMaintenance.php(105): UpdateMediaWiki->execute()
#10 /usr/home/saper/public_html/pg/w/maintenance/update.php(151): require_once('/usr/home/saper...')
#11 {main}
2012-03-15 01:52:38 +00:00
|
|
|
'rc_ip' => self::checkIPAddress( $ip ),
|
2008-11-27 18:55:47 +00:00
|
|
|
'rc_patrolled' => intval($patrol),
|
2010-01-21 22:01:38 +00:00
|
|
|
'rc_new' => 1, # obsolete
|
2006-12-13 20:08:02 +00:00
|
|
|
'rc_old_len' => 0,
|
2010-01-21 22:01:38 +00:00
|
|
|
'rc_new_len' => $size,
|
|
|
|
|
'rc_deleted' => 0,
|
|
|
|
|
'rc_logid' => 0,
|
|
|
|
|
'rc_log_type' => null,
|
|
|
|
|
'rc_log_action' => '',
|
|
|
|
|
'rc_params' => ''
|
2004-01-17 05:49:39 +00:00
|
|
|
);
|
2004-08-09 05:38:11 +00:00
|
|
|
|
2004-01-17 05:49:39 +00:00
|
|
|
$rc->mExtra = array(
|
2010-01-21 22:01:38 +00:00
|
|
|
'prefixedDBkey' => $title->getPrefixedDBkey(),
|
2005-06-29 07:01:24 +00:00
|
|
|
'lastTimestamp' => 0,
|
|
|
|
|
'oldSize' => 0,
|
|
|
|
|
'newSize' => $size
|
2004-01-17 05:49:39 +00:00
|
|
|
);
|
|
|
|
|
$rc->save();
|
2011-09-07 16:20:23 +00:00
|
|
|
return $rc;
|
2004-06-20 11:55:24 +00:00
|
|
|
}
|
|
|
|
|
|
2011-10-29 01:17:26 +00:00
|
|
|
/**
|
|
|
|
|
* @param $timestamp
|
|
|
|
|
* @param $title
|
|
|
|
|
* @param $user
|
|
|
|
|
* @param $actionComment
|
|
|
|
|
* @param $ip string
|
|
|
|
|
* @param $type
|
|
|
|
|
* @param $action
|
|
|
|
|
* @param $target
|
|
|
|
|
* @param $logComment
|
|
|
|
|
* @param $params
|
|
|
|
|
* @param $newId int
|
2012-02-21 23:39:14 +00:00
|
|
|
* @param $actionCommentIRC string
|
2011-10-29 01:17:26 +00:00
|
|
|
* @return bool
|
|
|
|
|
*/
|
2012-02-21 23:39:14 +00:00
|
|
|
public static function notifyLog( $timestamp, &$title, &$user, $actionComment, $ip, $type,
|
|
|
|
|
$action, $target, $logComment, $params, $newId=0, $actionCommentIRC='' )
|
2009-01-09 18:30:47 +00:00
|
|
|
{
|
2009-01-09 18:38:10 +00:00
|
|
|
global $wgLogRestrictions;
|
|
|
|
|
# Don't add private logs to RC!
|
2009-01-10 22:07:12 +00:00
|
|
|
if( isset($wgLogRestrictions[$type]) && $wgLogRestrictions[$type] != '*' ) {
|
2009-01-09 18:38:10 +00:00
|
|
|
return false;
|
|
|
|
|
}
|
2009-01-09 18:30:47 +00:00
|
|
|
$rc = self::newLogEntry( $timestamp, $title, $user, $actionComment, $ip, $type, $action,
|
2012-02-21 23:39:14 +00:00
|
|
|
$target, $logComment, $params, $newId, $actionCommentIRC );
|
2009-01-09 18:30:47 +00:00
|
|
|
$rc->save();
|
2009-01-09 18:38:10 +00:00
|
|
|
return true;
|
2009-01-09 18:30:47 +00:00
|
|
|
}
|
|
|
|
|
|
2011-04-11 12:47:55 +00:00
|
|
|
/**
|
|
|
|
|
* @param $timestamp
|
|
|
|
|
* @param $title Title
|
|
|
|
|
* @param $user User
|
|
|
|
|
* @param $actionComment
|
|
|
|
|
* @param $ip string
|
|
|
|
|
* @param $type
|
|
|
|
|
* @param $action
|
|
|
|
|
* @param $target Title
|
|
|
|
|
* @param $logComment
|
|
|
|
|
* @param $params
|
|
|
|
|
* @param $newId int
|
2012-02-21 23:39:14 +00:00
|
|
|
* @param $actionCommentIRC string
|
2011-04-11 12:47:55 +00:00
|
|
|
* @return RecentChange
|
|
|
|
|
*/
|
2012-02-21 23:39:14 +00:00
|
|
|
public static function newLogEntry( $timestamp, &$title, &$user, $actionComment, $ip,
|
|
|
|
|
$type, $action, $target, $logComment, $params, $newId=0, $actionCommentIRC='' ) {
|
2008-01-10 09:54:35 +00:00
|
|
|
global $wgRequest;
|
2007-03-16 16:01:07 +00:00
|
|
|
|
2004-01-17 05:49:39 +00:00
|
|
|
$rc = new RecentChange;
|
|
|
|
|
$rc->mAttribs = array(
|
2010-01-21 22:01:38 +00:00
|
|
|
'rc_timestamp' => $timestamp,
|
|
|
|
|
'rc_cur_time' => $timestamp,
|
|
|
|
|
'rc_namespace' => $target->getNamespace(),
|
|
|
|
|
'rc_title' => $target->getDBkey(),
|
|
|
|
|
'rc_type' => RC_LOG,
|
|
|
|
|
'rc_minor' => 0,
|
|
|
|
|
'rc_cur_id' => $target->getArticleID(),
|
|
|
|
|
'rc_user' => $user->getId(),
|
|
|
|
|
'rc_user_text' => $user->getName(),
|
|
|
|
|
'rc_comment' => $logComment,
|
|
|
|
|
'rc_this_oldid' => 0,
|
|
|
|
|
'rc_last_oldid' => 0,
|
|
|
|
|
'rc_bot' => $user->isAllowed( 'bot' ) ? $wgRequest->getBool( 'bot', true ) : 0,
|
|
|
|
|
'rc_moved_to_ns' => 0,
|
|
|
|
|
'rc_moved_to_title' => '',
|
Unbreak maintenance/deleteDefaultMessages.php for PostgreSQL
deleteDefaultMessages.php was failing during upgrade
from MediaWiki 1.7.3 with a databaser error.
A stub user:
$user = User::newFromName( 'MediaWiki default' );
has user ID 0, so that $user->isAnon() is true.
Unfortunately, ManualLogEntry::publish() from r96441
tries to insert $user->getName() ("MediaWiki default")
into rc_ip.
PostgreSQL won't allow this, because rc_ip is of
Postgres-specific CIDR type.
Traceback:
Checking existence of old default messages...
...deleting old default messages (this may take a long time!)...A database query syntax error has occurred.
The last attempted database query was:
"INSERT INTO "recentchanges" (rc_timestamp,rc_cur_time,rc_namespace,rc_title,rc_type,rc_minor,rc_user,rc_user_text,rc_comment,rc_this_oldid,rc_last_oldid,rc_bot,rc_moved_to_ns,rc_moved_to_title,rc_ip,rc_patrolled,rc_new,rc_old_len,rc_new_len,rc_deleted,rc_logid,rc_log_type,rc_log_action,rc_params,rc_id) VALUES ('2012-03-14 21:51:05 GMT','2012-03-14 21:51:05 GMT','8','1movedto2','3','0','0','MediaWiki default','No longer required','0','0',1,'0','','MediaWiki default','1','0',NULL,NULL,'0','1','delete','delete','a:0:{}','1')"
from within function "RecentChange::save".
MySQL returned error "1: ERROR: invalid input syntax for type cidr: "MediaWiki default"
LINE 1: ...ki default','No longer required','0','0',1,'0','','MediaWiki...
^"
Backtrace:
#0 /usr/home/saper/public_html/pg/w/includes/db/DatabasePostgres.php(332): DatabaseBase->reportQueryError('ERROR: invalid...', 1, 'INSERT INTO "re...', 'RecentChange::s...', '')
#1 /usr/home/saper/public_html/pg/w/includes/db/Database.php(904): DatabasePostgres->reportQueryError('ERROR: invalid...', 1, 'INSERT INTO "re...', 'RecentChange::s...', '')
#2 /usr/home/saper/public_html/pg/w/includes/db/DatabasePostgres.php(604): DatabaseBase->query('INSERT INTO "re...', 'RecentChange::s...', '')
#3 /usr/home/saper/public_html/pg/w/includes/RecentChange.php(199): DatabasePostgres->insert('recentchanges', Array, 'RecentChange::s...')
#4 /usr/home/saper/public_html/pg/w/includes/logging/LogEntry.php(479): RecentChange->save('pleasedontudp')
#5 /usr/home/saper/public_html/pg/w/includes/WikiPage.php(2042): ManualLogEntry->publish('1')
#6 /usr/home/saper/public_html/pg/w/includes/WikiPage.php(1937): WikiPage->doDeleteArticleReal('No longer requi...', false, 0, false, '', Object(User))
#7 /usr/home/saper/public_html/pg/w/maintenance/deleteDefaultMessages.php(73): WikiPage->doDeleteArticle('No longer requi...', false, 0, false, '', Object(User))
#8 /usr/home/saper/public_html/pg/w/maintenance/update.php(128): DeleteDefaultMessages->execute()
#9 /usr/home/saper/public_html/pg/w/maintenance/doMaintenance.php(105): UpdateMediaWiki->execute()
#10 /usr/home/saper/public_html/pg/w/maintenance/update.php(151): require_once('/usr/home/saper...')
#11 {main}
2012-03-15 01:52:38 +00:00
|
|
|
'rc_ip' => self::checkIPAddress( $ip ),
|
2010-01-21 22:01:38 +00:00
|
|
|
'rc_patrolled' => 1,
|
|
|
|
|
'rc_new' => 0, # obsolete
|
|
|
|
|
'rc_old_len' => null,
|
|
|
|
|
'rc_new_len' => null,
|
|
|
|
|
'rc_deleted' => 0,
|
|
|
|
|
'rc_logid' => $newId,
|
|
|
|
|
'rc_log_type' => $type,
|
|
|
|
|
'rc_log_action' => $action,
|
|
|
|
|
'rc_params' => $params
|
2004-01-17 05:49:39 +00:00
|
|
|
);
|
Unbreak maintenance/deleteDefaultMessages.php for PostgreSQL
deleteDefaultMessages.php was failing during upgrade
from MediaWiki 1.7.3 with a databaser error.
A stub user:
$user = User::newFromName( 'MediaWiki default' );
has user ID 0, so that $user->isAnon() is true.
Unfortunately, ManualLogEntry::publish() from r96441
tries to insert $user->getName() ("MediaWiki default")
into rc_ip.
PostgreSQL won't allow this, because rc_ip is of
Postgres-specific CIDR type.
Traceback:
Checking existence of old default messages...
...deleting old default messages (this may take a long time!)...A database query syntax error has occurred.
The last attempted database query was:
"INSERT INTO "recentchanges" (rc_timestamp,rc_cur_time,rc_namespace,rc_title,rc_type,rc_minor,rc_user,rc_user_text,rc_comment,rc_this_oldid,rc_last_oldid,rc_bot,rc_moved_to_ns,rc_moved_to_title,rc_ip,rc_patrolled,rc_new,rc_old_len,rc_new_len,rc_deleted,rc_logid,rc_log_type,rc_log_action,rc_params,rc_id) VALUES ('2012-03-14 21:51:05 GMT','2012-03-14 21:51:05 GMT','8','1movedto2','3','0','0','MediaWiki default','No longer required','0','0',1,'0','','MediaWiki default','1','0',NULL,NULL,'0','1','delete','delete','a:0:{}','1')"
from within function "RecentChange::save".
MySQL returned error "1: ERROR: invalid input syntax for type cidr: "MediaWiki default"
LINE 1: ...ki default','No longer required','0','0',1,'0','','MediaWiki...
^"
Backtrace:
#0 /usr/home/saper/public_html/pg/w/includes/db/DatabasePostgres.php(332): DatabaseBase->reportQueryError('ERROR: invalid...', 1, 'INSERT INTO "re...', 'RecentChange::s...', '')
#1 /usr/home/saper/public_html/pg/w/includes/db/Database.php(904): DatabasePostgres->reportQueryError('ERROR: invalid...', 1, 'INSERT INTO "re...', 'RecentChange::s...', '')
#2 /usr/home/saper/public_html/pg/w/includes/db/DatabasePostgres.php(604): DatabaseBase->query('INSERT INTO "re...', 'RecentChange::s...', '')
#3 /usr/home/saper/public_html/pg/w/includes/RecentChange.php(199): DatabasePostgres->insert('recentchanges', Array, 'RecentChange::s...')
#4 /usr/home/saper/public_html/pg/w/includes/logging/LogEntry.php(479): RecentChange->save('pleasedontudp')
#5 /usr/home/saper/public_html/pg/w/includes/WikiPage.php(2042): ManualLogEntry->publish('1')
#6 /usr/home/saper/public_html/pg/w/includes/WikiPage.php(1937): WikiPage->doDeleteArticleReal('No longer requi...', false, 0, false, '', Object(User))
#7 /usr/home/saper/public_html/pg/w/maintenance/deleteDefaultMessages.php(73): WikiPage->doDeleteArticle('No longer requi...', false, 0, false, '', Object(User))
#8 /usr/home/saper/public_html/pg/w/maintenance/update.php(128): DeleteDefaultMessages->execute()
#9 /usr/home/saper/public_html/pg/w/maintenance/doMaintenance.php(105): UpdateMediaWiki->execute()
#10 /usr/home/saper/public_html/pg/w/maintenance/update.php(151): require_once('/usr/home/saper...')
#11 {main}
2012-03-15 01:52:38 +00:00
|
|
|
|
2004-01-17 05:49:39 +00:00
|
|
|
$rc->mExtra = array(
|
2010-01-21 22:01:38 +00:00
|
|
|
'prefixedDBkey' => $title->getPrefixedDBkey(),
|
2006-03-06 13:51:58 +00:00
|
|
|
'lastTimestamp' => 0,
|
2008-04-20 14:24:10 +00:00
|
|
|
'actionComment' => $actionComment, // the comment appended to the action, passed from LogPage
|
2012-02-21 23:39:14 +00:00
|
|
|
'actionCommentIRC' => $actionCommentIRC
|
2004-01-17 05:49:39 +00:00
|
|
|
);
|
2009-01-09 18:30:47 +00:00
|
|
|
return $rc;
|
2004-01-17 05:49:39 +00:00
|
|
|
}
|
|
|
|
|
|
2011-10-29 01:17:26 +00:00
|
|
|
/**
|
|
|
|
|
* Initialises the members of this object from a mysql row object
|
|
|
|
|
*
|
|
|
|
|
* @param $row
|
|
|
|
|
*/
|
2008-10-17 23:52:57 +00:00
|
|
|
public function loadFromRow( $row ) {
|
2004-01-17 05:49:39 +00:00
|
|
|
$this->mAttribs = get_object_vars( $row );
|
2008-10-27 19:59:54 +00:00
|
|
|
$this->mAttribs['rc_timestamp'] = wfTimestamp(TS_MW, $this->mAttribs['rc_timestamp']);
|
|
|
|
|
$this->mAttribs['rc_deleted'] = $row->rc_deleted; // MUST be set
|
2004-01-17 05:49:39 +00:00
|
|
|
}
|
2004-08-09 05:38:11 +00:00
|
|
|
|
2011-10-29 01:17:26 +00:00
|
|
|
/**
|
|
|
|
|
* Makes a pseudo-RC entry from a cur row
|
|
|
|
|
*
|
|
|
|
|
* @param $row
|
|
|
|
|
*/
|
2008-10-17 23:52:57 +00:00
|
|
|
public function loadFromCurRow( $row ) {
|
2004-01-17 09:49:43 +00:00
|
|
|
$this->mAttribs = array(
|
2005-08-02 13:35:19 +00:00
|
|
|
'rc_timestamp' => wfTimestamp(TS_MW, $row->rev_timestamp),
|
2004-12-19 08:00:50 +00:00
|
|
|
'rc_cur_time' => $row->rev_timestamp,
|
|
|
|
|
'rc_user' => $row->rev_user,
|
|
|
|
|
'rc_user_text' => $row->rev_user_text,
|
|
|
|
|
'rc_namespace' => $row->page_namespace,
|
|
|
|
|
'rc_title' => $row->page_title,
|
|
|
|
|
'rc_comment' => $row->rev_comment,
|
2005-07-01 05:28:07 +00:00
|
|
|
'rc_minor' => $row->rev_minor_edit ? 1 : 0,
|
2004-12-19 08:00:50 +00:00
|
|
|
'rc_type' => $row->page_is_new ? RC_NEW : RC_EDIT,
|
|
|
|
|
'rc_cur_id' => $row->page_id,
|
2005-07-01 23:50:11 +00:00
|
|
|
'rc_this_oldid' => $row->rev_id,
|
|
|
|
|
'rc_last_oldid' => isset($row->rc_last_oldid) ? $row->rc_last_oldid : 0,
|
2004-01-17 09:49:43 +00:00
|
|
|
'rc_bot' => 0,
|
|
|
|
|
'rc_moved_to_ns' => 0,
|
2004-01-18 02:24:12 +00:00
|
|
|
'rc_moved_to_title' => '',
|
2004-06-14 10:40:24 +00:00
|
|
|
'rc_ip' => '',
|
2006-05-23 18:23:29 +00:00
|
|
|
'rc_id' => $row->rc_id,
|
|
|
|
|
'rc_patrolled' => $row->rc_patrolled,
|
2006-12-09 12:28:02 +00:00
|
|
|
'rc_new' => $row->page_is_new, # obsolete
|
2006-12-23 23:08:41 +00:00
|
|
|
'rc_old_len' => $row->rc_old_len,
|
|
|
|
|
'rc_new_len' => $row->rc_new_len,
|
2008-03-16 21:02:10 +00:00
|
|
|
'rc_params' => isset($row->rc_params) ? $row->rc_params : '',
|
|
|
|
|
'rc_log_type' => isset($row->rc_log_type) ? $row->rc_log_type : null,
|
|
|
|
|
'rc_log_action' => isset($row->rc_log_action) ? $row->rc_log_action : null,
|
|
|
|
|
'rc_log_id' => isset($row->rc_log_id) ? $row->rc_log_id: 0,
|
2008-10-27 19:59:54 +00:00
|
|
|
'rc_deleted' => $row->rc_deleted // MUST be set
|
2004-01-17 09:49:43 +00:00
|
|
|
);
|
|
|
|
|
}
|
|
|
|
|
|
2006-12-22 19:43:20 +00:00
|
|
|
/**
|
|
|
|
|
* Get an attribute value
|
|
|
|
|
*
|
2010-09-28 01:33:11 +00:00
|
|
|
* @param $name String Attribute name
|
2006-12-22 19:43:20 +00:00
|
|
|
* @return mixed
|
|
|
|
|
*/
|
|
|
|
|
public function getAttribute( $name ) {
|
2009-12-11 21:07:27 +00:00
|
|
|
return isset( $this->mAttribs[$name] ) ? $this->mAttribs[$name] : null;
|
2006-12-22 19:43:20 +00:00
|
|
|
}
|
2004-01-17 09:49:43 +00:00
|
|
|
|
2011-10-29 01:17:26 +00:00
|
|
|
/**
|
|
|
|
|
* @return array
|
|
|
|
|
*/
|
2009-09-03 16:15:55 +00:00
|
|
|
public function getAttributes() {
|
|
|
|
|
return $this->mAttribs;
|
|
|
|
|
}
|
|
|
|
|
|
2004-09-02 23:28:24 +00:00
|
|
|
/**
|
2005-07-01 10:44:48 +00:00
|
|
|
* Gets the end part of the diff URL associated with this object
|
2004-09-02 23:28:24 +00:00
|
|
|
* Blank if no diff link should be displayed
|
2011-10-29 01:17:26 +00:00
|
|
|
* @param $forceCur
|
|
|
|
|
* @return string
|
2004-09-02 23:28:24 +00:00
|
|
|
*/
|
2008-10-17 23:52:57 +00:00
|
|
|
public function diffLinkTrail( $forceCur ) {
|
|
|
|
|
if( $this->mAttribs['rc_type'] == RC_EDIT ) {
|
2004-01-17 05:49:39 +00:00
|
|
|
$trail = "curid=" . (int)($this->mAttribs['rc_cur_id']) .
|
|
|
|
|
"&oldid=" . (int)($this->mAttribs['rc_last_oldid']);
|
2008-10-17 23:52:57 +00:00
|
|
|
if( $forceCur ) {
|
2004-08-22 17:24:50 +00:00
|
|
|
$trail .= '&diff=0' ;
|
2004-01-17 05:49:39 +00:00
|
|
|
} else {
|
2004-08-22 17:24:50 +00:00
|
|
|
$trail .= '&diff=' . (int)($this->mAttribs['rc_this_oldid']);
|
2004-01-17 05:49:39 +00:00
|
|
|
}
|
|
|
|
|
} else {
|
2004-08-22 17:24:50 +00:00
|
|
|
$trail = '';
|
2004-01-17 05:49:39 +00:00
|
|
|
}
|
|
|
|
|
return $trail;
|
|
|
|
|
}
|
2005-06-29 07:01:24 +00:00
|
|
|
|
2011-10-29 01:17:26 +00:00
|
|
|
/**
|
|
|
|
|
* @return string
|
|
|
|
|
*/
|
2009-01-12 22:52:09 +00:00
|
|
|
public function getIRCLine() {
|
Per CR on r44412 and my promise in the commit summary of r94990, stop abusing $wgInternalServer (intended for Squid URLs) for IRC/e-mail URLs and introduce $wgCanonicalServer for these purposes instead. This revision introduces two new hooks for WMF hacks, in exchange for making the core code saner.
* Introduce $wgCanonicalServer, which should typically be a fully qualified version of $wgServer but in practice can be anything that you'd like to be used in IRC/e-mail notifs
** Default value is $wgServer, expanded to http:// if protocol-relative
** This means you can easily set HTTPS as the 'default' protocol to use in IRC and e-mail notifs by setting $wgCanonicalServer to https://example.com
* Introduce Title::getCanonicalURL(). Similar to getInternalURL(), including a hook for WMF usage (which will be needed as long as secure.wikimedia.org is used)
** Also add escapeCanonicalURL(). Due to some ridiculous accident of history, the other escapeFooURL() functions don't have a $variant parameter; I decided not to follow that bad example
* Reinstate the spirit of r44406 and r44412: instead of calling getInternalURL() (or getCanonicalURL()) and regexing the title parameter out, obtain the path to index.php using $wgCanonicalServer . $wgScript and append params to that. Sadly, we need to add a hook here to support the secure server hack for WMF, but that's the price of saner code in this case
* Introduce the {{canonicalurl:}} and {{canonicalurle:}} parser functions, which work just like {{fullurl:}} and {{fullurle:}} except that they use getCanonicalURL() instead of getFullURL()
* Use {{canonicalurl:}} in the enotif_body message, fixing bug 29993 (protocol-relative URLs appear in e-mail notifications)
2011-08-19 11:23:17 +00:00
|
|
|
global $wgUseRCPatrol, $wgUseNPPatrol, $wgRC2UDPInterwikiPrefix, $wgLocalInterwiki,
|
|
|
|
|
$wgCanonicalServer, $wgScript;
|
2005-11-03 11:27:10 +00:00
|
|
|
|
2011-03-15 18:35:32 +00:00
|
|
|
if( $this->mAttribs['rc_type'] == RC_LOG ) {
|
Revert r97711
WONTFIX:
* (bug 30245) Use the correct way to construct a log page title.
This was previously reverted for 1.19 and now reverting again for
1.20, only this time proposing it not to be temporary.
Right now this is already live on 2 wikis and as soon as it goes
live on a non-English wiki (since English namespace name for Log
matches the canonical name "Log", and as such causes no breakage yet
for bots using the IRC feed), as soon as it goes live on a
non-English wiki it will all log actions that bots are monitoring
using the irc feed.
(because no matter which log action is monitored, it all goes
back to detecting the page title of Special:Log)
If properly announced ahead of time it could be done, but we don't
have that time anymore. Perhaps re-try in 1.21 or 1.22, but as far
as I'm concerned, this bug can be kept WONTFIX as it only affects
the IRC feed. And it's not worth the loss that will undoubtedly
result from breaking this.
Theoretically a certain amount of time for the announcement could be
required, and if the change enables something or fixes a security
problem, it could be justified, but for this it is just not worth
it.
The human-readable output from the API and on Special:Log are fully
localized and even better so with the rewrite that Niklas did last
year. The IRC feed however, has little to no gain from this and only
causes breakages for the the large amount of bot usage from it, of
which many are no longer maintained and as such will not be fixed,
no matter how much time it is given. Granted those will probably
break no matter what at some point, but hopefully we will have
push notification *with* structured data[2] by that time to
encourage rewrites of those bots.
Change-Id: I229e345c74b10f4d96b8d2d305b4a7623825b3f6
Links:
* https://www.mediawiki.org/wiki/Special:Code/MediaWiki/97711
* https://www.mediawiki.org/wiki/Requests_for_comment/Structured_data_push_notification_support_for_recent_changes
2012-04-14 15:08:04 +00:00
|
|
|
// Don't use SpecialPage::getTitleFor, backwards compatibility with
|
|
|
|
|
// IRC API which expects "Log".
|
|
|
|
|
$titleObj = Title::newFromText( 'Log/' . $this->mAttribs['rc_log_type'], NS_SPECIAL );
|
2006-03-06 13:51:58 +00:00
|
|
|
} else {
|
2008-04-20 14:31:02 +00:00
|
|
|
$titleObj =& $this->getTitle();
|
2006-03-06 13:51:58 +00:00
|
|
|
}
|
2006-04-02 04:09:00 +00:00
|
|
|
$title = $titleObj->getPrefixedText();
|
2008-10-19 23:59:39 +00:00
|
|
|
$title = self::cleanupForIRC( $title );
|
2006-04-02 04:09:00 +00:00
|
|
|
|
2011-03-15 18:35:32 +00:00
|
|
|
if( $this->mAttribs['rc_type'] == RC_LOG ) {
|
2006-03-06 13:51:58 +00:00
|
|
|
$url = '';
|
2005-06-29 07:01:24 +00:00
|
|
|
} else {
|
Per CR on r44412 and my promise in the commit summary of r94990, stop abusing $wgInternalServer (intended for Squid URLs) for IRC/e-mail URLs and introduce $wgCanonicalServer for these purposes instead. This revision introduces two new hooks for WMF hacks, in exchange for making the core code saner.
* Introduce $wgCanonicalServer, which should typically be a fully qualified version of $wgServer but in practice can be anything that you'd like to be used in IRC/e-mail notifs
** Default value is $wgServer, expanded to http:// if protocol-relative
** This means you can easily set HTTPS as the 'default' protocol to use in IRC and e-mail notifs by setting $wgCanonicalServer to https://example.com
* Introduce Title::getCanonicalURL(). Similar to getInternalURL(), including a hook for WMF usage (which will be needed as long as secure.wikimedia.org is used)
** Also add escapeCanonicalURL(). Due to some ridiculous accident of history, the other escapeFooURL() functions don't have a $variant parameter; I decided not to follow that bad example
* Reinstate the spirit of r44406 and r44412: instead of calling getInternalURL() (or getCanonicalURL()) and regexing the title parameter out, obtain the path to index.php using $wgCanonicalServer . $wgScript and append params to that. Sadly, we need to add a hook here to support the secure server hack for WMF, but that's the price of saner code in this case
* Introduce the {{canonicalurl:}} and {{canonicalurle:}} parser functions, which work just like {{fullurl:}} and {{fullurle:}} except that they use getCanonicalURL() instead of getFullURL()
* Use {{canonicalurl:}} in the enotif_body message, fixing bug 29993 (protocol-relative URLs appear in e-mail notifications)
2011-08-19 11:23:17 +00:00
|
|
|
$url = $wgCanonicalServer . $wgScript;
|
2011-03-15 18:35:32 +00:00
|
|
|
if( $this->mAttribs['rc_type'] == RC_NEW ) {
|
Per CR on r44412 and my promise in the commit summary of r94990, stop abusing $wgInternalServer (intended for Squid URLs) for IRC/e-mail URLs and introduce $wgCanonicalServer for these purposes instead. This revision introduces two new hooks for WMF hacks, in exchange for making the core code saner.
* Introduce $wgCanonicalServer, which should typically be a fully qualified version of $wgServer but in practice can be anything that you'd like to be used in IRC/e-mail notifs
** Default value is $wgServer, expanded to http:// if protocol-relative
** This means you can easily set HTTPS as the 'default' protocol to use in IRC and e-mail notifs by setting $wgCanonicalServer to https://example.com
* Introduce Title::getCanonicalURL(). Similar to getInternalURL(), including a hook for WMF usage (which will be needed as long as secure.wikimedia.org is used)
** Also add escapeCanonicalURL(). Due to some ridiculous accident of history, the other escapeFooURL() functions don't have a $variant parameter; I decided not to follow that bad example
* Reinstate the spirit of r44406 and r44412: instead of calling getInternalURL() (or getCanonicalURL()) and regexing the title parameter out, obtain the path to index.php using $wgCanonicalServer . $wgScript and append params to that. Sadly, we need to add a hook here to support the secure server hack for WMF, but that's the price of saner code in this case
* Introduce the {{canonicalurl:}} and {{canonicalurle:}} parser functions, which work just like {{fullurl:}} and {{fullurle:}} except that they use getCanonicalURL() instead of getFullURL()
* Use {{canonicalurl:}} in the enotif_body message, fixing bug 29993 (protocol-relative URLs appear in e-mail notifications)
2011-08-19 11:23:17 +00:00
|
|
|
$query = '?oldid=' . $this->mAttribs['rc_this_oldid'];
|
2008-12-10 15:56:02 +00:00
|
|
|
} else {
|
Per CR on r44412 and my promise in the commit summary of r94990, stop abusing $wgInternalServer (intended for Squid URLs) for IRC/e-mail URLs and introduce $wgCanonicalServer for these purposes instead. This revision introduces two new hooks for WMF hacks, in exchange for making the core code saner.
* Introduce $wgCanonicalServer, which should typically be a fully qualified version of $wgServer but in practice can be anything that you'd like to be used in IRC/e-mail notifs
** Default value is $wgServer, expanded to http:// if protocol-relative
** This means you can easily set HTTPS as the 'default' protocol to use in IRC and e-mail notifs by setting $wgCanonicalServer to https://example.com
* Introduce Title::getCanonicalURL(). Similar to getInternalURL(), including a hook for WMF usage (which will be needed as long as secure.wikimedia.org is used)
** Also add escapeCanonicalURL(). Due to some ridiculous accident of history, the other escapeFooURL() functions don't have a $variant parameter; I decided not to follow that bad example
* Reinstate the spirit of r44406 and r44412: instead of calling getInternalURL() (or getCanonicalURL()) and regexing the title parameter out, obtain the path to index.php using $wgCanonicalServer . $wgScript and append params to that. Sadly, we need to add a hook here to support the secure server hack for WMF, but that's the price of saner code in this case
* Introduce the {{canonicalurl:}} and {{canonicalurle:}} parser functions, which work just like {{fullurl:}} and {{fullurle:}} except that they use getCanonicalURL() instead of getFullURL()
* Use {{canonicalurl:}} in the enotif_body message, fixing bug 29993 (protocol-relative URLs appear in e-mail notifications)
2011-08-19 11:23:17 +00:00
|
|
|
$query = '?diff=' . $this->mAttribs['rc_this_oldid'] . '&oldid=' . $this->mAttribs['rc_last_oldid'];
|
2008-12-10 15:56:02 +00:00
|
|
|
}
|
2011-03-15 18:35:32 +00:00
|
|
|
if ( $wgUseRCPatrol || ( $this->mAttribs['rc_type'] == RC_NEW && $wgUseNPPatrol ) ) {
|
Per CR on r44412 and my promise in the commit summary of r94990, stop abusing $wgInternalServer (intended for Squid URLs) for IRC/e-mail URLs and introduce $wgCanonicalServer for these purposes instead. This revision introduces two new hooks for WMF hacks, in exchange for making the core code saner.
* Introduce $wgCanonicalServer, which should typically be a fully qualified version of $wgServer but in practice can be anything that you'd like to be used in IRC/e-mail notifs
** Default value is $wgServer, expanded to http:// if protocol-relative
** This means you can easily set HTTPS as the 'default' protocol to use in IRC and e-mail notifs by setting $wgCanonicalServer to https://example.com
* Introduce Title::getCanonicalURL(). Similar to getInternalURL(), including a hook for WMF usage (which will be needed as long as secure.wikimedia.org is used)
** Also add escapeCanonicalURL(). Due to some ridiculous accident of history, the other escapeFooURL() functions don't have a $variant parameter; I decided not to follow that bad example
* Reinstate the spirit of r44406 and r44412: instead of calling getInternalURL() (or getCanonicalURL()) and regexing the title parameter out, obtain the path to index.php using $wgCanonicalServer . $wgScript and append params to that. Sadly, we need to add a hook here to support the secure server hack for WMF, but that's the price of saner code in this case
* Introduce the {{canonicalurl:}} and {{canonicalurle:}} parser functions, which work just like {{fullurl:}} and {{fullurle:}} except that they use getCanonicalURL() instead of getFullURL()
* Use {{canonicalurl:}} in the enotif_body message, fixing bug 29993 (protocol-relative URLs appear in e-mail notifications)
2011-08-19 11:23:17 +00:00
|
|
|
$query .= '&rcid=' . $this->mAttribs['rc_id'];
|
2008-12-10 15:56:02 +00:00
|
|
|
}
|
Per CR on r44412 and my promise in the commit summary of r94990, stop abusing $wgInternalServer (intended for Squid URLs) for IRC/e-mail URLs and introduce $wgCanonicalServer for these purposes instead. This revision introduces two new hooks for WMF hacks, in exchange for making the core code saner.
* Introduce $wgCanonicalServer, which should typically be a fully qualified version of $wgServer but in practice can be anything that you'd like to be used in IRC/e-mail notifs
** Default value is $wgServer, expanded to http:// if protocol-relative
** This means you can easily set HTTPS as the 'default' protocol to use in IRC and e-mail notifs by setting $wgCanonicalServer to https://example.com
* Introduce Title::getCanonicalURL(). Similar to getInternalURL(), including a hook for WMF usage (which will be needed as long as secure.wikimedia.org is used)
** Also add escapeCanonicalURL(). Due to some ridiculous accident of history, the other escapeFooURL() functions don't have a $variant parameter; I decided not to follow that bad example
* Reinstate the spirit of r44406 and r44412: instead of calling getInternalURL() (or getCanonicalURL()) and regexing the title parameter out, obtain the path to index.php using $wgCanonicalServer . $wgScript and append params to that. Sadly, we need to add a hook here to support the secure server hack for WMF, but that's the price of saner code in this case
* Introduce the {{canonicalurl:}} and {{canonicalurle:}} parser functions, which work just like {{fullurl:}} and {{fullurle:}} except that they use getCanonicalURL() instead of getFullURL()
* Use {{canonicalurl:}} in the enotif_body message, fixing bug 29993 (protocol-relative URLs appear in e-mail notifications)
2011-08-19 11:23:17 +00:00
|
|
|
// HACK: We need this hook for WMF's secure server setup
|
|
|
|
|
wfRunHooks( 'IRCLineURL', array( &$url, &$query ) );
|
|
|
|
|
$url .= $query;
|
2005-06-29 07:01:24 +00:00
|
|
|
}
|
|
|
|
|
|
2011-09-06 13:17:22 +00:00
|
|
|
if( $this->mAttribs['rc_old_len'] !== null && $this->mAttribs['rc_new_len'] !== null ) {
|
|
|
|
|
$szdiff = $this->mAttribs['rc_new_len'] - $this->mAttribs['rc_old_len'];
|
2008-10-17 23:52:57 +00:00
|
|
|
if($szdiff < -500) {
|
2005-06-29 07:01:24 +00:00
|
|
|
$szdiff = "\002$szdiff\002";
|
2008-10-17 23:52:57 +00:00
|
|
|
} elseif($szdiff >= 0) {
|
2005-12-04 20:51:02 +00:00
|
|
|
$szdiff = '+' . $szdiff ;
|
|
|
|
|
}
|
2012-02-28 12:41:26 +00:00
|
|
|
// @todo i18n with parentheses in content language?
|
2005-12-04 20:51:02 +00:00
|
|
|
$szdiff = '(' . $szdiff . ')' ;
|
2005-06-29 07:01:24 +00:00
|
|
|
} else {
|
|
|
|
|
$szdiff = '';
|
|
|
|
|
}
|
|
|
|
|
|
2011-03-15 18:35:32 +00:00
|
|
|
$user = self::cleanupForIRC( $this->mAttribs['rc_user_text'] );
|
2006-03-06 13:51:58 +00:00
|
|
|
|
2011-03-15 18:35:32 +00:00
|
|
|
if ( $this->mAttribs['rc_type'] == RC_LOG ) {
|
2008-10-11 23:30:38 +00:00
|
|
|
$targetText = $this->getTitle()->getPrefixedText();
|
2012-02-21 23:39:14 +00:00
|
|
|
$comment = self::cleanupForIRC( str_replace( "[[$targetText]]", "[[\00302$targetText\00310]]", $this->mExtra['actionCommentIRC'] ) );
|
2011-03-15 18:35:32 +00:00
|
|
|
$flag = $this->mAttribs['rc_log_action'];
|
2006-03-06 13:51:58 +00:00
|
|
|
} else {
|
2011-03-15 18:35:32 +00:00
|
|
|
$comment = self::cleanupForIRC( $this->mAttribs['rc_comment'] );
|
2009-01-09 22:49:40 +00:00
|
|
|
$flag = '';
|
2011-03-15 18:35:32 +00:00
|
|
|
if ( !$this->mAttribs['rc_patrolled'] && ( $wgUseRCPatrol || $this->mAttribs['rc_new'] && $wgUseNPPatrol ) ) {
|
2009-01-09 22:49:40 +00:00
|
|
|
$flag .= '!';
|
|
|
|
|
}
|
2011-03-15 18:35:32 +00:00
|
|
|
$flag .= ( $this->mAttribs['rc_new'] ? "N" : "" ) . ( $this->mAttribs['rc_minor'] ? "M" : "" ) . ( $this->mAttribs['rc_bot'] ? "B" : "" );
|
2006-03-06 13:51:58 +00:00
|
|
|
}
|
2008-11-13 08:51:10 +00:00
|
|
|
|
2010-12-06 15:00:56 +00:00
|
|
|
if ( $wgRC2UDPInterwikiPrefix === true && $wgLocalInterwiki !== false ) {
|
2008-11-13 08:51:10 +00:00
|
|
|
$prefix = $wgLocalInterwiki;
|
|
|
|
|
} elseif ( $wgRC2UDPInterwikiPrefix ) {
|
|
|
|
|
$prefix = $wgRC2UDPInterwikiPrefix;
|
|
|
|
|
} else {
|
|
|
|
|
$prefix = false;
|
|
|
|
|
}
|
|
|
|
|
if ( $prefix !== false ) {
|
|
|
|
|
$titleString = "\00314[[\00303$prefix:\00307$title\00314]]";
|
2008-10-28 22:19:30 +00:00
|
|
|
} else {
|
|
|
|
|
$titleString = "\00314[[\00307$title\00314]]";
|
|
|
|
|
}
|
2011-10-29 01:17:26 +00:00
|
|
|
|
2006-03-06 13:51:58 +00:00
|
|
|
# see http://www.irssi.org/documentation/formats for some colour codes. prefix is \003,
|
2005-06-29 07:01:24 +00:00
|
|
|
# no colour (\003) switches back to the term default
|
2008-10-28 22:19:30 +00:00
|
|
|
$fullString = "$titleString\0034 $flag\00310 " .
|
2012-01-06 21:25:09 +00:00
|
|
|
"\00302$url\003 \0035*\003 \00303$user\003 \0035*\003 $szdiff \00310$comment\003\n";
|
2011-10-29 01:17:26 +00:00
|
|
|
|
2005-06-29 07:01:24 +00:00
|
|
|
return $fullString;
|
|
|
|
|
}
|
2006-03-06 13:51:58 +00:00
|
|
|
|
2006-12-13 20:08:02 +00:00
|
|
|
/**
|
|
|
|
|
* Returns the change size (HTML).
|
|
|
|
|
* The lengths can be given optionally.
|
2011-10-29 01:17:26 +00:00
|
|
|
* @param $old int
|
|
|
|
|
* @param $new int
|
|
|
|
|
* @return string
|
2006-12-13 20:08:02 +00:00
|
|
|
*/
|
2008-10-17 23:52:57 +00:00
|
|
|
public function getCharacterDifference( $old = 0, $new = 0 ) {
|
2006-12-13 20:08:02 +00:00
|
|
|
if( $old === 0 ) {
|
|
|
|
|
$old = $this->mAttribs['rc_old_len'];
|
|
|
|
|
}
|
|
|
|
|
if( $new === 0 ) {
|
|
|
|
|
$new = $this->mAttribs['rc_new_len'];
|
|
|
|
|
}
|
2009-12-11 21:07:27 +00:00
|
|
|
if( $old === null || $new === null ) {
|
2006-12-13 20:08:02 +00:00
|
|
|
return '';
|
|
|
|
|
}
|
2008-11-16 23:18:43 +00:00
|
|
|
return ChangesList::showCharacterDifference( $old, $new );
|
2006-12-09 11:36:35 +00:00
|
|
|
}
|
Unbreak maintenance/deleteDefaultMessages.php for PostgreSQL
deleteDefaultMessages.php was failing during upgrade
from MediaWiki 1.7.3 with a databaser error.
A stub user:
$user = User::newFromName( 'MediaWiki default' );
has user ID 0, so that $user->isAnon() is true.
Unfortunately, ManualLogEntry::publish() from r96441
tries to insert $user->getName() ("MediaWiki default")
into rc_ip.
PostgreSQL won't allow this, because rc_ip is of
Postgres-specific CIDR type.
Traceback:
Checking existence of old default messages...
...deleting old default messages (this may take a long time!)...A database query syntax error has occurred.
The last attempted database query was:
"INSERT INTO "recentchanges" (rc_timestamp,rc_cur_time,rc_namespace,rc_title,rc_type,rc_minor,rc_user,rc_user_text,rc_comment,rc_this_oldid,rc_last_oldid,rc_bot,rc_moved_to_ns,rc_moved_to_title,rc_ip,rc_patrolled,rc_new,rc_old_len,rc_new_len,rc_deleted,rc_logid,rc_log_type,rc_log_action,rc_params,rc_id) VALUES ('2012-03-14 21:51:05 GMT','2012-03-14 21:51:05 GMT','8','1movedto2','3','0','0','MediaWiki default','No longer required','0','0',1,'0','','MediaWiki default','1','0',NULL,NULL,'0','1','delete','delete','a:0:{}','1')"
from within function "RecentChange::save".
MySQL returned error "1: ERROR: invalid input syntax for type cidr: "MediaWiki default"
LINE 1: ...ki default','No longer required','0','0',1,'0','','MediaWiki...
^"
Backtrace:
#0 /usr/home/saper/public_html/pg/w/includes/db/DatabasePostgres.php(332): DatabaseBase->reportQueryError('ERROR: invalid...', 1, 'INSERT INTO "re...', 'RecentChange::s...', '')
#1 /usr/home/saper/public_html/pg/w/includes/db/Database.php(904): DatabasePostgres->reportQueryError('ERROR: invalid...', 1, 'INSERT INTO "re...', 'RecentChange::s...', '')
#2 /usr/home/saper/public_html/pg/w/includes/db/DatabasePostgres.php(604): DatabaseBase->query('INSERT INTO "re...', 'RecentChange::s...', '')
#3 /usr/home/saper/public_html/pg/w/includes/RecentChange.php(199): DatabasePostgres->insert('recentchanges', Array, 'RecentChange::s...')
#4 /usr/home/saper/public_html/pg/w/includes/logging/LogEntry.php(479): RecentChange->save('pleasedontudp')
#5 /usr/home/saper/public_html/pg/w/includes/WikiPage.php(2042): ManualLogEntry->publish('1')
#6 /usr/home/saper/public_html/pg/w/includes/WikiPage.php(1937): WikiPage->doDeleteArticleReal('No longer requi...', false, 0, false, '', Object(User))
#7 /usr/home/saper/public_html/pg/w/maintenance/deleteDefaultMessages.php(73): WikiPage->doDeleteArticle('No longer requi...', false, 0, false, '', Object(User))
#8 /usr/home/saper/public_html/pg/w/maintenance/update.php(128): DeleteDefaultMessages->execute()
#9 /usr/home/saper/public_html/pg/w/maintenance/doMaintenance.php(105): UpdateMediaWiki->execute()
#10 /usr/home/saper/public_html/pg/w/maintenance/update.php(151): require_once('/usr/home/saper...')
#11 {main}
2012-03-15 01:52:38 +00:00
|
|
|
|
2012-03-21 23:57:16 +00:00
|
|
|
private static function checkIPAddress( $ip ) {
|
Unbreak maintenance/deleteDefaultMessages.php for PostgreSQL
deleteDefaultMessages.php was failing during upgrade
from MediaWiki 1.7.3 with a databaser error.
A stub user:
$user = User::newFromName( 'MediaWiki default' );
has user ID 0, so that $user->isAnon() is true.
Unfortunately, ManualLogEntry::publish() from r96441
tries to insert $user->getName() ("MediaWiki default")
into rc_ip.
PostgreSQL won't allow this, because rc_ip is of
Postgres-specific CIDR type.
Traceback:
Checking existence of old default messages...
...deleting old default messages (this may take a long time!)...A database query syntax error has occurred.
The last attempted database query was:
"INSERT INTO "recentchanges" (rc_timestamp,rc_cur_time,rc_namespace,rc_title,rc_type,rc_minor,rc_user,rc_user_text,rc_comment,rc_this_oldid,rc_last_oldid,rc_bot,rc_moved_to_ns,rc_moved_to_title,rc_ip,rc_patrolled,rc_new,rc_old_len,rc_new_len,rc_deleted,rc_logid,rc_log_type,rc_log_action,rc_params,rc_id) VALUES ('2012-03-14 21:51:05 GMT','2012-03-14 21:51:05 GMT','8','1movedto2','3','0','0','MediaWiki default','No longer required','0','0',1,'0','','MediaWiki default','1','0',NULL,NULL,'0','1','delete','delete','a:0:{}','1')"
from within function "RecentChange::save".
MySQL returned error "1: ERROR: invalid input syntax for type cidr: "MediaWiki default"
LINE 1: ...ki default','No longer required','0','0',1,'0','','MediaWiki...
^"
Backtrace:
#0 /usr/home/saper/public_html/pg/w/includes/db/DatabasePostgres.php(332): DatabaseBase->reportQueryError('ERROR: invalid...', 1, 'INSERT INTO "re...', 'RecentChange::s...', '')
#1 /usr/home/saper/public_html/pg/w/includes/db/Database.php(904): DatabasePostgres->reportQueryError('ERROR: invalid...', 1, 'INSERT INTO "re...', 'RecentChange::s...', '')
#2 /usr/home/saper/public_html/pg/w/includes/db/DatabasePostgres.php(604): DatabaseBase->query('INSERT INTO "re...', 'RecentChange::s...', '')
#3 /usr/home/saper/public_html/pg/w/includes/RecentChange.php(199): DatabasePostgres->insert('recentchanges', Array, 'RecentChange::s...')
#4 /usr/home/saper/public_html/pg/w/includes/logging/LogEntry.php(479): RecentChange->save('pleasedontudp')
#5 /usr/home/saper/public_html/pg/w/includes/WikiPage.php(2042): ManualLogEntry->publish('1')
#6 /usr/home/saper/public_html/pg/w/includes/WikiPage.php(1937): WikiPage->doDeleteArticleReal('No longer requi...', false, 0, false, '', Object(User))
#7 /usr/home/saper/public_html/pg/w/maintenance/deleteDefaultMessages.php(73): WikiPage->doDeleteArticle('No longer requi...', false, 0, false, '', Object(User))
#8 /usr/home/saper/public_html/pg/w/maintenance/update.php(128): DeleteDefaultMessages->execute()
#9 /usr/home/saper/public_html/pg/w/maintenance/doMaintenance.php(105): UpdateMediaWiki->execute()
#10 /usr/home/saper/public_html/pg/w/maintenance/update.php(151): require_once('/usr/home/saper...')
#11 {main}
2012-03-15 01:52:38 +00:00
|
|
|
global $wgRequest;
|
|
|
|
|
if ( $ip ) {
|
|
|
|
|
if ( !IP::isIPAddress( $ip ) ) {
|
|
|
|
|
throw new MWException( "Attempt to write \"" . $ip . "\" as an IP address into recent changes" );
|
|
|
|
|
}
|
|
|
|
|
} else {
|
|
|
|
|
$ip = $wgRequest->getIP();
|
|
|
|
|
if( !$ip )
|
|
|
|
|
$ip = '';
|
|
|
|
|
}
|
|
|
|
|
return $ip;
|
|
|
|
|
}
|
2004-01-17 05:49:39 +00:00
|
|
|
}
|