Commit graph

415 commits

Author SHA1 Message Date
Jack Phoenix
c40fbea783 Make DifferenceEngine's markPatrolledLink and getRevisionHeader public so that hooked functions can use them where needed
The said hooks were added to core in
https://gerrit.wikimedia.org/r/#/c/298026/ . One of the many intended use
cases is https://gerrit.wikimedia.org/r/#/c/326074/ which currently fatals
due to these two being protected, and obviously we don't want to lose
functionality when hooking into one (or more) of the aforementioned hooks.

Change-Id: I260c8b57c0bb2af3a6982bd7142b112a4a023391
Depends-On: I02de9069854532faec4c0c1798a10f862e6dfd7c
2016-12-14 22:19:53 +00:00
Jack Phoenix
04736acd44 A few more hooks in DifferenceEngine
For mucking with the class member variable mNewContent and optionally
allowing the suppression of the "missing revision" message when revision
data is not found for a requested revision.

Originally implemented as the "GetUserMessagesDiffCurrent" hook (yes,
these three separate hooks in three separate places were essentially the
same) by Wikia for their SiteWideMessages extension.

Change-Id: Ie0c175af2af418d4ed3de28c94df918115312da3
2016-12-14 21:31:06 +00:00
Reedy
2c74b04356 ArticleViewCustom, EditPageGetDiffText and ShowRawCssJs were removed
Bug: T145728
Change-Id: Iddf29005abbaceaa1e3cc2c79e4becfb46294414
2016-12-03 12:27:07 +00:00
jenkins-bot
63ab00b60d Merge "Convert action=markpatrolled fallback interface to HTTP POST" 2016-11-08 17:43:25 +00:00
umherirrender
34fe90ac52 Remove empty lines at end of functions
It looks like there is something missing after the last statement
Also remove some other empty lines at begin of functions, ifs or loops
while at these files

Change-Id: Ib00b5cfd31ca4dcd0c32ce33754d3c80bae70641
2016-11-05 11:55:10 +01:00
Timo Tijhof
4ff510e4a7 Convert action=markpatrolled fallback interface to HTTP POST
The main interface already has javascript enhancement to use
the API and mw.notify. This patch affects permalinks without
tokens, and opening the link without javascript.

This will match the current behaviour of action=watch.

Bug: T130946
Change-Id: I6be2c07824c17b165e068fc4ac36ab192e12bc9d
2016-11-04 23:57:26 +00:00
Yuri Astrakhan
02015d0e63 Document diff/DifferenceEngine.php function
Change-Id: I999824d8ce569de93fe4c9a889edea582d07611c
2016-10-30 20:26:08 -04:00
Kunal Mehta
a7de5b0b7c Improve deprecation comment for MW_DIFF_VERSION
IDEs will now recognize it as deprecated.

Change-Id: Iac96449fb204a1e4b1e707138b3f0b5697bdfab4
2016-10-15 05:57:36 +00:00
Reedy
8a29a56fb1 Make ShowRawCssJs hook emit deprecated warnings
Bug: T147392
Change-Id: Iae3b1532a91a9bf545a0a3c8df1df5e59b4974db
2016-10-06 14:44:57 +01:00
Reedy
dee0d1ce4e Mark 3 hooks deprecated by ContentHandler as such
ArticleViewCustom, EditPageGetDiffText and EditPageGetPreviewText hooks
now marked as deprecated in 1.21.

TitleIsCssOrJsPage and TitleIsWikitextPage deprecation version dropped
from 1.25 to 1.21 to match other hooks.

Bug: T145728
Bug: T147382
Bug: T147383
Bug: T147384
Bug: T147385
Bug: T147386
Change-Id: I59b6b9f253857eb1040dad879a71e0d8cf141553
2016-10-05 23:41:14 +00:00
jenkins-bot
7e350ba150 Merge "Rename mediawiki.action.history.diff to mediawiki.diff.styles" 2016-09-06 15:56:17 +00:00
Leszek Manicki
a6b402c1c3 Rename mediawiki.action.history.diff to mediawiki.diff.styles
Diff is not shown on action=history, so the name was not valid.
This module contains only styles, so let's make it explicit in its name too.

mediawiki.action.history.diff module is temporarily left for
backwards compatibility. It should be removed when no longer used.

This also renames docs/uidesign/mediawiki.action.history.diff.html
to docs/uidesign/mediawiki.diff.html.

Change-Id: I7ecc08417c5f1870ed6f2ca139fd953d68f6ec8e
2016-09-06 11:11:33 +02:00
Aaron Schulz
950cf6016c Rename DB_SLAVE constant to DB_REPLICA
This is more consistent with LoadBalancer, modern, and inclusive
of master/master mysql, NDB cluster, and MariaDB galera cluster.

The old constant is an alias now.

Change-Id: I0b37299ecb439cc446ffbe8c341365d1eef45849
2016-09-05 22:55:53 -07:00
jenkins-bot
501d34c599 Merge "Revert "Move CSS for patrol from mediawiki.legacy to new module mediawiki.page.patrol"" 2016-08-11 23:05:06 +00:00
Bartosz Dziewoński
7cea81b8ff Revert "Move CSS for patrol from mediawiki.legacy to new module mediawiki.page.patrol"
This reverts commit e9f896d6a5.

Bug: T142750
Change-Id: Idb815d64d795d790ea2c07f2b5188ea5a46bfefb
2016-08-11 22:54:54 +00:00
jenkins-bot
3e9d53bfad Merge "Adding a bunch of hooks from wikiHow into DifferenceEngine, 2nd try" 2016-08-08 16:30:59 +00:00
Fomafix
e9f896d6a5 Move CSS for patrol from mediawiki.legacy to new module mediawiki.page.patrol
Also change the selector from
	div.patrollink
to
	.patrollink

Bug: T89981
Change-Id: Ib79d17fab61b1a7b940b2acff6d19a58a3fe0bc9
2016-08-06 13:46:47 +00:00
Florian
c35d1ce205 Remove DifferenceEngine::generateDiffBody()
Bug: T122754
Change-Id: Iedd319fa5e7b7218ee5341f18f31a8f1101b5eee
2016-08-01 00:37:25 +02:00
Reedy
58ea3e0902 MW_DIFF_VERSION is globally defined, drop MW_ prefix when used as
the class constant

Bug: T141272
Change-Id: I0a9e9037b2259515df6366184cc781ecb78f424c
2016-07-25 17:36:35 +01:00
Chad Horohoe
e0d2d91ef8 DifferenceEngine: Move MW_DIFF_VERSION to class constant DIFF_VERSION
Deprecated the former. It's only used in 2 extensions (both active),
so we can probably get rid of this within a single release cycle.

Change-Id: I39bef62556f8f0625a5741d54f9f84d15b50610d
2016-07-22 17:38:43 +00:00
Seb35
ff397feea8 Handle the default value of $wgExternalDiffEngine without warning
The default value (false) was not handled by the recent depreciation warnings
in 037f056, and was triggering the last warning. This removes this warning.

Change-Id: If7fe92d874eb10525a72f6d3a97f00117c79acc1
2016-07-09 10:07:49 +02:00
Jack Phoenix
03dfe2c3be Adding a bunch of hooks from wikiHow into DifferenceEngine, 2nd try
Now with less fatals and more functionality! At least I sure hope so.

Unlike the first time around (https://gerrit.wikimedia.org/r/206642), the
DifferenceEngineRenderRevisionAddParserOutput and
DifferenceEngineShowEmptyOldContent hooks now only affect things if a
hooked function returns false. Since by default nothing is hooked into
these brand new hooks, the behavior should stay exactly the same as before
this patch and things like bug T139435 shouldn't happen anymore.

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)

Bug: T139526
Change-Id: I10293be4581140c3edf0e4b538b04b31cb6f5730
2016-07-08 19:46:20 +03:00
jenkins-bot
724c16c4f4 Merge "Revert "Adding a bunch of hooks from wikiHow into DifferenceEngine"" 2016-07-06 21:57:33 +00:00
jenkins-bot
b8115ce691 Merge "Revert "Show parser output for diffs unless extension aborts"" 2016-07-06 21:49:13 +00:00
MaxSem
3f5717cac8 Revert "Adding a bunch of hooks from wikiHow into DifferenceEngine"
Causes fatals.

This reverts commit b02bfac06b.

Bug: T139526
Change-Id: I4c77b4d51408540a9238d38e8324028879b1bbf2
2016-07-06 17:43:32 -04:00
MaxSem
be3c147bde Revert "Show parser output for diffs unless extension aborts"
Reverting the underlying change.

This reverts commit 3354e8d550.

Bug: T139526
Change-Id: I2e0f2098981bda411f360eea89e5fac3b644f043
2016-07-06 21:32:44 +00:00
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
Max Semenik
dd57ff3cce Rethink diff limits
Now, instead of "if your changed paragraphs are larger than 10Kb, you're
screwed":
* Instead of relying on overall length, estimate complexity after splitting to words
  and taking any equal head and tail out of equation.
* Estimate based on words changed, which better reflects the actual complexity
  of generating a diff.
* New limit is determined scientifically, i.e. "above that number XDebug starts
  complaining about recursion limits reached in Vagrant".

Caveat: if new limits are hit, the consequences are more widespread as all adjacent
changed paragraphs are displayed without word level diffs, as opposed to only the
paragraph that's too long being affected. However, the new limit is much higher and
in wikitext you're supposed to put empty lines between paragraphs anyway, negating
this problem.

Bug: T128697
Change-Id: I4e91c7c40f5afdd116b847a859b8517522302489
2016-06-01 16:30:58 -07: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
33cb9e803a Improve diff docs
Change-Id: I42332051f6f1b94f459b06d6c69625bc2a1fa9cf
2016-05-18 01:59:29 +00:00
Max Semenik
20f066e971 Merge Wikidiff3 into DiffEngine
Change-Id: Ib4d083a5200824e4d032de6921c375e455e77fb2
2016-05-18 01:50:19 +00:00
Max Semenik
7e60f670bf Remove unused stuff from diffs
Change-Id: Ie7d46b9ed290912039c88bbf4548d4c3d97153c9
2016-05-18 01:39:31 +00:00
Max Semenik
1cac442f1f Refactor diffs
* Merge MappedDiff into WordLevelDiff
* Rename <something insane>WordAccumulator into WordAccumulator and namespace
* Better variable names

Change-Id: I5847f2bb89402d0537b9e99cccd24c547ce4e4e2
2016-05-17 18:17:05 -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
jenkins-bot
a0803c9bc5 Merge "TableDiffFormatter: Don't repeatedly call array_shift()" 2016-04-21 21:37:40 +00: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
Kevin Israel
073eb68ca9 TableDiffFormatter: Don't repeatedly call array_shift()
This also fixes a bug that could cause deleted lines to appear as if
they were replaced with blank lines rather than removed entirely.

Change-Id: I99dc2862b130c02aed311f93236eb6b2dc50a0fb
2016-03-09 04:09:07 -05:00
Ori Livneh
9e867b07b8 Don't quote assert expressions in DairikiDiff
Per HHVM issue 5128, it is not possible to use '$this' in string-literal
assert() expressions. We can either wait for this to be fixed (unlikely to
happen soon, since it involves deep interpreter internals), comment out or
remove the asserts, or simply unquote them, so that they are actual expressions
rather than strings. The downside to this is that assertions will always be
evaluated (but so what, they are extremely cheap), and that when an assertion
fail the error message will simply read 'assert(): Assertion failed in
/path/to/file on line XXX' as opposed to including the expression in the
output. Fair trade, IMO.

See: https://github.com/facebook/hhvm/issues/5128

Bug: T124163
Change-Id: Ib458b1b0c28f8d38e9df427196ae79814f6dc0c2
2016-03-08 18:10:52 -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