Commit graph

1892 commits

Author SHA1 Message Date
Daimona Eaytoy
bd5b6f98ba Fix new phan errors, part 3
These are almost only doc changes, with two exceptions:
1-In LinkHolderArray, int-alike array keys are now cast to int, to be uniform with what we do in other code paths
2-In ExtensionRegistration, changed a line to throw an Exception
immediately, instead of an ExtensionDependencyError. This is because the
latter takes an array with msg and type, but we were passing it a plain
string (and in fact the code was bugged).

Bug: T231636
Change-Id: I8b0ef50d279c2a87490dde6a467a4e22c0710afd
2019-10-12 10:35:22 +00:00
Daimona Eaytoy
95dc119527 Fix new phan errors, part 2
Still mostly doc-only.

Bug: T231636
Change-Id: I65cec6c716ce6859e14da00a12ef71e03603e59a
2019-10-12 10:35:09 +00:00
Daimona Eaytoy
e3412efac3 Unsuppress PhanParamReqAfterOpt, use PHP71 nullable types
These were all checked with codesearch to ensure nothing is overriding
these methods.
For the most part, I've updated the signature to use nullable types; for
two Pager's, I've just made all parameters non-optional, because you're
already forced to pass them with a required parameter at the end.

Bug: T231636
Change-Id: Ie047891f55fcd322039194cfa9a8549e4f1f6f14
2019-10-10 11:53:58 +02:00
James D. Forrester
74f8ae0a24 [BREAKING CHANGE] Services: Convert Parser's static to a const now HHVM is gone
Change-Id: I54eafc84694bf68fe791b482865a1763c0439cbf
2019-10-09 12:26:48 -07:00
Máté Szabó
a4ae3eb321 PPFrame: Use explicit varargs in method parameters
With the removal of HHVM support, we can now use explicit varargs
in function arguments. This patch updates the PPFrame interface to
do so, and also removes PhanCommentParamWithoutRealParam check suppressions,
which are now redundant.

It seems that classes implementing this interface were already using varargs.

Bug: T231710
Change-Id: Ib1d69575835df80dca4e43b0028ad9368f62bb58
2019-10-05 18:06:22 +02:00
jenkins-bot
3b9ac4a7f2 Merge "Remove meaningless (auto-generated?) constructor documentation" 2019-10-02 12:20:59 +00:00
Thiemo Kreuz
879f749a62 Remove meaningless (auto-generated?) constructor documentation
Yes, the constructor of a class constructs a new instance of that
class. That's what constructors are for. No need to document this.

Change-Id: Ia94f476512f437f48edfeb71d95b269ac2ca0ab4
2019-10-01 14:34:21 +02:00
Fomafix
3dff713fe4 Parser: Add Title type hints
getTitle() and Title() will never return NULL anymore. When mTitle is
not set then a TypeError be thrown at runtime. The explicit local
checks for is_null( $this->mTitle ) are not needed anymore when
$this-getTitle() instead of $this->mTitle is used.

Change-Id: I09a178e5c6938954edb2949f13660227d6a01fbc
2019-09-26 16:34:12 +02:00
jenkins-bot
c96b8354fc Merge "Parser: Use 'Special:Badtitle/Parser' instead of 'NO TITLE'" 2019-09-26 14:15:53 +00:00
Fomafix
a6e8182b9b Parser: Use 'Special:Badtitle/Parser' instead of 'NO TITLE'
Change-Id: I818ac7d4766c3e52b56c2bd4abddb88e4140003b
2019-09-22 21:35:15 +02:00
Umherirrender
268346e562 phan: Enable PhanTypeMismatchArgument issue
Bug: T231636
Depends-On: I5de4f8f32a47c3f41c990ffe2ebd091fc23d1a58
Change-Id: I34d65fe3ff1916f2af675f0b1f19641b0cdfadc0
2019-09-19 20:11:42 +02:00
Daimona Eaytoy
b138a9b228 Fix using null for a non-nullable argument
These are reported by phan as PhanTypeMismatchArgumentNullableInternal
when null_casts_as_any_type is disabled.

Change-Id: I85076ee31c1bfc59a19600e84da0d915e425890a
2019-09-19 16:55:03 +00:00
Daimona Eaytoy
dddc912fd6 Update docblocks for methods potentially returning null
These were discovered by setting `null_casts_as_any_type` to true in
phan, and filtering by `PhanTypeMismatchReturnNullable`. Of course there
are others, some of which are false positives, but we cannot suppress
them now (or the UnusedSuppressionPlugin will complain).

Change-Id: Ia8443e575c22f47a6d8c63038f4e7ac36815fc27
2019-09-15 15:22:39 +00:00
Daimona Eaytoy
15e4968ee9 parser: Declare some dynamic properties
Mostly via the @property annotation. This is to make phan a little
happier.

Change-Id: I3fde33955240dab20870821e9db93caba163845b
2019-09-08 19:03:03 +00:00
Umherirrender
94683c3d56 parser: Document PPFrame_DOM::expand() as taking DOMNodeList
Caught by PhanTypeMismatchArgument, to be enabled with I34d65fe3ff191.

Change-Id: Ifa41f1c8a099a8d6c4e37052c8d93dc8473ec4f0
2019-09-08 04:04:06 +00:00
Daimona Eaytoy
b5cbb5ab3f Upgrade phan config to 0.7.1
This allows us to remove many suppressions for phan false positives.

Bug: T231636
Depends-On: I82a279e1f7b0fdefd3bb712e46c7d0665429d065
Change-Id: I5c251e9584a1ae9fb1577afcafb5001e0dcd41c7
2019-09-04 08:20:53 +00:00
Daimona Eaytoy
43cc14657d Unsuppress phan issues, part 8
And also clean up the config.

Bug: T231636
Depends-On: Ie6233561de78457cae5e4e44e220feec2d1272d8
Change-Id: I82a279e1f7b0fdefd3bb712e46c7d0665429d065
2019-09-04 01:02:06 +00:00
Daimona Eaytoy
c659bc6308 Unsuppress another phan issue (part 7)
Bug: T231636
Depends-On: I2cd24e73726394e3200a570c45d5e86b6849bfa9
Depends-On: I4fa3e6aad872434ca397325ed7a83f94973661d0
Change-Id: Ie6233561de78457cae5e4e44e220feec2d1272d8
2019-09-03 17:19:21 +00:00
Daimona Eaytoy
327e8ea416 Unsuppress phan issues part 6
Bug: T231636
Depends-On: I50377746f01749b058c39fd8229f9d566224cc43
Change-Id: I2cd24e73726394e3200a570c45d5e86b6849bfa9
2019-09-01 09:48:45 +00:00
Daimona Eaytoy
5eac6d131c Unsuppress more phan issues (part 3)
Bug: T231636
Depends-On: I78354bf5f0c831108c8f606e50c87cf6bc00d8bd
Change-Id: I58e67c2b38389df874438deada4239510d21654f
2019-08-31 16:38:55 +00:00
Daimona Eaytoy
fb3428eb8f Unsuppress other phan issues with low count
And also update approximated counts, which for the most part are lower
than reported (hooray!)

Bug: T231636
Depends-On: Ica50297ec7c71a81ba2204f9763499da925067bd
Change-Id: I78354bf5f0c831108c8f606e50c87cf6bc00d8bd
2019-08-30 09:42:15 +00:00
Daimona Eaytoy
7f7efbe026 Globally unsuppress phan issues with low count
All of these suppression prevent the detection of many common mistakes,
and could easily prevent things like T231488. Especially if there are
few issues of a given type, it's way better to suppress them inline,
instead of disabling them for the whole core.
This patch only touches the one with a lower count (although those
counts may be out of date).

Bug: T231636
Change-Id: Ica50297ec7c71a81ba2204f9763499da925067bd
2019-08-30 09:40:47 +00:00
Fomafix
d2b0f2960b Use ->getTitle() instead of ->mTitle to get the title from Parser
This allows to make mTitle a private property.

Change-Id: If953546cf4bb0324e4ae41d2195254c37c0ad3b4
2019-08-27 12:29:39 +02:00
Aaron Schulz
6c31ca3f25 parsercache: use WRITE_ALLOW_SEGMENTS for cached ParserOutput values
This lets large output entries fit into memcached via key segmentation.

Follows b09b3980f9 which applied the feature to PageEditStash.

Bug: T204742
Change-Id: I33a60f5d718cd9033ea12d1d16046d2bede87b5b
2019-08-25 00:53:28 +00:00
jenkins-bot
07163a20dd Merge "BadFileLookup to replace wfIsBadImage" 2019-08-22 08:16:51 +00:00
Aaron Schulz
26b1ba3989 parser: document what 0/null rev IDs do when given to Parser::parse
This was extremely obscure and tricky to figure out before

Change-Id: Ibdbb669431819eecd34de508735864e977d51021
2019-08-21 11:13:49 -07:00
Aryeh Gregor
5e2199c5b0 BadFileLookup to replace wfIsBadImage
I think this probably shouldn't be directly in the MediaWiki namespace,
but I don't know where is a better place to put it.

In order to avoid gratuitous use of TitleFormatter, I changed the cache
format -- the old implementation used getPrefixedDBkey() and I switched
to an ns/dbkey pair. I also changed the cache keys to use SHA1 instead
of MD5, by Daniel's request.

The previous implementation cached the parsed blacklist for one minute
without invalidation, so it could return slightly stale results, but it
didn't retrieve the bad image list message on a cache hit. The new
implementation unconditionally retrieves the bad image list message, but
uses a hash of it in the cache key and caches for one day. The new
behavior happens to be more cleanly implementable in a service.

Bug: T200882
Bug: T139216
Change-Id: I69fed1b1f3cfc1aa149e0739780e67f6de01609d
2019-08-21 20:45:37 +03:00
Aryeh Gregor
8ec24b607a Introduce MovePageFactory
This will help make MovePage more testable.

In the course of abstracting the logic out of ParserFactoryTest to
FactoryArgTestTrait so it could be used in MovePageFactoryTest, I made
them all unit tests instead of integration. This required some
modification to the Parser constructor so that it didn't access
MediaWikiServices unnecessarily.

Change-Id: Idaa1633f32dfedfa37516bb9180cfcfbe7ca31aa
2019-08-19 20:25:31 +03:00
jenkins-bot
8d99548cb6 Merge "Add Parser::resetOutput() and getStripState()" 2019-08-16 08:38:56 +00:00
jenkins-bot
ea23891646 Merge "parser: use 'vary-revision-sha1' in Parser::statelessFetchTemplate" 2019-08-16 00:07:49 +00:00
sbassett
dcdbd13d97 Set @return-taint of Sanitizer::stripAllTags to tainted
phan-taint-check (aka SecurityCheckPlugin) doesn't recognize
Sanitizer::stripAllTags' output as tainted in certain situations.
Adding a @return-taint of tainted to ensure that it does, which
may result in the reporting of more issues.

Bug: T230234
Change-Id: I357c168417a26882c7c460df20f36ec2be401096
2019-08-13 17:07:27 -05:00
Tim Starling
ca5836a83e Add Parser::resetOutput() and getStripState()
For Parsoid's convenience, add to Parser resetOutput(), getStripState()
and a $revId parameter to startExternalParse().

Parser::resetOutput() allows Parsoid to get the ParserOutput of each
template without resetting the DOM cache.

Change-Id: I084676acdc8db185b8efd9b97b7d5326afd2a997
2019-08-13 13:40:07 +10:00
Aaron Schulz
147eefaa6e parser: use 'vary-revision-sha1' in Parser::statelessFetchTemplate
Bug: T226785
Change-Id: Ib306cdcbc939553ea318612cb5273d6b77c5e21c
2019-08-08 17:22:29 -07:00
Tim Starling
bdedfb8ffa Suppress notice from ParserOutput::__sleep()
Bug: T229366
Change-Id: I8f0a537f0b6b76aac0c52e691ec4653c51c49940
2019-08-01 10:11:12 +10:00
Tim Starling
212ae934cd Revert rename of mSpeculativeRevId to speculativeRevIdUsed
And add a test which is confirmed to fail on HHVM prior to this change
with the error message "serialize(): "" returned as member variable from
__sleep() but does not exist".

Bug: T229366
Change-Id: I236bb4d64bc2e9f7756885e8c418399804eac5e1
2019-07-31 02:42:27 +00:00
Tim Starling
ae116da889 Code cleanup related to initSpeculativePageId()
Change-Id: I5b97c6292a28df6633c573a05c89210b096db5a8
2019-07-26 16:41:00 +10:00
Aaron Schulz
5099ee9f72 parser: add speculative page IDs to use with {{PAGEID}}
This works similarly to speculative rev IDs with {{REVISIONID}}.
Re-parses can be avoided if the page ID is correctly guessed.

Also make the {{PAGEID:X}} parser function set vary-page-id.

Bug: T226785
Change-Id: I0b19be45e6ddd6cde330bfcd09d243e4e5beda01
2019-07-26 16:41:00 +10:00
jenkins-bot
16b53c9085 Merge "parser: inject a Logger into Parser instead of using wfDebug()" 2019-07-25 10:41:07 +00:00
Sam Wilson
c251368ff7 Add null to Parser::getTitle return doc
Change-Id: I5086f636114cec83f0188d2309ea70aef27df13d
2019-07-24 13:00:13 +08:00
Aaron Schulz
3a044ca51c parser: inject a Logger into Parser instead of using wfDebug()
Add Parser::setOutputFlag helper method to reduce code duplication.
Also, clean up various Parser and SaveParse debug log messages.

Bug: T226785
Change-Id: I5dce2220bd43f5d642c017b88d02870dcb92f44e
2019-07-17 21:30:55 -07:00
jenkins-bot
3e74b6eeaa Merge "parser: add vary-revision-sha1 and related ParserOutput methods" 2019-07-17 23:57:17 +00:00
Aaron Schulz
dd6ed7840f parser: add vary-revision-sha1 and related ParserOutput methods
This can be used to avoid double parsed on save if the prior output
can be reused in-spite of involving a self content reference.

Change-Id: Idcd30a3fa3f7012dac76ce8bbf46625453ae331f
2019-07-17 05:12:18 +00:00
jenkins-bot
ed0193f1fb Merge "Improve type hints in parser related classes" 2019-07-09 15:11:57 +00:00
Umherirrender
dd25f3df6b Improve type hints in parser related classes
Change-Id: Ia07a2eb32894f96b195fa3189fb5f617e68f2581
2019-07-05 21:29:32 +00:00
jenkins-bot
20e65a1915 Merge "parser: inject the time for {{REVISIONTIMESTAMP}} on pre-save parse" 2019-06-23 22:13:48 +00:00
jenkins-bot
a8f3021181 Merge "Deprecate Sanitizer::setupAttributeWhitelist/attributeWhitelist" 2019-06-21 16:12:05 +00:00
jenkins-bot
8e87dddf1a Merge "Remove OutputPage::enableSectionEditLinks(), ParserOptions::get/setEditSection()" 2019-06-20 19:18:41 +00:00
C. Scott Ananian
bda42cef3c Deprecate Sanitizer::setupAttributeWhitelist/attributeWhitelist
These methods should be made private in the next release, but
hard-deprecate them for 1.34.

Tweak the return value of the attribute whitelist to be an
associative rather than a sequential array, which makes the
lookup of allowed attributes more efficient and avoids an
array_flip for every html element sanitized.

Bug: T221677
Change-Id: I17d734937accec6c2679dbe17328cf9554bd556a
2019-06-20 14:42:20 -04:00
Derick Alangi
716bb024aa Parser: Remove deprecated method Parser::fetchFile()
Deprecated in 1.32 and no longer used, see usage below;

Usage
=====

https://codesearch.wmflabs.org/search/?q=%5CbfetchFile%5C(%20(.*%3F)%2C%20(.*%3F)%20%5C)&i=nope&files=&repos=

Change-Id: Id0f76ee5c0e2a230dabb563c9d9e5c0a584f6b2c
2019-06-20 17:16:30 +00:00
Reedy
2c35b5be5f Add some @since tags to ParserOutput::SUPPORTS_ constants
Change-Id: I2f6588fe563ed5c1dc5ef2a70e2ed59fdca99018
2019-06-20 15:33:00 +01:00