Commit graph

363 commits

Author SHA1 Message Date
Thiemo Mättig
c72b98e8d6 Fix/update inline documentation in WikiPage class
* Add missing "new" to methods that actually support it.
* Use more precise type hints in PHPDoc comments.
* Lowercase "string" and "array", they aren't objects.
* Drop a useless comment that only repeats the method name.
* Add some line breaks.

Change-Id: I2f50179eedffcb1809c46fa7ee1c062144a94ffe
2014-03-25 19:21:50 +01:00
jenkins-bot
a301420273 Merge "Revert "Rollback: Make update of recentchanges table later"" 2014-03-07 22:54:23 +00:00
aude
81d5a7833d Add visibility in PoolCounter classes
Change-Id: Ieb8916235fa37247aa11a4d1fad59d929997d0e6
2014-03-07 00:37:42 +01:00
Umherirrender
3abf9d6bc0 Revert "Rollback: Make update of recentchanges table later"
The automatic patrolling on a already rolled rollback should be kept,
see bug 62157.

Bug: 62157
This reverts commit e6980c32f1.

Change-Id: I3b626452a0bab11e8b2a12545976cbd1df92ae1f
2014-03-06 21:25:59 +01:00
jenkins-bot
01e3296722 Merge "Call WikiPage::doViewUpdates also on missing article page view" 2014-02-18 20:21:37 +00:00
umherirrender
979b570e2d Give alreadyrolled error when rollback will be a null edit
When a rollback will not create a new version, the rollback should not
be success normally. Raise the alreadyrolled error to indicate this
situation.

This can happen, when the same user already rolled back his edit in the
meantime.

Change-Id: I953ae1ca79abb37bc44f3f8244a42a34111e6ab8
2014-02-17 20:24:13 +01:00
umherirrender
269315bbe1 Call WikiPage::doViewUpdates also on missing article page view
Reset notification timestamp also for deleted pages on the watchlist,
this will give a empty notification on api's
prop=info&inprop=notificationtimestamp for the timestamp after visiting
a deleted page.

This also reset the remaining newtalk flags for anon user talks which
are effected by bug 14077.

Change-Id: Ibdb22ab1e0bea02b6ef730cd5737f91801b8d700
2014-02-15 18:39:45 +00:00
jenkins-bot
c56495090a Merge "Use TablePager on Special:ProtectedPages (using log_search)" 2014-02-13 20:02:22 +00:00
umherirrender
ca7c098134 Use TablePager on Special:ProtectedPages (using log_search)
Adding the pr_id to log_search table and use a join to get the user,
timestamp and comment from the logging table. For logs without the pr_id
a placeholder text is shown.
The code for page protection is changed from a replace to delete/insert
to have for each pr_id a log_id and not reusing pr_ids which was used
for the first protection on a protection change.
The log_deleted field is checked to avoid showing revision deleted data
from the logging table.

This is a alternative patch for
Ie40057398a7829c698df3d68813006798a72dccb
and Iade82653999ca770586762b3c1383f73dfe3a5ee to avoid a schema change
on table page_restriction.
Idea by Aaron Schulz.

Change-Id: Ia0dc5895ec672896fe4b75c2e0f76da2474bd6e4
2014-02-13 20:48:53 +01:00
Alexandre Emsenhuber
25863cbe2a Explicitely return null from WikiPage::newFromID()
Follow-up I8943b4dec5 (d7f465f).

To match the documentation.

Change-Id: I7b960704d6b3a83e389ece182bf94142341ea88c
2014-02-13 18:50:50 +01:00
Chad Horohoe
d7f465f7e8 Return early when page id is less than 1
Wasteful DB query when we know the page won't exist.

Bug: 61166
Change-Id: I8943b4dec5088dadffefbd74f54653cb09043b7c
2014-02-10 21:52:01 -08:00
Alexandre Emsenhuber
8d701eeeea Remove trailing line breaks from wfDebugLog() messages
This is useless since the message is passed through trim() and a
line break is added afterwards.

Change-Id: I1a26b30a07f7c9c749fce5bb6b2b4b3d79901b7c
2014-02-04 22:16:13 +01:00
umherirrender
e6980c32f1 Rollback: Make update of recentchanges table later
Avoid update of recentchanges table on edit failure.

Change-Id: If48e57d7ff9a63a85cac32f8b81ffd1c3d3910f3
2014-01-29 20:36:28 +00:00
Siebrand Mazeland
13b3fe2981 Remove deprecated MediaWiki::articleFromTitle() and WikiPage::createUpdates()
No uses found in core or Gerrit extensions.

* MediaWiki::articleFromTitle() (deprecated in 1.18)
* WikiPage::createUpdates() (deprecated in 1.18)

Change-Id: I689249b579ee89f883b97fdb4ac79fb3502c45dc
2014-01-22 18:28:36 +01:00
Brad Jorsch
a2120b0bd0 Make imagelinks work like templatelinks
Due to bug 17259 (which is fixed in a better way in Id44d566a),
imagelinks only records the redirect and not the actual image used when
an image redirect is referenced. This causes various problems, such as
cascading protection not working through image redirects.

It makes more sense for imagelinks to work like tempaltelinks, recording
both so that things like cascading protection don't have to care about
image redirects explicitly.

Comparing imagelinks to templatelinks also reveals a few places
(WikiPage::doDeleteUpdates, WikiPage::doCascadeProtectionUpdates) that
should be triggering a LinksUpdate if the image links changed.

Bug: 23002
Bug: 23542
Bug: 26503
Change-Id: I64fe7d25646cae2c8213211893c6f821f3504dbf
2014-01-07 23:13:43 +00:00
Reedy
09f84556bd Make WikiPage::$mPreparedEdit public
Partial revert of I2c34baaf8b64b204444efa1bfa6ea356e0124c54

Change-Id: Id4e90c612941ff2bdb50d7a68f4e18b004c9f744
2014-01-07 22:59:17 +00:00
umherirrender
073abe3e12 No variable assignment on return statement
Split the variable assignment and the return statement in two lines for
better readability.

When there was two return statements in one method the logic was swapped
to have only one return statement.

Change-Id: Id7a01b4a2df96036435f9e1a9be5678dd124b0af
2014-01-02 09:43:35 +00:00
Siebrand Mazeland
4e8687a884 Remove deprecated methods from Revision, SkinTemplate, and WikiPage
No uses found in core of Gerrit extensions.

- Revision::revText() (deprecated in 1.17)
- SkinTemplate::jstext() (deprecated in 1.21)
- WikiPage::quickEdit() (deprecated in 1.18)
- WikiPage::useParserCache() (deprecated in 1.18)
- WikiPage::viewUpdates() (deprecated in 1.18)

Change-Id: I9eee23ea3ce381b6b8373da899287bcaea4cead4
2013-12-27 19:44:14 +01:00
Aaron Schulz
b57e457091 Added a page_links_updated column for job de-duplication
Change-Id: I74b6f507ef7371db92e0c3f058d38c0ca5dea9ef
2013-12-24 10:54:32 +00:00
Brad Jorsch
cc95e09519 Fix WikiPage::prepareContentForEdit's default format handling
If some caller passes null for the $serialization_format parameter,
they're going to break the in-memory caching of the prepared edit even
though it's likely that the format being used is the same as the format
being used by everything else.

It seems sensible to cache null as the default format for the content
object to avoid this.

Bug: 57026
Change-Id: I4ddcf6e388636e6a6397b664b8683ad774a09a04
2013-12-13 20:10:22 +00:00
jenkins-bot
d4eefca4dd Merge "Deleting a page and then immediately create-protecting it caused a PHP Fatal error" 2013-12-10 20:50:37 +00:00
umherirrender
661c5c3f01 Fixed spacing
- Added space after foreach
- Added/Removed spaces inside arrays

Change-Id: Ia8775824fa33976b1a4dab43e07f1bff0c57479c
2013-12-08 20:31:47 +01:00
jenkins-bot
4d4471ec88 Merge "Truncate protect reason for whole multibyte characters" 2013-11-21 12:58:21 +00:00
umherirrender
3fd1c59a7f Avoid Database::encodeExpiry, when simple timestamp is given
Also remove wfTimestampNow because Database::timestamp will default to
now, when no param is given.

Change-Id: I0b065f4cdf67e1473548e641cf2864b4a2232ef8
2013-11-20 20:05:19 +01:00
umherirrender
5e34e79700 Truncate protect reason for whole multibyte characters
This avoids broken characters for long comment.
The reason is shown on action=edit for unprivilieged users.

Change-Id: Ie8099f50628d55ff880760721169803ccbb3555c
2013-11-20 19:56:42 +01:00
Aaron Schulz
91f29bf1b6 Tweaked WikiPage::clear() comment a bit
Change-Id: I9ec27b575de5547d1ab0569c4c2cdd1307f8307a
2013-11-18 19:05:45 +00:00
aude
8842bc95fc Add function to clear mPreparedEdit, to use in cases of mutable content
In Wikibase, EntityContent is mutable and needs to clear
prepared edit before performing a save.

Follow-up to I2c34baa

Change-Id: I770bf2dc960c0a67a9b8315b7cdf24f3b89b6480
2013-11-17 11:30:28 -08:00
Aaron Schulz
a879897170 Avoid extra parsing in prepareContentForEdit()
* WikiPage::clear() no longer resets mPreparedEdit
* Also actually made mPreparedEdit protected

bug: 57026
Change-Id: I2c34baaf8b64b204444efa1bfa6ea356e0124c54
2013-11-15 00:18:57 +00:00
Brad Jorsch
6f25ee40f1 Add a RefreshLinks job when a template is deleted
When a template is deleted, all pages transcluding it need to be
reparsed so that entries for transcluding pages in the various links
tables due to the transcluded content are properly removed.

Bug: 5382
Change-Id: I838b546caa3f5887e6bd312017c1fa71d3c3463a
2013-11-06 12:56:53 -05: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
Tim Starling
d1bc243f65 Remove all instances of the word "iff"
It's elitist mathematical jargon. In all cases dealt with here, it adds
no additional meaning compared to "if", beyond what was already obvious
from context. Thus, its only purpose is to smugly demonstrate that the
author attended their second-year mathematics classes, at the expense of
causing confusion for everyone who doesn't have such a background.

If you really think you need to convey extra information beyond what
"if" gives you, the English language contains plenty of devices for doing
so, without resorting to neologisms.

Change-Id: Iae21095d02ec2935c10e94f532235c2671c115b1
2013-10-23 10:56:54 -07:00
jenkins-bot
853ee35c20 Merge "Fix PHP CodeSniffer errors and warnings" 2013-10-09 15:17:59 +00:00
jenkins-bot
e3ebb0b8b3 Merge "Fix revision table cleanup on delete" 2013-10-08 20:36:45 +00:00
Siebrand Mazeland
77140ff411 Fix PHP CodeSniffer errors and warnings
Change-Id: I573d73b4cf1dcddfe14e9d565e4f170ad024ea31
2013-10-08 19:32:04 +02:00
jenkins-bot
ae857e90c5 Merge "Fixup parameter type hints" 2013-10-08 17:31:22 +00:00
Tim Starling
d3364da9ce Fix revision table cleanup on delete
The ContentHandler branch inappropriately moved this essential
query to content-type-dependent code, despite the fact that revision
table cleanup needs to be done independently of content type. Before
r15707, the revision query was done immediately before the page query,
but it was moved down to allow it to be brought into the same
if (!$dbw->cascadingDeletes() ) block as the link updates. I have moved
it to immediately after the page delete, so that the rollback which has
since been added will not affect the expensive revision table query.

This should fix the database corruption we are seeing on some page
deletions (13 affected pages on enwiki, 14 on nlwiki, etc.)

Bug: 53687
Change-Id: I7a54c4416be07fb8cc7a5698e77927ccb24cbd6e
2013-10-04 14:35:13 +10:00
jenkins-bot
f1032105da Merge "Reduce chance for parser cache race conditions" 2013-09-30 17:01:13 +00:00
Marius Hoch
a906177c20 Clear legacy restriction field on page restriction update
This causes problems where some pages can't be unprotected
as we still take the legacy field into account. See also
bug 33334.

Change-Id: Ibaec827289b1070ee110635d6c9d7b60e061384b
2013-09-25 22:50:54 +02:00
Aaron Schulz
9750150c2e Reduce chance for parser cache race conditions
* Move cache time definition to happen before parse so it is less likely
  to override the cache with a stale value and a high cache timestamp.

bug: 46014
Change-Id: I021d27885ac260d89232ff11ec3cccf976e44f0f
2013-09-24 13:57:51 -07:00
Reedy
37b7baa0f4 Fixup parameter type hints
Remove returns where return is void

Change-Id: I19e911695a545745954cff1fd8372bb4ce35e166
2013-09-17 04:15:17 +01:00
Tychay
bfaa602229 Merge "Make it slightly easier for extensions to hook into page protection." 2013-08-26 22:03:18 +00:00
Matthias Mullie
92859c59c3 Make it slightly easier for extensions to hook into page protection.
Split parts of doUpdateRestrictions() into several more concise functions.
The biggest drawback is increasing $dbw->encodeExpiry() calls times 3. This is
not much of a problem given that's a very inexpensive function and it is only
called very few times ($limit holds 2 values in current codebase)

Added $reason to the ProtectionForm::save hook, so that other code hooking into
and adding their own settings into page protection form can also process the
reason for the protection change.

Change-Id: I879290ed83e4e47e9561d4c352fbd50c07d7e18a
2013-08-26 14:13:43 -07:00
Kunal Mehta
5eb1d775bd Add a function that returns a list of categories the page is a member of
Main reason is so internal code does not have to recreate the database query
each time. This will also be useful for extensions.

Change-Id: Ia80c051ff0691087564710f2864ed617d5b9ee96
2013-08-14 21:07:38 -07:00
Owen Davis
5ea6530a9b Deleting a page and then immediately create-protecting it caused a PHP Fatal error
Change-Id: Ife75371bceda0f5342ee9eb5388d26e0363bebbe
2013-08-13 14:35:13 +10:00
jenkins-bot
f3b38123cb Merge "Abort page restriction if no null revision can be created" 2013-07-29 17:40:57 +00:00
Kevin Israel
a976c974a6 Update 'right-protect', 'right-autoconfirmed' messages
* The "autoconfirmed" right is now only used to determine "newbie"
  status for the purpose of rate limiting, so I updated the
  "right-autoconfirmed" message accordingly.
* The "protect" right now does not allow the user to edit protected
  pages, so I updated the "right-protect" message accordingly.
* Also removed outdated portions of code comments referring to the
  now-fixed bug identified in r31462; the 'protect' right is now
  necessary to edit any directly or indirectly cascade-protected
  page.

Follows-up I6bf650a3fbdab8589ae6945c8c916eafd949e41c.

Change-Id: Ia3cc487dd0ad168001a076ebd612eb64764e92ef
2013-07-09 20:30:53 +00:00
jenkins-bot
ad2d984f2d Merge "Unbreak cascading protection" 2013-07-09 20:25:47 +00:00
Kevin Israel
80823c2539 Unbreak cascading protection
Title::getRestrictions can return "sysop", which will not match if
replaced out of $cascadingRestrictionLevels but not $editrestriction,
making it impossible to cascade protect a page with the default value
of $wgCascadingRestrictionLevels.

Follows-up I6bf650a3fbdab8589ae6945c8c916eafd949e41c.

Change-Id: Ie7183ed9509ea9c65a7197fc9cead6c8423b852e
2013-07-09 18:28:37 +00:00
Matthias Mullie
c819ae8819 Abort page restriction if no null revision can be created
In practice, this should not currently be happening: null revision can not be
created if no previous revision exists, which should not be the case where we
call the function in doUpdateRestrictions. However, since newNullRevision can
potentially return null (it's documented that way, perhaps some day in the
future, additional code paths can lead to null), we should check for it.

Also: after completing the restriction updates, the null revision is passed
along to a hook, which is documented[1] to get a Revision object. Right now,
in theory, this could be incorrect.

1: https://www.mediawiki.org/wiki/Manual:Hooks/NewRevisionFromEditComplete

Change-Id: I89b0be823d9933d557470005c390a9102f931684
2013-07-08 18:23:05 +02:00
jenkins-bot
6faa8d0dbd Merge "Don't queue refreshLinks jobs on null edit" 2013-07-08 15:16:06 +00:00