Commit graph

546 commits

Author SHA1 Message Date
Derick Alangi
1afd52e3e4 REST: Move Helper classes to their own namespace
Mixing Handlers with Helpers doesn't look nice for consistency
reasons. Helpers should be in their own place (grouped) in the
Handlers directory as they're really "helpers for the handlers".

Change-Id: Ieeb7a0a706a4cb38778f312bfbfe781a1f366d14
2023-01-16 21:16:09 +01:00
jenkins-bot
78ca6a925b Merge "Clarify wording for high-volume grants" 2023-01-13 04:49:43 +00:00
EpicPupper
8ad4530c4a Clarify wording for high-volume grants
Bug: T70312
Change-Id: Id289cd298393e213426d2e4fe38b3a32f53b5dfd
2023-01-12 23:17:51 -05:00
jenkins-bot
5ba4ade4b0 Merge "Simplify callback in HTMLForm tests" 2023-01-11 09:20:30 +00:00
Bartosz Dziewoński
84a43f20f0 Simplify callback in HTMLForm tests
The anonymous function was equivalent to just specifying 'wfMessage'.
Same as in I355504984d343a2c7c469759f791612c5b6d6556 in Wikibase.

Change-Id: Ib94b7cceabce25ca95374d944255c7197e6a476a
Follows-Up: Ica0740049f0a3e8ec764903c5b71825e4d628a3f
2023-01-10 21:34:00 +01:00
Derick Alangi
d51522dfd3 ParsoidOutputAccess: Mark dummy parser output as non-cacheable
Bug: T311728
Change-Id: I55f153d21f91ef93fe5c788fd054fa481fc2ab10
2023-01-10 12:43:30 +01:00
jenkins-bot
c9fea125c7 Merge "PageContentHelper: Remove back-compat code for VisualEditor" 2023-01-10 11:30:50 +00:00
Derick Alangi
cdd49f7536 ParsoidOutputAccess: Completely handle unsupported content models
Pages with content models not supported by Parsoid before already
had dummy parser output written to PC but we still got an internal
server error because the output didn't have a render key.

This patch fixes the issue and when we try to render page with
unsupported content models, we get the dummy parser outputs.

Bug: T311728
Change-Id: I49ebbfc0475fb296f2a906ce7dce237641fb375b
2023-01-10 08:38:51 +00:00
Derick Alangi
467fbd3f6c PageContentHelper: Remove back-compat code for VisualEditor
Was introduced in I10af85b2da96568cfffd03867d1cb299645fb371 for
backward compatibility with VisualEditor extension.

Change-Id: I180c5d95d1056cd2b5d2126b0622c5316dbf9c7b
2023-01-10 08:38:06 +00:00
Brian Wolff
07cdef809c Deprecate creating HTMLFormFields without reference to parent form
Currently it is documented that mParent in HTMLFormField may be null.
This can happen if the form element is constructed manually via
new, instead of the normal way via HTMLForm methods.

As it stands, much of the code assumes that mParent is always set
despite the documentation. Lets mark creating form fields without
parent set as deprecated. The current situation seems like a
recipe for bugs, and after the deprecation period this would allow
us to simplify some of the HTMLFormField code.

Bug: T326456
Change-Id: Ica0740049f0a3e8ec764903c5b71825e4d628a3f
Depends-On: I15a39605e3eec8a5c265c4a331039fa906eda036
2023-01-08 18:20:16 -08:00
jenkins-bot
26df447672 Merge "rdbms: Consolidate logger channels into one" 2023-01-03 23:39:38 +00:00
Timo Tijhof
4ef0891994 rdbms: Consolidate logger channels into one
Notable changes:

* In SqlBagOStuff::getConnectionFromServerInfo, only two loggers were
  injected. The rest implicitly got a NullLogger due to being absent.
  These are now effectively unsilenced.

* Database::__construct() required almost all parameters, even the
  loggers. I've wanted to move some of DatabaseFactory into the ctor
  here for a while. In order to make this change not a breaking
  change, the new 'logger' parameter is optional with NullLogger as
  default. This allowed some of the test cases, which were simply
  passing NullLogger, to be fixed by passing nothing instead of
  passing the new option name.

  The Database class is behind a dozen layers of indirection for
  real use, so this will still be injected just fine (DBF, LB, LBF,
  MWLBF, etc.).

* In LegacyLogger, the handling for $wgDBerrorLog was previously
  limited to DBConnection and DBQuery. This now includes errors
  from other (generally, newer) parts of Rdbms as well, which were
  previously missing.

  This only affects sites (typically CI and dev setup) where
  $wgDBerrorLog is used, as opposed to the more common
  $wgDebugLogGroups by-channel configuration.

* TransactionProfiler gets its logger injected in a rather odd way,
  via entrypoints (MediaWiki.php, ApiMain.php, and MaintenanceRunner)
  as opposed to service wiring. This is kept as-is for now.

* In LBFactoryTest, in particular testInvalidSelectDBIndependent2,
  there are cases that intentionally produce failures of which
  the result is then observed. In CI we assert that dberror.log is
  empty so instead of adding the missing logger fields to that
  LBFactory instance, the only one set (replLogger) is removed.
  The alternative is to set 'logger' now, which would naturally
  cause CI failures due to unexpected entries coming through to
  non-mocked error log.

Bug: T320873
Change-Id: I7ca996618e41b93f488cb5c4de82000bb36e0dd3
2023-01-03 22:46:38 +00:00
Umherirrender
e59cf6c133 Use SlotRecord::MAIN instead of hard coded value
Makes it clear what about the value is (slot role name)

Change-Id: I0dc195aa24c0e699a32d3b07e62d58e90cfac84d
2023-01-03 16:24:42 +01:00
DannyS712
1f8e5bcefe DummyServicesTrait: add content handler factory
Simplify mocking common cases of the content handler factory
only support specific content models.

Change-Id: Ib7f4099a2b1655b1bfb4d90f03105c27d17042ed
2023-01-02 01:09:42 +00:00
Umherirrender
72751cbecb Replace deprecated Language::getMessagesFileName
Bug: T325982
Change-Id: I3c583d7d6914dd46311fd379168ee7dbae71707b
2022-12-28 15:56:30 +00:00
jenkins-bot
4fde3b96de Merge "ParsoidOutputAccess should support all models that serialize to wikitext." 2022-12-16 19:36:18 +00:00
daniel
e1c3af9177 ParsoidOutputAccess should support all models that serialize to wikitext.
The motivation is to restore parsoid support for the content models
defined in the Proofread extension.

Bug: T246403
Change-Id: I33d269e42fede28139f7c923504326a77d11ee13
2022-12-16 12:20:10 +01:00
Derick Alangi
ce8e5f1549 Introduce HtmlMessageOutputHelper for system messages
This introduces an interface HtmlOutputHelper that is implemented
by both HtmlMessageOutputHelper or HtmlOutputRendererHelper based
on the page we're dealing with.

Bug: T323558
Change-Id: I1fb8dcc5cc05ce3f32f3c1862b88045f1c8e612b
2022-12-16 11:49:56 +01:00
jenkins-bot
630925a09d Merge "HtmlOutputRendererHelper: test that parser cache is used." 2022-12-15 18:22:11 +00:00
daniel
91c1380d1e HtmlOutputRendererHelper: test that parser cache is used.
This protected against the performance regression that was addressed in
abec307409.

Change-Id: Ie5f7c2c713a10eec19bc19e0ba709f36599fb291
2022-12-15 17:56:14 +00:00
jenkins-bot
4b2c11a85a Merge "Parsoid: return 404 when page is deleted." 2022-12-15 12:09:47 +00:00
jenkins-bot
dba0bf3877 Merge "add redirects to page/history and link endpoints" 2022-12-15 11:37:43 +00:00
daniel
6decc0ba09 Parsoid: return 404 when page is deleted.
If HtmlOutputRendererHelper can't produce output because the page
doesn't exist, don't crash. Return a 404 instead.

Bug: T325205
Change-Id: I6a713025e2eb447ed61de8949c820bd9cda7594e
2022-12-15 12:13:57 +01:00
jenkins-bot
59e24a4559 Merge "actions: Replace deprecated Linker::commentBlock" 2022-12-14 21:33:22 +00:00
Derick Alangi
fe091a7cad Parsoid: Default parsoid version to "0.0.0" for unsupported models
When parsoid was dealing with content for content models that it does
not support, the corresponding pagebundle used `null` as the version
which will break when converting the it to JSON.

This patch fixes this by just using a version which is not specified
like 0.0.0

A better fix would be for page bundle to not explode when the version is
set to null. The other real fix is for Parsoid to not ask for rendering of
pages that are not wikitext.

Bug: T325137
Change-Id: Iff1ce432d1b2d30f3f74c53a0602c11034db5874
2022-12-14 13:07:18 +01:00
daniel
4f22f967c5 Parsoid: implicitly enable linting in API endpoints
Logging linter data should be enabled automatically by
HtmlOutputRendererHelper.

This change enables linting data for requests coming in via the
v1/page/{title}/html endpoint.

Change-Id: Idafd29784ec712547e36fea88a8c159784b97f2b
2022-12-13 13:35:06 +01:00
jenkins-bot
bdbaa2d0fc Merge "rdbms: improve Database::queryMulti() error handling" 2022-12-13 00:47:33 +00:00
daniel
5559d2d471 Parsoid: Enable lint data and parser cache together
The previous attempt at restoring call to the ParserLogLinterData hook
had the undesirable effect of bypassing parser cache. This change
optionally enables the call to the lind data hook without disabling
parser cache.

This patch us working under the assumption that we only need to log lint
data for canonical parses.

Follow-Up to I1f69498ef75

Change-ID: I39ab54ca6e9f9a6a58b59cdd6feea07638fc908f
2022-12-12 22:57:07 +01:00
jenkins-bot
374d578707 Merge "ParsoidOutputAccess: generate dummy output for unsupported models." 2022-12-12 20:13:31 +00:00
jenkins-bot
947c3ddba0 Merge "ParsoidOutputAccess: only cache output for wikitext" 2022-12-12 20:09:30 +00:00
daniel
75d6892134 ParsoidOutputAccess: generate dummy output for unsupported models.
While RESTbase insists on getting Parsoid renderings for any content
model, don't waste CPU cycles trying to render garbage. Just output
dummy content. Nobody should ever see it.

Bug: T324711
Change-Id: I407171a5f515b594603b287a7a9e49f54e837161
2022-12-12 19:57:31 +00:00
Aaron Schulz
aa3459fb12 rdbms: improve Database::queryMulti() error handling
Allow automatic retry if the first query fails due to the
connection having already been lost. Hide packet warnings
in doMultiStatementQuery(), which can occur due to dropped
connections.

Make queryMulti() actually mark the transaction or session
as corrupt when needed,

Improve executeQuery() handling of empty $sqls arrays.
Pass the full SQL statement array to beginIfImplied().

Add re-connection tests for queryMulti().

Related documentation changes:
* Clarify affectedRows()/insertId() documentation.
* Update queryMulti() documentation to mention exceptions.
* Add comments about avoiding direct BEGIN/COMMIT/ROLLBACK.
  These should be avoided in queryMulti() as well.

Bug: T322689
Change-Id: I51d213acccfacc48674dbcf08c177cd9872c6e15
2022-12-12 19:52:58 +00:00
jenkins-bot
b340554a4d Merge "ParsoidHandler: test wt2html with old revision" 2022-12-12 13:22:36 +00:00
jenkins-bot
08cf3b486a Merge "LanguageVariantConverter: Add fallback to core LanguageConverter" 2022-12-12 12:24:26 +00:00
jenkins-bot
78bfce6ec9 Merge "Replace comments about deprecated Linker::commentBlock/formatComment" 2022-12-11 20:12:25 +00:00
Abijeet
5c113a833a LanguageVariantConverter: Add fallback to core LanguageConverter
If variant conversion is not supported by Parsoid, fallback to using
the old LanguageConverter.

We still call parsoid to perform variant conversion in order to add
metadata that is missing when the core language converter is used.

Bug: T318401
Change-Id: I0499c853b4e301f135339fc137054bd760ee237d
Depends-On: Ie94aaa11963ec1e9e99136af469a05fa4005710d
2022-12-11 12:12:33 +05:30
Umherirrender
cc7128fd16 Replace comments about deprecated Linker::commentBlock/formatComment
Bug: T324906
Change-Id: I7d9766ffca47e1ea3f2120b095d6ca7c8ae7aeb6
2022-12-11 01:03:15 +00:00
Umherirrender
a28137aef8 actions: Replace deprecated Linker::commentBlock
Bug: T324906
Change-Id: I32096a18d68046b00e2a21b619e2105c431e2562
2022-12-11 00:17:37 +00:00
daniel
5f2026c31c ParsoidHandler: test wt2html with old revision
Update the test for wt2html to assert that it works properly with an old
revision.

Bug: T324801
Change-Id: Ia2a7e28cd999712b1bd890eed48d0a5de931700f
2022-12-09 19:33:18 +01:00
Amir Sarabadani
a1b4699fea Reorg: Move MagicWord related files to under parser/
This is approved as part of T166010 RFC.

Bug: T321882
Change-Id: Ia4498c0a20e38a6a288dc14065ea8242c84fbc49
2022-12-09 13:48:35 +01:00
msantos
63deedc94c add redirects to page/history and link endpoints
* Add normalization redirects for page/history, page/history/counts
and links/language endpoints

Bug: T301372
Change-Id: I731fbfdcfb538c3e8a5dd32349ebaa0e642bf338
2022-12-09 12:17:38 +00:00
daniel
9842811e75 ParsoidOutputAccess: only cache output for wikitext
ChangeProp is currently requesting a parsoid parse for all page updates,
regardless of content model. Parsoid renderings of non-wikitext content are
unusable, so we shouldn't bother the parser cache with them. This is
especially true for wikidata items.

Bug: T324711
Change-Id: I6f6325f2b8581dfcc9a8bcd97281ccf4caa7e8f1
2022-12-08 18:29:24 +00:00
Abijeet
803092d4af tests: Remove unnecessary override to use pig-latin
Pig latin is enabled by default since
Ia80ad33cbf5e311fa8b84bd765a8df8d156f4c38

Change-Id: I0cd922bb0ee1fd7bce2ced2eacbdb6ed25ada7d8
2022-12-08 17:52:00 +05:30
jenkins-bot
1b3d4d17d4 Merge "Throw a 400 when asking parsoid to render an unknown content model." 2022-12-07 22:44:45 +00:00
daniel
a79b73e722 Make parsoid accept all content models.
This allows parsoid render anything, even if the output is garbage.
This is a quick fix pending the real solution (T311728).

Bug: T324711
Change-Id: If4e4eb8582ab8a62f592394820b30c1b28fb1216
2022-12-07 22:23:54 +00:00
daniel
d34e73b0c1 Throw a 400 when asking parsoid to render an unknown content model.
Bug: T324711
Change-Id: I0a78e5c57e2b8449b393bccc86148aee4ad87bc8
2022-12-07 23:09:58 +01:00
Derick Alangi
e1344b76cd Fix typo (hmtl) to html where necessary
Change-Id: If837968f402c71813121754b8fbdb5519c3dae34
2022-12-07 17:11:48 +01:00
jenkins-bot
bcb6cc5bbb Merge "HtmlOutputRendererHelper: fix semantics of getRevisionId" 2022-12-07 12:33:21 +00:00
jenkins-bot
ca84394a1d Merge "Use services in WikitextContentHandler" 2022-12-07 11:43:18 +00:00
daniel
9ff8edfa1e HtmlOutputRendererHelper: fix semantics of getRevisionId
getRevisionId is documented to return 0 for fake revisions, but it was
returning 0 for the current revision as well. This patch makes a clear
distinction, with 0 meaning current (like elsewhere in the code), and
null meaning a fake revision.

This patch includes a fix for redirect handling in ParsoidHandler::wt2html.
This fix is needed here because it previously relied on getRevisionId()
to return the actual revision ID; this would fail, since getRevisionId()
will return 0 when the current revision of a page is requested.

Change-Id: I33d1ab54023c6ac96c6bb5e4750b980e381cb464
2022-12-06 23:06:25 +01:00