Commit graph

125 commits

Author SHA1 Message Date
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
jenkins-bot
b7625d63a6 Merge "Introduce ContentHandler::getSecondaryDataUpdates." 2018-09-17 14:06:19 +00:00
daniel
7960d5385f Introduce ContentHandler::getSecondaryDataUpdates.
This adds getSecondaryDataUpdates and getDeletionUpdates
to ContentHandler, and updates WikiPage and DerivedPageDataUpdates
to handle DataUpdates from all slots.

Bug: T194038
Bug: T194037
Change-Id: I75c96318f58a5cdda48484f7040ae41e6f42392a
2018-09-14 16:18:18 +02:00
daniel
4835a75ec5 Use RevisionRenderer for rendering ParserOutput
Bug: T174035
Bug: T174036
Change-Id: I1085b05d635dd954c143c8a398fae909632ba0a9
2018-09-11 15:25:39 +00:00
jenkins-bot
809fd6b9b5 Merge "Make warning about deprecated SlotDiffRenderer wrapper less noisy" 2018-08-27 03:58:36 +00:00
Gergő Tisza
34e4e81011
Make warning about deprecated SlotDiffRenderer wrapper less noisy
Bug: T202686
Change-Id: I7623daa32e460ce131e1b27eb6e4397dc572612f
2018-08-26 21:00:02 +02:00
Brad Jorsch
a9033efb28 MCR: Add temporary web UI mcrundo action
Since SDC doesn't actually require the edit form to handle multi-slot
editing, updating EditPage with its normal undo handling is being put
off for later. But in the mean time we still want some sort of "undo" to
work, hence this mcrundo that doesn't allow for editing.

Bug: T200216
Change-Id: I1f11d8ed141cb11576d2df883856d03e8f64bd38
Depends-On: Iedd9bf6c057e8b396a575bab700b15bd38b32cc9
2018-08-23 16:15:14 +00:00
Gergő Tisza
d31580eeb0
[MCR] Render multi-slot diffs
Move logic for rendering a diff between two content objects out of
DifferenceEngine, into a new SlotDiffRenderer class. Make
DifferenceEngine use multiple SlotDiffRenderers, one per slot.

This separates the class tree for changing high-level diff properties
such as the header or the revision selection method (same as before:
subclass DifferenceEngine and override ContentHandler::getDiffEngineClass
or implement GetDifferenceEngine) and the one for changing the actual
diff rendering for a given content type (subclass SlotDiffRenderer and
override ContentHandler::getSlotDiffRenderer or implement
GetSlotDiffRenderer). To keep B/C, when SlotDiffRenderer is not overridden
for a given content type but DifferenceEngine is, that DifferenceEngine
will be used instead.
The weak point of the scheme is overriding the DifferenceEngine methods
passing control to the SlotDiffRenderers (the ones calling
getDifferenceEngines), without calling the parent. These are:
showDiffStyle, getDiffBody, getDiffBodyCacheKeyParams. Extensions doing
that will probably break in unpredictable ways (most likely, only
showing the main slot diff). Nothing in gerrit does it, at least.

A new GetSlotDiffRenderer hook is added to modify rendering for content
models not owned by the extension, much like how GetDifferenceEngine
works.

Also deprecates public access to mNewRev/mOldRev and creates public
getters instead. DifferenceEngine never supported external changes to
those properties, this just acknowledges it.

Bug: T194731
Change-Id: I2f8a9dbebd2290b7feafb20e2bb2a2693e18ba11
Depends-On: I04e885a33bfce5bccc807b9bcfe1eaa577a9fd47
Depends-On: I203d8895bf436b7fee53fe4718dede8a3b1768bc
2018-08-20 15:39:12 +02:00
Gergő Tisza
47b5d95f12 Create DifferenceEngine before calling GetDifferenceEngine
This way the hook is able to consider what kind of DifferenceEngine
was created by default, or even wrap/decorate it.

Change-Id: Ibb6b1b087a2dda445be2b5e8c7518c7d169b5192
2018-08-20 13:32:49 +00:00
Aryeh Gregor
90d4f56fe4 Mass conversion of $wgContLang to service
Brought to you by vim macros.

Bug: T200246
Change-Id: I79e919f4553e3bd3eb714073fed7a43051b4fb2a
2018-08-11 22:44:29 -06:00
Brad Jorsch
7e7e84a53e Hard-deprecate ContentHandler::makeParserOptions()
Followup to I01373b29.

Bug: T194263
Change-Id: I8c5a2a1485d515373d1a0005ee0f5ee782690a2c
Depends-On: I2260fe7322cace9003c3c17be95cfba8df4bdbbe
Depends-On: I7e6a17466ba17f85b4f247b329a0d248855abdd1
Depends-On: I254a583b7f7ddd1797aa40f0ddfb973161185a49
Depends-On: Ib8ed827012c7bd73fcdaa6c0c6edd44869c79f14
Depends-On: Ia95f3e2c1ea944366ff9a478c3c86f8565023394
Depends-On: I4b591969166acdd73ed70b117a7a135d993fa42a
2018-07-13 14:33:00 -04:00
Brad Jorsch
c6810d74d1 Deprecate ContentHandler::makeParserOptions()
Having a different ParserOptions for each content model isn't feasible
in an MCR world. And the only thing using this was Wikibase, which has
been fixed to do what it needs in a different way.

Bug: T194263
Change-Id: I01373b29ee25fa9346c6b0317155be4ccdc8c515
2018-07-13 14:32:59 -04:00
Umherirrender
130ec2523d Fix PhanTypeMismatchDeclaredParam
Auto fix MediaWiki.Commenting.FunctionComment.DefaultNullTypeParam sniff

Change-Id: I865323fd0295aabd06f3e3c75e0e5043fb31069e
2018-07-07 00:34:30 +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
Stanislav Malyshev
9a3d33107b Add cleanup for handlers cache.
This is useful if we want to override certain handler for testing
but have no way to remove it from cache otherwise.

Change-Id: Icb4f9360c6e7684d15e91a7009a5a3a3e2febb37
2018-03-15 15:36:47 -07: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
Framawiki
41dcd3f25f ContentHandler: simplify tag tests
Follows up 62713be990.

Change-Id: Id1f7e6ae470b461e26ef8b7346f715873ccea4c9
2017-12-15 04:28:28 +00:00
ryan10145
19c45cdb16 Changed Instances of rawParams() to plaintextParams()
Bug: T182213
Change-Id: Ibf24dee5ea19092e8a38e57f34c98f513d4c9b21
2017-12-07 20:20:40 +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
Umherirrender
9b8b314992 Fix spacing for @param and indent of function comments
In phpcs.xml rename renamed sniffs and add the failing sniffs,
because now the whole sniff is no longer excluded.

Change-Id: If5b0bd16028761abc2c47ace9e97d37ad14bb36f
2017-08-15 14:33:29 +00:00
Umherirrender
a9007e8baf Add missing & to @param documentation to match functon call
Change-Id: I81e68310abcbc59964b22e0e74842d509f6b1fb9
2017-08-11 18:47:46 +02: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
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
Brad Jorsch
0facbe3e3d Try harder to avoid parser cache pollution
* ParserOptions is reorganized so it knows all the options and their
  defaults, and can report whether the non-key options are at their
  defaults.
* Definition of the "canonical" ParserOptions (which is unfortunately
  different from the "default" ParserOptions) is moved from
  ContentHandler to ParserOptions.
* WikiPage uses this to throw an exception if it's asked to cache
  with options that aren't used in the cache key.
* ParserCache gets some temporary code to try to avoid a massive cache
  stampede on upgrade.

Bug: T110269
Change-Id: I7fb9ffca96e6bd04db44d2d5f2509ec96ad9371f
Depends-On: I4070a8f51927121f690469716625db4a1064dea5
2017-06-05 14:17:28 +00:00
jenkins-bot
aa3319c4c0 Merge "Miscellaneous indentation tweaks" 2017-02-28 18:38:36 +00:00
Bartosz Dziewoński
ecdef925bb Miscellaneous indentation tweaks
I was bored. What? Don't look at me that way.

I mostly targetted mixed tabs and spaces, but others were not spared.
Note that some of the whitespace changes are inside HTML output,
extended regexps or SQL snippets.

Change-Id: Ie206cc946459f6befcfc2d520e35ad3ea3c0f1e0
2017-02-27 19:23:54 +01: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
Stanislav Malyshev
fb44ca9094 Add GetContentModels hook to allow extensions to enumerate dynamic content models.
Bug: T155139
Change-Id: Icb41c470dfa4638676eb3ba0e74f437e85acc792
2017-02-02 12:00:42 -08:00
Stanislav Malyshev
8de54f8349 Add content model indexing
Bug: T156371
Change-Id: I1514f9db70870ec05b30153cc56558af0a28b8c9
2017-01-26 15:42:52 -08:00
rlot
99800a9e03 Removed deprecated ContentHandler hooks.
Plus removed unused "ContentHandler::runLegacyHooks"

Bug: T154498
Change-Id: Ie398fd4e06d3e286fe8e24112d0c8b4ac7d883dc
2017-01-18 21:19:17 +00:00
mynk-96
037c58d9b1 moved Exception classes from ContentHandler.php
Bug: T153243
Change-Id: Ieb37b34e76441c5f68ec565c43421c50ac9be7e7
2016-12-26 14:31:39 +00:00
Reedy
11a0f7d858 Remove ContentHandler::deprecated()
Now unused, replaced with wfDeprecated() calls specifically

Bug: T145728
Change-Id: Id269bcd2958f23ecbc7f4f06a8c3ab5873c53117
2016-10-12 23:41:18 +00:00
Reedy
dee0d1ce4e Mark 3 hooks deprecated by ContentHandler as such
ArticleViewCustom, EditPageGetDiffText and EditPageGetPreviewText hooks
now marked as deprecated in 1.21.

TitleIsCssOrJsPage and TitleIsWikitextPage deprecation version dropped
from 1.25 to 1.21 to match other hooks.

Bug: T145728
Bug: T147382
Bug: T147383
Bug: T147384
Bug: T147385
Bug: T147386
Change-Id: I59b6b9f253857eb1040dad879a71e0d8cf141553
2016-10-05 23:41:14 +00:00
Fomafix
a4645dc202 Directly use Language::factory instead of wfGetLangObj
figureMessage always returns a valid language code.

Change-Id: Ifa11ca278e7a6f49781846bb6d1eec94669999f3
2016-09-24 12:18:13 +02:00
Brian Wolff
386bed1ffd Allow undoing edits that change content model if top
This allows people to revert content model changes
using the undo button, provided that we are undoing
the topmost edit (Otherwise it may get confusing
if you try to undo an edit in the middle of the
history that changes content model).

Bug: T145044
Change-Id: Ic528f65d0dc581c4e241a22f19c512e02aeaa9e7
2016-09-08 20:19:40 -07:00
Kunal Mehta
a94311363f ContentHandler: Remove entirely-unused mModelName property
This property isn't documented anywhere nor used anywhere.

Change-Id: I37b20260c6abbec49364b31183dd2337be44846b
2016-09-07 23:10:12 -07:00
Kunal Mehta
35e511086b Don't throw exceptions in ContentHandler::getUndoContent()
The method is not documented to throw any exceptions, and already
returns false on failure, and it can be seen as a failure case when the
content models are not the same.

Bug: T145044
Change-Id: I0394d19cd65f9dd3ee350d2cde95afb11ab9e7f4
2016-09-07 20:52:19 -07:00
Aaron Schulz
950cf6016c Rename DB_SLAVE constant to DB_REPLICA
This is more consistent with LoadBalancer, modern, and inclusive
of master/master mysql, NDB cluster, and MariaDB galera cluster.

The old constant is an alias now.

Change-Id: I0b37299ecb439cc446ffbe8c341365d1eef45849
2016-09-05 22:55:53 -07:00
jenkins-bot
4b70bc2b28 Merge "Extract ParserOutput search index data fields from WikiTextContentHandler" 2016-08-19 18:40:17 +00:00
aude
64ee3d3269 Extract ParserOutput search index data fields from WikiTextContentHandler
Bug: T142491
Change-Id: I69b010b893135e53fac7f16f4b927b8fbcba06d2
2016-08-19 09:26:17 -04:00
Kunal Mehta
4b5c1745ec Allow marking legacy ContentHandler hooks as deprecated
Instead of having a single development flag that controls whether all
the hooks emit warnings, use the standard hook deprecation method to
mark individual hooks as deprecated once we have determined that their
usage is minimal.

Change-Id: I9a00ae131cb7f609c1d44926d1f6547089f70c34
2016-08-18 17:43:49 +00:00
Stanislav Malyshev
add1ebe2ab Make content handlers assemble content for search
Bug: T89733
Change-Id: Ie45de496ecc826211d98eea3a410c7639b4be0a4
2016-07-26 13:08:45 -07:00
Stanislav Malyshev
86b55ad03c Create API to allow content handlers to handle structured data definitions
Change-Id: Ia1738803c42f6114575587c1c838fec62b6f54aa
Bug: T89733
2016-07-06 13:41:20 -07:00
Thiemo Mättig
c415767e0e Add actual documentation for ContentHandler::getActionOverrides
Change-Id: I7fd803204ad137dd3510ea321ff7e6fa11d910c0
2016-05-18 15:49:26 +02:00
Aaron Schulz
bd863cc1f3 Avoid master queries in getAutoDeleteReason()
This largely used the slaves anyway, but not for certain bits.

Bug: T92357
Change-Id: I909a14b25a959ee28960aa7aa3d799c5f10988d1
2016-04-28 14:26:38 -07:00
Reedy
4277983737 Fix undefined $modelId in MWUnknownContentModelException
Change-Id: I13b93cc1e9d7c050765fab5d8de4e17ca4319dc1
2016-03-14 21:57:03 +00:00
Thiemo Mättig
da9cf2df1a Make use of …::class feature in ContentHandler/DatabaseUpdater
Change-Id: Ic0d51a41c50f52e1fbdab58e3b63319caa5c7d1d
2016-03-14 16:54:50 +01:00
aude
437f60f358 Add ContentHandler::supportsCategories method
and check for this in WikiPage::doEditUpdates before
inserting a new CategoryMembershipChangeJob.

Some content models like the Wikibase ones do not
have categories and it's wasteful to add these jobs
for all Wikibase edits.

Bug: T126977
Change-Id: I2c54a4ba1546445dc41101e15cb83a2c6cc2b1c9
2016-03-02 15:20:56 +01: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
Bene
9e3e3306b0 Allow callbacks to be passed to $wgContentHandlers
Change-Id: Icf980313a6e7fcc83f5183c450b0a824353596b8
2016-02-06 09:48:11 +01:00