Commit graph

57 commits

Author SHA1 Message Date
Kunal Mehta
cc5d9a92a2 build: Updating mediawiki/mediawiki-codesniffer to 24.0.0
Change-Id: I66b1775b7c1d36076d9ca78cbeb42787a743f2aa
2019-02-07 18:39:42 +00:00
Gergő Tisza
792b23d710
Fix exception language in MovePage
Follows up I8f6c9647ee.

Change-Id: Iff2941bfc9e14f52ddd33f0a3d522c5a0d594c3e
2019-01-17 15:56:07 -08:00
Gergő Tisza
e1d2c92ac6
Fix error reporting in MovePage
Bug: T210739
Change-Id: I8f6c9647ee949b33fd4daeae6aed6b94bb1988aa
2019-01-16 18:14:52 -08:00
Gergő Tisza
eda915cb7a
Fix missing ATOMIC_CANCELABLE in MovePage::move()
Follow-up to I4aaa8af50d684de.

Bug: T213168
Change-Id: I0566b37117b6c69d4043e77e6368bf79fa84e325
2019-01-08 11:37:27 -08:00
Alexia E. Smith
d81f57dc24 Can't call escaped() on a string.
Bug: T211442
Change-Id: Ica5b9cf380a646d9520d5307a937d1e51b7b0099
2018-12-10 13:32:12 -06:00
Alexia E. Smith
ea1781053e Cancel the transaction if the file fails to move. This prevents
losing files when there is a database error.

Bug: T211442
Change-Id: I4aaa8af50d684de9d72224d43dfe5209b930810f
2018-12-10 10:14:26 -06:00
daniel
db987c700a [MCR] Introduce SlotRoleHandler and SlotRoleRegistry
These new classes provide a mechanism for defining the
behavior of slots, like the content models it supports.
This acts as an extension point for extensions that need
to define custom slots, like the MediaInfo extension
for the SDC project.

Bug: T194046
Change-Id: Ia20c98eee819293199e541be75b5521f6413bc2f
2018-11-30 12:29:05 -08:00
Daimona Eaytoy
495331ff07 Add a Status and a $reason parameter to TitleMove hook
So that using this hook it's possible to prevent the move, also
providing some more context.
Also, clean error message: instead of going with "you do not have
permission blah blah" for *every* kind of error, use it only when the
error is actually about permissions, and use a generic message
otherwise.

Bug: T208907
Change-Id: I4733724075b7514e9db59e7be772d9409aa9da87
2018-11-13 08:51:02 +00:00
GeoffreyT2000
19dd287981 Increment edit count for all page moves
The user_editcount field should be incremented for all page moves, not just those done using Special:MovePage. Also, if talk pages and/or subpages are moved along with the base page, they will all be included in the edit count.

Bug: T195550
Change-Id: If75a45e4404ca7162b59bf85fa62a996383658b9
2018-10-26 23:35:01 +00:00
daniel
539cb2816a Avoid fatal when finding no base revision for a null revision.
Bug: T205675
Change-Id: Iae67649a1be9597086033ad34d9d00556ba35730
2018-10-04 19:54:31 +02:00
Brad Jorsch
56fddb98a1 Provide a RevisionRecord with the correct title after a move
Currently we're creating the null revision for the move before actually
updating the page's title, so when it gets passed through
RevisionRenderer the output uses the old page's title in the <h1>.

To make that null revision have the correct title, let's try simply
updating the page table before creating it instead. The ordering
shouldn't matter since this all happens in an atomic section.

Bug: T203661
Change-Id: I9ebdcbc566b11dea3a9bdd402ea4418c4e51b096
2018-09-06 14:05:17 -04: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
jenkins-bot
2f8e83821b Merge "Replace call_user_func_array(), part 2" 2018-06-09 14:25:26 +00:00
Max Semenik
6e956d55aa Replace call_user_func_array(), part 2
Uses new PHP 5.6 syntax like ...parameter unpacking and
calling anything looking like a callback to make the code more readable.
There are much more occurrences but this commit is intentionally limited
to an easily reviewable size.

In one occurrence, a simple conditional instead of trickery was much more readable.

This patch finishes all the easy stuf in the core, the remainder is either unobvious
or would result in smaller readability gains. It will be carefully dealt with in
further commits.

Change-Id: I79a16c48bfb98b75e5b99f2f6f4fa07b3ae02c5b
2018-06-07 20:19:26 -07:00
Kunal Mehta
d5e4bf920c Ensure $user is passed by reference in TitleMoveComplete hook on HHVM
Suggested by Anomie in T118683#3688320.

Bug: T118683
Change-Id: I57e05c5ae42c8b85d0a8f9631a459c5686b27893
2018-06-07 13:41:09 -07:00
Matěj Suchánek
18a2fd3268 Tag redirects from moves as new redirects
Bug: T184117
Change-Id: Ic9a0abcb530787f652e7d439ecc7cac5f603be56
2018-02-09 15:45:29 +00:00
Brad Jorsch
fa4a909def Replace more uses of "SELECT *"
With the introduction of CommentStore, selects from various table
require certain joins or column aliases for proper operation. The
upcoming actor table change, and the suggested title table change, will
add more such requirements.

Change-Id: Ic8213bff74b8350b15cd271d0ef252e63e7e79bd
2017-10-13 19:02:56 +00:00
Brad Jorsch
6ec1a31502 Handle comment truncation in CommentStore
Since the caller doesn't (and shouldn't) know whether CommentStore is
using the old or the new schema, it should leave truncation of comments
to CommentStore.

Change-Id: I92954c922514271d774518d6a6c28a01f33c88c2
2017-09-01 15:03:45 -04:00
WMDE-Fisch
6df9ed1ad6 update mediawiki-codesniffer to 0.11.0 and fix issues
- mostly auto fixes
- some too long lines fixed
- ignore amp space in one case  passing by reference

Change-Id: I6472f83bc3cbf4bd629d83050cc3319b19ec465c
2017-08-11 22:27:51 +02:00
Umherirrender
b5cddfb27b Remove empty lines at begin of function, if, foreach, switch
Organize phpcs.xml a bit

Change-Id: Ifb767729b481b4b686e6d6444cf48b1f580cc478
2017-07-01 11:34:16 +00:00
Umherirrender
55148b143e Use delete_and_move_reason in content language on move over redirect
Follows I9645f23c5d6132abb304e254b039036ebca4b064

Bug: T161993
Change-Id: I08426118947ef5a9ea887a973fdf0a9176639aab
2017-04-08 11:08:00 +02: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
This, that and the other
f3f2df07ec Add parameter to API modules to apply change tags to log entries
Adds support for tagging log entries for the block, import,
managetags, and move API modules, using a 'tags' parameter.

Bug: T97720
Change-Id: I9d75d2cece317a7704c4bc6d734ad3cafe24544e
2017-01-12 16:30:17 -06:00
MGChecker
2ee4c67286 Introduce separate log action for deleting pages on move
Since T106119, moves that overwrite a redirect produce a deletion log
entry. It should be possibleto identify such deletions within other ones.
Note that this patch only applies for actions in the future because there
is no way to easily identify these cases for the software (until now).

Bug: T145991
Change-Id: I3c006bca57351d82031c4fdce0c53f65d630b0d9
2016-11-13 01:27:04 +01:00
Aaron Schulz
0852a000a5 Add caching to ResourceLoaderWikiModule::preloadTitleInfo()
This is one of the top three DB queries showing up in xenon
reverse flamegraph profiling.

It works via a per-wiki check key that is bumped whenever
someone changes a .js or .css page on that wiki.

Change-Id: I73f419558864ba3403b4601a098f6aaf84a3e7c1
2016-10-20 20:54:11 +00:00
Kunal Mehta
f9b54ea843 MovePage: Check ContentHandler::canBeUsedOn()
If the old content model cannot be used on the new page title, the page
move should be disallowed.

Change-Id: I6078a4cde5a76a050dddedf59634d800765cbabf
2016-09-29 16:09:43 -07:00
Max Semenik
2b51bd1847 Fix function name case
Change-Id: Ibd4f682d2ed8500a50d85aae38f17281646f7c2d
2016-09-26 15:32:54 -07:00
Aaron Schulz
7cd8913897 Avoid INSERT..SELECT in MovePage
That construct has poor locking characteristics in terms of
auto-inc columns as well as not allowing such inserts concurrently
for statement-based replication. Also, the INSERT..SELECT did not
have an ORDER BY, which could lead to pr_id drift with statement
based replication.

Change-Id: I47ca89abcbe4598d3b56cf077a47055500a0647f
2016-08-19 11:31:44 -07:00
James D. Forrester
71e336981b MovePage: Fix old, old bug with moving over redirects
When moving over a redirect with no revs, there was a weird
hack to delete the old redirect page... without logs, or cleaning
up the orphaned revision. WHOOPS

Switched it to using the standard deletion, which seems to work.
Note this will produce a deletion log entry as well as a move log
entry. This may scare people.

Bug: T106119
Change-Id: I9645f23c5d6132abb304e254b039036ebca4b064
2016-07-30 12:08:26 +00:00
Aaron Schulz
3a922d36d8 Convert onTransactionIdle() callers to DeferredUpdate subclasses
* This puts the complex logic here after the commit step for
  all DBs, making the main multi-DB transaction more likely
  to be atomic. Previously, the idle callbacks could be hit
  bewteen DB commits.
* Enforce transactionality via AtomicSectionUpdate.
* Use $this instead of $that hacks for old PHP versions.

Change-Id: Idf7d54fdac6487f86907099680f5c1c4f5530b4e
2016-07-25 16:49:15 -07:00
addshore
818984e5cb Remove WatchedItemStore::getDefaultInstance
Change-Id: I0c7d706fabee8d1f6fcfbc4c568f375953de8058
2016-05-06 08:47:37 +00:00
Reedy
b5656b6953 Many more function case mismatches
Change-Id: I5d3a5eb8adea1ecbf136415bb9fd7a162633ccca
2016-03-19 00:20:58 +00:00
addshore
fee0afdc8a Move WatchedItem logic to WatchedItemStore
This also removes assumptions that when a page
in one Namespace should be watched / removed
that the page in the talk / subject ns for the
page should have the same action applied

This should maintain all backward compatability
for the WatchedItem class

This also includes tests written by:
 - WMDE-leszek
 - Addshore

Bug: T127956
Change-Id: Iad9abafe4417bb479151a3bfbee6e1c78a3afe3c
2016-03-08 15:41:22 +00:00
Matthew Flaschen
793499cde0 Add TitleMoveStarting, mirroring TitleMoveCompleting
This is a pre-requisite to fix a Flow move regression, T127785.

This allows running an atomic entirely within the move with the correct
ordering.

Bug: T127785
Change-Id: Ie772f737f917854e4cfefe52ec3bea4669c9efe0
2016-02-25 13:31:04 -05:00
Kunal Mehta
6e9b4f0e9c Convert all array() syntax to []
Per wikitech-l consensus:
 https://lists.wikimedia.org/pipermail/wikitech-l/2016-February/084821.html

Notes:
* Disabled CallTimePassByReference due to false positives (T127163)

Change-Id: I2c8ce713ce6600a0bb7bf67537c87044c7a45c4b
2016-02-17 01:33:00 -08:00
Aaron Schulz
87f54c37f1 Add $revision to TitleMoveCompleting for completeness
Follow up to 9cc2f62bf5.

Change-Id: Ibb48f6673b9be1863563262fff8bedc5aed7926c
2015-12-16 19:11:15 -08:00
Eric Evans
9cc2f62bf5 Pass created revision to TitleMoveComplete hook
The EventBus extension needs to forward the created (null) revision ID as
part of the page move event.  Looking this value up when the hook fires is
problematic, because without a connection to the master DB the query might
very well return nothing (if it races in before the entry is replicated to
the slave).

This changeset passes the newly created Revision on to the hook so that it
doesn't need to be queried separately.

Bug: T116786
Change-Id: I1b48e2904fc8d99f2cde604f274f79a2b47d7fc2
2015-12-16 18:35:56 -06:00
Aaron Schulz
d0b9ffed76 Make TitleMoveComplete hook events apply in transactions
* All updates for an event are atomic for the main DB.
* This follows-up 9e51328790 by reverting the auto-commit
  behavoir which was a side-effect of that change.
* Added TitleMoveCompleting hook with is a pre-commit version
  of the same hook. Various extension could benefit from the
  atomicity of running in the main transaction.

Change-Id: Ife5990bbedca1de78bcf83f2d6fdeeae8086ffad
2015-12-09 18:23:49 +00:00
Aaron Schulz
8f15bc8ec9 Restore TitleMoveComplete by-reference flags to avoid errors
They should be removed from extensions, but they don't
really hurt much for now.

Change-Id: I64b570e376062155afdf879c3ce85560127c6792
2015-10-27 18:15:39 +00:00
Aaron Schulz
9e51328790 Convert MovePage to startAtomic()/endAtomic()
* This makes moves of a page and its subpages atomic
  as one operation. Note that $wgMaximumMovedPages
  already bounds the number of page rows changed.
* The TitleMoveComplete hook will fire for all
  titles after the operation rather than after
  each title move.
* Remove LocalFile comment about it commiting the
  transaction because LocalFile::lock()/unlock()
  check trxLevel() and reference count.

Change-Id: Ic7f6964f94f0b0f0bedc27012e5b5b012a4afdb2
2015-10-21 18:34:26 +00:00
jenkins-bot
f6b7ffab94 Merge "Migrate move protect log to new log system" 2015-08-18 23:17:03 +00:00
umherirrender
3964b4cc05 Migrate move protect log to new log system
Migrate the move protect log as first sub type of the protection log,
because it does not have complex log parameter, which needs some way of
handling/migration.
It also keeps the gerrit change smaller and hopefully makes review
easier.
The other sub types of the protection log will be migrated in a later
patch set.

This allows use of gender on Special:Log. Old message is kept for use
in IRC. A test was added to ensure an unchanged IRC message.

Bug: T47988
Change-Id: I57b3bd8a7dc823acdbb56520d2364f5542283373
2015-08-18 22:20:35 +00:00
Kunal Mehta
0ce88ddfb2 Populate rev_content_model when a move causes default content model to change
If the default content model changes due to a page move, a NULL in
rev_content_model will now reference the new default, which is not how
the revision was serialized, causing an exception to be thrown.

This was caused by a5bc9f49cd, since previously NULL would use the
correct, but techncially inaccurate, page_content_model.

Bug: T105260
Change-Id: I0c29d0e657ad0b656e5da6ba365f337229ad4dfd
2015-07-24 15:58:22 -07:00
Kunal Mehta
75c813cc9a MovePage: Move target existence check into isValidMove()
The target existence check is not dependent upon the user who is making
the move, so move it into MovePage::isValidMove() instead of
MovePage::checkPermissions() which not all callers will call.

Bug: T97536
Change-Id: I3aad1455ad4c064cbeaf35221a00ca6baba97c33
2015-04-29 10:36:03 -07:00
Aaron Schulz
5085a4b5cf Made wfFindFile/wfLocalFile callers use explicit "latest" flags
* Callers that should not use caches won't
* Aliased the old "bypassCache" param to "latest"

bug: T89184
Change-Id: I9f79e5942ced4ae13ba4de0b4c62908cc746e777
2015-03-06 04:18:50 +00:00
Amir E. Aharoni
5238644610 Shorten long lines in MovePage.php to make phpcs pass
Change-Id: I4b6b2975f8e2b9508f0a78fb176093974c935cf1
2015-03-03 22:02:23 +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
jenkins-bot
c39aefd439 Merge "Fix fatal error in I0349cfe0e322" 2014-11-04 06:53:31 +00:00
This, that and the other
60fd612e0e Fix fatal error in I0349cfe0e322
Change-Id: I4ac41d56c2e0f98cd8f026c7deac1e8ab69e8d54
2014-11-04 17:44:19 +11:00
jenkins-bot
a5aa9f0b95 Merge "Update article count when pages are moved" 2014-11-04 06:25:07 +00:00