Commit graph

424 commits

Author SHA1 Message Date
Umherirrender
be42e09aa8 build: Prepare for mediawiki/mediawiki-codesniffer to 0.9.0
The used phpcs has a bug, so the version 0.9.0 could not be enforced at the moment.
Will be fixed in next version, see T167168

Changed:
- Remove duplicate newline at end of file
- Add space between function and ( for closures
- and -> &&, or -> ||

Change-Id: I4172fb08861729bccd55aecbd07e029e2638d311
2017-06-26 17:14:31 +00:00
WMDE-Fisch
7b5f08e703 Replace deprecated Context::getStats() with MWServices::getStatsdDataFactory()
Change-Id: I1756f69ca2ebd301a5049bf758d1a87c37771fe6
2017-03-17 12:07:03 +01:00
jenkins-bot
aa3319c4c0 Merge "Miscellaneous indentation tweaks" 2017-02-28 18:38:36 +00:00
Bartosz Dziewoński
ecdef925bb Miscellaneous indentation tweaks
I was bored. What? Don't look at me that way.

I mostly targetted mixed tabs and spaces, but others were not spared.
Note that some of the whitespace changes are inside HTML output,
extended regexps or SQL snippets.

Change-Id: Ie206cc946459f6befcfc2d520e35ad3ea3c0f1e0
2017-02-27 19:23:54 +01:00
James D. Forrester
9635dda73a includes: Replace implicit Bugzilla bug numbers with Phab ones
It's unreasonable to expect newbies to know that "bug 12345" means "Task T14345"
except where it doesn't, so let's just standardise on the real numbers.

Change-Id: I6f59febaf8fc96e80f8cfc11f4356283f461142a
2017-02-21 18:13:24 +00:00
Brad Jorsch
fb3ae6fbe3 Replace use of &$this
Use of &$this doesn't work in PHP 7.1. For callbacks to methods like
array_map() it's completely unnecessary, while for hooks we still need
to pass a reference and so we need to copy $this into a local variable.

Bug: T153505
Change-Id: I8bbb26e248cd6f213fd0e7460d6d6935a3f9e468
2017-01-31 23:01:54 -05:00
Fomafix
d2997347a2 PHP code style: No space after unary not operator
Change-Id: I4d3df0cfcda4d88e405164123893e57786fbe15e
2017-01-05 16:00:59 +00:00
jenkins-bot
9ac29c74ed Merge "Cleanup some incorrect return annotations" 2016-12-16 07:22:24 +00:00
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
Erik Bernhardson
d67197fa11 Cleanup some incorrect return annotations
Most of these are simply changing annotations to reflect
reality. If a function can return false to indicate failure
the @return should indicate it.

Some are fixing preg_match calls, preg match returns 1, 0 or false,
but the functions all claim to return booleans.

This is far from all the incorrect return types in mediawiki, there
are around 250 detected by phan, but have to start somewhere.

Change-Id: I1bbdfee6190747bde460f8a7084212ccafe169ef
2016-12-12 10:15:05 -08: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