Commit graph

65 commits

Author SHA1 Message Date
daniel
0d51852087 Regression test for autopatrolling rollbacks
Bug: T198449
Change-Id: Ic280c38ac2ba0a0842c484f671e7e99f50cd54d5
2018-06-29 11:59:51 +02:00
daniel
c7564daa80
[MCR] Rollback for all slots
Bug: T194034
Change-Id: Ifd23bc1cd64ddc090e1c1c26aacda37e8ba7a18b
2018-06-23 15:14:47 +02:00
addshore
0ef66de3cf MCR RevisionStore, multi content mode..
Bug: T174024
Change-Id: Ifabf39e12ba843eb754ad0c029b7d16a311047a5
2018-06-14 17:30:33 +02:00
addshore
125bf7e44f [MCR] RevisionStore, enable insertions for new schema
Enable inserts to the new MCR db schema in single slot mode only.

TODO:
 - RELEASE NOTES

Notes:
 - When in MIGRATION_WRITE_NEW or greater, deleting and then
 restoring a page will result in different data in the revision table.
 For example, if you delete a page that has text_ids present in the
 revision table and restore it, the text_ids will be blank after.
 - When in MIGRATION_WRITE_BOTH or greater the archive table will
 start to ar_content_model entries where previously it would have been
 given NULL. This is due to the old content schema having NULL in the db
 when the default content model is used, but the new schema will always
 have a value, taken from the content_models table

Note: If259b1e1c49ce was squashed into this change.

Bug: T183488
Bug: T174024
Change-Id: Ic2221da30c8f6ac2ba42720fcd568f2d0ed70534
2018-06-14 13:36:08 +00:00
daniel
e8632ab0f6 [MCR] Factor PageUpdater out of WikiPage
This introduces PageUpdater to replace WikiPage::doEditContent,
and DerivedPageDataUpdater, to replace WikiPage::doEditUpdates
and WikiPage::prepareContentForEdit.

See docs/pageupdater.txt for a description of their
functionality.

MCR migration notes:

* The interface of PageUpdater is expected to
remain mostly stable after this patch. Code that has been using
WikiPage::doEditContent can be confidently migrated to using the
new mechanism for revision creation.

* This patch keeps the code inside PageUpdater largely aligned
with the old code in WikiPage, to make review easier to to avoid
mistakes. It is intended to be refactored further, moving
application logic into stateless services.

* DerivedPageDataUpdate is intended as a stepping stone for further
refactoring. Its behavior is designed to be compatible with
callback code that currently relies on
WikiPage::prepareContentForEdit. Much of the code that currently
lives in DerivedPageDataUpdate should be factored out into
services, all behavior relevant to calling code should be exposed
via narrow interfaces.

Bug: T174038
Bug: T196653
Change-Id: If610c68f4912e89af616cdcac1d35a1be3946afa
2018-06-14 13:22:13 +00:00
daniel
e4b775acf1 Suppress addCoreDBData() in tests overriding the revision schema.
Some unit tests for the MCR schema migration change the DB schema
in the test setup. However, addCoreDBData() will not work with the
modified schema. Since these tests don't actually need addCoreDBData()
to do anything, they can simply override it to do nothing.

Without this change, tests for Ic2221da30c and Ifabf39e12ba843
fail with $wgMultiContentRevisionSchemaMigrationStage = MIGRATION_WRITE_BOTH.

Change-Id: I86e140ec981dfa4e904822b1600399c533f9e3d6
2018-06-14 07:41:28 +00:00
jenkins-bot
6bfa7c3754 Merge "Introduce per-schema unit tests for revision storage." 2018-06-07 13:47:00 +00:00
daniel
32e9266d8d Introduce per-schema unit tests for revision storage.
This introduces traits for testing different schema variations.
These are not very useful in this patch, but make it much easier
to add tests for MCR schema migration in subsequent patches.

The code in this patch was previously part of If259b1e1c49ceaa4.

Change-Id: I239572f75bebbc9c731a3e3860c4eff179dc15e4
2018-06-07 13:31:16 +00:00
kaldari
9c387f5036 Record a log entry on page creation
This is controlled by a new config variable, $wgPageCreationLog,
which is set to false by default.

Bug: T12331
Change-Id: Ie3f6cc5ece0134433d5e4a572ea5eb0c3b700b8c
2018-05-29 09:10:40 -07:00
James D. Forrester
0db10b84b0 tests: Assert that the user who deleted a page is logged as such
These tests are rather basic, but they're better than the nothing that
seems to be the current state. Revision deletion is still untested and
suppression is only very lightly tested. More tests should be added.

Bug: T188479
Bug: T188773
Change-Id: Iba0f41ffddc6af45e0a4be86176708160f4821f4
2018-04-26 00:49:00 +00:00
Brad Jorsch
fd3ddd93e2 Fix WikiPageDbTestBase::testNewFromId_returnsNullOnNonExistingId
This test is passing an "integer" that is beyond what even 64-bit PHP
can properly represent as an integer, so it likely winds up passing it
as '7.3574757437438E+19' to the database. MySQL, being MySQL, doesn't
care much, but other DBs do.

Change it to 2**31-1 instead.

Change-Id: Ieba51f034eaa1c3eabb2ada6b1ce876beefd3bff
2018-03-17 22:02:13 -04:00
James D. Forrester
326d655fc9 Drop 'comma' value for wgArticleCountMethod
We have three methods for page counting currently supported for wikitext
non-redirect pages; 'any' counts any page that exists, 'link' counts any
page that has any outbound links, and 'comma' which searches for any ','
in the text having loaded it. This last option is much slower than these
other two, and is only used on a very small number of installations. Now
by dropping support for this method we can simplify this code and so run
it more often. Note that non-wikitext pages already did not support this
count method.

Installations with this setting set to 'comma', or any other string will
now work as if it was configured with 'any'.

Bug: T188472
Change-Id: I965927edcd2485ec4b49b2d80fdf216dbf19520b
2018-03-01 16:37:23 -08:00
Brad Jorsch
27c61fb1e9 Add actor table and code to start using it
Storing the user name or IP in every row in large tables like revision
and logging takes up space and makes operations on these tables slower.
This patch begins the process of moving those into one "actor" table
which other tables can reference with a single integer field.

A subsequent patch will remove the old columns.

Bug: T167246
Depends-On: I9293fd6e0f958d87e52965de925046f1bb8f8a50
Change-Id: I8d825eb02c69cc66d90bd41325133fd3f99f0226
2018-02-23 10:06:20 -08:00
addshore
e5879da149 Pass $key into CommentStore methods and use MediawikiServices
This allows CommentStore to be added to MediaWikiServices
without the need of an aditional Factory.

This change includes a compatability layer to allow the behaviour
from 1.30 to continue to be used while deprecated.

CommentStore::newKey has been deprecated.
Keys are now passed into the public methods of CommentStore
where needed.
The following CommentStore methods have had their signatures changed
to introduced a $key parameter, but when used in conjunction with
CommentStore::newKey behaviour will remain unchanged:
  * CommentStore::getFields
  * CommentStore::getJoin
  * CommentStore::getComment
  * CommentStore::getCommentLegacy
  * CommentStore::insert
  * CommentStore::insertWithTemplate

Change-Id: I3abb62a5cfb0dcd456da9f4eb35583476ae41cfb
2018-02-05 15:34:12 +00:00
Umherirrender
45da581551 Use ::class to resolve class names in tests
This helps to find renamed or misspelled classes earlier.
Phan will check the class names

Change-Id: Ie541a7baae10ab6f5c13f95ac2ff6598b8f8950c
2018-01-26 22:49:13 +01:00
addshore
1583f478da [MCR] Tests for WikiPage::doUpdateRestrictions
Bug: T180989
Change-Id: I75518d5ba34119e88e3e382523583fa8b65bc730
2018-01-04 11:28:01 +00:00
Umherirrender
255d76f2a1 build: Updating mediawiki/mediawiki-codesniffer to 15.0.0
Clean up use of @codingStandardsIgnore
- @codingStandardsIgnoreFile -> phpcs:ignoreFile
- @codingStandardsIgnoreLine -> phpcs:ignore
- @codingStandardsIgnoreStart -> phpcs:disable
- @codingStandardsIgnoreEnd -> phpcs:enable

For phpcs:disable always the necessary sniffs are provided.
Some start/end pairs are changed to line ignore

Change-Id: I92ef235849bcc349c69e53504e664a155dd162c8
2018-01-01 14:10:16 +01:00
Kunal Mehta
2c16290785 Add @covers tags to page tests
Change-Id: Iadb7e8697e9992ca281b7dfe70cf832c82e194de
2017-12-24 23:29:00 -08:00
Umherirrender
5b351e86ea Use another pageid in WikiPageDbTestBase::testInsertOn_idSpecified
integer bigger than 2147483648 is bad on 32-bit php

1) WikiPageContentHandlerDbTest::testInsertOn_idSpecified
Failed asserting that -816015107 is identical to 3478952189.

> echo intval( 3478952189 );
-816015107

Change-Id: Ia2ab870dfe53bef873def3905ae93ea52d4ab2ad
2017-12-15 22:36:06 +00:00
Kunal Mehta
6fbea1aae4 WikiPageTest: Fix typo in @covers
Change-Id: I3f3a3b2a1f5e5aed61cd71db17ae6a6a01fe2ecb
2017-12-06 20:19:25 -08:00
addshore
7a46b709aa Tests for WikiPage::insertOn
Change-Id: I1bf7d19c4baaf0f720fcd6a1d9c16bf7489b5392
2017-12-05 11:29:20 -08:00
addshore
c4878eb281 Tests for WikiPage::updateIfNewerOn
This method is deprecated but due to refactoring
we should still test it.

Change-Id: I171ab731fff48ddd9fa54ef433881154377a2c7f
2017-12-05 11:29:19 -08:00
addshore
11dbd4ec8e Tests for WikiPage::updateRevisionOn
Bug: T180989
Change-Id: I245d9d467e3113bf49e06ee5c725205d4225671a
2017-12-05 11:29:19 -08:00
addshore
2af18246aa Test for WikiPge::insertProtectNullRevision
Bug: T180989
Change-Id: Iffee0bbe9fb18bb6c7f7af10b6405007468ac0b9
2017-12-05 11:29:18 -08:00
addshore
ece8130b6a Tests for WikiPage::newFromID
Bug: T180989
Change-Id: Idb4d7ce8ccc27226b0f00e2127acef6158dd32a9
2017-12-05 11:29:17 -08:00
addshore
d0f584696d Test for WikiPage::newFromRow
Bug: T180989
Change-Id: If630e3e3561ac2017a2b7c82ade842e86f8cb22e
2017-12-05 11:29:17 -08:00
addshore
5b217dfc9b Tests for WikiPage::insertRedirectEntry
Bug: T180989
Change-Id: I677202b22594c7fc8fcf97b805ae69726945f96d
2017-12-05 09:16:46 +00:00
addshore
47db625832 Test for WikiPage::updateRedirectOn
Bug: T180989
Change-Id: I798ded72142503e52395b45fe9ec71a215d5ab92
2017-12-04 13:11:26 +01:00
addshore
ec5d1fd6f9 Add test for WikiPage::updateCategoryCounts
Bug: T180989
Change-Id: Iff4bb885e5d385a7b3ec6169ee9a3e1e82d7d993
2017-12-04 09:46:33 +00:00
addshore
81c156b402 Refactor test for WikiPage::doRollback
This test was not running and a comment said
it was broken.
This patch refactors the test.

Bug: T180989
Change-Id: I46b73371e5fd65860fce6cc101bad6abfa20e91d
2017-12-04 09:46:28 +00:00
addshore
6c3e67f2be WikiPage tests @covers for doDeleteArticleReal & commitRollback
Bug: T180989
Change-Id: I70dcad9d527be4d91a88a14fe9787c53a7cf7d2f
2017-12-04 09:46:23 +00:00
addshore
1ceabc0f64 Split WikiPageTest into ContentHandler & NoContentHandler tests
Follow up to Iccdcd4a4f72c8b1329d36ff2e8699ba6b23c9ae7

Bug: T180989
Change-Id: Ib37a058586c7222ffe3ee5dc5f0e134ee18f0ff7
2017-12-04 10:46:02 +01:00
addshore
45a0481935 Cleanup WikiPageTest
Change-Id: Id95b7153c42ddcd391f966b75f54e00c13d7ce5a
2017-11-30 20:20:11 +01:00
jenkins-bot
fc5dced1ce Merge "Add new core tags" 2017-11-30 18:43:28 +00:00
petarpetkovic
62713be990 Add new core tags
Add tags to types of edits that get automatic edit summaries:
- Making a page a redirect
- Changing redirect target
- Changing an existing redirect into a non-redirect
- Blanking of the page
- Removing nearly all (more than 90%) content
- Rolling back an edit

Bug: T167656
Bug: T73236
Change-Id: Ie7f637fcec5ee659c1086e28e8ba21f470c45160
2017-11-30 10:29:58 -08:00
addshore
f963c76dfa Remove unused WikiPageTestContentHandlerUseDB (test)
This class had the wrong name so has not been run since
it was written in 2012.

In If5b1fa39610dbe366649f79beda58f4ea6d58c8f I fixed the
name but the tests fail, so lets just remove it and rewrite
the tests.

Change-Id: Iccdcd4a4f72c8b1329d36ff2e8699ba6b23c9ae7
2017-11-23 19:11:25 +00:00
Brad Jorsch
7d93d1d1cd Remove Article static methods deprecated in 1.24
The Article::selectFields(), Article::onArticleCreate(),
Article::onArticleDelete(), and Article::onArticleEdit() methods have
been deprecated in favor of the correponding WikiPage methods since
1.24. Remove them.

Change-Id: I30f3d88f8d28ccaebf5a858058e183112d29a1a7
2017-10-26 12:22:01 -04:00
MusikAnimal
d09554b6ef Add basic IP range support to Special:Contributions
This works by using the new table introduced with T156318.

The only thing that differs from normal Special:Contribs is we are
showing the IP address next to each entry. This is it how it is
displayed if you request to see newbie contributions:
https://en.wikipedia.org/wiki/Special:Contributions?contribs=newbie

For the time being, Special:DeletedContributions does not support
IP ranges. Various other irrelevant links such as Uploads and Logs
are also hidden.

Refer to P4725 for a way to automate creation of edits by random
IPs in your dev environment.

IP::isValidBlock() has been deprecated with this dependent change:
https://gerrit.wikimedia.org/r/#/c/373165/

Bug: T163562
Change-Id: Ice1bdae3d16cf365da14c6df0e8d91d2b914e064
2017-09-05 16:15:33 -04:00
Brad Jorsch
11cf01dd9a Add comment table and code to start using it
A subsequent patch will remove the old columns.

Bug: T166732
Change-Id: Ic3a434c061ed6e443ea072bc62dda09acbeeed7f
2017-08-30 15:05:00 +10:00
Bartosz Dziewoński
8785e4a5b3 Replace remaining uses of deprecated DB_SLAVE with DB_REPLICA
Change 950cf6016c took care of the most,
but a few remain, either outside of includes/ and maintenance/
directories (which that change was limited to), or in code introduced
afterwards.

Change-Id: I9c363d0219ea7e71cde520faba39406949a36d27
2017-08-05 10:10:26 +00:00
Kunal Mehta
d1cf48a397 build: Update mediawiki/mediawiki-codesniffer to 0.10.1
And auto-fix all errors.

The `<exclude-pattern>` stanzas are now included in the default ruleset
and don't need to be repeated.

Change-Id: I928af549dc88ac2c6cb82058f64c7c7f3111598a
2017-07-22 18:24:09 -07:00
Brad Jorsch
1aac0a2992 Wrap parser output in <div class="mw-parser-output">
This will allow CSS to target just the parser output, without also
accidentally targeting the edit form, diff tables, and so on.

Bug: T37247
Change-Id: If4eb5bf71f94fa366ec4eddb6964e8f4df6b824a
Depends-On: I330c6aa4aaee045614b1801ed34bc9e03be69650
Depends-On: I52a518fa44e017841fe78474012cd69823e0a41d
2017-05-08 05:32:03 +00:00
James D. Forrester
1e9c361960 tests: 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: I46261416f7603558dceb76ebe695a5cac274e417
2017-02-21 02:14:34 +00:00
daniel
e74264c071 Avoid joining against page table when finding a page's oldest revision.
Bug: T156537
Change-Id: Ifd27710cada823318ac3662d3c16323eb9a78839
2017-02-01 13:05:00 +01:00
This, that and the other
73224f4f8b User group memberships that expire
This patch adds an ug_expiry column to the user_groups table, a timestamp
giving a date when the user group expires. A new UserGroupMembership class,
based on the Block class, manages entries in this table.

When the expiry date passes, the row in user_groups is ignored, and will
eventually be purged from the DB when UserGroupMembership::insert is next
called. Old, expired user group memberships are not kept; instead, the log
entries are available to find the history of these memberships, similar
to the way it has always worked for blocks and protections.

Anyone getting user group info through the User object will get correct
information. However, code that reads the user_groups table directly will
now need to skip over rows with ug_expiry < wfTimestampNow(). See
UsersPager for an example of how to do this.

NULL is used to represent infinite (no) expiry, rather than a string
'infinity' or similar (except in the API). This allows existing user group
assignments and log entries, which are all infinite in duration, to be
treated the same as new, infinite-length memberships, without special
casing everything.

The whole thing is behind the temporary feature flag
$wgDisableUserGroupExpiry, in accordance with the WMF schema change policy.

The opportunity has been taken to refactor some static user-group-related
functions out of User into UserGroupMembership, and also to add a primary
key (ug_user, ug_group) to the user_groups table.

There are a few breaking changes:
- UserRightsProxy-like objects are now required to have a
  getGroupMemberships() function.
- $user->mGroups (on a User object) is no longer present.
- Some protected functions in UsersPager are altered or removed.
- The UsersPagerDoBatchLookups hook (unused in any Wikimedia Git-hosted
  extension) has a change of parameter.

Bug: T12493
Depends-On: Ia9616e1e35184fed9058d2d39afbe1038f56d7fa
Depends-On: I86eb1d5619347ce54a5f33a591417742ebe5d6f8
Change-Id: I93c955dc7a970f78e32aa503c01c67da30971d1a
2017-01-27 09:24:20 +00:00
Subin Siby
5eff86b740 Remove deprecated function Article::doEdit() and WikiPage::doEdit()
Bug: T61113
Bug: T154498
Change-Id: Ie6c1bb4ee5ee45ac2db432877a7038659231c091
2017-01-19 02:44:01 +00:00
Reedy
27f9e4af03 WikiPage::getText() was removed
Bug: T145728
Change-Id: I9e5ac149ad1780719b5c8f4e27048168cf33c0b9
2016-12-12 18:51:37 +00:00
Thiemo Mättig
00c3f09566 Remove empty lines from PHP and JavaScript comment blocks
This is a pure documentation change. It mostly removes empty lines from
comments (and entirely empty comments), as well as adds a few missing
documentation blocks and fixes a minor mistake. I hope it's ok to have
this in one patch. I can split it, please tell me.

Change-Id: I9668338602ac77b903ab6b02ff56bd52743c37c4
2016-12-09 09:01:06 +00:00
Reedy
ec6d6762ea Article::getAutosummary() and WikiPage::getAutosummary() were removed
Bug: T145728
Change-Id: I233571658b902c93a148a992ea99eb159551e732
2016-12-03 12:16:41 +00:00
Kunal Mehta
61adc1e146 Use namespaced ScopedCallback
The un-namespaced \ScopedCallback is deprecated.

Change-Id: Ie014d5a775ead66335a24acac9d339915884d1a4
2016-10-17 15:46:05 -07:00