Commit graph

2943 commits

Author SHA1 Message Date
Arlo Breault
f372e352b7 Remove PageContent::getRedirectTarget
Requires the latest version release of Parsoid.

Follows-Up: I0a4b0de8f366358689e39e558e5f20ecfc13e040
Change-Id: I67a0d8f3733cfe108d5fdab96909379f466363d7
2023-06-13 14:43:22 -04:00
Daimona Eaytoy
518a5da533 Replace deprecated MWException
Bug: T328220
Change-Id: I0408575ee71e58d1c9e9ebedabab35bd3813f515
2023-06-12 12:27:49 +00:00
Daimona Eaytoy
4d5cd3a84f Replace deprecated MWException
Bug: T328220
Change-Id: I66be7a6dd752d6b9c254beb65f4eb5ace3c89776
2023-06-09 17:21:12 +02:00
Daimona Eaytoy
8adf1bfb93 Replace some more usages of deprecated MWException
Bug: T328220
Change-Id: I3c36835fbd90acc301731e2b33ae4815cd4b0cc5
2023-06-09 02:07:08 +02:00
Daimona Eaytoy
0d29958cc1 Replace more usages of deprecated MWException
Bug: T328220
Change-Id: Ib619ead0f397188d828e6e5dfc80ed1fa7175c7d
2023-06-08 21:37:07 +00:00
jenkins-bot
3814e7a1a5 Merge "Add return type to getIndicators() in ParserOutput & OutputPage" 2023-06-08 14:24:28 +00:00
jenkins-bot
b88ae224e9 Merge "Replace usages of deprecated MWException" 2023-06-08 11:39:28 +00:00
jenkins-bot
478be1caea Merge "Mark PageContent::getRedirectTarget for removal" 2023-06-07 14:53:03 +00:00
Daimona Eaytoy
1c6e872bd4 Replace usages of deprecated MWException
Use SPL exceptions instead when the exception is unchecked.

Bug: T328220
Change-Id: Ia1e5edc2ef3269a44b670262b78b305d07559829
2023-06-06 17:05:32 +02:00
Arlo Breault
9825ee1bcb Check early for a badrevision exception when Parsoid tries to getContent
RevisionRecord::getContent can return null when errors are encountered.
Check for those early in ParsoidHanlder::tryToCreatePageConfig so we can
return an appropriate HttpException to clients.

Bug: T336501
Change-Id: I647ed253691970bbf39321a3cd652ea14bc11278
2023-06-05 16:52:24 +00:00
Arlo Breault
82fd6e87d8 Mark PageContent::getRedirectTarget for removal
The caller was removed in e82f11c.

Parsoid needs to remove the abstract method from the abstract class
before this can be removed.  That's done in,
I16fda2cd624654ba3079b4c1385ed9a886de9dcc

Change-Id: I0a4b0de8f366358689e39e558e5f20ecfc13e040
2023-06-02 18:26:39 -04:00
Subramanya Sastry
0e9656e6da Add return type to getIndicators() in ParserOutput & OutputPage
This is in preparation for changes on the Parsoid side to make
sure its signature is compatible with the ContentMetadataCollector
interface there.

Change-Id: Ife4ae81dbc304097da7dcba40b143f7030b959f3
2023-06-02 16:13:01 +05:30
Matt Fitzpatrick
a7e4d70d45 Sanitizer: Permit the aria-level HTML attribute in wikitext
Allows editors to identify a pseudo-heading as a heading of a given
hierarchical level to assistive technologies. Also allows levels 7
and deeper.

<div role="heading" aria-level="2">Example</div>

See also https://www.w3.org/WAI/GL/wiki/Using_role%3Dheading

Change-Id: Ia465a076db334d08cd1f548f2363a0f7cafe7690
2023-05-21 12:57:53 +03:00
jenkins-bot
8c369d467a Merge "Add a page property for __TOC__" 2023-05-20 12:49:41 +00:00
Arlo Breault
8a286dbceb Support multilingual SVGs in page language in galleries
Follow-up of I348840ef405e1370cc0c17d69051bce30153c9c0 for the gallery part.

Bug: T205040
Bug: T310453
Change-Id: Ia0c699675d40f6effbe359818aca3278c56042e3
2023-05-15 07:55:06 +00:00
jenkins-bot
e1c1632d9c Merge "ParserOutput: Ensure page title is updated after merging properties" 2023-05-11 18:23:20 +00:00
Umherirrender
e04d3a28f6 Replace internal Hooks::runner
The Hooks class contains deprecated functions and the whole class is
going to get removed, so remove the convenience function and inline the
code.

Bug: T335536
Change-Id: I8ef3468a64a0199996f26ef293543fcacdf2797f
2023-05-11 06:17:38 +00:00
Subramanya Sastry
632481c382 ParserOutput: Ensure page title is updated after merging properties
Eventually we should merge the "title text" and "display title" in
ParserOutput (T293514) but for now mirror the logic in
ParserOutput::mergeHtmlMetadataFrom() and update the title text
from the source if it hasn't already been set in the destination.
This patch ensures that after page properties are merged during
metadata collection, the title text is suitably updated if the
'displaytitle' property is set.

This will let Parsoid pass displaytitle (metadata) tests in integrated
mode since Parsoid relies on merging metadata from multiple ParserOutput
objects (in the DataAccess object that is used to expand templates, etc.)

Once this patch is merged, Parsoid patches may start failing CI till
we submit a patch there to fix up the integrated test failures list
since some previously failing tests may now pass.

Bug: T293514
Bug: T294621
Change-Id: Ia673f1261ccd03caf455122b71cfb9769b02f22e
2023-05-10 08:53:41 +00:00
Amir Sarabadani
623d3dc419 rdbms: Move ReadOnlyMode and ConfiguredReadOnlyMode to rdbms library
The db/ directory does not have an owner and it's a mess in general.
These classes don't depend on anything in core except the rdbms library.
Let's simply move it there. In other words, Krinkle made me do it.

Since the class was moved in I6202e52ba73 merged less than a week ago,
no need to alias anything.

Bug: T321882
Change-Id: I24ceeb8bf765a50f441270136acd612359d50aa2
2023-05-04 23:41:21 +02:00
jenkins-bot
e465824493 Merge "Parser: Simplify showTOC/suppressTOC logic" 2023-05-01 20:02:40 +00:00
jenkins-bot
40bf6ec625 Merge "Add ParserOutputFlags::NO_TOC" 2023-05-01 20:01:12 +00:00
jenkins-bot
ddc1cfc94e Merge "Reorg: Move ReadOnlyMode classes to db/" 2023-04-28 19:26:29 +00:00
jenkins-bot
c5152db020 Merge "Remove back-compat for <editsection>" 2023-04-28 15:59:12 +00:00
jenkins-bot
ba80b34b9d Merge "LanguageVariantConverter: Use LanguageConverter::hasVariant() to check source" 2023-04-28 15:58:22 +00:00
C. Scott Ananian
52d1259b1b Parser: Simplify showTOC/suppressTOC logic
Just a bit of cleanup to simplify the logic around showing/suppressing
the TOC.

Change-Id: I99f1f29bf067df2ea3f9f235af7ce054d7e4af68
Followup-To: Ib41e6e4926cb752826ad75d10e8692125fc0b064
2023-04-28 11:23:58 -04:00
C. Scott Ananian
0448851e92 Add ParserOutputFlags::NO_TOC
Rather than suppress the TOCData in ParserOutput when __NOTOC__ is used,
set a new parser output flag, NO_TOC, since some clients want to know
whether there are sections present on the page irrespective of whether
the UX for the Table Of Contents should be displayed/suppressed.

Added OutputPage::getOutputFlag() as an @internal method for the
moment; eventually we should use the same object to represent
metadata in ParserOutput and OutputPage (T301020).

Bug: T332243
Followup-To: Ife2126ace95ac4d9ec44f6374c63d8fc995cf034
Followup-To: Iea6426336f93c053a5977768f0785cdb46daf5bf
Change-Id: Ib41e6e4926cb752826ad75d10e8692125fc0b064
2023-04-28 10:56:57 -04:00
Amir Sarabadani
d59ffa4202 Reorg: Move ReadOnlyMode classes to db/
They are not suitable to go to rdbms library as they depend on mediawiki
pieces, the second best place is the db/ directory.

Bug: T321882
Change-Id: I6202e52ba7306d74261206c2ba7930c5f1a0a18e
2023-04-28 12:13:01 +02:00
Amir Sarabadani
e182010622 Reorg: Move SiteStats*.php to SiteStats/
It's going to be a bit small and narrow but it's better than sitting in
the root of includes/ plus I hope we can hollow out SiteStatsUpdate
class into the third one and or move this under a better directory in
the future.

Bug: T321882
Change-Id: Ia503b53b31ca00600f8c18b61a2652c3e146494e
2023-04-27 01:16:29 +02:00
Bartosz Dziewoński
6ba47296d9 Fix Phan suppressions related to Title::castFrom*() and friends
There is no way to express that Title::castFromPageIdentity(),
Title::castFromPageReference() and Title::castFromLinkTarget()
can only return null when the parameter is null. We need to add
Phan suppressions or explicit types almost everywhere that these
methods are used with parameters that are known to not be null.

Instead, introduce new methods Title::newFromPageIdentity() and
Title::newFromPageReference() (Title::newFromLinkTarget() already
exists), without the null-coalescing behavior, and use them when
the parameter is not null. This lets static analysis tools, and
humans, easily understand where nulls can't appear.

Do the same with the corresponding TitleFactory methods.

Change the obvious uses of castFrom*() to newFrom*() (if there is
a Phan suppression, a type check, or a method call on the result).

Change-Id: Ida4da75953cf3bca372a40dc88022443109ca0cb
2023-04-22 16:45:09 +02:00
jenkins-bot
2b5d25ba71 Merge "Fix breakages generating TOC for API Help pages" 2023-04-17 17:22:23 +00:00
jenkins-bot
78a7e31dc0 Merge "Add Hook suffix to ParserModifyImageHTMLHook" 2023-04-17 15:37:22 +00:00
jenkins-bot
b1979fef97 Merge "Revert "Display SVGs in page view language for language variants"" 2023-04-17 13:27:36 +00:00
Func
eb065bb6e1 Revert "Display SVGs in page view language for language variants"
This reverts commit 42aa5f9481.

Reason for revert: Caused T334753, the proposed fix may need more time for review. Let's revert for now, before the train cut.

Bug: T310453
Bug: T334753
Change-Id: I790604eef00491b7f2a921fb3423a2f727f6593b
2023-04-17 11:53:37 +00:00
Umherirrender
95814d8d6f Add Hook suffix to ParserModifyImageHTMLHook
Common naming convention for hook runner interfaces

Bug: T334689
Change-Id: I3043454a502289e5ee2492f7bf2ab01e155c30ba
2023-04-16 19:32:48 +02:00
jenkins-bot
97d5377ea3 Merge "Display SVGs in page view language for language variants" 2023-04-13 21:11:10 +00:00
Subramanya Sastry
3e297c43ad Fix breakages generating TOC for API Help pages
* TOCData in Parsoid expects to process non-string-key indexed arrays.

* Don't use 'null' as the default for maxtoclevel to ensure that
  TOC is always displayed even when it isn't passed in as a param
  by callers.

* Follows up on 05535be6 which only partially fixed the breakage
  caused by 153a4157 and 439656e0

Bug: T334551
Change-Id: I8883b58574ea8ed0566de2c44dba3408a47d2d0c
2023-04-12 15:37:03 -05:00
jenkins-bot
65812ee715 Merge "parser: Make all LinkHolderArray properties private" 2023-04-08 22:28:31 +00:00
jenkins-bot
f7f572cc4b Merge "Remove the nativeGalleryEnabled parsoidSetting" 2023-03-31 03:06:55 +00:00
Arlo Breault
bc1601f874 Remove the nativeGalleryEnabled parsoidSetting
This is now enabled in production (Ic5a4a9950d51f63b17f4c5e70516bec87b981aa5)
and not something we want to remain configurable.

It is removed from Parsoid in I52ddfd21ff2e72a34cb5eb68742e3dfb85c6ccf6

Change-Id: I6a4d7d33fb42270fc5da3a922aa0a959180fb33f
2023-03-30 17:52:56 -04:00
jenkins-bot
e584096b54 Merge "CoreMagicVariables.php: Improve documentation of DEADLINE_DATE_SPEC_BY_UNIT" 2023-03-29 19:54:42 +00:00
jenkins-bot
631189a66b Merge "Enabled native gallery editing in Parsoid by default" 2023-03-29 16:19:20 +00:00
Bartosz Dziewoński
0a0ef8e653 Enabled native gallery editing in Parsoid by default
Bug: T329662
Change-Id: I5bf774b2bd3021d5c67a6f2a2f039fc3ccfc7469
2023-03-29 17:21:29 +02:00
C. Scott Ananian
4d4a96b469 CoreMagicVariables.php: Improve documentation of DEADLINE_DATE_SPEC_BY_UNIT
Followup-To: I9acb42b0d9ff67798a1624cbf9c7cac99c8fbe2f
Change-Id: I7022a04f359226058a90ba2b2195984862de1ebf
2023-03-29 09:53:04 -04:00
Aaron Schulz
366a0afd63 parser: improve cache TTL accuracy for CURRENT*/LOCAL* magic words
Consolidate cache TTL handling within CoreMagicVariables.

Make the TTL account for how many seconds away the value is from changing.
For example, CURRENTHOUR should change soon after the next hour is reached.
There is a minimum adjustment TTL to avoid parser-after-save delays.

This allows for longer caching in most cases, as well as more up-to-date
rendering when the hour/day/week/year is about to change. Previously, there
were blind TTLs, which are either way too pessimistic or way too generous.

This commit does not change the CURRENTTIME, CURRENTTIMESTAMP, LOCALTIME,
and LOCALTIMESTAMP words, since there is no reasonable way to cache output
while keeping them up-to-date.

Bug: T320668
Change-Id: I9acb42b0d9ff67798a1624cbf9c7cac99c8fbe2f
2023-03-28 22:35:17 +00:00
jenkins-bot
90997943f9 Merge "Parser: Remove back-compatibility NO_TOC_CONVERSION code" 2023-03-27 20:43:53 +00:00
Winston Sung
42aa5f9481 Display SVGs in page view language for language variants
Bug: T310453
Change-Id: I45e495d2c4fc026bdfc54e3219ff7138789d25dd
2023-03-27 19:59:20 +00:00
jenkins-bot
7b98392676 Merge "ParserOutputAccess: Fork primary and secondary caches for parsoid" 2023-03-27 08:09:07 +00:00
jenkins-bot
6c32cc6698 Merge "Allow setting a ParserOption to generate Parsoid HTML" 2023-03-27 08:08:56 +00:00
C. Scott Ananian
2caf69797c ParserOutputAccess: Fork primary and secondary caches for parsoid
Uses flag to detect which cache instance to use based on ParserOptions
and sets the primary and secondary caches accordingly.  This ensures
that the ParserCacheMetadata cache used by the ParserCache is also
appropriately forked for Parsoid, as Parsoid may consult different
options in the ParserCache than core does.

A follow up patch will attempt to refactor this to be less
parsoid-specific.

Bug: T327769
Bug: T330677
Co-authored-by: Alangi Derick <alangiderick@gmail.com>
Change-Id: Id580b97ad9a0b90bbe56d4de3c2f999274fe329b
2023-03-26 21:46:07 -04:00
C. Scott Ananian
cfd9c516e1 Allow setting a ParserOption to generate Parsoid HTML
This is an initial quick-and-dirty implementation.  The
ParsoidParser class will eventually inherit from \Parser,
but this is an initial placeholder to unblock other Parsoid
read views work.

Currently Parsoid does not fully implement all the ParserOutput
metadata set by the legacy parser, but we're working on it.

This patch also addresses T300325 by ensuring the the Page HTML
APIs use ParserOutput::getRawText(), which will return the entire
Parsoid HTML document without post-processing.  This is what
the Parsoid team refers to as "edit mode" HTML. The
ParserOutput::getText() method returns only the <body> contents
of the HTML, and applies several transformations, including
inserting Table of Contents and style deduplication; this is
the "read views" flavor of the Parsoid HTML.

We need to be careful of the interaction of the `useParsoid` flag with
the ParserCacheMetadata.  Effectively `useParsoid` should *always* be
marked as "used" or else the ParserCache will assume its value doesn't
matter and will serve legacy content for parsoid requests and
vice-versa.  T330677 is a follow up to address this more thoroughly by
splitting the parser cache in ParserOutputAccess; the stop gap in this
patch is fragile and, because it doesn't fork the ParserCacheMetadata
cache, may corrupt the ParserCacheMetadata in the case when Parsoid
and the legacy parser consult different sets of options to render a
page.

Bug: T300191
Bug: T330677
Bug: T300325
Change-Id: Ica09a4284c00d7917f8b6249e946232b2fb38011
2023-03-26 21:46:05 -04:00