Commit graph

393 commits

Author SHA1 Message Date
Aaron Schulz
6e014bb753 Add ILoadBalancer interface
Remove redundant LoadBalancer docs (those without @since).

Change-Id: I981177b6854cfdbea4a51b6db7e365dac0da258a
2016-09-13 19:53:36 -07:00
Aaron Schulz
05589cad6b Move PECL memcached class to /libs
Remove IP class dependency, which is simple enough here

Change-Id: I3aed6ae6747d8d2b9e75b492e5d5293ba4ce9edd
2016-09-07 22:55:11 -07:00
Timo Tijhof
b2585a95b2 filecache: Remove unused ObjectFileCache class
This was originally intended for use by ResourceLoader but it was
incomplete and not actually used by ResourceLoader at first.

Then 93d358cd added support for FileCache to ResourceLoader with
a separate ResourceFileCache class.

Also fixed typo in HTMLFileCache from 6559b8bf.

ObjectFileCache is not mentioned anywhere else in Wikimedia Git.

Change-Id: I69cca27ee7cd922da12f1793660432709c273be6
2016-09-06 17:09:50 -07:00
jenkins-bot
a206443c0e Merge "Change "slave" => "replica DB" in /maintenance" 2016-09-06 01:05:50 +00:00
Aaron Schulz
c0a9ab0f6d Change "slave" => "replica DB" in /maintenance
Change-Id: Ibd3d617901130378a935402326cd4eefbb382c9e
2016-09-06 00:13:08 +00:00
Aaron Schulz
e99bb1b7dc objectcache: allow for callbacks to mask SYNC_WRITE latency
Change-Id: I908222ad3788ebe330aa58831cda139da32becd8
2016-09-01 13:44:18 -07:00
Aaron Schulz
9b81de7960 Move some DB error classes with the rest as type DBUnexpectedError
Change-Id: I97d61d32495e6d88ce274772369390c76d7ff3c4
2016-08-29 23:22:21 +00:00
Bartosz Dziewoński
3b84eb02c2 Implement NumericUppercaseCollation
This collation orders text with numbers "naturally", so that
'Foo 1' < 'Foo 2' < 'Foo 12'.

Note that this only works in terms of sequences of digits, and the
behavior for decimal fractions or pretty-formatted numbers may be
unexpected.

This is only expected to work mostly correctly for English-language
text. Consider it a proof of concept. You probably want to use
an UCA collation with '-u-kn' suffix rather than this.

Bug: T8948
Change-Id: Ie268f2d92c5c75d0aaecf54ede2bdda1af3b309d
2016-08-23 18:41:01 +00:00
Aaron Schulz
420efbfb61 Move EnqueueableDataUpdate to a separate file
Change-Id: Iabc291cd1f3c5390ca8bcc5da64a0ff01a082575
2016-08-22 21:20:49 -07:00
Aaron Schulz
f16eb73ecf Move invalidatePages() to new PurgeJobUtils class
This does not really belong in SqlDataUpdate.

Change-Id: I7166e50696483371f95db3a8b6bce44b0f866ccd
2016-08-23 01:09:08 +00:00
jenkins-bot
6a72a63e31 Merge "Split DBLockManager classes into their own files" 2016-08-22 17:37:34 +00:00
Bartosz Dziewoński
89107070d1 Support 'hide-if' parameters in OOUI HTMLForm
For plain HTML forms, we just put the required data in the 'data-hide-if'
attribute. For OOUI, it's not so easy - while we could just call
->setAttribute(...) on the FieldLayout, this would disappear when
infusing (since it's not part of the config), and we have no control over
when some piece of JavaScript decides to infuse the element. Even if we
managed to handle it first, infusing replaces the DOM nodes for elements
with new ones, which would "disable" our event handlers.

To solve this, I'm creating two new layouts HTMLFormFieldLayout and
HTMLFormActionFieldLayout (subclassing FieldLayout and ActionFieldLayout)
with a common trait (mixin) HTMLFormElement. This is all implemented both
in PHP and JS. Right now it only serves to carry the 'hide-if' data from
PHP to JS code, but I imagine it'll be extended in the future for other
HTMLForm features not yet present in the OOUI version (e.g. 'cloner'
fields).

The code in hide-if.js has been modified to work with jQuery objects or
with OOjs UI Widgets with minimal changes. I had to duplicate the map of
HTMLFormField classes to modules they require there (from autoinfuse.js),
which is ugly - I'm fixing this in a follow-up commit
I3da75706209cbc16b19cc3f02b355e58ca75fec9.

Bug: T141558
Change-Id: I3b06a6f75eed01d3e0bdc5dd33e1b40b7a2fc0a2
2016-08-22 15:42:22 +00:00
Aaron Schulz
7f3faf091f Split DBLockManager classes into their own files
Change-Id: If903a90a5be2d6ff11504d34eb125e86c1ab1191
2016-08-20 10:33:37 -07:00
jenkins-bot
4b70bc2b28 Merge "Extract ParserOutput search index data fields from WikiTextContentHandler" 2016-08-19 18:40:17 +00:00
aude
64ee3d3269 Extract ParserOutput search index data fields from WikiTextContentHandler
Bug: T142491
Change-Id: I69b010b893135e53fac7f16f4b927b8fbcba06d2
2016-08-19 09:26:17 -04:00
Tim Starling
535501ed62 Add a script to build an HHVM RepoAuthoritative bytecode file
This script compiles a list of known MW sources, including core and
extensions, and generates a RepoAuthoritative bytecode file. Some ideas
were taken from Bryan Davis's scap-hhvm-compile shell script.

Also, renamed the old maintenance/hiphop directory to maintenance/hhvm,
respecting the rename of the upstream project.

Change-Id: I55798729d0553d2840e8099e81d604a814e8664c
2016-08-16 13:32:19 +10:00
jenkins-bot
3cfcd55011 Merge "resourceloader: Move queue formatting out of OutputPage" 2016-08-11 14:09:58 +00:00
Gergő Tisza
854a462dc0 Remove $wgDisableAuthManager
Change-Id: I2b2c9693a275fcc026916bd97f303e7a5c8df341
2016-08-09 23:00:27 +00:00
Timo Tijhof
80e5b160e0 resourceloader: Move queue formatting out of OutputPage
HTML formatting of the queue was distributed over several OutputPage methods.
Each method demanding a snippet of HTML by calling makeResourceLoaderLink()
with a limited amount of information. As such, makeResourceLoaderLink() was
unable to provide the client with the proper state information.

Centralising it also allows it to better reduce duplication in HTML output
and maintain a more accurate state.

Problems fixed by centralising:

1. The 'user' module is special (due to per-user 'version' and 'user' params).
   It is manually requested via script-src. To avoid a separate (and wrong)
   request from something that requires it, we set state=loading directly.
   However, because the module is in the bottom, the old HTML formatter could
   only put state=loading in the bottom also. This sometimes caused a wrong
   request to be fired for modules=user if something in the top queue
   triggered a requirement for it.

2. Since a464d1d4 (T87871) we track states of page-style modules, with purpose
   of allowing dependencies on style modules without risking duplicate loading
   on pages where the styles are loaded already. This didn't work, because the
   state information about page-style modules is output near the stylesheet,
   which is after the script tag with mw.loader.load(). That runs first, and
   mw.loader would still make a duplicate request before it learns the state.

Changes:

* Document reasons for style/script tag order in getHeadHtml (per 09537e83).

* Pass $type from getModuleStyles() to getAllowedModules(). This wasn't needed
  before since a duplicate check in makeResourceLoaderLink() verified the
  origin a second time.

* Declare explicit position 'top' on 'user.options' and 'user.tokens' module.
  Previously, OutputPage hardcoded them in the top. The new formatter doesn't.

* Remove getHeadScripts().
* Remove getInlineHeadScripts().
* Remove getExternalHeadScripts().
* Remove buildCssLinks().
* Remove getScriptsForBottomQueue().

* Change where Skin::setupSkinUserCss() is called. This methods lets the skin
  add modules to the queue. Previously it was called from buildCssLinks(),
  via headElement(), via prepareQuickTemplate(), via OutputPage::output().
  It's now in OutputPage::output() directly (slightly earlier). This is needed
  because prepareQuickTemplate() calls bottomScripts() before headElement().
  And bottomScript() would lazy-initialise the queue and lock it before
  setupSkinUserCss() is called from headElement().
  This makes execution order more predictable instead of being dependent on
  the arbitrary order of data extraction in prepareQuickTemplate (which varies
  from one skin to another).

* Compute isUserModulePreview() and isKnownEmpty() for the 'user' module early
  on so. This avoids wrongful loading and fixes problem 1.

Effective changes in output:

* mw.loader.state() is now before mw.loader.load(). This fixes problem 2.
* mw.loader.state() now sets 'user.options' and 'user.tokens' to "loading".
* mw.loader.state() now sets 'user' (as "loading" or "ready"). Fixes problem 1.

* The <script async src> tag for 'startup' changed position (slightly).
  Previously it was after all inline scripts and stylesheets. It's still after
  all inline scripts and after most stylesheets, but before any user styles.
  Since the queue is now formatted outside OutputPage, it can't inject the
  meta-ResourceLoaderDynamicStyles tag and user-stylesheet hack in the middle
  of existing output. This shouldn't have any noticable impact.

Bug: T87871
Change-Id: I605b8cd1e1fc009b4662a0edbc54d09dd65ee1df
2016-08-08 12:23:09 -07:00
jenkins-bot
356b3420d6 Merge "Make content handlers assemble content for search" 2016-08-04 15:54:36 +00:00
jenkins-bot
c5f68ec77a Merge "Introduce MediaHandlerFactory to create MediaHandler objects" 2016-08-04 09:27:23 +00:00
Kunal Mehta
b4596edd00 Introduce MediaHandlerFactory to create MediaHandler objects
This will allow further refactoring of override logic in parser tests.

Ideally the factory class would not use $wgMediaHandlers directly, but
that ends up breaking too many tests for now.

Change-Id: I34a63ee7089ff26f86f3dd6f3cd1a37928bc4005
2016-08-03 16:47:41 -07:00
Timo Tijhof
ae762b1157 resourceloader: Separate 'user.styles' module from 'user'
Fixes addModuleStyles() violation from T92459 (a464d1d41).

Similar to 93ed259cf and Id2342454b for the 'site' module.
Doesn't need to be in separate commits since per-user HTML isn't
cached the same way.

Bug: T92459
Bug: T108590
Change-Id: I195f67d061de1306c97413aada7919e9f1b1d12c
2016-08-02 22:07:07 +00:00
Bartosz Dziewoński
15692fa6d4 Move HTMLFormField subclasses to a separate directory
It's getting more difficult to navigate the files in includes/htmlform/
with every new field and every new helper class that is being added.

Change-Id: I92ce2356baf6151f17b2440970d5abdf86503820
2016-08-01 07:58:56 +00:00
Stanislav Malyshev
add1ebe2ab Make content handlers assemble content for search
Bug: T89733
Change-Id: Ie45de496ecc826211d98eea3a410c7639b4be0a4
2016-07-26 13:08:45 -07:00
Aaron Schulz
94ab94bd2d Renamed MWCallableUpdate class file to match the class
Change-Id: Ia595cee94a696b83b00fe9f2a91b49bce51c08dd
2016-07-26 03:42:57 -07:00
jenkins-bot
dda1b39062 Merge "Make statsd counts for MWCallableUpdate actually useful" 2016-07-22 23:30:27 +00:00
Aaron Schulz
16ad2a779e Make statsd counts for MWCallableUpdate actually useful
Include the method that made the callback in the key.

Change-Id: Ifc7c486ee5c8d57b2516456569bb724cf7dc2b99
2016-07-21 23:52:09 -07:00
Tim Starling
b2f7bb4d76 Preprocessor_Hash: use child arrays instead of linked lists
The singly-linked list data structure of Preprocessor_Hash was causing
stack exhaustion due to the need for a recursion depth proportional to
the number of children of a given PPNode, in serialize() and on
object destruction. So, switch to array-based storage. PPNode_* becomes
a temporary proxy around the underlying storage, which avoids circular
references and keeps the storage very compact. Preprocessor_DOM uses
similar temporary PPNode objects, so the fact that

  $node->getFirstChild() !== $node->getFirstChild()

should not cause any new problems.

* Increment cache version
* Use JSON serialization of the store array instead of serialize(),
  since JSON is more compact, even after gzipping.
* For efficiency, make $accum a plain array, and use it as an array
  where possible, instead of using helper functions.

Performance and memory usage for typical input are slightly improved:
something like 4% faster for the whole parse, and 20% less memory for
the tree.

Bug: T73486
Change-Id: I0d6c162b790d6dc1ddb0352aba6e4753854f4c56
2016-07-22 05:25:11 +00:00
Ori Livneh
f181cdec56 Add option for sharing info about this MediaWiki install via pingback
When $wgPingback is true, MediaWiki will periodically ping
https://www.mediawiki.org/beacon with basic information about the local
MediaWiki installation.  This data includes, for example, the type of system,
PHP version, and chosen database backend.

The pingback is sent via a deferred (post-send) update whenever $wgVersion
changes, using the updatelog table to ensure we don't send duplicate pingbacks.
A database lock ensures only one thread attempts to send the pingback, and a
cache key throttles attempts to no more than once per hour.

$wgPingback is false by default. The web installer has a checkbox for
controlling this option, and it is checked by default. This nudges new installs
to turn on pingbacks, but does not sneak this decision past sysops of existing
installs.

Change-Id: Ie43a6b46a07ebd9ccc1b9c3001f2ea02435d826b
2016-07-21 21:00:28 +00:00
Aaron Schulz
3c21f0e8e5 Add AutoCommitUpdate class and replace some onTransactionIdle callers
* This puts the complex logic here after the commit step for
  all DBs, making the main multi-DB transaction more likely
  to be atomic.
* Made some cleanups to AtomicSectionUpdate and made it cancel
  if the transaction is rolled back as it should.
* Also cleaned up some closures for PHP 5.4.

Change-Id: If2f7bb6b1ba6daf1cfdc934f27c32b0b10431a3d
2016-07-21 05:24:28 +00:00
jenkins-bot
392ea68622 Merge "Only store currently-existing categories in the categories table" 2016-07-19 19:26:56 +00:00
James D. Forrester
22125d280d Follow-up 83ec590: Add new updateExtensionJsonSchema to autoload
Change-Id: Ibf61cf36c094ac192b6a7f9aa010659a12e5c5bb
2016-07-18 15:20:40 -07:00
Brion Vibber
3b5f60f2c8 Remove old Esperanto character conversion support
Deletes LanguageEo.php class which only had remains of the server-side
character conversion (sx <-> ŝ, etc). This is being obsoleted in favor
of client-side IMEs provided by UniversalLanguageSelector extension.

Removes deprecated $wgEditEncoding, which was only used for this.

Turns Language::recodeInput() and Language::recordForEdit() into no-ops
for any old or extension code that happened to still use them.

Bug: T62677
Change-Id: Ib647353538d258dee941f2f7c571191060bc9c7d
2016-07-18 19:20:49 +00:00
Brad Jorsch
47e2ef34b0 Only store currently-existing categories in the categories table
A "currently-existing category" is defined as a category that either
contains any pages or has a description page. Thus:
* Category::initialize() now schedules an update to insert a row if the
  title exits but the row is missing.
* Category::refreshCounts() now removes the row if the title doesn't
  exist and the category is empty.
* WikiPage::onArticleCreate() loads the Category object, to trigger
  bullet #1.
* WikiPage::updateCategoryCounts() refreshes the counts if it results in
  the row showing 0 pages, to trigger bullet #2.
* LinksDeletionUpdate refreshes the counts if the row shows 0 pages, to
  trigger bullet #2.

A maintenance script is provided to update the category table for this
new definition.

Bug: T28411
Bug: T50824
Change-Id: I0f0adf124c181ae5d3c7c95b3b5fb275a725794c
2016-07-18 12:52:19 -04:00
Ed Sanders
af7ffaeeec Rename 'slider' gallery mode to 'slideshow'
Bug: T140093
Change-Id: I6f01344b9ac61e3d2a8e7a9d920ba37786537ff8
2016-07-12 14:48:58 +01:00
Tim Starling
5726c9ceb0 Some Balancer improvements for performance and compatibility
* Use a doubly-linked list for the AFE list, instead of an array,
  allowing efficient insertion and removal from the middle, and trivial
  O(1) lookup of existing elements.
* Use a hashtable of singly-linked lists for storing Noah's Ark buckets,
  instead of iterating through the entire AFE list on every push.
* Store attributes in an array instead of serializing them in the
  tokenizer. This allows us to avoid sorting them in the output. For the
  Noah's Ark clause, the array is copied and then sorted on demand.
* XHTML-style serialization with self-closing tags.
* Clear the AFE list in stopParsing(), otherwise all the BalanceElement
  objects are kept alive until after serialization, thus using O(N^2)
  memory (in stack depth N) since the full serialization is stored at
  each stack level.

Change-Id: I517129c0658f03eb2ddee61fdf33ffe6fbd48509
2016-07-12 14:18:04 +10:00
C. Scott Ananian
ce081a3d7b Hook up Balancer as a Tidy implementation.
This is an HTML5-compliant parse/serialize tidy implementation, with
well-delineated hacks to support the <p>-wrapping done by legacy tidy.

Change-Id: I4fd433fd6f1847061b0bf4b3e249c918720d4fae
2016-07-12 14:18:04 +10:00
C. Scott Ananian
a7e2b5b284 HTML5 Balancer
This adds an implementation of the HTML5 Tree Builder algorithm to PHP,
along with test cases from the tree builder derived from the
html5lib-tests package on github.  The test cases were preprocessed
into JSON for the `domino` HTML5 parser, and we're using the JSON
form of the tests.

The implementation follows both the language of the HTML5 specification
and the implementation in `domino` very closely, easing updates if the
specification changes.

This code is used in follow-on commits to support an HTML5-based
"tidy" for mediawiki and the `{{#balance}}` parser function, which
ensures that a template expands to properly-balanced HTML, with all
tags closed and nothing left on the HTML active formatting elements
list.

See: https://github.com/fgnass/domino
Change-Id: I6f4d20a43510dd819776bb333b639315b19d150d
2016-07-12 14:18:04 +10:00
jenkins-bot
5f28abd840 Merge "ApiQuery: Don't mess with PHP output buffering" 2016-07-10 23:28:21 +00:00
Kevin Israel
293c4381a0 Run generateLocalAutoload.php
Follows-up ae0bae92af.

Change-Id: I5f7decd6a5279e941a7e1406dca77bbe37a1f3cb
2016-07-08 18:52:20 -04:00
Kevin Israel
81d5d8adc2 ApiQuery: Don't mess with PHP output buffering
Specifically, it is not necessary to use output buffering functions
to capture XML generated by the export code because it is already
possible to set the "output sink" object to be used.

* Created a DumpStringOutput class, which appends all output to a
  string property rather than printing output immediately.
* Used that class, instead of ob_start() and ob_get_clean(), in
  ApiQuery and ExportTest.

Change-Id: I238f5d5ec7fd442c845b25cb59ef81ac3285099f
2016-07-08 18:30:55 -04:00
jenkins-bot
fa40f8f145 Merge "Create API to allow content handlers to handle structured data definitions" 2016-07-07 16:56:09 +00:00
Prateek Saxena
e3aa36ddee Gallery: Add new slider mode
Bug: T128429
Change-Id: I14cac38cf1c66d9ba9584772a1cd3f345731b2af
2016-07-07 09:11:32 -07:00
Stanislav Malyshev
86b55ad03c Create API to allow content handlers to handle structured data definitions
Change-Id: Ia1738803c42f6114575587c1c838fec62b6f54aa
Bug: T89733
2016-07-06 13:41:20 -07:00
Stanislav Malyshev
7ade0a7c67 Create BagOStuff implementation to talk to RestBase
Or any other HTTP REST server.

Bug: T137272
Change-Id: Iefef24ffa831ba59d7725da8d20d5addb544b3ab
2016-07-06 17:52:07 +00:00
jenkins-bot
40ac7fd1b5 Merge "Add API module to receive CSP reports." 2016-06-29 15:26:23 +00:00
Gergő Tisza
5b674601ba Run maintenance/generateLocalAutoload.php
Change-Id: I0cf208b927d28a09a8603604fdfe0a6c1e9beb6b
2016-06-29 11:35:24 +00:00
Leszek Manicki
1a9460308e Refactor database-related code in ApiQueryWatchlist
This moves generating of a complex Watchlist and RecentChanges
related query to a WatchedItemQueryService class.
ApiQueryWatchlist class no longer contains any database-related
code.

Bug: T132565
Change-Id: I5a5cda13f8091baa430ac1a8e2176e0efd1ae192
2016-06-29 10:21:17 +02:00
Brian Wolff
ae0bae92af Add API module to receive CSP reports.
There are two expected usecases for this:
* The proposed builtin CSP support at I80f6f4
* Setting CSP headers on media served from upload.wikimedia.org

This was split from I80f6f46

For details on CSP, see http://www.w3.org/TR/CSP2/
See also https://www.mediawiki.org/wiki/Requests_for_comment/Content-Security-Policy

Related to (but not directly a fix for) T117618

Bug: T135963
Change-Id: Id92126ca7707186757e77fe50cd336ff1acb8b3f
2016-06-28 15:37:27 -04:00