Commit graph

241 commits

Author SHA1 Message Date
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
Aaron Schulz
57731929ab Added limit to countRevisionsBetween() for sanity
* This was causing dozens of DB query timeout errors at WMF

Change-Id: Ie51a491ff5d22c2d84934e83d4b3f690c9dbd595
2014-04-07 15:18:19 -07:00
umherirrender
23fab68274 Fix spacing after @param and friends in comments
Searched for:
\@(param|return|throws|since|deprecated|access|todo|var)[ \t]{2,}

Change-Id: Icce22ba9fe0635455691ca58d9872d618151f346
2014-04-05 20:02:29 +00:00
aude
6a5c9bd28b Add visibility to DifferenceEngine methods
Change-Id: I415719442ca1778be36f173067d4b090fbe9265a
2014-03-06 15:34:51 +01:00
Thiemo Mättig
6806400129 Added and updated Doxygen comments in content handler and diff namespaces
Reasons for touching this are:
* "@param type $var" were mixed in a lot of places. Both works but the
  MediaWiki coding conventions suggest that specific order.
* Things like String and Bool aren't objects and shouldn't be uppercase.
* Tried to fill missing types in "@param $var".
* Tried to fill missing descriptions in "@return type" when I could.
* Removed duplicate descriptions if a @see is sufficend.
* Removed useless descriptions ("isUsefull returns true if usefull").
* Removed useless @return void.
* Replaces mixed[] with array (does have the exact same meaning).
* Tried to find better replacements for "varargs", phpDocumentor
  suggest $var,...
* Order should be @since, @param, @throws, @return, @see. This is the
  order Doxygen renders this.

There is always more to do but I think this is already much better
than before. Please feel free to put more change sets on top of mine
or request more changes by adding comments.

Change-Id: I05262ce06caabf79f68772302524ac91bbead1c6
2014-03-06 11:17:41 +01:00
Siebrand Mazeland
f077c4b1d6 Update formatting
Change-Id: I18aff576262479c9bb1c56eb8e1d1aaae200e4b1
2014-02-06 09:27:05 +01:00
jenkins-bot
1f84a574e3 Merge "Improve clarity of diff-multi message" 2014-01-31 17:24:00 +00:00
jenkins-bot
f726bbf6e7 Merge "Add oldRev parameter to DiffRevisionTools hook" 2014-01-29 01:44:01 +00:00
Jackmcbarn
25b83169c8 Add oldRev parameter to DiffRevisionTools hook
Add a third parameter to the DiffRevisionTools hook, containing the old
revision.

Bug: 57721
Change-Id: I6ee956c5b9901033f618d7e4d09f8f416f3d72cb
2014-01-28 20:43:55 -05:00
Jackmcbarn
874fed9306 Improve clarity of diff-multi message
When one user has made all of the intermediate revisions in a diff,
make it clear whether or not this is the same user that made the
latest revision.

Bug: 59833
Change-Id: I7db9a02ae8bc7a8e092fcdc257b5e17595de02b4
2014-01-09 10:10:35 -05:00
Brad Jorsch
d8b1b79ea4 Move redirect rendering into WikitextContent
There's no good reason for everything that wants to render a page to
have to test whether the page is a redirect and then call
Article::viewRedirect to get the fancy rendering instead of using the
ParserOutput. This logic can easily be moved into
WikitextContent::getParserOutput so callers can just use the
returned ParserOutput.

At the same time, we can handle "#REDIRECT [[File:Foo]]" and
"#REDIRECT [[Category:Foo]]" the way people expect, by recording the
link in pagelinks rather than imagelinks/categorylinks (although this
means fixing ImagePage's bug about assuming anything in imagelinks that
is a redirect is a redirect to the image too).

And we can finally fix bug 14323, too.

Bug: 14323
Bug: 17259
Bug: 27621
Bug: 42642
Bug: 50488
Change-Id: Id44d566a7ca35a1b9579d0c0e947877c980b0686
Followup: I1c7582d1bf7ec4184a45b00154e3dd5b39dd444b
Followup: I3653b608941813a73281f4f0545bea2487d43964
2014-01-07 09:18:22 -05:00
Siebrand Mazeland
9cd43cd01a Replace inline tab with space
Spotted by Umherirrender in
https://gerrit.wikimedia.org/r/#/c/96554/1/includes/diff/DifferenceEngine.php

Change-Id: I363a3299d61e2cfb7c31db9c293a2c7e73fcef44
2013-11-21 18:32:38 +00:00
Siebrand Mazeland
c13d478e9b Break long lines in includes/diff/
Change-Id: I778079edb147623f54f6140e11e25120b04c382e
2013-11-20 20:22:36 +01:00
Siebrand Mazeland
abefd2c07e Update formatting for includes/diff
Change-Id: Id032a32ca6ebea3daf5313a05602c5e98603d983
2013-11-20 20:11:57 +01:00
Siebrand
60fa0e1c3b Revert "DifferenceEngine cleanup"
This reverts commit 1f423cc609.

Change-Id: I2254eb37376063a081ad89481654b735fb0360b1
2013-11-11 16:35:19 +00:00
Max Semenik
1f423cc609 DifferenceEngine cleanup
* Remove mPrefixes from variables
* Turn a define into class const

Change-Id: I80874627df9dffae596f8f7cb3ca28f19ba1f167
2013-11-09 04:21:32 +04:00
Max Semenik
651c43140f DifferenceEngine minor fixes
* Function docs
* Remove useless variable assignment

Change-Id: I292e1391e0c24399b2c203b9f7fe7c58df089ad0
2013-11-02 02:28:13 +04:00
Siebrand Mazeland
e61cb8218b Update docs and declare visibility on class props
Change-Id: Ib0f02202d075d4a56dc4e37b08d7ac9399e8c86c
2013-11-01 12:35:27 +01:00
aude
607bcd6c63 Put get diff body cache key into own function
This allows derivative DifferenceEngine classes to
generate cache keys in a different format, as appropriate.

(e.g. for Wikibase, allow diffs to be cached by language
and fully localized)

Bug: 55667
Change-Id: I22bf4e70f86da832a86baf6790ad4a403fce4bf1
2013-10-31 10:27:55 +00:00
Bartosz Dziewoński
dfc3e3df90 Correctly update wl_notificationtimestamp when viewing old revisions
== Prelude ==
wl_notificationtimestamp controls sending the user e-mail
notifications about changes to pages, as well as showing the "updated
since last visit" markers on history pages, recent changes and
watchlist.

== The bug ==
Previously, on every view of a page, the notification timestamp was
cleared, regardless of whether the user as actually viewing the latest
revision. When viewing a diff, however, the timestamp was cleared only
if one of the revisions being compared was the latest one of its page.

The same behavior applied to talk page message indicators (which are
actually stored sepately to cater to anonymous users).

This was inconsistent and surprising when one was attempting to, say,
go through the 50 new posts to a discussion page in a peacemeal
fashion.

== The fix ==
If the revision being viewed is the latest (or can't be determined),
the timestamp is cleared as previously, as this is necessary to
reenable e-mail notifications for given user and page.

If the revision isn't the latest, the timestamp is updated to
revision's timestamp plus one second. This uses up to two simple
(selectField) indexed queries per page view, only fired when we
do not already know we're looking at the latest version.

Talk page indicator is updated to point at the next revision after the
one being viewed, or cleared if viewing the latest revision. The
UserClearNewTalkNotification hook gained $oldid as the second argument
(a backwards-compatible change). In Skin, we no longer ignore the
indicator being present if we're viewing the talk page, as it might
still be valid.

== The bonus ==
Comments and formatting was updated in a few places, including
tables.sql and Wiki.php.

The following functions gained a second, optional $oldid parameter
(holy indirection, Batman!):
* WikiPage#doViewUpdates()
* User#clearNotification()
* WatchedItem#resetNotificationTimestamp()

DifferenceEngine gained a public method mapDiffPrevNext() used
to parse the ids from URL parameters like oldid=12345&diff=prev,
factored out of loadRevisionIds(). A bug where the NewDifferenceEngine
hook would not be called in some cases, dating back to its
introduction in r45518, was fixed in the process.

Bug: 41759
Change-Id: I4144ba1987b8d7a7e8b24f4f067eedac2ae44459
2013-10-27 17:47:53 +00:00
Chad Horohoe
d0c8ba037c Remove wfDl() and cleanup everything it touched
wfDl() is a wrapper around dl(), which is an evil function and
basically only works from the command line of Zend. Luckily
no extension has ever used this thing, so let's just remove it
outright.

For comparison, here's a list of places it does not work:
- hhvm
- php as apache module
- php compiled with zts support
- safe_mode
- Basically any shared host that cares about security

Most callers are using it to check for extension support and are
actually failing gracefully when wfDl() returns false. In these
places we're just going to use extension_loaded().

While we're at it, clean up some of the test skip logic in the
media tests so we can bail as early as possible if we know we
can't complete the test.

This also immediately removes $wgLoadFileinfoExtension. It's been
enabled by default since 5.3 and falls back gracefully when the
support isn't available.

Change-Id: Ieb430dfc74483731dde51d6e20fa700d641ba1f4
2013-10-09 10:51:35 -07:00
jenkins-bot
3b6f122867 Merge "Show the revision ID on error message when content is missing on difference page" 2013-09-17 17:20:22 +00:00
Alexandre Emsenhuber
ea8ac38e45 Show the revision ID on error message when content is missing on difference page
Currently if the revision exists but its content is not found, it will make
loadText() return false; which in turn will make a call to showMissingRevision()
from showDiff(). However since the revision exists; it will not match the
condition in showMissingRevision() and thus an error message will appear without
any revision ID.

Change-Id: Idd8a5f20a3c082a3b02bd77557e0f4dc4c66e876
2013-09-17 06:52:14 +00:00
Alexandre Emsenhuber
17f2fe778f Removed unneeded else branches in DifferenceEngine
The "if" always exit, so there is no need to use else branches;
also added blank lines for better readability.

Change-Id: I7d8321652a90fbba99e53fa0c1fe018492883b8a
2013-09-17 06:51:05 +00:00
jenkins-bot
3884fa4e5f Merge "Don't ask users to mark own page creations as patrolled" 2013-09-16 19:22:29 +00:00
umherirrender
d50199ddce Add class around diff-empty and add it as notice
Add the moment the message is added within a class=diff-multi,
which is not true.

Bug: 53168
Follow-Up: I458fb688b0001fb674ece65b3fdabf56fc658a29
Change-Id: Ic3040ceca4ff1459181c84f041490e9e72b12802
2013-08-25 17:06:49 +02:00
jenkins-bot
ae1274fd28 Merge "DifferenceEngine: Remove broken comment" 2013-07-22 11:44:03 +00:00
Marius Hoch
038602f9bc Don't ask users to mark own page creations as patrolled
Bug: 51224
Change-Id: I2d38c25b547a8735da135955854584aa02b4394d
2013-07-20 21:31:59 +02:00
umherirrender
2bdb4895f9 diff: Display "(No difference)" instead of an empty diff
This makes it easier to see the fact, because without a hint, the user
can mean, that there is something missing, but here the missing is okay
and for that, the message is helpful.

Change-Id: I458fb688b0001fb674ece65b3fdabf56fc658a29
2013-07-17 20:40:35 +02:00