Commit graph

269 commits

Author SHA1 Message Date
jenkins-bot
b2f295eb6d Merge "DifferenceEngine: Autodetect if wikidiff2 is installed" 2016-07-06 21:17:40 +00:00
Matthew Flaschen
3354e8d550 Show parser output for diffs unless extension aborts
It was backwards.

Bug: T139433
Change-Id: Ie370da9d77e1d7608e2d5492f9d34094af233d0b
2016-07-05 20:08:32 -04:00
Kunal Mehta
037f056e0e DifferenceEngine: Autodetect if wikidiff2 is installed
If wikidiff2 is installed, use it for diffing without requiring
$wgExternalDiffEngine to be set to 'wikidiff2'.

Also add some extra sanity-checking by coercing all non-string values to
false and make sure the custom diff executable passes `is_executable()`.

Change-Id: I32b670ebf613be9f1c034d65d006829a215614da
2016-07-02 16:19:07 -07:00
Jack Phoenix
b02bfac06b Adding a bunch of hooks from wikiHow into DifferenceEngine
These hooks allow things such as:
* adding CSS(/JS) into the OutputPage when viewing diffs
* adding extra HTML content (such as avatars) into diff views
* hiding the bottom "mark as patrolled" link
* altering the parser output that is used by DifferenceEngine
* and more

Example extension using these hooks is wikiHow's
/extensions/wikihow/hooks/, specifically the file DiffHooks.php (but the
hooks are setup in WikihowHooks.php).

Live example of the DiffHooks stuff in action can be found at wikiHow.com,
for example:
http://www.wikihow.com/index.php?title=Set-Your-Homepage&diff=17112892&oldid=15888129
(user avatars, additional CSS, changes to the old/new revision header
texts/links)

Change-Id: Icbc987fa4806e7bfc66743375301912b428dc348
2016-06-21 22:19:03 +03:00
umherirrender
72632115d6 Fix various phpcs error from last security patches
Found by tests:
https://integration.wikimedia.org/ci/job/mediawiki-core-phpcs-trusty/1069/console

Breaking merges

Change-Id: If01b94705cd7b939ac380053730b1b602c838a8e
2016-05-20 20:20:36 +02:00
Max Semenik
9097fb54c5 Use pool counter for generating large diffs to prevent DoS.
Bug: T130947
Change-Id: If560844664051c04e01b954377b4bdfdb744d13f

Signed-off-by: Chad Horohoe <chadh@wikimedia.org>
2016-05-20 09:49:12 -07:00
Brian Wolff
17b3659995 SECURITY: Add data attribute to patrol links so it can't be spoofed by user
Javascript used to look just for the patrollinks class, which
could be set by the user in order to patrol an arbitrary page.

Bug: T103239
Change-Id: I13fcc3ce479c0a4a90a6217c2e5244f051eaf862

Signed-off-by: Chad Horohoe <chadh@wikimedia.org>
2016-05-20 09:25:35 -07:00
Max Semenik
e08cd0de84 Make wikidiff3 the only diff engine
In addition to much improved worst-case performance, it also has better
relevance.

Bug: T128896
Change-Id: I3b52c502d7cd5923c5a02942afbe75aba9016148
2016-04-26 13:09:44 -07:00
Reedy
982d210712 DifferenceEngine::setText() was removed
Bug: T122754
Change-Id: I796f0c4d86d0d5a8c2b24820dc84b18a7dc50981
Depends-On: Ia52054a85944f51adb8a644e703db02f6833b262
2016-04-02 10:22:23 +01:00
Reedy
b5656b6953 Many more function case mismatches
Change-Id: I5d3a5eb8adea1ecbf136415bb9fd7a162633ccca
2016-03-19 00:20:58 +00:00
jenkins-bot
c42f066420 Merge "Log slow diffs" 2016-03-18 00:52:59 +00:00
Max Semenik
7b18a62c0e Log slow diffs
Change-Id: Id17e116cd58d433bf6bb51c38096727a660135b9
2016-03-11 13:11:43 -08:00
umherirrender
8678e32b8d Change remaining places to use short array syntax
Change-Id: I0785c73a239c11188ad7411c5cd8ed09a2dbc9b3
2016-03-11 18:41:26 +01:00
Max Semenik
edf7889821 Convert timing to ms before we've recorded too much data
Change-Id: I0a4e18290cdc662e597484a94205a481415cbb7b
2016-03-10 15:03:48 -08:00
Max Semenik
f4ad20c1d4 Instrument diff timing
Bug: T128697
Change-Id: I748286abac025092abc33b3b7b8a0d3dabafdd25
2016-03-04 15:06:48 -08:00
Max Semenik
44ed77c07e Don't treat configured but absent engine as executable
E.g. if you have $wgExternalDiffEngine = 'wikidiff2' but after
a PHP update you no longer have the module you still shouldn't attempt
to shell out to some nonexistent wikidiff2.

Bug: T74030
Change-Id: I745cd1cb2e152f4fbb95c8f782d70117f8c844f1
2016-03-04 15:06:39 -08:00
Max Semenik
356aea3ab6 Ditch support for original wikidiff
It's been unmaintained for a while and does not support
various languages adequately.
Also, document $wgExternalDiffEngine.

Change-Id: Ia8aeffd79d550fb7a1a7121456940446eea8bd4f
2016-03-04 12:47:59 -08:00
Kunal Mehta
6e9b4f0e9c Convert all array() syntax to []
Per wikitech-l consensus:
 https://lists.wikimedia.org/pipermail/wikitech-l/2016-February/084821.html

Notes:
* Disabled CallTimePassByReference due to false positives (T127163)

Change-Id: I2c8ce713ce6600a0bb7bf67537c87044c7a45c4b
2016-02-17 01:33:00 -08:00
Aashaka Shah
124026a712 Add IContextSource as parameter to ChangeTags::formatSummaryRow
Using IContextSource avoids the use of $wgLang and wfMessage which make
use of global $wgTtle.

Add IContextSource as parameter to ChangeTags::formatSummaryRow to avoid
globals. Define an IContextSource instance in all functions which
reference ChangeTags::formatSummaryRow and pass it in ChangeTags::formatSummaryRow
function call.

Also make the default value of IContextSource $context as null in
parameter, to avoid breaking changes for old callers in extensions.

Document default null value of IContextSource and add a @note to prefer
IContextSource over null value.

Remove trailing whitespace, and make code order according to parameter
order.

Bug: T105648
Change-Id: Ib54a6a96b73f6cd8fcdf8e520db2448a1e811cfa
2016-02-04 23:32:24 +05:30
Chad Horohoe
3f7ecb4027 WebRequest::appendQuery*() functions no longer take $onlyquery
Deprecated since 1.25, unused anywhere

Change-Id: I52224635cfeaf4748abeaa07b0c92e7f452fa93f
2016-01-06 15:15:10 -08:00
Florian
d52fc330ff diff: Make DifferenceEngine patrol link creation more flexible
* Move the main logic from DifferenceEngine::markPatrolledLink() to
  DifferenceEngine::getMarkPatrolledLinkInfo(). Returning an array of
  information instead of a complete HTML string.

Bug: T101491
Change-Id: Id09ccf60aec9b693d7df648a6dfcde629545f620
2015-12-23 00:17:08 +00:00
Timo Tijhof
b1e3f9e38d Don't trigger 'wikipage.diff' hook for content that looks like a diff
Follows-up 9cfb9cb9fb, and b62f0e9156.

Add data-mw="interface" to elements created by the interface
(e.g. not user-generated content) and use this to narrow down
scope of elements eligible for JavaScript binding.

This avoids bugs where e.g. the diff hook triggers on a wiki page about diffs.
This isn't a security issue per-se, but causing odd behaviour.

Also add missing tests for data-ooui filtering (follows-up aa9a52da).

Change-Id: I9a0c86c92d411538bd9e203ec6ae54616fdf49b8
2015-12-15 16:29:58 -08:00
cenarium
68692ebb69 Add user and previous rev to HistoryRevisionTools, and user to DiffRevisionTools
The next revision in the page history isn't necessarily the previous
revision (due to selective undeletions, history merges, etc). This
passes the next revision to HistoryRevisionTools so extensions can check
if needed. Also, it passes the user to this hook and DiffRevisionTools
to avoid use of wgUser or having to retrieve context.

Change-Id: Ibc68f19040eebe3614e07f753f26bbfd376ae28d
2015-12-14 00:35:59 +00:00
Aaron Schulz
4f781c7bf9 Convert some users to WANObjectCache for consistency
These callers don't need to do purges, but can still perfectly
take advantage of this instance over a plain BagOStuff. Namely:
* Replication and snapshot lag awareness
* Preemptive regeneration
* Easy process cache support

The idea is for there to only be one caching class/factory
to use, instead of having rules for picking which one to use.

Change-Id: I8e362df451c0c28731fc853c044c4c4b8e097f01
2015-10-19 16:46:52 +00:00
Aaron Schulz
39ad19a671 Removed $options from RecentChange::newFromConds
* The FORCE INDEX statements are not needed

Change-Id: Ia6f386140e88ad01fc35a10b00dbcb0d1eb934ea
2015-09-29 10:31:55 -07:00
umherirrender
70f3afd548 Remove unneeded empty lines at begin of if/else/foreach body
An if body must not begin with an empty line

Change-Id: I62b058be337fcc85a120fcd3dadce564db59a271
2015-06-19 20:05:45 +02:00
Vivek Ghaisas
9f5b6f5aeb Fix whitespace issues around parentheses
Fix issues found by MediaWiki.WhiteSpace.SpaceyParenthesis sniff.

Bug: T102617
Change-Id: Iec7f71e64081659fba373ec20d9d2006306a98f4
2015-06-16 22:14:02 +03:00
Ori Livneh
b31e567b78 hierarchicalize(!) stat names
Graphite expects name components to be dot-separated, so our habit of using
dashes doesn't really make sense. Change metric names to be more compatible
with Graphite, except the job queue's, since that will require a gdash
dashboard definition migration.

Change-Id: I77d0ff7606a8fc88434e4352d23415a9a8f4725a
2015-06-03 16:27:13 -07:00
Ebrahim Byagowi
fd53351456 i18n: Apply lang on UI messages on diff table
Change-Id: Ib37e4f9115e935fa60b461c2fcc36047fe4c9dc6
2015-04-18 08:56:01 +00:00
Aaron Schulz
4d58457784 Added slave/master fallback logic in Revision
* This is a more specific form of the logic removed in 3c2bc32ae1.
  It does not suffer the problem of causing constant master DB
  queries due to a bad template reference or such.
* It will use the master if writes from the current thread
  are pending or were recently committed. This deals with the
  common problem of code that needs to read things it just wrote,
  such as diffs on rollback or edit hooks.
* This commit reverts 8624e261f by making the hack obsolete.

Bug: T93866
Bug: T94407
Change-Id: Ib9ecb75e1236e767bdc86d124d5e22a03ae0fb5f
2015-03-31 23:39:28 +00:00
Marius Hoch
8624e261f0 Fallback to read from master in DifferenceEngine::loadRevisionData
In DifferenceEngine we need to show a diff immediately after
an edit happened if someone did a rollback. To make that work
again, try loading a revision from master if we have more than
one database servers and we failed loading the revision from
a slave.

Change-Id: I08a16faa9e637c614c6d2fc9a10536c7b41685a8
Follows: 3c2bc32ae1
Bug: T93866
2015-03-25 16:09:21 +01:00
jenkins-bot
579d6e7555 Merge "Add anchor "mw-oldid" for beginning of page content in diff view" 2015-03-04 10:22:58 +00:00
Federico Leva
1bdfef2d26 Add anchor "mw-oldid" for beginning of page content in diff view
* #top, #mw-content-text and others exist, but all point to the
  beginning of the diff, not of the actual page content.
* Pick mw- prefix and technical but familiar related name, in
  the hope it's not confusing nor too hard to remember.
* Lowercase letters, similar to #top, #footer, #file etc. were also
  considered and discard, inspired to usual names:
  https://www.wikidata.org/wiki/Q10966628

Bug: T4313
Change-Id: Ia90f2541327480535e9943ac30bfa19791a19620
2015-03-04 10:09:36 +00:00
jenkins-bot
61b2f07f6b Merge "Add hook for custom difference engine (WikEdDiff)" 2015-02-23 12:32:10 +00:00
umherirrender
75e3d29506 Pass user to Title::quickUserCan in DifferenceEngine
Change-Id: I2e984a51b7ad357a08ed1827b76f7f9803785cfc
2015-01-29 16:46:28 +01:00
Ricordisamoa
4ece7f53aa Revision: mark getRaw*() methods as deprecated
Revision->getRawUser()
=> Revision->getUser( Revision::RAW )

   Revision->getRawUserText()
=> Revision->getUserText( Revision::RAW )

   Revision->getRawComment()
=> Revision->getComment( Revision::RAW )

The body of Revision->getRawUserText() has been moved
into Revision->getUserText().
Every usage has been replaced.

Change-Id: Ic6fbfbc0507dcf88072fcb2a2e2364ae1436dce7
2015-01-18 06:57:56 +01:00
Niklas Laxström
80ca508ed1 Add User::equals
Seems stupid omission. Title has one. Why do I need to think how
to determine how to users objects point to the same user. Allows
more expressive code.

Also fixes a bug in multiple places where users "0" and "00" were
considered equal.

Change-Id: I682392e564b332b77ab489f2ad394fa2d28098a5
2015-01-13 15:04:45 +01:00
Aaron Schulz
4ff8136807 Removed remaining profile calls
Change-Id: I31c81c78715048004fc8fca0f27d09c1fa71c118
2015-01-08 02:49:33 -08:00
Chad Horohoe
aa21e125a3 Remove obvious function-level profiling
Xhprof generates this data now. Custom profiling of various
sub-function units are kept.

Calls to profiler represented about 3% of page execution
time on Special:BlankPage (1.5% in/out); after this change
it's down to about 0.98% of page execution time.

Change-Id: Id9a1dc9d8f80bbd52e42226b724a1e1213d07af7
2015-01-07 11:14:24 -08:00
Niklas Laxström
4741900b5e Escape unescaped messages shown on a diff page
Change-Id: I05c07625a2dbb3c5d3ab46d1cfafeaed6a248bba
2014-12-18 20:01:32 +00:00
Aaron Schulz
e369f66d00 Replace wfRunHooks calls with direct Hooks::run calls
* This avoids the overhead of an extra function call

Change-Id: I8ee996f237fd111873ab51965bded3d91e61e4dd
2014-12-10 12:26:59 -08:00
cacycle@gerrit.wikimedia.org
ef55b2c7b5 Add hook for custom difference engine (WikEdDiff)
The new Extension:WikEdDiff is a custom inline difference engine.
There is currently no hook to integrate custom difference engines.
This patch adds a new hook called 'GetDifferenceEngine' in
/includes/content/ContentHandler.php in function
'createDifferenceEngine()'.

Passed variables:
$context: IContextSource context to be used for diff
$old: Revision ID to show and diff with
$new: Either a revision ID or one of the strings 'cur', 'prev' or 'next'
$refreshCache: If set, refreshes the diff cache
$unhide: If set, allow viewing deleted revs
&$differenceEngine: output parameter, difference engine object to be used
for diff

If the hook handler returns false, a valid difference engine object is
returned in the passed-by-reference variable $differenceEngine.
If the handler returns true, the default engine is used as fallback.

The specified diff engine class will typically be an extension of the
class DifferenceEngine (includes/diff/DifferenceEngine.php) with
modifications, e.g. of function generateTextDiffBody() and
__construct() (without deprecated parameter $rcid).

Also fixes a missing declaration in DifferenceEngine that is required for
extending this class.

Bug: 71916
Change-Id: I9da63c1ceb339bfeba7beddc712be51977b95f65
2014-11-13 18:02:29 +00:00
Ebrahim Byagowi
36372030d4 i18n: Use native digits on 'difference-missing-revision'
Change-Id: I19cd68562690c4ab8b077681d0f3d18d4286a5cd
2014-09-26 19:53:59 +00:00
Daniel Evans
6c2262319b add mw-diff-* classes to view diff page header links
Wrap links in page revision diff header with classes like page revision history
entry links.

Bug: 44242
Change-Id: I0066827bd57c2d40b4b8bd5634cb46c5ce306f28
2014-08-16 01:21:39 +01:00
umherirrender
3b2b6a2773 Add missing @param to function docs
Change-Id: I47fa96a976f55a1a93cb75397285edb8c7f4cd8a
2014-08-14 20:22:52 +02:00
umherirrender
02dc9da399 Cleanup some docs (includes/[a-d])
- Swap "$variable type" to "type $variable"
- Added missing types
- Fixed spacing inside docs
- Makes beginning of @param/@return/@var/@throws in capital
- Changed some types to match the more common spelling

Change-Id: I7b65fe04db431342cc58b469dc48f41a50c4e891
2014-07-24 19:42:45 +02:00
umherirrender
abfa0d7854 Standardize @todo
Always use lowercase @todo
Changed some "@FIXME" to "@todo FIXME: "

Change-Id: I016d1f9511e6f3bbd22427f0fffeccd77ab5e0db
2014-07-23 22:27:20 +02:00
Bartosz Dziewoński
108d4aa2ba Article: Add RL modules for the ParserOutput when showing CSS/JS page
It previously added only the page HTML, which meant that ResourceLoader
modules associated with the page and other metadata was lost. This
affected the new way of doing things in SyntaxHighlight (Idf4ad439).

We still do not show categories, language links and other things
on the pages (although internally they behave just like in wikitext)

Also needs a fix in DifferenceEngine because our code sucks so much.

Bug: 64859
Change-Id: I5867985693b27ccc9195fddde8b922e67463e836
2014-06-20 19:48:25 +00:00
Krinkle
811a6172b3 Merge "Removed unneeded spaces and colons in @param and friends" 2014-04-08 18:05:38 +00:00
umherirrender
725d9d125d Removed unneeded spaces and colons in @param and friends
Also swapped some "$var type" to "type $var" or added missing types
before the $var. Changed some other types to match the more common
spelling. Makes beginning of some text in captial.

Change-Id: Ic36c8c7820a6c2d603f1138130670c6bf6a1ca59
2014-04-08 16:02:49 +00:00