Commit graph

206 commits

Author SHA1 Message Date
Amir Sarabadani
3dc1b21110 ContentHandler: Avoding saving in ParserCache in search index jobs
This is adding a lot of PC entries for pages that possibly won't ever
be visited. This is similar to what Refreshlinks job does and doesn't
save at all.

Bug: T285993
Change-Id: I68c14932d568795ab54074e073eab2a80517ed70
2022-02-10 01:07:44 +00:00
daniel
f5623b6082 content: Document use cases for JsonContent
This also marks JsonContentHandler as stable to extend, which
was missing from the parent patch.

Bug: T275976
Change-Id: Ied8c2930017bc9ec28e522a774da1050b2b1ffde
2022-02-08 22:39:45 +00:00
jenkins-bot
289e2cb656 Merge "rdbms: Hard-deprecate legacy cruft from introduction of ResultWrapper" 2022-01-12 06:17:27 +00:00
TChin
47adb6d65a Refactor global variables to use MediaWikiServices instead
Automatically refactors wg prefixed globals to use MediaWikiServices config using Rector. Doesn't include files that set globals or files that fail CI.

Rector Gist: https://gist.github.com/tchin25/7cc54f6d23aedef010b22e4dfbead228

* This patch uses a modified source code rector library for our specific use case and the rector will have different effects without it.

A writeup for future reference is here: https://meta.wikimedia.org/wiki/User:TChin_(WMF)/Using_Rector_On_MediaWiki

Change-Id: I1a691f01cd82e60bf41207d32501edb4b9835e37
2022-01-10 13:55:53 -05:00
Amir Sarabadani
87e1a6a2be rdbms: Hard-deprecate legacy cruft from introduction of ResultWrapper
Bug: T286694
Change-Id: Ifc58dd478592be49dd55caddfc9aeb536da1e1d6
2022-01-06 07:17:38 +01:00
Siddharth VP
191cadb6a5 Fix typos in comments (C-D)
Change-Id: I568fb93b53feb83f026d485136dd0d116d677f4f
2021-12-30 18:00:02 +05:30
jenkins-bot
1fc7c9443a Merge "Hard-deprecate Content::prepareSave." 2021-11-23 11:20:21 +00:00
jenkins-bot
fef2689b0a Merge "Deprecate $hasHistory param to ContentHandler::getAutoDeleteReason()" 2021-11-15 16:57:35 +00:00
Daimona Eaytoy
1ccd95dca4 Deprecate $hasHistory param to ContentHandler::getAutoDeleteReason()
Unused except for DeleteAction, which now uses a custom query (similar
to the one in ContentHandler::getAutoDeleteReason). Passing the
parameter is hence hard-deprecated, and it will be removed in 1.39.

Also escalate the exception logging from wfDebug to error, since we want
to know what exceptions are being caught.

Bug: T288282
Change-Id: I91ed9574da68bc7ff36e968f016da390b6d295ed
2021-11-11 23:14:42 +00:00
Roman Stolar
56e5616e96 Hard-deprecate Content::prepareSave.
Use ContentHandler::validateSave instead.

Bug: T287159
Depends-On: I3d847d1714224b2e5903d3b1e8f1c218d850c17b
Depends-On: Ie71d1b590560b1210dd4599afb17ad41a2ec687e
Depends-On: I4b9287372a95f4b6178dc321105081552d040ef8
Change-Id: Iee3dd92747019ae18830fc9d0e904afc2d1939e4
2021-11-11 14:01:19 +00:00
Roman Stolar
5461404d69 Move Content::prepareSave to ContentHandler
Update method name in ContentHandler, soft-deprecate method on Content.
This will require making a semi-backwards-incompatible
change no matter what, we don't really have a great way
of hard-deprecating overriding methods.
Replace all callers of Content::prepareSave in core.

Add tests for ContentHandler::validateSave.

Bug: T287159
Change-Id: I7f23e6e97b1c7d27a6aaefdb88b19b2fc6e8b3a8
2021-11-11 15:40:42 +02:00
Roman Stolar
957697e1e0 Hard-deprecate Content::getParserOutput and AbstractContent::fillParserOutput.
Use ContentRenderer::getParserOutput instead.
Extensions defining a content model should override ContentHandler::fillParserOutput.
Update tests.

Bug: T287158
Change-Id: I1c71a8429806f1813a39f5807256b2eb9fb9901f
2021-10-29 14:04:22 +03:00
Lucas Werkmeister
97661702dc Fix reference to moved flag in phpdoc
$generateHtml is now wrapped in the ContentParseParams, referring to it
by its old name is confusing.

Bug: T287158
Change-Id: I31e0a596881ecd7d3bea709ab3f8029779cb7f02
2021-10-12 11:57:38 +02:00
Fomafix
1a21fcfd5b ContentHandler: Add deprecated type check to hook PageContentLanguage
Hard deprecate other types than a Language object as return value in
parameter $pageLang of the hook PageContentLanguage. Other types are
deprecated since change a08fc9eed6 included in MediaWiki 1.33.

Change-Id: I92916be55baa4d25ec2b279cee17adb26dd139fb
2021-10-05 10:04:02 +00:00
Roman Stolar
a68e641f9d Move Content::getParserOutput & AbstractContent::fillParserOutput to ContentHandler
Update/Create override classes of ContentHandler.
Soft-deprecate and remove method from Content and classes that override them.

Bug: T287158
Change-Id: Idfcfbfe1a196cd69a04ca357281d08bb3d097ce2
2021-09-29 13:10:51 +03:00
Roman Stolar
642afef215 Hard-deprecate Content::preSaveTransform.
Use ContentTransformer::preSaveTransform instead.
Extensions defining  a content model should override ContentHandler::preSaveTransform.

Bug: T287156
Change-Id: I2a8c60470366fd95d056e0dfa8144f209bb7117e
2021-08-25 16:14:59 +03:00
jenkins-bot
c03a36a48a Merge "Introduce concept of generateHTMLOnEdit() for ContentHandler" 2021-08-25 10:17:31 +00:00
Amir Sarabadani
66a4b414e5 Introduce concept of generateHTMLOnEdit() for ContentHandler
This way you can avoid rendering HTML and storing ParserCache entries

Bug: T285987
Change-Id: I3c7023b776f2a1e35dafdbb6ac0eb3eb73ae5fd4
2021-08-24 22:40:46 +02:00
Fomafix
c7ebc1ec44 Fix various typos in documentation
Bug: T201491
Change-Id: I144c120cc88bda723c8608ed7fb0ccb709f295f1
2021-08-23 09:03:44 +00:00
jenkins-bot
0640586f88 Merge "Move Content::preloadTransform to ContentHandler" 2021-08-17 15:37:12 +00:00
Roman Stolar
42442e01ff Move Content::preloadTransform to ContentHandler
Update ContentTransformer to access ContentHandler::preLoadTransform through the service.
Prepare object to hold a data that required for ContentHandler::preLoadTranform params.

This is a fully backwards compatible change.
We are doing hard deprecation via MWDebug::detectDeprecatedOverride.

However, with the ContentHandler calling Content and
Content calling ContentHandler, it doesn't matter whether
callers use Content or ContentHandler. This will allow us
to naturally convert all callers.

Bug: T287157
Change-Id: I89537e1e7d24c6e15252b2b51890a0bd81ea3e6b
2021-08-17 15:17:34 +00:00
Umherirrender
b4bd3d4ee8 Remove dead variables and functions and unneeded parenthesis
Found by sonarqube

Change-Id: I3464d25e94d98aaca55d9209d5175542b335f994
2021-08-13 21:41:59 +02:00
Petr Pchelko
bf438e8c87 Support deprecated Content::preSaveTransform override
If an exctension ContentHandler overrides one of the
subclasses of the core ContentHandler, for example
TextContentHandler, when switching calls we no longer
call deprecated Content::preSaveTransform for the
extension Content model.

Bug: T288191
Change-Id: Ie7edc97be9098f3cd188949bd37943c37a0b65ff
2021-08-05 08:56:47 -07:00
Petr Pchelko
b782a7e66d Move Content::preSaveTransform to ContentHandler
Create ContentTransformer to access ContentHandler::preSaveTransform through the service.
Prepare object to hold a data that required for ContentHandler::preSaveTranform params.

This will require making a semi-backwards-incompatible
change no matter what, we don't really have a great way
of hard-deprecating overriding methods.

However, with the ContentHandler calling Content and
Content calling ContentHandler, and with the ProxyContent
trick to stop infinite recursion, it doesn't matter whether
callers use Content or ContentHandler. This will allow us
to naturally convert all callers. But won't really allow
hard-deprecation.

Bug: T287156
Change-Id: If6a2025868ceca3a3b6f11baec39695e47292e40
2021-07-29 18:06:02 +03:00
libraryupgrader
5357695270 build: Updating dependencies
composer:
* mediawiki/mediawiki-codesniffer: 36.0.0 → 37.0.0
  The following sniffs now pass and were enabled:
  * Generic.ControlStructures.InlineControlStructure
  * MediaWiki.PHPUnit.AssertCount.NotUsed

npm:
* svgo: 2.3.0 → 2.3.1
  * https://npmjs.com/advisories/1754 (CVE-2021-33587)

Change-Id: I2a9bbee2fecbf7259876d335f565ece4b3622426
2021-07-22 03:36:05 +00:00
jenkins-bot
b077d151a1 Merge "Increase length of automatic edit summaries to current maximum" 2021-06-28 12:09:30 +00:00
DannyS712
47d70dbfba Post Revision-removal cleanup
Updates for the removal of the Revision class itself
and the various methods/hooks/variables removed in the
process, including:

- Update some documentation removing most references
to the Revision class and updating the MCR migration
notes to reflect the past tense for Revision methods.

- Change some capitalization from "Revision" to "revision"
to make it clear comments are about revisions in general,
not the Revision class in particular.

- Minor code tweaks including removing unused variables that
were around for the old hooks that were removed, and
removing the use of DeprecatablePropertyArray where no
longer needed for anything.

- Fix incorrect documentation for PageUpdater::getStatus(),
the status value changed a while ago to have revision-record
in addition to revision, and recently to only have the
revision-record, but ironically PageUpdater was never updated.

- Removed Parser::$mRevisionObject, used to be a Revision object
and was deprecated in 1.35, missed earlier because it was no
longer being set to Revision objects, always null.

- Add RevisionRecord typehints in DummyLinker to match those
in the corresponding Linker methods

This should be a no-op in terms of functionality.

Bug: T247143
Change-Id: I03bbb94fc29085855448780b1a5ad9063911ecc4
2021-06-24 00:32:39 +00:00
Alexander Vorwerk
623c9561cc Hard deprecate ContentHandler::getForTitle()
ContentHandler::getForTitle() is deprecated since 1.35.

Depends-On: I52c40084d96e88b2edab46c15a10b83b7decf192
Change-Id: I9b3967a59714e231467a08e5a603f600ff1ab7c2
2021-06-20 12:10:40 +02:00
DannyS712
3fe579f832 Increase length of automatic edit summaries to current maximum
Bug: T221617
Change-Id: I6cc4fb1678d542b90a3c4d652261483f98108e31
2021-06-19 03:16:51 +00:00
Thiemo Kreuz
2ba01c7ee7 Remove some more comments that literally repeat the code
… including PHPDoc tags like `@return <type> $variableName`.
A return value doesn't have a variable name. I can see that
some people do this intentionally, repeating the variable
name that was used in the final `return $var;` at the end
of a method. This can indeed be helpful. I leave a lot of
these untouched and removed them only when it's obviously
wrong, or does not provide any additional information in
addition to what the code already says.

Change-Id: Ia18cd9f25ef658b08ad25b97a744897e2a8deffc
2021-06-18 21:23:56 +00:00
Alexander Vorwerk
615ee84446 Hard deprecate ContentHandler::cleanupHandlersCache()
deprecated since 1.35 and unused.

Change-Id: I5a0d57c801a8d8bddb5ac7188b6517fb052891dc
2021-06-02 15:17:52 +00:00
Alexander Vorwerk
e34e93f24a Soft deprecate ContentHandler::getContentText()
ContentHandler::getContentText() was introduced as a migration
helper and is mostly pointless now. Thus it should be deprecated
and later removed. This patch softs deprecates that method.

This patch also deprecates the corresponding setting
$wgContentHandlerTextFallback.

Bug: T268041
Change-Id: I7d477935a16316996c4f52a3d6466029745817b4
2021-05-17 17:59:28 +00:00
James D. Forrester
f2f9345e39 Replace uses of DB_MASTER with DB_PRIMARY in documentation and local variables
This is just a start.

Bug: T254646
Change-Id: I9213aad4660e27afe7ff9e5d2e730cbf03911068
2021-05-14 12:40:34 -07:00
DannyS712
f60ea069ba Remove remaining non-test uses of Revision objects
The following methods no longer support Revision parameters:
- CategoryMembershipChange::__construct
- ContentHandler::getUndoContent
- DerivedPageDataUpdater::prepareUpdate
- DifferenceEngine::getRevisionHeader

The following methods were removed entirely:
- Title::countAuthorsBetween

The following methods return arrays that formerly include
a 'revision' key that would emit deprecation warnings when
accessed and return a Revision object. The Revision object
has been removed from the arrays, and the 'revision-record'
key should be used to get the relevant RevisionRecord instead:
- PageUpdater::doModify
- PageUpdater::doCreate
- Parser::statelessFetchTemplate

The ParserOptions `templateCallback` option is a callback
that is called in Parser::fetchTemplateAndTitle() and should
return an array - the 'revision' key to that array used to
be a Revision object and was used if no 'revision-record'
was returned - it is now ignored.

Bug: T247143
Change-Id: I163ada88d649c75697aff4fa31a3a3c0bdef78b7
2021-05-04 13:10:22 -07:00
jenkins-bot
41456132c2 Merge "Revert "Add change tags for media additions/removals"" 2021-03-26 15:42:17 +00:00
Urbanecm
5519a25cf2 Revert "Add change tags for media additions/removals"
This reverts commit 5a0bfa9d98.

Reason for revert: caused a train blocker (T278429) plus Daniel says it's "super expensive"

Bug: T278429
Bug: T266067
Change-Id: I6724b4bc02d29c12c3fe18cc1e8fa17a443257d5
2021-03-26 15:16:08 +00:00
Petr Pchelko
cf763fe116 Drop most hard-deprecated methods in Article
Bug: T239975
Change-Id: I6ca9fbaa699d0465a59e86abbf2bca6bbdb69c01
2021-03-24 19:34:41 +00:00
jenkins-bot
e3cdbbdbaf Merge "Add change tags for media additions/removals" 2021-03-22 17:51:04 +00:00
James D. Forrester
d540be2925 ContentHandler::latestRevision: Fix documentation typo
Change-Id: I9dc99139b6d00fd367a3f70787bb5be96971bb84
2021-03-22 08:09:28 -07:00
Matthias Mullie
5a0bfa9d98 Add change tags for media additions/removals
This introduces 3 new tags to track changes in media usage
across articles. These tags are both hidden & disabled by
default.

Bug: T266067
Change-Id: I3e7acafe0b2266cf6e253dfef42fa6c666424469
2021-03-10 09:08:39 +00:00
Umherirrender
299f05c324 Use always RevisionStore in ContentHandler::getAutoDeleteReason
RevisionStore includes the RevisionLookup, use the same instance

Change-Id: I064605aa6b1037daf4507278cdb5a94ee8e8964b
2020-11-14 02:46:24 +01:00
Lucas Werkmeister
d960d2f79d Make ContentHandler::latestRevision() available to subclasses
This method is useful when overriding getParserOutputForIndexing(), to
avoid the equivalent of T247859.

Note that the method is not stable to override, only to call.

Change-Id: Idd7e6ca6786f2c463737a47296b3da5f5e0e16f1
2020-10-12 12:13:40 +02:00
Lucas Werkmeister
775b068396 Clarify HTML generation for indexing in ContentHandler
Require that getDataForSearchIndex() is only called with the result of
getParserOutputForIndexing(), and update the documentation of both
methods. Extensions may now override getParserOutputForIndexing() to
skip generating HTML; MediaWiki guarantees that the HTML itself is not
required by the base implementation of getDataForSearchIndex().

Note that for Wikitext content, many meta-data fields of ParserOutput –
links, sections, etc. – can only be obtained by actually parsing the
content and generating HTML, whether the caller asked for it or not.
However, this is not the case for all content models. This change allows
those content models to save some work when indexing their content,
while still working with the MediaWiki getDataForSearchIndex() method.

The new requirement on getDataForSearchIndex() is strictly speaking a
breaking change, but not one that could be marked as a deprecation
first. Hopefully, the release notes entry is enough.

Bug: T239931
Bug: T264283
Change-Id: I50f3a530f25fbcf019d36d09c070b11a46066c61
2020-10-09 13:20:58 +02:00
Matěj Suchánek
51642e0aae Replace tabs with spaces
Change-Id: Id034c34a294585f58dba58c26db466e0e39cb557
2020-09-04 18:04:07 +02:00
jenkins-bot
39705eb311 Merge "Replace "@stable for subclassing" with "@stable to extend"" 2020-07-13 09:31:38 +00:00
jenkins-bot
0270990f0b Merge "Replace "@stable for calling" by "@stable to call"" 2020-07-13 09:27:04 +00:00
daniel
3c50afa46b Replace "@stable for subclassing" with "@stable to extend"
For compliance with the new version of the table interface policy
(T255803).

This patch was created by an automated search & replace operation
on the includes/ directory.

Bug: T257789
Change-Id: Ie32c1b11b3d16ddfc0c83a757327d449ff80b2e4
2020-07-13 11:00:30 +02:00
daniel
f7116bb3a2 Replace "@stable for overriding" with "@stable to override"
For compliance with the new version of the table interface policy
(T255803).

This patch was created by an automated search & replace operation
on the includes/ directory.

Bug: T257789
Change-Id: I5ffbb91882ecce2019ab644839eab5e8fb8a1c5f
2020-07-13 10:57:12 +02:00
daniel
272db6afde Replace "@stable for calling" by "@stable to call"
For compliance with the new version of the table interface policy
(T255803).

This patch was created by an automated search & replace operation
on the includes/ directory.

Bug: T257789
Change-Id: If560596f5e1e0a3da91afc36e656e7c27f040968
2020-07-13 08:55:28 +00:00
daniel
7b14d2f563 Mark Content and ContentHandler base classes as extensible
Bug: T247862
Change-Id: I37666c6372bd922768cf426b12951699d890272b
2020-07-09 12:03:56 +02:00