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
|
|
|
|
|
*/
|
2012-06-29 09:51:55 +00:00
|
|
|
|
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_namespace namespace #
|
|
|
|
|
* rc_title non-prefixed db key
|
|
|
|
|
* rc_type is new entry, used to determine whether updating is necessary
|
2013-10-25 20:10:42 +00:00
|
|
|
* rc_source string representation of change source
|
2010-01-21 22:01:38 +00:00
|
|
|
* 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
|
2005-06-29 07:01:24 +00:00
|
|
|
* oldSize text size before the change
|
|
|
|
|
* newSize text size after the change
|
2012-05-18 21:01:12 +00:00
|
|
|
* pageStatus status of the page: created, deleted, moved, restored, changed
|
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
|
|
|
*/
|
2010-01-21 22:01:38 +00:00
|
|
|
class RecentChange {
|
2013-10-25 20:10:42 +00:00
|
|
|
// Constants for the rc_source field. Extensions may also have
|
|
|
|
|
// their own source constants.
|
|
|
|
|
const SRC_EDIT = 'mw.edit';
|
|
|
|
|
const SRC_NEW = 'mw.new';
|
|
|
|
|
const SRC_LOG = 'mw.log';
|
|
|
|
|
const SRC_EXTERNAL = 'mw.external'; // obsolete
|
|
|
|
|
|
2013-11-19 07:39:35 +00:00
|
|
|
public $mAttribs = array();
|
|
|
|
|
public $mExtra = array();
|
2011-04-11 12:47:55 +00:00
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* @var Title
|
|
|
|
|
*/
|
2013-11-19 07:39:35 +00:00
|
|
|
public $mTitle = false;
|
2011-04-11 12:47:55 +00:00
|
|
|
|
2012-07-13 19:50:25 +00:00
|
|
|
/**
|
|
|
|
|
* @var User
|
|
|
|
|
*/
|
|
|
|
|
private $mPerformer = false;
|
|
|
|
|
|
2013-12-18 16:02:33 +00:00
|
|
|
public $numberofWatchingusers = 0; # Dummy to prevent error message in SpecialRecentChangesLinked
|
2013-11-19 07:39:35 +00:00
|
|
|
public $notificationtimestamp;
|
2004-01-17 05:49:39 +00:00
|
|
|
|
2013-11-19 08:37:41 +00:00
|
|
|
/**
|
|
|
|
|
* @var int Line number of recent change. Default -1.
|
|
|
|
|
*/
|
|
|
|
|
public $counter = -1;
|
|
|
|
|
|
2015-09-17 09:56:22 +00:00
|
|
|
/**
|
|
|
|
|
* @var array Array of change types
|
|
|
|
|
*/
|
|
|
|
|
private static $changeTypes = array(
|
|
|
|
|
'edit' => RC_EDIT,
|
|
|
|
|
'new' => RC_NEW,
|
|
|
|
|
'log' => RC_LOG,
|
|
|
|
|
'external' => RC_EXTERNAL,
|
|
|
|
|
);
|
|
|
|
|
|
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
|
|
|
/**
|
2014-04-14 19:43:18 +00:00
|
|
|
* @param mixed $row
|
2011-10-29 01:17:26 +00:00
|
|
|
* @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 );
|
2013-11-18 22:07:49 +00:00
|
|
|
|
2004-01-17 05:49:39 +00:00
|
|
|
return $rc;
|
|
|
|
|
}
|
2004-08-09 05:38:11 +00:00
|
|
|
|
2014-05-15 10:18:28 +00:00
|
|
|
/**
|
|
|
|
|
* Parsing text to RC_* constants
|
|
|
|
|
* @since 1.24
|
|
|
|
|
* @param string|array $type
|
|
|
|
|
* @throws MWException
|
|
|
|
|
* @return int|array RC_TYPE
|
|
|
|
|
*/
|
|
|
|
|
public static function parseToRCType( $type ) {
|
|
|
|
|
if ( is_array( $type ) ) {
|
|
|
|
|
$retval = array();
|
|
|
|
|
foreach ( $type as $t ) {
|
|
|
|
|
$retval[] = RecentChange::parseToRCType( $t );
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return $retval;
|
|
|
|
|
}
|
|
|
|
|
|
2015-09-17 09:56:22 +00:00
|
|
|
if ( !array_key_exists( $type, self::$changeTypes ) ) {
|
|
|
|
|
throw new MWException( "Unknown type '$type'" );
|
2014-05-15 10:18:28 +00:00
|
|
|
}
|
2015-09-17 09:56:22 +00:00
|
|
|
return self::$changeTypes[$type];
|
2014-05-15 10:18:28 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Parsing RC_* constants to human-readable test
|
|
|
|
|
* @since 1.24
|
2014-08-13 19:41:39 +00:00
|
|
|
* @param int $rcType
|
2014-05-15 10:18:28 +00:00
|
|
|
* @return string $type
|
|
|
|
|
*/
|
|
|
|
|
public static function parseFromRCType( $rcType ) {
|
2015-09-17 09:56:22 +00:00
|
|
|
return array_search( $rcType, self::$changeTypes, true ) ?: "$rcType";
|
|
|
|
|
}
|
2014-05-15 10:18:28 +00:00
|
|
|
|
2015-09-17 09:56:22 +00:00
|
|
|
/**
|
|
|
|
|
* Get an array of all change types
|
|
|
|
|
*
|
|
|
|
|
* @since 1.26
|
|
|
|
|
*
|
|
|
|
|
* @return array
|
|
|
|
|
*/
|
|
|
|
|
public static function getChangeTypes() {
|
|
|
|
|
return array_keys( self::$changeTypes );
|
2014-05-15 10:18:28 +00:00
|
|
|
}
|
|
|
|
|
|
2006-12-22 19:43:20 +00:00
|
|
|
/**
|
|
|
|
|
* Obtain the recent change with a given rc_id value
|
|
|
|
|
*
|
2014-07-24 17:42:45 +00:00
|
|
|
* @param int $rcid The rc_id value to retrieve
|
2015-06-01 11:05:58 +00:00
|
|
|
* @return RecentChange|null
|
2006-12-22 19:43:20 +00:00
|
|
|
*/
|
|
|
|
|
public static function newFromId( $rcid ) {
|
2012-06-29 09:51:55 +00:00
|
|
|
return self::newFromConds( array( 'rc_id' => $rcid ), __METHOD__ );
|
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
|
|
|
|
|
*
|
2014-04-14 19:43:18 +00:00
|
|
|
* @param array $conds Array of conditions
|
|
|
|
|
* @param mixed $fname Override the method name in profiling/logs
|
|
|
|
|
* @param array $options Query options
|
2015-06-01 11:05:58 +00:00
|
|
|
* @return RecentChange|null
|
2007-08-06 03:29:40 +00:00
|
|
|
*/
|
2012-12-29 02:53:18 +00:00
|
|
|
public static function newFromConds( $conds, $fname = __METHOD__, $options = array() ) {
|
2007-08-06 03:29:40 +00:00
|
|
|
$dbr = wfGetDB( DB_SLAVE );
|
2012-12-29 02:53:18 +00:00
|
|
|
$row = $dbr->selectRow( 'recentchanges', self::selectFields(), $conds, $fname, $options );
|
2012-06-29 09:51:55 +00:00
|
|
|
if ( $row !== false ) {
|
2007-08-06 03:29:40 +00:00
|
|
|
return self::newFromRow( $row );
|
2012-06-29 09:51:55 +00:00
|
|
|
} else {
|
|
|
|
|
return null;
|
2007-08-06 03:29:40 +00:00
|
|
|
}
|
|
|
|
|
}
|
2004-01-17 09:49:43 +00:00
|
|
|
|
2012-11-08 18:25:59 +00:00
|
|
|
/**
|
|
|
|
|
* Return the list of recentchanges fields that should be selected to create
|
|
|
|
|
* a new recentchanges object.
|
|
|
|
|
* @return array
|
|
|
|
|
*/
|
|
|
|
|
public static function selectFields() {
|
|
|
|
|
return array(
|
|
|
|
|
'rc_id',
|
|
|
|
|
'rc_timestamp',
|
|
|
|
|
'rc_user',
|
|
|
|
|
'rc_user_text',
|
|
|
|
|
'rc_namespace',
|
|
|
|
|
'rc_title',
|
|
|
|
|
'rc_comment',
|
|
|
|
|
'rc_minor',
|
|
|
|
|
'rc_bot',
|
|
|
|
|
'rc_new',
|
|
|
|
|
'rc_cur_id',
|
|
|
|
|
'rc_this_oldid',
|
|
|
|
|
'rc_last_oldid',
|
|
|
|
|
'rc_type',
|
2013-10-25 20:10:42 +00:00
|
|
|
'rc_source',
|
2012-11-08 18:25:59 +00:00
|
|
|
'rc_patrolled',
|
|
|
|
|
'rc_ip',
|
|
|
|
|
'rc_old_len',
|
|
|
|
|
'rc_new_len',
|
|
|
|
|
'rc_deleted',
|
|
|
|
|
'rc_logid',
|
|
|
|
|
'rc_log_type',
|
|
|
|
|
'rc_log_action',
|
|
|
|
|
'rc_params',
|
|
|
|
|
);
|
|
|
|
|
}
|
|
|
|
|
|
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
|
|
|
/**
|
2014-04-14 19:43:18 +00:00
|
|
|
* @param array $attribs
|
2012-01-14 15:27:30 +00:00
|
|
|
*/
|
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
|
|
|
/**
|
2014-04-14 19:43:18 +00:00
|
|
|
* @param array $extra
|
2012-01-14 15:27:30 +00:00
|
|
|
*/
|
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() {
|
2012-10-25 12:43:21 +00:00
|
|
|
if ( $this->mTitle === false ) {
|
2004-01-17 05:49:39 +00:00
|
|
|
$this->mTitle = Title::makeTitle( $this->mAttribs['rc_namespace'], $this->mAttribs['rc_title'] );
|
|
|
|
|
}
|
2013-11-18 22:07:49 +00:00
|
|
|
|
2004-01-17 05:49:39 +00:00
|
|
|
return $this->mTitle;
|
|
|
|
|
}
|
|
|
|
|
|
2012-07-13 19:50:25 +00:00
|
|
|
/**
|
|
|
|
|
* Get the User object of the person who performed this change.
|
|
|
|
|
*
|
|
|
|
|
* @return User
|
|
|
|
|
*/
|
|
|
|
|
public function getPerformer() {
|
|
|
|
|
if ( $this->mPerformer === false ) {
|
|
|
|
|
if ( $this->mAttribs['rc_user'] ) {
|
2014-12-02 18:13:06 +00:00
|
|
|
$this->mPerformer = User::newFromId( $this->mAttribs['rc_user'] );
|
2012-07-13 19:50:25 +00:00
|
|
|
} else {
|
|
|
|
|
$this->mPerformer = User::newFromName( $this->mAttribs['rc_user_text'], false );
|
|
|
|
|
}
|
|
|
|
|
}
|
2013-11-18 22:07:49 +00:00
|
|
|
|
2012-07-13 19:50:25 +00:00
|
|
|
return $this->mPerformer;
|
|
|
|
|
}
|
|
|
|
|
|
2011-10-29 01:17:26 +00:00
|
|
|
/**
|
|
|
|
|
* Writes the data in this object to the database
|
2014-04-14 19:43:18 +00:00
|
|
|
* @param bool $noudp
|
2011-10-29 01:17:26 +00:00
|
|
|
*/
|
2011-11-03 17:07:29 +00:00
|
|
|
public function save( $noudp = false ) {
|
2014-02-14 06:34:35 +00:00
|
|
|
global $wgPutIPinRC, $wgUseEnotif, $wgShowUpdatedMarker, $wgContLang;
|
2004-08-09 05:38:11 +00:00
|
|
|
|
2007-01-22 23:50:42 +00:00
|
|
|
$dbw = wfGetDB( DB_MASTER );
|
2012-10-25 12:43:21 +00:00
|
|
|
if ( !is_array( $this->mExtra ) ) {
|
2004-01-17 05:49:39 +00:00
|
|
|
$this->mExtra = array();
|
|
|
|
|
}
|
2004-08-09 05:38:11 +00:00
|
|
|
|
2012-10-25 12:43:21 +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
|
2014-10-23 20:03:14 +00:00
|
|
|
if ( $dbw->strictIPs() && $this->mAttribs['rc_ip'] == '' ) {
|
2006-08-16 00:59:34 +00:00
|
|
|
unset( $this->mAttribs['rc_ip'] );
|
|
|
|
|
}
|
|
|
|
|
|
2012-12-01 19:11:21 +00:00
|
|
|
# Trim spaces on user supplied text
|
|
|
|
|
$this->mAttribs['rc_comment'] = trim( $this->mAttribs['rc_comment'] );
|
|
|
|
|
|
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
|
2012-10-25 12:43:21 +00:00
|
|
|
$this->mAttribs['rc_timestamp'] = $dbw->timestamp( $this->mAttribs['rc_timestamp'] );
|
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
|
2014-10-23 20:03:14 +00:00
|
|
|
if ( $dbw->cascadingDeletes() && $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
|
2014-12-09 07:23:30 +00:00
|
|
|
Hooks::run( '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 ) {
|
2013-03-04 19:43:22 +00:00
|
|
|
$this->notifyRCFeeds();
|
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
|
2012-10-25 12:43:21 +00:00
|
|
|
if ( $wgUseEnotif || $wgShowUpdatedMarker ) {
|
2012-07-13 19:50:25 +00:00
|
|
|
$editor = $this->getPerformer();
|
|
|
|
|
$title = $this->getTitle();
|
2012-01-06 21:25:09 +00:00
|
|
|
|
2014-12-09 07:23:30 +00:00
|
|
|
if ( Hooks::run( 'AbortEmailNotification', array( $editor, $title, $this ) ) ) {
|
2012-07-17 19:58:53 +00:00
|
|
|
# @todo FIXME: This would be better as an extension hook
|
|
|
|
|
$enotif = new EmailNotification();
|
2012-08-07 23:47:25 +00:00
|
|
|
$enotif->notifyOnPageChange( $editor, $title,
|
2012-07-17 19:58:53 +00:00
|
|
|
$this->mAttribs['rc_timestamp'],
|
|
|
|
|
$this->mAttribs['rc_comment'],
|
|
|
|
|
$this->mAttribs['rc_minor'],
|
2012-05-18 21:01:12 +00:00
|
|
|
$this->mAttribs['rc_last_oldid'],
|
|
|
|
|
$this->mExtra['pageStatus'] );
|
2012-07-17 19:58:53 +00:00
|
|
|
}
|
2005-12-08 01:36:33 +00:00
|
|
|
}
|
2015-05-21 06:13:28 +00:00
|
|
|
|
|
|
|
|
// Update the cached list of active users
|
|
|
|
|
if ( $this->mAttribs['rc_user'] > 0 ) {
|
|
|
|
|
JobQueueGroup::singleton()->lazyPush( RecentChangesUpdateJob::newCacheUpdateJob() );
|
|
|
|
|
}
|
2004-01-17 05:49:39 +00:00
|
|
|
}
|
2011-10-29 01:17:26 +00:00
|
|
|
|
2013-03-04 19:43:22 +00:00
|
|
|
/**
|
|
|
|
|
* Notify all the feeds about the change.
|
2014-05-27 00:50:11 +00:00
|
|
|
* @param array $feeds Optional feeds to send to, defaults to $wgRCFeeds
|
2013-03-04 19:43:22 +00:00
|
|
|
*/
|
2014-05-27 00:50:11 +00:00
|
|
|
public function notifyRCFeeds( array $feeds = null ) {
|
2013-03-04 19:43:22 +00:00
|
|
|
global $wgRCFeeds;
|
2014-05-27 00:50:11 +00:00
|
|
|
if ( $feeds === null ) {
|
|
|
|
|
$feeds = $wgRCFeeds;
|
|
|
|
|
}
|
2013-03-04 19:43:22 +00:00
|
|
|
|
2014-02-06 08:20:27 +00:00
|
|
|
$performer = $this->getPerformer();
|
|
|
|
|
|
2014-05-27 00:50:11 +00:00
|
|
|
foreach ( $feeds as $feed ) {
|
2014-02-06 08:20:27 +00:00
|
|
|
$feed += array(
|
|
|
|
|
'omit_bots' => false,
|
|
|
|
|
'omit_anon' => false,
|
|
|
|
|
'omit_user' => false,
|
|
|
|
|
'omit_minor' => false,
|
|
|
|
|
'omit_patrolled' => false,
|
|
|
|
|
);
|
2013-03-04 19:43:22 +00:00
|
|
|
|
|
|
|
|
if (
|
2014-02-06 08:20:27 +00:00
|
|
|
( $feed['omit_bots'] && $this->mAttribs['rc_bot'] ) ||
|
|
|
|
|
( $feed['omit_anon'] && $performer->isAnon() ) ||
|
|
|
|
|
( $feed['omit_user'] && !$performer->isAnon() ) ||
|
|
|
|
|
( $feed['omit_minor'] && $this->mAttribs['rc_minor'] ) ||
|
|
|
|
|
( $feed['omit_patrolled'] && $this->mAttribs['rc_patrolled'] ) ||
|
2013-03-04 19:43:22 +00:00
|
|
|
$this->mAttribs['rc_type'] == RC_EXTERNAL
|
|
|
|
|
) {
|
|
|
|
|
continue;
|
|
|
|
|
}
|
|
|
|
|
|
2014-01-22 07:14:13 +00:00
|
|
|
$engine = self::getEngine( $feed['uri'] );
|
|
|
|
|
|
|
|
|
|
if ( isset( $this->mExtra['actionCommentIRC'] ) ) {
|
|
|
|
|
$actionComment = $this->mExtra['actionCommentIRC'];
|
|
|
|
|
} else {
|
|
|
|
|
$actionComment = null;
|
|
|
|
|
}
|
|
|
|
|
|
2013-11-19 12:29:45 +00:00
|
|
|
/** @var $formatter RCFeedFormatter */
|
2014-05-27 00:50:11 +00:00
|
|
|
$formatter = is_object( $feed['formatter'] ) ? $feed['formatter'] : new $feed['formatter']();
|
2013-03-04 19:43:22 +00:00
|
|
|
$line = $formatter->getLine( $feed, $this, $actionComment );
|
2015-08-19 02:57:39 +00:00
|
|
|
if ( !$line ) {
|
|
|
|
|
// T109544
|
|
|
|
|
// If a feed formatter returns null, this will otherwise cause an
|
|
|
|
|
// error in at least RedisPubSubFeedEngine.
|
|
|
|
|
// Not sure where/how this should best be handled.
|
|
|
|
|
continue;
|
|
|
|
|
}
|
2013-03-04 19:43:22 +00:00
|
|
|
|
|
|
|
|
$engine->send( $feed, $line );
|
2008-10-19 23:59:39 +00:00
|
|
|
}
|
|
|
|
|
}
|
2011-10-29 01:17:26 +00:00
|
|
|
|
2008-10-19 23:59:39 +00:00
|
|
|
/**
|
2013-08-26 20:58:29 +00:00
|
|
|
* Gets the stream engine object for a given URI from $wgRCEngines
|
2013-03-04 19:43:22 +00:00
|
|
|
*
|
2013-11-19 12:29:45 +00:00
|
|
|
* @param string $uri URI to get the engine object for
|
|
|
|
|
* @throws MWException
|
2014-01-22 07:14:13 +00:00
|
|
|
* @return RCFeedEngine The engine object
|
2013-03-04 19:43:22 +00:00
|
|
|
*/
|
2014-01-22 07:14:13 +00:00
|
|
|
public static function getEngine( $uri ) {
|
2013-08-26 20:58:29 +00:00
|
|
|
global $wgRCEngines;
|
2013-03-04 19:43:22 +00:00
|
|
|
|
|
|
|
|
$scheme = parse_url( $uri, PHP_URL_SCHEME );
|
|
|
|
|
if ( !$scheme ) {
|
|
|
|
|
throw new MWException( __FUNCTION__ . ": Invalid stream logger URI: '$uri'" );
|
|
|
|
|
}
|
|
|
|
|
|
2013-08-26 20:58:29 +00:00
|
|
|
if ( !isset( $wgRCEngines[$scheme] ) ) {
|
2013-03-04 19:43:22 +00:00
|
|
|
throw new MWException( __FUNCTION__ . ": Unknown stream logger URI scheme: $scheme" );
|
|
|
|
|
}
|
|
|
|
|
|
2013-08-26 20:58:29 +00:00
|
|
|
return new $wgRCEngines[$scheme];
|
2013-03-04 19:43:22 +00:00
|
|
|
}
|
|
|
|
|
|
2007-08-06 03:29:40 +00:00
|
|
|
/**
|
|
|
|
|
* Mark a given change as patrolled
|
|
|
|
|
*
|
2014-04-14 19:43:18 +00:00
|
|
|
* @param RecentChange|int $change RecentChange or corresponding rc_id
|
|
|
|
|
* @param bool $auto For automatic patrol
|
|
|
|
|
* @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
|
2012-10-25 12:43:21 +00:00
|
|
|
: RecentChange::newFromId( $change );
|
2011-07-09 09:17:35 +00:00
|
|
|
|
2012-10-25 12:43:21 +00:00
|
|
|
if ( !$change instanceof RecentChange ) {
|
2008-09-04 15:17:51 +00:00
|
|
|
return null;
|
2008-09-20 07:55:14 +00:00
|
|
|
}
|
2013-11-18 22:07:49 +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
|
|
|
|
|
*
|
2013-11-18 22:03:29 +00:00
|
|
|
* NOTE: Can also return 'rcpatroldisabled', 'hookaborted' and
|
|
|
|
|
* 'markedaspatrollederror-noautopatrol' as errors
|
2014-04-14 19:43:18 +00:00
|
|
|
* @param User $user User object doing the action
|
|
|
|
|
* @param bool $auto For automatic patrol
|
|
|
|
|
* @return array Array of permissions errors, see Title::getUserPermissionsErrors()
|
2008-09-04 15:17:51 +00:00
|
|
|
*/
|
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
|
2012-10-25 12:43:21 +00:00
|
|
|
if ( !$wgUseRCPatrol && ( !$wgUseNPPatrol || $this->getAttribute( 'rc_type' ) != RC_NEW ) ) {
|
|
|
|
|
$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 ) );
|
2014-12-09 07:23:30 +00:00
|
|
|
if ( !Hooks::run( 'MarkPatrolled', array( $this->getAttribute( 'rc_id' ), &$user, false ) ) ) {
|
2012-10-25 12:43:21 +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
|
2014-12-11 08:59:28 +00:00
|
|
|
if ( $user->getName() === $this->getAttribute( 'rc_user_text' )
|
2013-11-18 22:03:29 +00:00
|
|
|
&& !$user->isAllowed( 'autopatrol' )
|
|
|
|
|
) {
|
2012-10-25 12:43:21 +00:00
|
|
|
$errors[] = array( 'markedaspatrollederror-noautopatrol' );
|
2008-10-17 23:52:57 +00:00
|
|
|
}
|
2012-10-25 12:43:21 +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
|
2012-10-25 12:43:21 +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 );
|
2014-12-09 07:23:30 +00:00
|
|
|
Hooks::run( 'MarkPatrolledComplete', array( $this->getAttribute( 'rc_id' ), &$user, false ) );
|
2013-11-18 22:07:49 +00:00
|
|
|
|
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
|
2014-04-14 19:43:18 +00:00
|
|
|
* @return int 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(
|
2012-10-25 12:43:21 +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
|
|
|
);
|
2012-12-29 02:53:18 +00:00
|
|
|
// Invalidate the page cache after the page has been patrolled
|
|
|
|
|
// to make sure that the Patrol link isn't visible any longer!
|
|
|
|
|
$this->getTitle()->invalidateCache();
|
2013-11-18 22:07:49 +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
|
|
|
|
|
*
|
2014-04-14 19:43:18 +00:00
|
|
|
* @param string $timestamp
|
|
|
|
|
* @param Title $title
|
|
|
|
|
* @param bool $minor
|
|
|
|
|
* @param User $user
|
|
|
|
|
* @param string $comment
|
|
|
|
|
* @param int $oldId
|
|
|
|
|
* @param string $lastTimestamp
|
|
|
|
|
* @param bool $bot
|
|
|
|
|
* @param string $ip
|
|
|
|
|
* @param int $oldSize
|
|
|
|
|
* @param int $newSize
|
|
|
|
|
* @param int $newId
|
|
|
|
|
* @param int $patrol
|
2011-04-11 12:47:55 +00:00
|
|
|
* @return RecentChange
|
|
|
|
|
*/
|
2015-05-21 07:21:03 +00:00
|
|
|
public static function notifyEdit(
|
|
|
|
|
$timestamp, &$title, $minor, &$user, $comment, $oldId, $lastTimestamp,
|
|
|
|
|
$bot, $ip = '', $oldSize = 0, $newSize = 0, $newId = 0, $patrol = 0
|
|
|
|
|
) {
|
2004-01-17 05:49:39 +00:00
|
|
|
$rc = new RecentChange;
|
2012-07-13 19:50:25 +00:00
|
|
|
$rc->mTitle = $title;
|
|
|
|
|
$rc->mPerformer = $user;
|
2004-01-17 05:49:39 +00:00
|
|
|
$rc->mAttribs = array(
|
2013-11-18 22:07:49 +00:00
|
|
|
'rc_timestamp' => $timestamp,
|
|
|
|
|
'rc_namespace' => $title->getNamespace(),
|
|
|
|
|
'rc_title' => $title->getDBkey(),
|
|
|
|
|
'rc_type' => RC_EDIT,
|
|
|
|
|
'rc_source' => self::SRC_EDIT,
|
|
|
|
|
'rc_minor' => $minor ? 1 : 0,
|
|
|
|
|
'rc_cur_id' => $title->getArticleID(),
|
|
|
|
|
'rc_user' => $user->getId(),
|
|
|
|
|
'rc_user_text' => $user->getName(),
|
|
|
|
|
'rc_comment' => $comment,
|
2010-01-21 22:01:38 +00:00
|
|
|
'rc_this_oldid' => $newId,
|
|
|
|
|
'rc_last_oldid' => $oldId,
|
2013-11-18 22:07:49 +00:00
|
|
|
'rc_bot' => $bot ? 1 : 0,
|
|
|
|
|
'rc_ip' => self::checkIPAddress( $ip ),
|
|
|
|
|
'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,
|
2010-01-21 22:01:38 +00:00
|
|
|
'rc_log_action' => '',
|
2013-11-18 22:07:49 +00:00
|
|
|
'rc_params' => ''
|
2004-01-17 05:49:39 +00:00
|
|
|
);
|
2004-08-09 05:38:11 +00:00
|
|
|
|
2013-03-07 16:50:43 +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,
|
2013-11-18 22:07:49 +00:00
|
|
|
'oldSize' => $oldSize,
|
|
|
|
|
'newSize' => $newSize,
|
|
|
|
|
'pageStatus' => 'changed'
|
2004-01-17 05:49:39 +00:00
|
|
|
);
|
2015-05-21 07:21:03 +00:00
|
|
|
|
|
|
|
|
DeferredUpdates::addCallableUpdate( function() use ( $rc ) {
|
|
|
|
|
$rc->save();
|
|
|
|
|
if ( $rc->mAttribs['rc_patrolled'] ) {
|
|
|
|
|
PatrolLog::record( $rc, true, $rc->getPerformer() );
|
|
|
|
|
}
|
|
|
|
|
} );
|
2013-11-18 22:07:49 +00:00
|
|
|
|
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()
|
2011-04-11 12:47:55 +00:00
|
|
|
*
|
2014-04-14 19:43:18 +00:00
|
|
|
* @param string $timestamp
|
|
|
|
|
* @param Title $title
|
|
|
|
|
* @param bool $minor
|
|
|
|
|
* @param User $user
|
|
|
|
|
* @param string $comment
|
|
|
|
|
* @param bool $bot
|
|
|
|
|
* @param string $ip
|
|
|
|
|
* @param int $size
|
|
|
|
|
* @param int $newId
|
|
|
|
|
* @param int $patrol
|
2011-04-11 12:47:55 +00:00
|
|
|
* @return RecentChange
|
2006-07-10 15:41:30 +00:00
|
|
|
*/
|
2015-05-21 07:21:03 +00:00
|
|
|
public static function notifyNew(
|
|
|
|
|
$timestamp, &$title, $minor, &$user, $comment, $bot,
|
|
|
|
|
$ip = '', $size = 0, $newId = 0, $patrol = 0
|
|
|
|
|
) {
|
2004-01-17 05:49:39 +00:00
|
|
|
$rc = new RecentChange;
|
2012-07-13 19:50:25 +00:00
|
|
|
$rc->mTitle = $title;
|
|
|
|
|
$rc->mPerformer = $user;
|
2004-01-17 05:49:39 +00:00
|
|
|
$rc->mAttribs = array(
|
2013-11-18 22:07:49 +00:00
|
|
|
'rc_timestamp' => $timestamp,
|
|
|
|
|
'rc_namespace' => $title->getNamespace(),
|
|
|
|
|
'rc_title' => $title->getDBkey(),
|
|
|
|
|
'rc_type' => RC_NEW,
|
|
|
|
|
'rc_source' => self::SRC_NEW,
|
|
|
|
|
'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' => 0,
|
|
|
|
|
'rc_bot' => $bot ? 1 : 0,
|
|
|
|
|
'rc_ip' => self::checkIPAddress( $ip ),
|
|
|
|
|
'rc_patrolled' => intval( $patrol ),
|
|
|
|
|
'rc_new' => 1, # obsolete
|
|
|
|
|
'rc_old_len' => 0,
|
|
|
|
|
'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
|
|
|
|
2013-03-07 16:50:43 +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,
|
2012-05-18 21:01:12 +00:00
|
|
|
'newSize' => $size,
|
|
|
|
|
'pageStatus' => 'created'
|
2004-01-17 05:49:39 +00:00
|
|
|
);
|
2015-05-21 07:21:03 +00:00
|
|
|
|
|
|
|
|
DeferredUpdates::addCallableUpdate( function() use ( $rc ) {
|
|
|
|
|
$rc->save();
|
|
|
|
|
if ( $rc->mAttribs['rc_patrolled'] ) {
|
|
|
|
|
PatrolLog::record( $rc, true, $rc->getPerformer() );
|
|
|
|
|
}
|
|
|
|
|
} );
|
2013-11-18 22:07:49 +00:00
|
|
|
|
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
|
|
|
/**
|
2014-04-14 19:43:18 +00:00
|
|
|
* @param string $timestamp
|
|
|
|
|
* @param Title $title
|
|
|
|
|
* @param User $user
|
|
|
|
|
* @param string $actionComment
|
|
|
|
|
* @param string $ip
|
|
|
|
|
* @param string $type
|
|
|
|
|
* @param string $action
|
|
|
|
|
* @param Title $target
|
|
|
|
|
* @param string $logComment
|
|
|
|
|
* @param string $params
|
|
|
|
|
* @param int $newId
|
|
|
|
|
* @param string $actionCommentIRC
|
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,
|
2013-11-18 22:03:29 +00:00
|
|
|
$action, $target, $logComment, $params, $newId = 0, $actionCommentIRC = ''
|
|
|
|
|
) {
|
2009-01-09 18:38:10 +00:00
|
|
|
global $wgLogRestrictions;
|
2013-11-18 22:03:29 +00:00
|
|
|
|
2009-01-09 18:38:10 +00:00
|
|
|
# Don't add private logs to RC!
|
2012-10-25 12:43:21 +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();
|
2013-11-18 22:07:49 +00:00
|
|
|
|
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
|
|
|
/**
|
2014-04-14 19:43:18 +00:00
|
|
|
* @param string $timestamp
|
|
|
|
|
* @param Title $title
|
|
|
|
|
* @param User $user
|
|
|
|
|
* @param string $actionComment
|
|
|
|
|
* @param string $ip
|
|
|
|
|
* @param string $type
|
|
|
|
|
* @param string $action
|
|
|
|
|
* @param Title $target
|
|
|
|
|
* @param string $logComment
|
|
|
|
|
* @param string $params
|
|
|
|
|
* @param int $newId
|
|
|
|
|
* @param string $actionCommentIRC
|
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,
|
2012-10-25 12:43:21 +00:00
|
|
|
$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
|
|
|
|
2012-05-18 21:01:12 +00:00
|
|
|
## Get pageStatus for email notification
|
|
|
|
|
switch ( $type . '-' . $action ) {
|
|
|
|
|
case 'delete-delete':
|
|
|
|
|
$pageStatus = 'deleted';
|
|
|
|
|
break;
|
|
|
|
|
case 'move-move':
|
|
|
|
|
case 'move-move_redir':
|
|
|
|
|
$pageStatus = 'moved';
|
|
|
|
|
break;
|
|
|
|
|
case 'delete-restore':
|
|
|
|
|
$pageStatus = 'restored';
|
|
|
|
|
break;
|
|
|
|
|
case 'upload-upload':
|
|
|
|
|
$pageStatus = 'created';
|
|
|
|
|
break;
|
|
|
|
|
case 'upload-overwrite':
|
|
|
|
|
default:
|
|
|
|
|
$pageStatus = 'changed';
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
|
2004-01-17 05:49:39 +00:00
|
|
|
$rc = new RecentChange;
|
2012-07-13 19:50:25 +00:00
|
|
|
$rc->mTitle = $target;
|
|
|
|
|
$rc->mPerformer = $user;
|
2004-01-17 05:49:39 +00:00
|
|
|
$rc->mAttribs = array(
|
2013-11-18 22:07:49 +00:00
|
|
|
'rc_timestamp' => $timestamp,
|
|
|
|
|
'rc_namespace' => $target->getNamespace(),
|
|
|
|
|
'rc_title' => $target->getDBkey(),
|
|
|
|
|
'rc_type' => RC_LOG,
|
|
|
|
|
'rc_source' => self::SRC_LOG,
|
|
|
|
|
'rc_minor' => 0,
|
|
|
|
|
'rc_cur_id' => $target->getArticleID(),
|
|
|
|
|
'rc_user' => $user->getId(),
|
|
|
|
|
'rc_user_text' => $user->getName(),
|
|
|
|
|
'rc_comment' => $logComment,
|
2010-01-21 22:01:38 +00:00
|
|
|
'rc_this_oldid' => 0,
|
|
|
|
|
'rc_last_oldid' => 0,
|
2013-11-18 22:07:49 +00:00
|
|
|
'rc_bot' => $user->isAllowed( 'bot' ) ? $wgRequest->getBool( 'bot', true ) : 0,
|
|
|
|
|
'rc_ip' => self::checkIPAddress( $ip ),
|
|
|
|
|
'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,
|
2010-01-21 22:01:38 +00:00
|
|
|
'rc_log_action' => $action,
|
2013-11-18 22:07:49 +00:00
|
|
|
'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
|
|
|
|
2013-03-07 16:50:43 +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
|
2013-11-18 22:07:49 +00:00
|
|
|
'pageStatus' => $pageStatus,
|
2012-02-21 23:39:14 +00:00
|
|
|
'actionCommentIRC' => $actionCommentIRC
|
2004-01-17 05:49:39 +00:00
|
|
|
);
|
2013-11-18 22:07:49 +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
|
|
|
|
|
*
|
2014-04-14 19:43:18 +00:00
|
|
|
* @param mixed $row
|
2011-10-29 01:17:26 +00:00
|
|
|
*/
|
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 );
|
2012-10-25 12:43:21 +00:00
|
|
|
$this->mAttribs['rc_timestamp'] = wfTimestamp( TS_MW, $this->mAttribs['rc_timestamp'] );
|
2008-10-27 19:59:54 +00:00
|
|
|
$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
|
|
|
|
2006-12-22 19:43:20 +00:00
|
|
|
/**
|
|
|
|
|
* Get an attribute value
|
|
|
|
|
*
|
2013-03-11 17:15:01 +00:00
|
|
|
* @param string $name 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
|
2014-04-14 19:43:18 +00:00
|
|
|
* @param bool $forceCur
|
2011-10-29 01:17:26 +00:00
|
|
|
* @return string
|
2004-09-02 23:28:24 +00:00
|
|
|
*/
|
2008-10-17 23:52:57 +00:00
|
|
|
public function diffLinkTrail( $forceCur ) {
|
2012-10-25 12:43:21 +00:00
|
|
|
if ( $this->mAttribs['rc_type'] == RC_EDIT ) {
|
|
|
|
|
$trail = "curid=" . (int)( $this->mAttribs['rc_cur_id'] ) .
|
|
|
|
|
"&oldid=" . (int)( $this->mAttribs['rc_last_oldid'] );
|
|
|
|
|
if ( $forceCur ) {
|
2013-02-09 21:44:24 +00:00
|
|
|
$trail .= '&diff=0';
|
2004-01-17 05:49:39 +00:00
|
|
|
} else {
|
2012-10-25 12:43:21 +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
|
|
|
}
|
2013-11-18 22:07:49 +00:00
|
|
|
|
2004-01-17 05:49:39 +00:00
|
|
|
return $trail;
|
|
|
|
|
}
|
2005-06-29 07:01:24 +00:00
|
|
|
|
2006-12-13 20:08:02 +00:00
|
|
|
/**
|
|
|
|
|
* Returns the change size (HTML).
|
|
|
|
|
* The lengths can be given optionally.
|
2014-04-14 19:43:18 +00:00
|
|
|
* @param int $old
|
|
|
|
|
* @param int $new
|
2011-10-29 01:17:26 +00:00
|
|
|
* @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 ) {
|
2012-10-25 12:43:21 +00:00
|
|
|
if ( $old === 0 ) {
|
2006-12-13 20:08:02 +00:00
|
|
|
$old = $this->mAttribs['rc_old_len'];
|
|
|
|
|
}
|
2012-10-25 12:43:21 +00:00
|
|
|
if ( $new === 0 ) {
|
2006-12-13 20:08:02 +00:00
|
|
|
$new = $this->mAttribs['rc_new_len'];
|
|
|
|
|
}
|
2012-10-25 12:43:21 +00:00
|
|
|
if ( $old === null || $new === null ) {
|
2006-12-13 20:08:02 +00:00
|
|
|
return '';
|
|
|
|
|
}
|
2013-11-18 22:07:49 +00:00
|
|
|
|
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 ) ) {
|
2013-11-18 22:03:29 +00:00
|
|
|
throw new MWException( "Attempt to write \"" . $ip .
|
|
|
|
|
"\" as an IP address into recent changes" );
|
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
|
|
|
}
|
|
|
|
|
} else {
|
|
|
|
|
$ip = $wgRequest->getIP();
|
2012-10-25 12:58:46 +00:00
|
|
|
if ( !$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
|
|
|
$ip = '';
|
2012-10-25 12:58:46 +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
|
|
|
}
|
2013-11-18 22:07:49 +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
|
|
|
return $ip;
|
|
|
|
|
}
|
2012-12-29 02:53:18 +00:00
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Check whether the given timestamp is new enough to have a RC row with a given tolerance
|
|
|
|
|
* as the recentchanges table might not be cleared out regularly (so older entries might exist)
|
|
|
|
|
* or rows which will be deleted soon shouldn't be included.
|
|
|
|
|
*
|
2014-04-14 19:43:18 +00:00
|
|
|
* @param mixed $timestamp MWTimestamp compatible timestamp
|
|
|
|
|
* @param int $tolerance Tolerance in seconds
|
2012-12-29 02:53:18 +00:00
|
|
|
* @return bool
|
|
|
|
|
*/
|
|
|
|
|
public static function isInRCLifespan( $timestamp, $tolerance = 0 ) {
|
|
|
|
|
global $wgRCMaxAge;
|
2013-11-18 22:07:49 +00:00
|
|
|
|
2012-12-29 02:53:18 +00:00
|
|
|
return wfTimestamp( TS_UNIX, $timestamp ) > time() - $tolerance - $wgRCMaxAge;
|
|
|
|
|
}
|
2015-06-10 12:39:17 +00:00
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Parses and returns the rc_params attribute
|
|
|
|
|
*
|
|
|
|
|
* @since 1.26
|
|
|
|
|
*
|
|
|
|
|
* @return array|null
|
|
|
|
|
*/
|
|
|
|
|
public function parseParams() {
|
|
|
|
|
$rcParams = $this->getAttribute( 'rc_params' );
|
|
|
|
|
|
2015-06-10 18:29:05 +00:00
|
|
|
MediaWiki\suppressWarnings();
|
2015-06-10 12:39:17 +00:00
|
|
|
$unserializedParams = unserialize( $rcParams );
|
2015-06-10 18:29:05 +00:00
|
|
|
MediaWiki\restoreWarnings();
|
2015-06-10 12:39:17 +00:00
|
|
|
|
|
|
|
|
return $unserializedParams;
|
|
|
|
|
}
|
2004-01-17 05:49:39 +00:00
|
|
|
}
|