Commit graph

178 commits

Author SHA1 Message Date
Brad Jorsch
77d62edef3 Refactor hashing utility functions from MWCryptRand and make public
MWCryptRand already has some useful utility functions wrapping PHP's
hash() and hash_hmac(). Let's make them public so we can use them from
other code.

But since "MWCryptRand" isn't really a good place for hashing functions,
let's move them to "MWCryptHash" instead.

Change-Id: I7542c719ac72beba7b0f6aa170bdb4c69fa6beab
2015-10-01 01:18:23 +00:00
jenkins-bot
2cb893c085 Merge "Introduce CategoryMembershipChange" 2015-09-30 12:44:37 +00:00
Aaron Schulz
c0cb80beac Added DeleteLinksJob to support purging backlinks via job runners
* This jobs should only be constructed via relevant Content object,
  e.g. the result of enqueueUpdate() being called on a DataUpdate
  returned by Content::getSecondaryUpdates().
* Also modified LinksDeletionUpdate to support a $pageId parameter.
* LinksDeletionUpdate can now be enqueued to a DeleteLinksJob.

Change-Id: I650dcf0bd172ede0d61357ec158a4704ae1f2033
2015-09-29 17:40:19 -07:00
addshore
2fb2a3f14b Introduce CategoryMembershipChange
This is split from:
I03516bb34144d95e5f25c46ae98ab70ce699b31b

Change-Id: I27539d25ef3e81cf991657dffc0a62b9719d21d8
2015-09-29 23:59:34 +01:00
Kunal Mehta
9a3c7b43ea Move FileContentsHasher into includes/utils/
The class only contains two dependencies upon MediaWiki (ObjectCache &
wfGlobalCacheKey) which are suitable for inclusion in the utils
directory.

Change-Id: I85b4c763be2670c40f26d93e75cedcb68eaa7987
2015-09-24 18:27:28 -07:00
jenkins-bot
827e10dc40 Merge "Use wikimedia/cldr-plural-rule-parser" 2015-09-24 23:15:56 +00:00
Aaron Schulz
9f01cee8fa Moved all load balancer classes to /loadbalancer
* Also split out LBFactory classes to their own files

Change-Id: I9e649878afcffdb736c09c0574e5f99b1e72382f
2015-09-24 22:56:05 +00:00
Niklas Laxström
4a3fd2e42a Use wikimedia/cldr-plural-rule-parser
Replaces the parser included in MediaWiki with same code in
a library.

Change-Id: I1d2675466a543269e17faf213aa68d2b7afaf78e
2015-09-24 21:41:50 +02:00
jenkins-bot
173493f0ce Merge "resourceloader: Improve caching for LESS file compilation" 2015-09-24 00:44:39 +00:00
Ori Livneh
12afb3607d resourceloader: Improve caching for LESS file compilation
Caching the output of a LESS compiler is tricky, because a LESS file may
include additional LESS files via @imports, in which case the cache needs
to vary as the contents of those files vary (and not just the contents of
the primary LESS file).

To solve this, we first introduce a utility class, FileContentsHasher. This
class is essentially a smart version of md5_file() -- given one or more file
names, it computes a hash digest of their contents. It tries to avoid
re-reading files by caching the hash digest in APC and re-using it as long as
the files' mtimes have not changed. This is the same approach I used in
I5ceb8537c.

Next, we use this class in ResourceLoaderFileModule in the following way:
whenever we compile a LESS file, we cache the result as an associative array
with the following keys:

* `files` : the list of files whose contents influenced the compiled CSS.
* `hash`  : a hash digest of the combined contents of those files.
* `css`   : the CSS output of the compiler itself.

Before using a cached value, we verify that it is still current by asking
FileContentHasher for a hash of the combined contents of all referenced files,
and we compare that against the value of the `hash` key of the cached entry.

Bug: T112035
Change-Id: I1ff61153ddb95ed17e543bd4af7dd13fa3352861
2015-09-24 00:34:17 +00:00
Aaron Schulz
25a44aa3e4 Added support for enqueueable DataUpdates
* Updates can now declare themselves as having enqueueUpdate()
  as an alternative to doUpdate(). This lets more expensive
  or slave lag producing updates use the job queue if desired.
* Added a $mode flag to DataUpdate::runUpdates() to prefer
  pushing jobs over calling doUpdate().
* Made page deletions defer deletion updates when possible.

Bug: T95501
Change-Id: Ic6f50f92768089ba0fbc223b8d178f5a91512959
2015-09-23 12:07:41 -07:00
Aaron Schulz
918fed0ab5 Moved LinksDeletionUpdate to a separate file
* Also removed unused updateCategoryCounts() method

Change-Id: I25f64d3771a23d18e7993433dab449adec375d9b
2015-09-22 11:07:47 -07:00
jenkins-bot
35f61c7c4b Merge "registration: Allow extensions to specify which MW core versions they require" 2015-09-22 04:57:47 +00:00
Erik Bernhardson
f66559b616 Produce monolog messages through kafka+avro
This allows a logging channel to be configured to write
directly to kafka. Logs can be serialized either to json
blobs or the more compact apache avro format.

The Kafka handler for monolog needs a list of one of more
kafka servers to query cluster metadata from. This should be
able to use any monolog formatter, although some like
JsonFormatter require you to disable formatBatch as Kafka
protocol would prefer to encode each record independently in
the protocol.  This requires the nmred/kafka-php library,
version >= 1.3.0.

Adds a new formatter which serializes to the apache avro
format. This is a compact binary format which uses pre-
defined schemas. This initial implementation is very simple
and takes the plain schemas as a constructor argument.

Adds a new option to MonologSpi to wrap handlers in a
BufferHandler. This doesn't flush until the request shuts
down and prevents any network requests in the logger from
adding latency to web requests.

Related mediawiki/vendor update: Ibfe4bd2036ae8e998e2973f07bd9a6f057691578

The necessary config is something like:

array(
    'loggers' => array(
        'CirrusSearchRequests' => array(
            'handlers' => array( 'kafka' ),
        ),
    ),
    'handlers' => array(
        'kafka' => array(
            'factory' => '\\MediaWiki\\Logger\\Monolog\\KafkaHandler::factory',
            'args' => array( 'localhost:9092' ),
            'formatter' => 'avro',
            'buffer' => true,
        ),
    ),
    'formatters' => array(
        'avro' => array(
            'class' => '\\MediaWiki\\Logger\\Monolog\\AvroFormatter',
            'args' => array(
                array(
                    'CirrusSearchRequests' => array(
                        'type' => 'record',
                        'name' => 'CirrusSearchRequests'
                        'fields' => array( ... )
                    ),
                ),
            ),
        ),
    ),
)

Bug: T106256
Change-Id: I6ee744b3e5306af0bed70811b558a543eed22840
2015-09-21 12:45:23 -07:00
Kunal Mehta
cef1f31167 registration: Allow extensions to specify which MW core versions they require
This adds a "requires" property to extension.json, which extensions and
skins can use to indicate which versions of MediaWiki core they support.
The hacky wfUseMW() is now deprecated in favor of this.

Rather than writing our own version constraint and parser library, we
can re-use composer's, which was recently split out into a separate
library named "composer/semver" for this patch.

Any syntax accepted by composer[1] is available for usage here. Test
cases have been provided to demonstrate how versions are parsed. For now
it is recommended that people stick to expressing compatability with
stable versions (e.g. ">= 1.26").

This patch does not support requiring specific MediaWiki core WMF
branches, since those do not follow the standard semver format that
composer parses. If we are unable to parse $wgVersion, all checking will
be skipped and reported as compatible.

[1] https://getcomposer.org/doc/01-basic-usage.md#package-versions

Bug: T99084
Change-Id: I7785827216e16c596356d0ae42d6b30f3f179f10
2015-09-21 09:56:53 -07:00
jenkins-bot
f8659ae6ea Merge "SpecialMovepage: Convert form to use OOUI controls" 2015-09-15 22:40:01 +00:00
Tim Starling
e9d523b9bd Add Html5Depurate tidy driver
Also document input format for MWTidy::tidy().

Change-Id: I77071d3db0524695c2baf9a4670ca2455438c83d
2015-09-11 03:32:32 +00:00
Tim Starling
2c6c954e23 Abstract and refactor Tidy support
* Split tidy implementations into a class hierarchy
* Bring all tidy configuration into a single associative array and
  deprecate the old configuration.
* Remove $wgAlwaysUseTidy

This is preparatory to replacement of Tidy (T89331). I used the name
"Raggett" for things relating to Dave Raggett's Tidy, since if we use
"tidy" to mean the new abstract system as well as Raggett's tidy, it
gets confusing.

Change-Id: I77af1a16cbbb47fc226d05fb9aad56c58e8910b5
2015-09-10 20:18:52 -07:00
Bartosz Dziewoński
5befb9b747 SpecialMovepage: Convert form to use OOUI controls
Recreated the form with OOUI widgets. This required putting together
ComplexTitleInputWidget to handle the split namespace+title field on
this page.

Bug: T86865
Change-Id: Ice69df851137e3454ae2c9f4c75494b18cf8a75a
2015-09-01 21:03:38 +02:00
Ori Livneh
e8c17972dd Replace bundled IPSet library with composer dependency
Complete the 'librarization' of IPSet by replacing the code in core with a
dependency on the external library.

Change-Id: I789b4fb42ee1da44ea3d8e1db551b047e11a439e
2015-08-26 10:38:09 -07:00
Bartosz Dziewoński
2f30ff7a86 Introduce mediawiki.ForeignApi
mw.ForeignApi is an extension of mw.Api, automatically handling
everything required to communicate with another MediaWiki wiki via
cross-origin requests (CORS).

Authentication-related MediaWiki extensions may extend it further to
ensure that the user authenticated on the current wiki will be
automatically authenticated on the foreign one. A CentralAuth
implementation is provided in I0fd05ef8b9c9db0fdb59c6cb248f364259f80456.

Bug: T66636
Change-Id: Ic20b9682d28633baa87d22e6e9fb71ce507da58d
2015-08-21 17:00:01 +00:00
jenkins-bot
2766e4714c Merge "Refactor NamespaceInputWidget" 2015-08-21 15:32:59 +00:00
CSteipp
e412ff5ecc Revert "Enable users to watch category membership changes"
This reverts commit f6879ea16e.

Bug: T109638
Change-Id: I770d8d33a4cff3829bdea9a4df24de209cbe691b
2015-08-20 10:35:56 -07:00
Bartosz Dziewoński
b6046dff66 Refactor NamespaceInputWidget
* Refactor NamespaceInputWidget into two widgets: NamespaceInputWidget
  and ComplexNamespaceInputWidget. The former is now only the dropdown
  (and inherits from DropdownInputWidget), the latter is the dropdown
  plus two checkboxes.
* Change ComplexNamespaceInputWidget configuration to take nested config
  for `invert`, `associated`, and `namespace`, rather than require
  parameters like `invertName` and so on for every combination.
* Implement standalone JavaScript versions of both widgets (previously
  mw.widgets.NamespaceInputWidget could only be created via infusion
  of the PHP widget).

Bug: T99256
Bug: T106138
Bug: T109559
Change-Id: Ie2fee6d035339ceb934fca991675480db3d630d1
2015-08-20 15:10:51 +00:00
Kevin Israel
a7cb317188 Remove maintenance script fixSlaveDesync.php
Though this script was run on Wikimedia sites years ago (see T8399), there
are enough reasons to doubt it will be run again:

* There is a hardcoded maximum page_id value, which would have to be
  changed or removed before reuse.
* It scans the entire page table in a single SELECT query and stores all
  values of page_id and page_latest in a PHP array, which might not be
  feasible on a large wiki.
* It writes directly to slaves. In contrast, the manual page for
  pt-table-sync (from Percona Toolkit) says in general, "[...] it always
  makes the changes on the replication master, never the replication slave
  directly. This is in general the only safe way to bring a replica back
  in sync [...]".
* It only works on the page/revision/text tables. In contrast, pt-table-sync
  can work on any table having a primary key.
* It does try to detect whether revisions are missing on the master (instead
  of on the slave). However, this won't work because of a bug introduced in
  r91243 / bb1df74f87 (it actually queries the master twice and puts the
  second result set in $slaveIDs).

Change-Id: I85c98821af308abf7dde8068d7cbca17d06b1362
2015-08-19 06:33:53 -04:00
jenkins-bot
f6b7ffab94 Merge "Migrate move protect log to new log system" 2015-08-18 23:17:03 +00:00
umherirrender
3964b4cc05 Migrate move protect log to new log system
Migrate the move protect log as first sub type of the protection log,
because it does not have complex log parameter, which needs some way of
handling/migration.
It also keeps the gerrit change smaller and hopefully makes review
easier.
The other sub types of the protection log will be migrated in a later
patch set.

This allows use of gender on Special:Log. Old message is kept for use
in IRC. A test was added to ensure an unchanged IRC message.

Bug: T47988
Change-Id: I57b3bd8a7dc823acdbb56520d2364f5542283373
2015-08-18 22:20:35 +00:00
jenkins-bot
0ea03a7f56 Merge "Enable users to watch category membership changes" 2015-08-14 06:58:48 +00:00
jenkins-bot
811e45ae56 Merge "Import BatchRowUpdate classes from Echo" 2015-08-14 01:38:50 +00:00
Erik Bernhardson
85d5626d6c Import BatchRowUpdate classes from Echo
This is a set of classes written for Echo to simplify writing
maintenance scripts that iterate over an entire table and update
some of those rows.

This has shown to be reusable elsewhere, especially the BatchRowIterator
class and will be useful to have generally avilable in core. The Echo
classes are all prefixed with the Echo name so there wont be any
conflict is both are installed.

Change-Id: I64c1751106caf34f41af799dbaf8794115537f06
2015-08-13 21:28:13 -04:00
Kai_WMDE
f6879ea16e Enable users to watch category membership changes
Bug: T9148
Change-Id: I5a89d8f19804b1120f4c755d834e2da6ca12ceae
2015-08-13 17:58:06 +02:00
Aaron Schulz
0086965fd0 Removed ScopedPHPTimeout; unused
Change-Id: Ic3a3500ddd410c68a30d3f3d1947f632e1aff5fd
2015-08-10 11:29:11 -07:00
jenkins-bot
d2278d1c2a Merge "Added DBAccessObjectUtils class to avoid duplication" 2015-08-03 23:26:15 +00:00
Gergő Tisza
e56f7b6c63 Sample StatsD messages when instructed
Bug: T106457
Change-Id: I8ddb5a53dcbaf398f5a114d2a4a862842e980db4
2015-08-03 22:09:18 +00:00
Kunal Mehta
f318d7a04b Add base interface for setters in RequestContext and DerivativeContext
Change-Id: I819633ca5344f73a196623569bb58fd8372d6779
2015-08-03 11:55:41 +00:00
jenkins-bot
78721711d7 Merge "Monolog: Add Formatter that uses MWExceptionHandler::getRedactedTraceAsString" 2015-07-31 19:52:02 +00:00
Bryan Davis
27dcc9f051 Monolog: Add Formatter that uses MWExceptionHandler::getRedactedTraceAsString
Add a Monolog Formatter class that uses
MWExceptionHandler::getRedactedTraceAsString when outputting stack
traces.

Bug: T107440
Change-Id: Ic580c137e27aac95435f7b073a18cf61820b172f
2015-07-31 13:02:39 -06:00
Legoktm
8fd9634774 Revert "Use OOUI HTMLForm for Special:Watchlist"
Issues with spacing (T107311), probably shouldn't have
been merged right before the branch cut.

This reverts commit 9508c5bd57.

Change-Id: Ibf2ca5a33b8ab0f7381c720c6c92fbfd7a7c819d
2015-07-30 18:55:20 +00:00
Florian
9508c5bd57 Use OOUI HTMLForm for Special:Watchlist
Bug: T99256
Change-Id: I47a8649208279a4090623a3088112fcff9abc4d3
2015-07-27 20:15:15 +00:00
Aaron Schulz
f1e1313a16 Support for storing files under SHA-1 names
* Added a "storageLayout" flag to LocalRepo config (supports "sha1")
* Added a simple migration script to copy files the SHA1 paths
* Currently works with img_auth.php + thumb_handler.php for URLs
* Added visibility to some LocalFile methods
* Simple tests for the wrapper class.

Co-Authored-By: Gilles Dubuc <gdubuc@wikimedia.org>
Change-Id: Iad46ad669c8ae3c02d10da10c3f7a16fe161663f
Bug: T1210
2015-07-21 16:19:22 +02:00
Florian
c226b13545 Implement UserInputWidget in OOUI/MW Widgets
To use OOUI for forms with user name autocomplete, the new widget
UserInputWidget interacts like the jQuery pendant (working with css
class "mw-autocomplete-user").

It is also available in HTMLForm as "user".

Example usage: Iaeff912e6437d6ebef0d5b1919ce8cf53a7fd5f1

Change-Id: I9501c85f4288c255bbe3a5284e99b57b6169916f
2015-07-20 06:11:16 +02:00
Bartosz Dziewoński
2ac9e2a432 Implement NamespaceInputWidget
* Add PHP version of NamespaceInputWidget, co-authored by Florian,
  which consists of a DropdownInputWidget offering a choice of
  namespaces and two CheckboxInputWidgets allowing to also match
  associated namespace (talk/content) or to invert the choice.
* Add an incomplete JS version of NamespaceInputWidget, which is only
  really functional when infused from the PHP version (it can't
  generate the dropdown by itself, for example). Implement some JS to
  improve the experience of selecting the "all namespaces" option in
  the dropdown (by disabling the checkboxes when this happens).
* Split off a 'mediawiki.widgets.styles' module, which has the basic
  styles for PHP widgets which are to be loaded in the head. Make
  OutputPage::enableOOUI() also add this module (which should stay
  reasonably small).
* Use the new widget in HTMLForm's HTMLSelectNamespace field. It can
  be seen in action on Special:LinkSearch, for example.

Co-Authored-By: Florian <florian.schmidt.welzow@t-online.de>
Co-Authored-By: Bartosz Dziewoński <matma.rex@gmail.com>
Change-Id: I5cbfa9d0f6a8641148ce476b7dbe65e9096b4485
2015-07-17 13:33:59 +00:00
jenkins-bot
77594dc2ba Merge "HTMLForm: Add 'title' type" 2015-07-16 18:33:13 +00:00
Aaron Schulz
528334e3a1 Moved LoadMonitorMySQL to a separate file
Change-Id: I529402416b8f12a511300b007b4f4aaf79054ad7
2015-07-14 18:32:18 -07:00
Aaron Schulz
704583440e Added DBAccessObjectUtils class to avoid duplication
* WikiPage is the first caller to use this instead of DIY
* This can be used elsewhere to keep callers uniform

Change-Id: Ia6371eaa185d70d1431271b2c6c955523cd424e8
2015-07-14 19:53:09 +00:00
Kunal Mehta
d7d663bc54 HTMLForm: Add 'title' type
HTMLTitleTextField will automatically validate title input, can
optionally ensure the title is in a specific namespace, is creatable, or
already exists.

The field currently doesn't support GET requests since validation on
empty strings fails.

Bug: T104420
Change-Id: I45718462570d0a523a148c3830b1116b634df050
2015-07-09 15:44:09 +00:00
Aaron Schulz
6e283d394f Formally defined IDatabase and made a few Database methods protected
* IDEs can now make sense of IDatabase, which is useful for
  lazy connections. The interface might also help lower coupling.
* This also updates DBConnRef, which implements IDatabase
* Some discouraged methods are left out of IDatabase.
  These methods either encourage manual query building,
  are only needed by the updater, are obscure/unused,
  or either wise encourage bad practice. DBConnRef still
  supports these if called to avoid breakage though.

Change-Id: Ia83530820f185415725c1d5f54b5172121b4938f
2015-07-02 12:26:30 -07:00
Max Semenik
b1876e3dd7 API: Remove WDDX and dump formats
Per RFC: https://www.mediawiki.org/wiki/Requests_for_comment/Ditch_crappy_API_formats

Change-Id: I4c9e64875be509906021255d70b90688f2e5ddf3
2015-07-01 11:43:39 -04:00
Kunal Mehta
fa31bf1675 Add Special:ChangeContentModel
Special:ChangeContentModel allows for users with the 'editcontentmodel'
right to change the content model of a page.

Visiting Special:ChangeContentModel will contain an input field for a
page title. The user will then be sent to
Special:ChangeContentModel?pagetitle=<input> where the page title is
read only, with a content model selector and optional reason field.

The special page only allows converting between content models that
extend TextContent for simplicity. Advanced conversions should be done
via the API.

All content model changes via the special page or API generate a null
revision in the page history and a log entry at
Special:Log/contentmodel. The log entry has a revert link for
convenience (like the move log).

Bug: T72592
Co-Authored-By: Lewis Cawte <lewis@lewiscawte.me>
Change-Id: I296a67c09fcbc880c8c3a648eb5086580725ea46
2015-06-30 13:14:50 -07:00
Roan Kattouw
85e7751452 Add a PHP implementation of TitleInputWidget
From the PHP side it's really just an infusable TextInputWidget.

Change-Id: I607339c2e967e502f85164c9b1ea79dc0a17c9cc
2015-06-30 00:03:27 +00:00