'MediaWiki\\Logger\\Monolog\\LegacyHandler' => __DIR__ . '/includes/debug/logger/monolog/LegacyHandler.php',
'MediaWiki\\Logger\\Monolog\\LineFormatter' => __DIR__ . '/includes/debug/logger/monolog/LineFormatter.php',
'MediaWiki\\Logger\\Monolog\\LogstashFormatter' => __DIR__ . '/includes/debug/logger/monolog/LogstashFormatter.php',
+ 'MediaWiki\\Logger\\Monolog\\MwlogHandler' => __DIR__ . '/includes/debug/logger/monolog/MwlogHandler.php',
'MediaWiki\\Logger\\Monolog\\SyslogHandler' => __DIR__ . '/includes/debug/logger/monolog/SyslogHandler.php',
'MediaWiki\\Logger\\Monolog\\WikiProcessor' => __DIR__ . '/includes/debug/logger/monolog/WikiProcessor.php',
'MediaWiki\\Logger\\NullSpi' => __DIR__ . '/includes/debug/logger/NullSpi.php',
$pageSet = $this->getPageSet();
$pageSet->execute();
- $result = [];
-
$result = $pageSet->getInvalidTitlesAndRevisions( [
'invalidTitles', 'special', 'missingIds', 'missingRevIds', 'interwikiTitles',
] );
}
$authRes = false;
- $context = new DerivativeContext( $this->getContext() );
$loginType = 'N/A';
// Check login token
convertForSearchResult( $matches->termMatches() );
$titles = [];
$count = 0;
- $limit = $params['limit'];
if ( $matches->hasMoreResults() ) {
$this->setContinueEnumParameter( 'offset', $params['offset'] + $params['limit'] );
] );
$ids = [];
- $count = 0;
$watchedItemQuery = MediaWikiServices::getInstance()->getWatchedItemQueryService();
$items = $watchedItemQuery->getWatchedItemsWithRecentChangeInfo( $wlowner, $options, $startFrom );
--- /dev/null
+<?php
+/**
+ * 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
+ */
+
+namespace MediaWiki\Logger\Monolog;
+
+use Monolog\Handler\SyslogUdpHandler;
+use Monolog\Logger;
+
+/**
+ * Log handler that will append the record's channel to a fixed 'application
+ * prefix' given at construction time.
+ *
+ * The use case for this handler is to deprecate udp2log with a localhost
+ * syslog endpoint. The application name is then used to reconstruct the
+ * message's channel.
+ *
+ * @since 1.32
+ * @copyright © 2019 Wikimedia Foundation and contributors
+ */
+class MwlogHandler extends SyslogUdpHandler {
+
+ /**
+ * @var string $appprefix
+ */
+ private $appprefix;
+
+ /**
+ * @var string $hostname
+ */
+ private $hostname;
+
+ /**
+ * @param string $appprefix Application prefix to use, channel will be appended.
+ * @param string $host Syslog host
+ * @param int $port Syslog port
+ * @param int $facility Syslog message facility
+ * @param int $level The minimum logging level at which this handler
+ * will be triggered
+ * @param bool $bubble Whether the messages that are handled can bubble up
+ * the stack or not
+ */
+ public function __construct(
+ $appprefix,
+ $host,
+ $port = 514,
+ $facility = LOG_USER,
+ $level = Logger::DEBUG,
+ $bubble = true
+ ) {
+ parent::__construct( $host, $port, $facility, $level, $bubble );
+ $this->appprefix = $appprefix;
+ $this->hostname = php_uname( 'n' );
+ }
+
+ protected function syslogHeader( $severity, $app ) {
+ $pri = $severity + $this->facility;
+
+ // Goofy date format courtesy of RFC 3164 :(
+ // RFC 3164 actually specifies that the day of month should be space
+ // padded rather than unpadded but this seems to work with rsyslog and
+ // Logstash.
+ $timestamp = date( 'M j H:i:s' );
+
+ return "<{$pri}>{$timestamp} {$this->hostname} {$app}: ";
+ }
+
+ private function splitMessageIntoLines( $message ): array {
+ if ( is_array( $message ) ) {
+ $message = implode( "\n", $message );
+ }
+
+ return preg_split( '/$\R?^/m', (string)$message, -1, PREG_SPLIT_NO_EMPTY );
+ }
+
+ protected function write( array $record ) {
+ $lines = $this->splitMessageIntoLines( $record['formatted'] );
+ $header = $this->syslogHeader(
+ $this->logLevels[$record['level']],
+ $this->appprefix . $record['channel'] );
+
+ foreach ( $lines as $line ) {
+ $this->socket->write( $line, $header );
+ }
+ }
+}
public function tryAuthorizedSubmit() {
$result = false;
- $identOkay = false;
if ( $this->mFormIdentifier === null ) {
$identOkay = true;
} else {
// Check version
$version = $conn->getServerVersion();
- $status = static::meetsMinimumRequirement( $conn->getServerVersion() );
+ $status = static::meetsMinimumRequirement( $version );
if ( !$status->isOK() ) {
return $status;
}
$this->$var = $params[$var];
}
}
- $this->sqlMode = $params['sqlMode'] ?? '';
+ $this->sqlMode = $params['sqlMode'] ?? null;
$this->utf8Mode = !empty( $params['utf8Mode'] );
$this->insertSelectIsSafe = isset( $params['insertSelectIsSafe'] )
? (bool)$params['insertSelectIsSafe'] : null;
# # Watchlist #####################################
if ( $user->isAllowed( 'editmywatchlist' ) ) {
$editWatchlistLinks = '';
- $editWatchlistLinksOld = [];
$editWatchlistModes = [
'edit' => [ 'subpage' => false, 'flags' => [] ],
'raw' => [ 'subpage' => 'raw', 'flags' => [] ],
private function getLogoPreloadlinks() {
$logo = $this->getLogoData( $this->getConfig() );
- $tags = [];
$logosPerDppx = [];
$logos = [];
*/
public function getDefaultModules() {
$out = $this->getOutput();
- $config = $this->getConfig();
$user = $this->getUser();
// Modules declared in the $modules literal are loaded
* should fall back to the next notice in its sequence
*/
private function getCachedNotice( $name ) {
- $needParse = false;
$config = $this->getConfig();
if ( $name === 'default' ) {
$this->outputHeader();
$this->checkPermissions();
- $user = $this->getUser();
-
$out = $this->getOutput();
$out->setPageTitle( $this->msg( 'deletedcontributions-title' ) );
* the user to modify the tags applied to those items.
*/
protected function showForm() {
- $userAllowed = true;
-
$out = $this->getOutput();
// Messages: tags-edit-revision-selected, tags-edit-logentry-selected
$out->wrapWikiMsg( "<strong>$1</strong>", [
] );
} else {
$sourceView = '';
- $previewButton = '';
}
$buttonFields[] = new OOUI\ButtonInputWidget( [
$lang = $this->getLanguage();
$list = [];
- $user = User::newFromId( $row->user_id );
$ugms = self::getGroupMemberships( intval( $row->user_id ), $this->userGroupCache );
foreach ( $ugms as $ugm ) {
$lang = $this->getLanguage();
$comment = $lang->getDirMark() . Linker::revComment( $rev, false, true, false );
- $date = $lang->userTimeAndDate( $row->rev_timestamp, $user );
$d = ChangesList::revDateLink( $rev, $user, $lang, $page );
# Show user names for /newbies as there may be different users.
$newParent = $this->serializer->getParentNode( $parent );
$parent = $newParent;
$parentData = $parent->snData;
- $pElement = $parentData->childPElement;
$parentData->childPElement = null;
$newRef = $refElement->userData;
} elseif ( $under && $parentData->isSplittable
* @param array $options Configuration options
*/
public function __construct( Widget $relativeInput, array $options = [] ) {
- $config = \RequestContext::getMain()->getConfig();
-
parent::__construct( $options );
$this->required = $options['required'] ?? false;
*/
public function render( SearchResult $result, $terms, $position ) {
$title = $result->getTitle();
- $iwPrefix = $result->getTitle()->getInterwiki();
$titleSnippet = $result->getTitleSnippet();
$snippet = $result->getTextSnippet( $terms );