Commit graph

679 commits

Author SHA1 Message Date
jenkins-bot
38a241252a Merge "docs: Add missing StubUserLang type to some @param/@return" 2023-02-03 23:45:03 +00:00
jenkins-bot
3eb74515fd Merge "OutputPage: Call setSections() from addParserOutputMetadata()" 2023-01-16 22:23:22 +00:00
Umherirrender
1af3e211eb docs: Add missing StubUserLang type to some @param/@return
Change-Id: Ic1f192c7a21e529113fd7d537a79b2e4f8983b9c
2023-01-12 19:04:20 +01:00
thiemowmde
e25503c6a3 diff: Update incomplete PHPDoc type in DifferenceEngine
Change-Id: Ib1591246d20ad63f0e64756054816352d9bdede4
2023-01-10 20:37:49 +00:00
jenkins-bot
293f8dfba8 Merge "Make use of ??= in more places" 2022-12-21 00:33:46 +00:00
Bartosz Dziewoński
0945f6976c OutputPage: Call setSections() from addParserOutputMetadata()
Remove calls elsewhere which now became redundant.

Bug: T325562
Bug: T325600
Change-Id: I1611f3bdea46a729ecf9daf699d761b018d49b55
2022-12-20 01:08:23 +01:00
Umherirrender
82466b0594 diff: Handle timestamp correct for suppressed revisions
- No linking when the user cannot see the suppressed revision
- Double-strike the timestamp (b6f148b)

Bug: T325450
Change-Id: If94e9655d72e59a2b9d5147c5c2338e98f0ad163
2022-12-17 23:17:16 +01:00
DannyS712
c1db64b808 Make use of ??= in more places
New feature from PHP 7.4

Change-Id: Ifa7a9bc7b2ec415ad7ecb23f4c1776f51f58fd6b
2022-12-17 01:10:13 +00:00
Umherirrender
fd516a98e1 Fix whitespaces after comma
Change-Id: Ide6de0a53661e6f650099d7b1f274a02699441df
2022-12-15 01:24:14 +01:00
Umherirrender
f65e6bb488 Replace deprecated Linker::commentBlock/revComment
Bug: T324906
Change-Id: I8cf96c3b7a03127ce1243f7a7e849b6d5a5d3dfa
2022-12-11 01:33:56 +01:00
Amir Sarabadani
2d60ba0c63 Reorg: Move DummyLinker and Linker to linker/
This feels like a no-brainer unless I'm missing something obvious

Bug: T321882
Change-Id: Id49c3d0dd6ea4593211048850856b5b8e05a8fb3
2022-12-08 06:38:17 +01:00
Tim Starling
540bddfb1f When content is marked bad, show an error, don't pretend it is empty
It misrepresents the users contribution to show empty text for a
revision when in fact the revision contained some text which we later
lost.

Also, errors from SqlBlobStore::fetchBlobs() did not stop a cache entry
from being written, so a subsequent cache hit would show the bad
revision as empty.

So, in Storage:
* Add BadBlobException, which is thrown by the Storage layer to
  indicate that a revision is marked as bad.
* Have SqlBlobStore::getBlobStore() return an error for bad blobs
  instead of an empty string.
* Duplicate the check for flags=error into SqlBlobStore::expandBlob().
  This avoids an unnecessary cache fetch, and avoids making
  decompressData() throw on error, which would be a b/c break.
* In SqlBlobStore::getBlob(), suppress the cache when there was an
  error.

In Revision:
* Add BadRevisionException, to wrap BadBlobException in the Revision
  layer.
* Return null from RevisionRecord::getContent() on a broader set of
  errors. Make it mostly non-throwing.
* Add RevisionRecord::getContentOrThrow() which returns a non-nullable
  Content.
* Note that SlotRecord::getContent() returns a non-nullable Content so
  now throws in more cases.

In the UI:
* In Article::view(), catch the exception and show an error message.
* In DifferenceEngine, catch the exception and make a suitable error
  message available via getRevisionLoadErrors(). In the diff page, show
  the error message in a box.
* In ApiComparePages and the legacy rvdiffto, show a warning.
* In RawAction, show a 404 by analogy with other error cases.
* In EditPage, there was already handling for $content=null with an
  appropriate error message (missing-revision-content). But having
  $this->textbox1 = null caused PHP 8.1 deprecation warnings, so I fixed
  that.
* In EditPage undo, there was already handling for null content, but I
  improved the error message: "does not exist or was deleted" seems more
  appropriate than "conflicting intermediate edits".

Change-Id: Idd1278d6d756ef37d64addb7b5f3be30747ea603
2022-12-05 22:03:45 +00:00
Reedy
0cb2c3c106 Fix casing of class and function name usages
Bug: T253628
Change-Id: I5c64f436d3cf757390b751ce3e34bfc7872bc176
2022-12-04 19:09:30 +00:00
jenkins-bot
1f39f2892c Merge "Really drop DifferenceEngine::getDiffBodyCacheKey" 2022-11-17 14:09:34 +00:00
jenkins-bot
381c1f0822 Merge "Track reason for rendering in more detail." 2022-11-17 12:44:01 +00:00
Matěj Suchánek
755e86c8fb Really drop DifferenceEngine::getDiffBodyCacheKey
In 81f69c2, I have only removed the callers. The method is
now dead code and should have been removed as well.

Change-Id: I556ed5398435f4d3a5f400e07e4819dd16e0df06
2022-11-17 12:24:09 +00:00
Matěj Suchánek
81f69c23dc Remove DifferenceEngine::getDiffBodyCacheKey
It has been deprecated since 1.31 and it is unused.

Change-Id: Ia2473ba8b5e68b884ec0ee0464147c3a063eb45e
2022-11-16 16:08:29 +01:00
daniel
0820a7701f Track reason for rendering in more detail.
When setting causeAgent for jobs, be specific.
When creating parserOptions, call setRenderReason.

This allows us to capture statistics on what actions cause jobs,
renders, and cache writes.

Change-Id: Iaef64beadce1489bebb6bb00855c3ba6013a29d8
2022-11-15 15:32:03 +00:00
Matěj Suchánek
b9b1bcc5bc Remove DifferenceEngine::textDiff
It has been deprecated since 1.32 and it is unused.

Change-Id: I30563b714ba2ca2a4c2789186cd64db8274a17df
2022-11-09 16:41:54 +00:00
Tim Starling
09d9b6d5c0 WordAccumulator: use htmlspecialchars with ENT_NOQUOTES
PHP 8.1 adds single quotes to the list of encoded characters when
htmlspecialchars() is called with no flags. That's usually harmless,
but this instance breaks an extension test. So use ENT_NOQUOTES which is
optimal for text which is not inside a tag or attribute.

Bug: T322099
Change-Id: I3a2c385771b3f00a38a238bf745bd2997be60a9c
2022-11-02 12:38:02 +11:00
Tim Starling
0077c5da15 Use short array destructuring instead of list()
Introduced in PHP 7.1. Because it's shorter and looks nice.

I used regex replacement.

Change-Id: I0555e199d126cd44501f859cb4589f8bd49694da
2022-10-21 15:33:37 +11:00
Daimona Eaytoy
947ff7c0f5 build: Update mediawiki/mediawiki-phan-config to 0.12.0
This patch only adds and removes suppressions, which must be done in the
same patch as the version bump.

Bug: T298571
Change-Id: I4044d4d9ce82b3dae7ba0af85bf04f22cb1dd347
2022-10-08 15:45:42 +02:00
Daimona Eaytoy
350e9b88c1 Fixes for the phan upgrade, part 1
Mainly, document some parameters as non-empty-array so that phan knows
the list of arguments won't be empty when unpacking.

In EditPage, account for hooks potentially unsetting the copyright
notice.

Also rewrite some code in LogPager, so it's hopefully easier for phan to
understand what's going on.

Change-Id: Ic0638571554424098d0743db32dd46723a08e103
2022-10-08 13:08:47 +00:00
C. Scott Ananian
c0c220e93d Use default ParserOutput::getText() options for injectTOC
We rely on the default settings for `skin` and `injectTOC` set by
OutputPage::addParserOutputText(), and so no longer need to explicitly
initialize these from the skin options.

Bug: T317333
Depends-On: Ica30569efbb5730eff5b807e8fc34beb2e13e74f
Change-Id: I5b8ecd1abf87e66bb75d7c26790f9e7c1b3a6da3
2022-09-08 15:56:14 -04:00
jenkins-bot
1fb3b92a0b Merge "OutputPage: Provide consistent info about whether the revision shown is current" 2022-08-31 13:37:23 +00:00
Bartosz Dziewoński
bbbf575f42 OutputPage: Provide consistent info about whether the revision shown is current
Previously, OutputPage::isRevisionCurrent() would check a replica
database, potentially different from the database used to fetch the
revision being displayed, according to OutputPage::getRevisionId().
Now the data for both functions is provided in the same way.

Bug: T314684
Change-Id: I266d643d1eed931df346889f43d72d42e5f4a3ba
2022-08-31 13:15:54 +00:00
Jon Robson
af9b17b660 DifferenceEngine: Should respect skin option for rendering table of contents
Bug: T311529
Change-Id: If6267f3389b166043fc94d7f952bc54122b1a378
2022-08-23 15:44:36 +00:00
Matěj Suchánek
3378c95852 Hard deprecate DifferenceEngine::textDiff
It has been deprecated since 1.32 and it is unused.

Change-Id: Icca017deb30dfc335f56ebc1ab2e6522c64e64af
2022-07-08 07:01:05 +00:00
jenkins-bot
8ce7ab0d6a Merge "Hard deprecate DifferenceEngine::getDiffBodyCacheKey" 2022-07-05 21:42:06 +00:00
Matěj Suchánek
07a9769501 Hard deprecate DifferenceEngine::getDiffBodyCacheKey
It has been deprecated since 1.31 and it is unused.

Change-Id: I44bc12e484b4d8ebf362c5ed3ed6052e70016453
2022-07-05 20:33:51 +02:00
Lucas Werkmeister
bc59ea456f Mark WordLevelDiff as newable for now
Using the same rationale as for its parent class, Diff: ideally there
should be some kind of factory for diffs, but currently, there isn’t.
Reuse the same task ID for the todo comment (T257472), as we think it’s
appropriate for both “diff” classes, Diff and WordLevelDiff.

Note that the TwoColumnConflict extension already uses this class as if
it were newable.

Bug: T311224
Change-Id: If2553d6ebc96636b83df8f58e0420dd7eb6ba5af
Co-Authored-By: Michael Große <michael.grosse@wikimedia.de>
2022-06-30 16:51:06 +02:00
Umherirrender
69b6c4983d Pass array to Assert::parameterType when asserting multiple types
Change-Id: I6db78db18b2d8982ce5158f44c03bfdb8d48f97c
2022-06-18 09:34:36 +02:00
Matěj Suchánek
e47c441078 Fix many typos in comments
Found using IntelliJ's "Typo" code inspection.

Change-Id: I746220ebe6e1e39f6cb503390ec9053e6518cf16
2022-05-10 12:46:11 +00:00
Aryeh Gregor
4a52bf553f Use MainConfigNames instead of string literals, #3
This edition brought to you by:

grep -ERIn $(grep -o "'[A-Za-z0-9_]*'" includes/MainConfigNames.php | tr
"\n" '|' | sed 's/|$/\n/') includes/

I only corrected a fraction of the results provided by that command. I'm
submitting the partial patch now so it doesn't bitrot.

Bug: T305805
Change-Id: If1918c0b3d88cdf90403921e4310740e206d6962
2022-04-26 14:31:26 +03:00
Umherirrender
0c9496c3bf diff: Replace deprecated User::getOption
Bug: T296083
Change-Id: I8362cec1c48a2f096d9d93e50d79e9e5cb127236
2022-04-22 14:21:13 +02:00
Umherirrender
1f71eccf63 phan: Disable null_casts_as_any_type setting
Make phan stricter about null types by setting null_casts_as_any_type to
false (the default in mediawiki-phan-config)
Remaining false positive issues are suppressed.
The suppression and the setting change can only be done together

Bug: T242536
Bug: T301991
Change-Id: I0f295382b96fb3be8037a01c10487d9d591e7e01
2022-03-21 18:25:07 +00:00
Umherirrender
d7248d63fb Fix various documentation related to null types (part II)
The functions returning null or the class property is set explict null.
Some function should not accept null or return null.

Found by phan strict checks

Change-Id: Ie50f23249282cdb18caa332f562a3945a58d86ff
2022-03-08 23:45:31 +00:00
Umherirrender
b126dbe3f2 Fix various documentation related to null types
The functions returning null or the class property is set explict null

Found by phan strict checks

Change-Id: I4a271093fb6526564d8083a08249c64cb21f2453
2022-02-26 10:31:24 +01:00
jenkins-bot
c82ced1ba1 Merge "diff: Fix small issues and compact syntax in DifferenceEngine" 2022-02-04 15:09:28 +00:00
Thiemo Kreuz
32bbb421c7 diff: Fix small issues and compact syntax in DifferenceEngine
The purpose of all these changes is not only to make the code
shorter, but to make it more readable.

Notable:
* Fix wrong type hints.
* The `foreach ( $roles )` loop was processing everything twice.
* Inline preg_replace_callback() callbacks.

Change-Id: I2b8146946ab6966cc6f047556a0a898624af181a
2022-02-04 10:55:48 +01:00
Ammarpad
c5fc8ae96c Add default comment when there's no comment on some changeslist pages
Default comment is added to changelist rows that have no comment/edit
summary. This affects history and diff pages as well contributions page.

The default comment is hidden by default.

Bug: T298645
Change-Id: I2982a69886a90797b2a658df13db9780e88b871c
2022-01-25 12:25:55 +01:00
Umherirrender
990acaa7a2 Avoid revision 0 listed in message difference-missing-revision
For Special:Diff/prev/1234567890 the message is
2 revisions of this difference (0 and 1234567890) were not found.

The 0 is not helpful

Change-Id: I6bada64c8cffb4e653ea7a46c31fb014fd6b862f
2022-01-08 12:19:57 +01:00
Siddharth VP
191cadb6a5 Fix typos in comments (C-D)
Change-Id: I568fb93b53feb83f026d485136dd0d116d677f4f
2021-12-30 18:00:02 +05:30
Legoktm
93f79a9122 Revert "Replace deprecated methods IContextSource::getWikiPage && IContextSource::canUseWikiPage"
This reverts commit ef458e8948.

Reason for revert: Causes page tabs to disappear on Special:WhatLinksHere.

Bug: T297744
Change-Id: I0ee282a9f7a5a9b2cfdc3261d800d9e27eaf977e
2021-12-14 12:43:15 -08:00
Amir Sarabadani
3cacc7f9c3 Fix local rendering of link in diff view with action=render
We probably should move Linker::expandLocalLinks( $text ) somewhere
better.

Bug: T263581
Change-Id: Iac446e761a709b6ceff5bd83dfa9a80db50a08d5
2021-12-01 17:18:53 +01:00
jenkins-bot
701b77930b Merge "Use LinkRenderer instead of building link HTML manually" 2021-11-27 08:28:50 +00:00
Reedy
2a2bb1e9bd Remove or replace usages of "sane"
Bug: T254646
Change-Id: I096b2cf738a1395a14f1d47bcbed0c2c686c2581
2021-11-22 13:35:17 +00:00
Reedy
7bf779524a Remove or replace usages of "sanity"
Bug: T254646
Change-Id: I2b120f0b9c9e1dc1a6c216bfefa3f2463efe1001
2021-11-19 23:19:42 +00:00
jenkins-bot
6f210f1128 Merge "Replace deprecated methods IContextSource::getWikiPage && IContextSource::canUseWikiPage" 2021-11-19 15:09:58 +00:00
Roman Stolar
ef458e8948 Replace deprecated methods IContextSource::getWikiPage && IContextSource::canUseWikiPage
Bug: T275710
Change-Id: I74b8f76a525793bc029d9ee1f7297b46ac0a9174
2021-11-16 13:58:39 +02:00