Commit graph

623 commits

Author SHA1 Message Date
Aaron Schulz
a98e6808ee Fix incorrect arguments to prepareContent() call in WikiPage
Bug: T198483
Change-Id: I7115a9f8c7d5a6d84b77149fda266ad05ff3274d
2018-07-02 14:46:13 +00:00
Matěj Suchánek
8ed6eed7a7 WikiPage: Do not set "undid revision ID" for rollbacks
It causes them to be tagged with the "mw-undo" tag, in addition to the
"mw-rollback" tag they already have.

Bug: T190374
Change-Id: Ia447a107f0844cfef4a51a72fdec7aeea0480c70
2018-06-29 22:55:08 +02:00
Kevin Israel
a50f61009d MWNamespace: Add getCategoryLinkType() method
This method returns the value used as cl_type for category links that
are "from" pages within the namespace, and is added to avoid duplication
of code across a few classes.

Change-Id: I4e55932a5a27858cfedb12009b455fcd02f9b5df
2018-06-29 15:37:11 +00:00
Matěj Suchánek
49aa084113 Mark rollbacking revision as patrolled
I just copy & pasted lines 1833-1838.

Bug: T198449
Change-Id: I5d356b074e048a2325a64bfe2c1e652c640c560f
2018-06-29 07:49:18 +00:00
Gergő Tisza
9f4da9f177
Fix table locking in WikiPage::doDeleteArticleReal
This reverts a recent change that caused the table array and the
join array to have mismatching keys, so that the select was a
cartesian product of page and revision_comment_temp (ie. any
page deletion locked the whole revision_comment_temp table).

Bug: T198350
Change-Id: Ifb6f0409d4f210d3ecb1da03f59aaba7e229e89e
2018-06-28 18:33:50 +02:00
Umherirrender
84f59b44bf Make WikiPage::convertSelectType protected
When override WikiPage this function is needed
to map the string to const

Change-Id: I4e4d597a77c859ad17bd6c29bed875fb4248b5fb
2018-06-24 12:26:32 +00:00
daniel
c7564daa80
[MCR] Rollback for all slots
Bug: T194034
Change-Id: Ifd23bc1cd64ddc090e1c1c26aacda37e8ba7a18b
2018-06-23 15:14:47 +02:00
jenkins-bot
712396e716 Merge "Make undo fail if more than just the main slot is affected." 2018-06-23 08:59:37 +00:00
daniel
ef1edcea3c Make undo fail if more than just the main slot is affected.
Bug: T194412
Change-Id: Ifdf9bc9d884844f9ffeb8019d9b13d5737862063
2018-06-22 15:18:41 +02:00
daniel
731a113aac MCR: rename $baseRevId paramter to match actual semantics.
The $baseRevId in WikiPage::doEditContent is used only to indicate what
revision an edit reverted to. It is not used to indicate the actual base
revision of an edit in any sense. Specifically, EditPage never sets it.

So, this change renames the parameter to $originalRevId to match $undidRevId.
It also renames PageUpdater::setBaseRevisionId to setOriginalRevisionId.
Further, this introduces a paramter to PageUpdater::hasEditConflict():

Before this change, PageUpdater::hasEditConflict() was based on the
revision set via PageUpdater::setBaseRevisionId(), assuming the semantics
of "base revision" used by EditPage. However, this is NOT how the $baseRevId
parameter in WikiPage works.

Bug: T197685
Change-Id: Ib78257d4d6ee7c4ec093d5706904c599b02c73e0
2018-06-22 11:57:59 +00:00
jenkins-bot
84fa176c9c Merge "Avoid deprecated LinkCache::singleton()" 2018-06-14 23:48:54 +00: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
Kunal Mehta
c4e5a9dd97 Avoid deprecated LinkCache::singleton()
Change-Id: Ie0e5c4ef0fe6ec896378bb2433af0898655dd907
2018-06-10 23:55:11 -07:00
Max Semenik
1e680456b4 Get rid of call_user_func(_array)(), part 3
Also cleaned up nearby code in a couple places.

Change-Id: Ibf44ee7c0ceb739d7e79406e4ff39303c316e285
2018-06-10 02:21:24 +00:00
jenkins-bot
369b34f0ae Merge "Record a log entry on page creation" 2018-06-03 07:43:35 +00:00
Bartosz Dziewoński
485f66f174 Use PHP 7 '??' operator instead of '?:' with 'isset()' where convenient
Find: /isset\(\s*([^()]+?)\s*\)\s*\?\s*\1\s*:\s*/
Replace with: '\1 ?? '

(Everywhere except includes/PHPVersionCheck.php)
(Then, manually fix some line length and indentation issues)

Then manually reviewed the replacements for cases where confusing
operator precedence would result in incorrect results
(fixing those in I478db046a1cc162c6767003ce45c9b56270f3372).

Change-Id: I33b421c8cb11cdd4ce896488c9ff5313f03a38cf
2018-05-30 18:06:13 -07:00
Bartosz Dziewoński
b191e5e860 Use PHP 7 '<=>' operator in 'sort()' callbacks
`$a <=> $b` returns `-1` if `$a` is lesser, `1` if `$b` is lesser,
and `0` if they are equal, which are exactly the values 'sort()'
callbacks are supposed to return.

It also enables the neat idiom `$a[x] <=> $b[x] ?: $a[y] <=> $b[y]`
to sort arrays of objects first by 'x', and by 'y' if they are equal.

* Replace a common pattern like `return $a < $b ? -1 : 1` with the
  new operator (and similar patterns with the variables, the numbers
  or the comparison inverted). Some of the uses were previously not
  correctly handling the variables being equal; this is now
  automatically fixed.
* Also replace `return $a - $b`, which is equivalent to `return
  $a <=> $b` if both variables are integers but less intuitive.
* (Do not replace `return strcmp( $a, $b )`. It is also equivalent
  when both variables are strings, but if any of the variables is not,
  'strcmp()' converts it to a string before comparison, which could
  give different results than '<=>', so changing this would require
  careful review and isn't worth it.)
* Also replace `return $a > $b`, which presumably sort of works most
  of the time (returns `1` if `$b` is lesser, and `0` if they are
  equal or `$a` is lesser) but is erroneous.

Change-Id: I19a3d2fc8fcdb208c10330bd7a42c4e05d7f5cf3
2018-05-30 18:05:20 -07: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
Aaron Schulz
c8085ad43f rdbms: make IDatabase::onTransaction* methods pass the DB handle for convenience
Change-Id: Ia45a26830d62326b103593268fbf34c907783c90
2018-04-24 16:45:11 -07:00
jenkins-bot
2224e31507 Merge "Drop archive.ar_text and ar_flags" 2018-04-23 20:15:26 +00:00
Aaron Schulz
766cdc944b Use CONN_TRX_AUTO in WikiPage speculative revision ID callback
This increases the odds of seeing newer data and not guessing a
wrong revision ID due to getting raced out between stash and save.

Change-Id: Icf0f9b9c4d559f4ddf05a4ca8679e3c4dca5620a
2018-04-23 17:24:30 +00:00
jenkins-bot
d672dab1c9 Merge "Don't pass USE INDEX to a $dbType parameter" 2018-04-19 22:20:50 +00:00
Reedy
16f1dc7549 Don't pass USE INDEX to a $dbType parameter
Bug: T192584
Change-Id: Ia2b761bad570532696419b4f23f84bc85ff2c0e8
2018-04-19 19:02:09 +00:00
Aaron Schulz
de75c4e63b Avoid triggering Category::refreshCounts() on HTTP GET requests
Trigger count refreshes more often during updates instead.

Change-Id: I0f4575e648109befb86a2c8f08b491a132fe56c3
2018-04-19 04:45:24 +00:00
Reedy
904210492c Follow-up 2c74b04356: Restore use of 'clearyourcache' message
Bug: T191800
Change-Id: I632fff6489e929847e7abc1d944277e3b0358314
2018-04-18 18:39:09 +00:00
James D. Forrester
225b462a50 Drop deprecated EnableAPI and EnableWriteAPI settings
The siteinfo API response's 'writeapi' value is now hard-set to true,
as are the ResourceLoader variables wgEnableAPI and wgEnableWriteAPI,
to be deprecated later.

Bug: T115414
Change-Id: I54ff9428b247ba203d67aba079149393f323d5a9
2018-04-18 00:30:34 +00:00
jenkins-bot
8bda7b9dcd Merge "Replace rc_patrolled values with contants, part I" 2018-04-12 20:56:54 +00:00
Amir Sarabadani
00a4f0939c Replace rc_patrolled values with contants, part I
This constants has been recently introduced and it's good to use them

Change-Id: I8ce56dc95de3e49610dca71c00965ca1ac74bcf0
2018-04-11 22:35:31 +02:00
Brad Jorsch
b3f258c360 WikiPage: Avoid locking comment and actor tables in doDeleteArticleReal
The existing code was using FOR UPDATE when selecting the revision table
rows to be added to the archive table, which meant it was locking not
only `revision`, `revision_comment_temp`, and `revision_actor_temp` that
are being updated but also `comment` and `actor` that we have no
intention of touching. And since those both are intended to be widely
shared, that's likely to lead to unnecessary lock contention.

To avoid that, we make two queries: one against only the rows we want to
lock with FOR UPDATE, and the second to actually fetch the data without
FOR UPDATE.

Bug: T191892
Change-Id: I40ecf1786249c886a5ff25f29ec01edee3ff205d
2018-04-11 15:26:54 +00:00
Brad Jorsch
21c6ae1163 Drop archive.ar_text and ar_flags
This should have been done long ago. Now it is being done.

This also changes ar_text_id to NOT NULL, since it should never be null
anymore, and DEFAULT 0 in preparation for MCR stopping writing it.

Bug: T33223
Change-Id: I18f1c740b7537c7dc3cfeba9b241d0a9f31caa34
2018-04-03 12:54:27 -04:00
Amir Sarabadani
728321e113 Make autopatrol third option in rc_patrolled and use it in API
Bug: T184791
Change-Id: If64ba8b845b122a87f20646dddf72ef257b793cb
2018-04-03 18:44:37 +02:00
jenkins-bot
33a220ef4f Merge "Revert "Pass revision being reverted to edit code"" 2018-03-27 14:23:20 +00:00
MaxSem
19770d6f65 Revert "Pass revision being reverted to edit code"
Too many regressions, doing it the different way.

This reverts commit b7737ebed1.

Bug: T190374
Change-Id: I12cb7470aeb7852ddea319c7e499ca3a7b45c84c
2018-03-26 22:28:46 +00:00
Aaron Schulz
c6d5f531d3 Make WikiPage::doViewUpdates use a PRESEND deferred update
This is better than a dubious try/catch which had the off chance
of letting partial implicit transactions be committed.

Change-Id: Ied4870df166dc5a8224866284ea6e1958e65f499
2018-03-26 19:32:07 +00:00
Max Semenik
b7737ebed1 Pass revision being reverted to edit code
Otherwise, PageContentSaveComplete hook users are unable to detect
reverts.

Bug: T189819
Change-Id: Ib1dc0c323a9a5083b462421c68575fc22ad4af35
2018-03-16 14:33:45 -07:00
Fomafix
55185c2e39 Article.php: Use BCP 47 language code for HTML attribute lang
Change-Id: If2194fbb98cbab284aba74e127cc3953a5714b9b
2018-03-07 14:18:11 +01:00
Kunal Mehta
a21ae2edac WikiPage: Avoid $user variable reuse in doDeleteArticleReal()
$user was being used to represent the person who was deleting the page as
well as a variable when dermining the person who made an edit in each
row as it was moved to the archive table.

Make it unambigious which variable is used to represent the person deleting
the article by renaming it to $deleter.

Bug: T188479
Change-Id: Ia06e7fb840ebc68446127352e336a7e33c813042
2018-02-27 21:56:50 -08:00
Brad Jorsch
ccc1c08089 Update more forms to limit comments by codepoints rather than bytes
This updates the deletion forms, Special:Block, Special:EditTags,
Special:MovePage, Special:RevisionDelete, Special:Undelete, and
Special:UserRights to limit by code point count rather than by byte (or,
in some cases, by UTF-16 code unit).

Bug: T185948
Change-Id: I20d11d7cc4f58902cbcb6dda70af533bce6dd170
2018-02-26 13:16:19 -05: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
jenkins-bot
3f59cb9f3a Merge "Pass change tags to NewRevisionFromEditComplete hook" 2018-02-19 22:55:54 +00:00
Eddie Greiner-Petter
d6cbf3ff43 site_stats: Unbreak counting newly created pages
Fixes a bug introduced on 331c9f9e2e that stopped newly created pages
from incrementing the counter of ss_total_pages in site_stats. The array
accepted by SiteStatsUpdate::factory is not meant to take a value with
the key 'total'. What's meant here is 'pages'. Let's change the variable
name as well to avoid confusion in the future.

Change-Id: I9c82d926206d9b46f333c6f6cb9d3c7d41db3a53
2018-02-16 22:20:29 +01:00
Brad Jorsch
2791fb0861 Hard-deprecate ParserOutput stateful transform methods
This also removes all the in-core calls that had been kept for the
benefit of extensions, and causes them to not have any effect since
anything that had been calling them was already either a no-op or will
probably be broken now that nothing in core is setting or checking the
flags.

Change-Id: Id22c1a5a6d6a249debb14063ae3f8838d105b634
2018-02-13 12:28:36 -05:00
Aaron Schulz
331c9f9e2e Migrage callers away from SiteStatsUpdate::__construct()
Change-Id: I4d81f5f87c93865e8fe1b7986074070376eab8f9
2018-02-13 03:48:36 +00: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
52d89ccc1f Fix back-compat method Article::updateRedirectOn
No reason to set $lastRevIsRedirect to null before pass it as argument

Change-Id: I5e3c54d828a381c682725a43e322e660186b38cb
2018-02-05 05:24:20 +00:00
Umherirrender
3124a990a2 Use ::class to resolve class names in includes files
This helps to find renamed or misspelled classes earlier.
Phan will check the class names

Change-Id: I07a925c2a9404b0865e8a8703864ded9d14aa769
2018-01-27 20:34:29 +01:00
addshore
b376e4bbda Remove deprecated PreparedEdit properties
The following properties of PreparedEdit were deprecated in
1.21 and have been removed:
  * PreparedEdit->newText
  * PreparedEdit->oldText
  * PreparedEdit->pst

These have no use left in core or extensions.

Change-Id: Ic48c817aaf3fbb6d5f33678fcb4843180f0bc9fb
2018-01-26 16:57:13 -08:00
Umherirrender
4a790fdd3c Bypass wfGetDB when LoadBalancer is used in scope
wfGetDB calls LoadBalander::getConnection for $wiki=false,
when there is already a LoadBalancer in scope, call it directly

Change-Id: I4e29fd4e93a0d1f274e61af99c96021d3d06f8f3
2018-01-20 21:07:17 +01:00