Commit graph

1037 commits

Author SHA1 Message Date
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
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
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
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
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
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
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
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
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
C. Scott Ananian
53fe91ded5 Hard deprecate Preprocessor_DOM
The Preprocessor_DOM implementation doesn't interact well with PHP memory
profiling, and has some limitations not present in the Preprocessor_Hash
implementation (see T216664).  There is no reason to keep around two
versions of the preprocessor: it just complicates on-going wikitext
feature development.

Hard deprecate use of Preprocessor_DOM, so we can remove the redundant
code in a future release.

Bug: T204945
Depends-On: Id38c9360e4d02b570996dbf7a660f964f02f1a2c
Change-Id: Ica5d1ad5b1e677542962fc36d582a793f941155e
2019-06-14 12:21:40 -04:00
Derick Alangi
21e2d71560 Replace some uses of deprecated wfFindFile() and wfLocalFile()
These global functions were deprecated in 1.34 and services made
available to replace them. See services below;

* wfFindFile() - MediaWikiServices::getInstance()->getRepoGroup()->findFile()
* wfLocalFind() - MediaWikiServices::getInstance()->getRepoGroup()->getLocalRepo()->newFile()

NOTES:

* wfFindFile() and wfLocalFind() usages in tests have been ignored
  in this change per @Timo's comments about state of objects.

* includes/upload/UploadBase.php also maintained for now as it causes
  some failures I don't fully understand, will investigate and handle
  it in a follow up patch.

* Also, includes/MovePage.php

Change-Id: I9437494de003f40fbe591321da7b42d16bb732d6
2019-06-11 13:26:37 +00:00
Aaron Schulz
e85fe191c9 parser: inject the time for {{REVISIONTIMESTAMP}} on pre-save parse
DerivedPageDataUpdater::prepareContent already locks in the revision
timestamp before insertion, so inject that into the parser options
used for any pre-save parse (e.g for edit filters).

This means that a reparse is no longer needed within in the same save
request to get the post-save canonical output. A parse will still be
required if the edit filter output used an edit stash output, since
the revision timestamp is not set at stash time.

Instead of using vary-revision, add a vary-revision-timestamp flag
for the revision timestamp words. The month/day/hour variants retain
their prior optimizations for allowing edit stash output reuse for
the post-save canonical output.

Change-Id: Ic2c13db4d21197c79a89de0de56745ca32918eb6
2019-06-09 13:12:57 +01:00
Aaron Schulz
19ab538705 parser: list the vary-* flags in the NewPP report HTML comment
Change-Id: I5a4afba2bfdb5b5b56ba0a01ed8ff444a67fbb1a
2019-05-29 10:58:56 -07:00
Aryeh Gregor
7149153754 Don't pass Config to Parser(Factory)
Change-Id: I5996b7cad8c8a61518d2997e955a4547c64a73a5
2019-05-20 11:19:21 -05:00
Derick Alangi
b76886d4f8 parser: Remove deprecated Parser class attribute $mUniqPrefix
This variable was deprecated in 1.26 and per a quick search using
Code Search: https://codesearch.wmflabs.org/search/?q=mUniqPrefix&i=nope&files=&repos=
it's no longer used. Hence, removed.

Change-Id: Ic8f939dde3ea511e8e46faf0f1b212d3db2d80cd
2019-04-22 12:38:51 +01:00
jenkins-bot
d02723401c Merge "Simplify and unify the {{REVISIONID}} handling code in Parser" 2019-04-17 22:17:10 +00:00
jenkins-bot
63591baccc Merge "Use LinkTarget in Linker instead of Title" 2019-04-17 18:16:28 +00:00
Aryeh Gregor
e6df285854 Remove all $wgParser use from core
Bug: T160811

Change-Id: I0556c04d33386d0339e02e2bf7a1ee74d97c2abd
2019-04-17 15:16:50 +03:00
Aaron Schulz
9f267e7d69 Simplify and unify the {{REVISIONID}} handling code in Parser
Improve documentation for Parser::getRevisionId().

Change-Id: I3cb8721e3bc2e3a06c3158cd60742bc10a458f20
2019-04-16 03:40:08 -07:00
Aryeh Gregor
b6e1e99bec Use LinkTarget in Linker instead of Title
Bug: T214318
Change-Id: I60b6208fa5b45a568e81f908a19cd0f244ef79be
2019-04-15 17:15:05 +03:00
Aaron Schulz
d256b472f7 parser: use "-" for revision ID for non-preview edit filter parse during save
This avoids a double parse when the edit stash is not used,
which can be confirmed via the SaveParse log for a page
using {{REVISIONID}} when edit stashing is disabled. This
now matches the reuse for the edit stash hit case.

Change-Id: I405c39d4d7ac04e39fbdfe400f73238b734c7833
2019-04-13 16:43:06 -07:00
Aaron Schulz
5e6d9340cb Add vary-revision-exist flag to handle {{REVISIONID}} and parser cache
Follow-up to c537eb1868

Bug: T220854
Change-Id: Idc19cc29764a38e3671ca1dea158bd5fb46eaf4d
2019-04-12 17:20:50 -07:00
Aryeh Gregor
80590a15dc Update Parser to use NamespaceInfo
Change-Id: I668a51487786e4ab05a153ca3995388e79c13b42
2019-04-11 15:40:49 +03:00
Aryeh Gregor
21f7ab7e22 Inject LinkRendererFactory into Parser
Change-Id: Idaf5a0f897dc3bd2aa9bf03be280281836bfc645
2019-04-07 15:02:30 +03:00
Reedy
c13fee87d4 Collapse some nested if statements
Change-Id: I9a97325d738d09370d29d35d5254bc0dadc57ff4
2019-04-04 19:02:22 +00:00
jenkins-bot
58d70885d8 Merge "Disable expensive {{REVISIONID}} magic word in miser mode" 2019-04-02 20:24:25 +00:00
Thiemo Kreuz
9314453c93 Make use of the list() feature where it makes sense
This code is functionally identical, but less error prone (not so easy
to forget or mix these numerical indexes).

This patch happens to touch the Parser, which might be a bit scary. We
can remove this file from this patch if you prefer.

Change-Id: I8cbe3a9a6725d1c42b86e67678c1af15fbc5961a
2019-03-24 20:12:23 +00:00
Aaron Schulz
c537eb1868 Disable expensive {{REVISIONID}} magic word in miser mode
This only applies to content namespaces for now since
the cost of vary-revision-id is much less of a concern.

The potential to harm page save time is far worse than what
use they have, which is almost entirely just hacks to check
for preview mode. These have nothing to do with the actual
revision ID nor timestamp itself. They simply check whether
the value is the empty string. Since this magic word still
only returns an empty string in preview mode, such checks
will keep working.

Bug: T137900
Depends-on: I1809354055513a5b9d9589e2d6acda7579af76e2
Change-Id: Ieff8423ae3804b42d264f630e1a029199abf5976
2019-03-09 10:50:49 -08:00
Max Semenik
1e9db557d7 Remove $wgMediaInTargetLanguage
It's a temporary feature flag not included in any release, just
removing it outright. The functonality will now be always enabled.

Bug: T205040
Change-Id: Ia9da82e6f6b2d270f1790a99fc8c35ad5e6aee5e
2019-03-08 15:24:39 -08:00
Fomafix
f17c297624 Use short assignment operator in PHP
Use
  $var .= $foo
instead of
  $var = $var . $foo

Change-Id: I5dcdd7278e618c14968e5ac1fb8ea43ac2200deb
2019-03-07 09:55:49 +01:00