Commit graph

49 commits

Author SHA1 Message Date
daniel
f503995c51 Add logging for redundant parsing to WikitextContent.
Bug: T205369
Change-Id: I67bfdc0340e0ddc1ecdaf3323f2171b2e752c680
2018-11-26 14:35:41 -08:00
Aryeh Gregor
f2e3c4d09f Give pages with ~~~~ a different cache TTL
This was supposed to already be the case, but it wasn't. The flag that
was set got cleared and never did anything.

Change-Id: Ide960f8cb9228f9a9d68c540369f122ada0a2a6f
2018-08-12 06:19:51 +00:00
Aryeh Gregor
4bdae1c9d2 Convert remaining MagicWord:: calls to MagicWordFactory
Bug: T200247
Depends-On: Ie061fe90f9b9eca0cbf7e8199d9ca325c464867a
Change-Id: I49c507f3875e46a8e15fd2c28d61c17188aabffc
2018-08-01 10:47:43 +03:00
James D. Forrester
326d655fc9 Drop 'comma' value for wgArticleCountMethod
We have three methods for page counting currently supported for wikitext
non-redirect pages; 'any' counts any page that exists, 'link' counts any
page that has any outbound links, and 'comma' which searches for any ','
in the text having loaded it. This last option is much slower than these
other two, and is only used on a very small number of installations. Now
by dropping support for this method we can simplify this code and so run
it more often. Note that non-wikitext pages already did not support this
count method.

Installations with this setting set to 'comma', or any other string will
now work as if it was configured with 'any'.

Bug: T188472
Change-Id: I965927edcd2485ec4b49b2d80fdf216dbf19520b
2018-03-01 16:37:23 -08:00
ryan10145
19c45cdb16 Changed Instances of rawParams() to plaintextParams()
Bug: T182213
Change-Id: Ibf24dee5ea19092e8a38e57f34c98f513d4c9b21
2017-12-07 20:20:40 +00:00
Umherirrender
b5cddfb27b Remove empty lines at begin of function, if, foreach, switch
Organize phpcs.xml a bit

Change-Id: Ifb767729b481b4b686e6d6444cf48b1f580cc478
2017-07-01 11:34:16 +00:00
Leszek Manicki
95b9d82a3a Fix parameter type docs
Changes:
 - uses int instead of number as param and return value type,
 - uses stdClass instead of stdObject
 - fixes ResourceLoaderClientHtml constructor's $target param type:
   it is string|null, not an array (previously misspelled as "aray")
 - changes the type of references to XML parser in XMP lib to resource
   instead of not existing XMLParser

Change-Id: I98c363ebc6658d1f4dcabad97a9a92f3fcd7ea8c
2016-12-14 17:01:47 +01:00
Kunal Mehta
85034abca5 content: Refactor normalization of line endings code
The code that normalizes line endings ("\r\n" and "\r" to "\n") and
trims trailing whitespace is buried in Parser::preSaveTransform(), and
was duplicated to TextContent in 96b6afb31d, as non-wikitext content
models should still be normalizing line endings.

This splits the duplicated code into
TextContent::normalizeLineEndings(), and utilize it in the Parser.
Additionally, expand the documentation of
TextContent::preSaveTransform() to document that subclasses should make
sure they normalize line endings during the PST stage.

And remove a useless rtrim() call from WikitextContent that did nothing.

Change-Id: I9094c671d4bbd23d75436f8f1d682d6dd6e6d2fc
2016-08-23 11:09:59 -07:00
Thiemo Mättig
0965bf5991 Add missing null type hints to Content::isCountable and implementations
Change-Id: I6e3128dddd296f6d33da23332b8ff8393837b61b
2016-02-25 14:13:22 +01:00
Kunal Mehta
6e9b4f0e9c Convert all array() syntax to []
Per wikitech-l consensus:
 https://lists.wikimedia.org/pipermail/wikitech-l/2016-February/084821.html

Notes:
* Disabled CallTimePassByReference due to false positives (T127163)

Change-Id: I2c8ce713ce6600a0bb7bf67537c87044c7a45c4b
2016-02-17 01:33:00 -08:00
Tim Starling
914f6a62a6 Introduce ParserOutput::getRawText()
Avoid polluting the parser cache with skin-dependent output from
Skin::doEditSectionLink() by introducing getRawText(), which provides
access to the uncooked text. Use this in
WikitextContent::fillParserOutput() which is the primary offender
judging by the debug logs (see referenced bug).

Bug: T124356
Change-Id: Ia9e1e4a6dc3a26f88eeebc64eed023ff20c53d58
2016-01-25 14:50:27 +11:00
umherirrender
70f3afd548 Remove unneeded empty lines at begin of if/else/foreach body
An if body must not begin with an empty line

Change-Id: I62b058be337fcc85a120fcd3dadce564db59a271
2015-06-19 20:05:45 +02:00
Aaron Schulz
c3e76a5966 Avoid pointless getNativeData() call in isCountable()
Change-Id: I40ed1972a8815de645d11217b35c1060d5007e5a
2015-05-20 23:56:25 -07:00
Ricordisamoa
2ae155da52 Fix phpcs errors in includes/
Mostly Squiz.WhiteSpace.SuperfluousWhitespace.EmptyLines

Change-Id: I678b2f0902f11cd1dfa1611b9da24e7237df9122
2015-01-08 20:15:07 +01:00
Chad Horohoe
aa21e125a3 Remove obvious function-level profiling
Xhprof generates this data now. Custom profiling of various
sub-function units are kept.

Calls to profiler represented about 3% of page execution
time on Special:BlankPage (1.5% in/out); after this change
it's down to about 0.98% of page execution time.

Change-Id: Id9a1dc9d8f80bbd52e42226b724a1e1213d07af7
2015-01-07 11:14:24 -08:00
Aaron Schulz
e369f66d00 Replace wfRunHooks calls with direct Hooks::run calls
* This avoids the overhead of an extra function call

Change-Id: I8ee996f237fd111873ab51965bded3d91e61e4dd
2014-12-10 12:26:59 -08:00
Brad Jorsch
bba2bc6ca0 Record redirect target in ParserOptions
Since Id44d566a, the text passed to the parser when parsing a
&redirect=no page no longer contains the #REDIRECT directive. For the
benefit of extensions that want to know the redirect target from various
parser hooks, record the target on the ParserOptions object associated
with the parse.

Bug: 62856
Change-Id: Icd1da9911a43eabacbd9e9a369a8326f67f270ff
2014-09-18 06:19:31 +00:00
Bartosz Dziewoński
7dc4b58615 Article: Don't hardcode <img> tags on redirect page
* Created a ResourceLoader module for redirect page styling.
* Fixed a couple of bugs in Article code.

Keeping two of the old files for a while because they might still be
referenced by something (bug 69277 comment 11).

Bug: 69277
Change-Id: I8fa565833545e41d0232101566da8c5ffa850e36
2014-09-05 22:00:57 +02:00
Kunal Mehta
ccee80b8a6 Make it easier to subclass Content and ContentHandler subclasses
Currently the names of associated Content classes are hardcoded,
meaning that any extension that wishes to subclass these implementations
must also re-implement that function, usually copying it exactly
with just the class name changed. Using "static" avoids that issue.

For ContentHandlers, I added a TextContentHandler::getContentClass,
which should be used when creating new Content objects.

Change-Id: I70f1a3291aec3460120ec20121a23f4cb68e04d1
2014-08-16 23:04:08 -07:00
umherirrender
02dc9da399 Cleanup some docs (includes/[a-d])
- Swap "$variable type" to "type $variable"
- Added missing types
- Fixed spacing inside docs
- Makes beginning of @param/@return/@var/@throws in capital
- Changed some types to match the more common spelling

Change-Id: I7b65fe04db431342cc58b469dc48f41a50c4e891
2014-07-24 19:42:45 +02:00
umherirrender
7ff005407e Remove colon after @deprecated/@param/@todo/@note
Change-Id: I4e66dad85eecf7e8e03ac760af900395e1bc11b6
2014-07-24 11:30:25 +02:00
Thiemo Mättig
f6cff5e392 Update documentation of what a "section" is
There are so many slightly different understandings of what a
"section" is or can be. I'm aware the documentation was improved
just a few weeks ago. I still find it incomplete and confusing.

1. I renamed it to $sectionId to make it more clear what it
really is.

2. Sections are usually numbers. 0, 1 and so on. There is no
reason to disallow the use of ints or even floats (this works
because the string representation of 0.0 is "0"). The code never
disallowed numbers.

3. 'T1' never was supported, as far as I can tell. 'T-1' is
supported. See Parser::extractSections().

4. null and false and '' all mean "the whole page" in
WikiPage::replaceSectionAtRev() but for some reason this meaning got
lost in WikitextContent::replaceSection(). I made it the same again.

Change-Id: Icc3997722d2ed742bf7703cd7c06d09199225720
2014-06-12 18:13:23 +02:00
daniel
48d5e5b3c9 Introduce ContentGetParserOutput hook
This hooks allows extensions to override the normal model-specific
rendering of page content. A typical use would be to provide syntax
highlighting for pages that contain scripts. In that sense,
ContentGetParserOutput is a generalization of the old ShowRawCssJs
hook.

This, together with I76412f9d, is a (hopefully) fixed version of the
reverted Ibfb2cbefea44.

Change-Id: I979e2438689648ba4c959d8083197ef14ce524e8
2014-05-10 14:27:33 +02:00
Bartosz Dziewoński
c3f7f91705 Documentation cleanup in Content-related files
Mostly extracted from I979e2438.

Change-Id: I6562d111c15425957eaaad31ded175811d7abf1c
2014-05-05 17:04:10 +02:00
withoutaname
652fdc09b7 Fix typos in WikitextContent.php
Fix typos in documentation for
/core/includes/content/WikitextContent.php

Change-Id: Idc0d4d9101309cea858473c86a4b12cf6e5f5ee4
2014-05-04 22:17:52 -07:00
Jackmcbarn
730c2c01a8 Allow passing parameters to preload
When pages are loaded in the edit box via preload, allow parameter
substitution. The interface-style $1 is used rather than the
template-style {{{1}}} to avoid conflicts with preloads that add template
parameters. Syntax is:
action=edit&preload=Foo&preloadparams[]=first&preloadparams[]=second

Bug: 12853
Change-Id: If02cf4b3dba9f9d22a956d8bfff224677cbce00d
2014-04-06 21:03:02 -04:00
Thiemo Mättig
6806400129 Added and updated Doxygen comments in content handler and diff namespaces
Reasons for touching this are:
* "@param type $var" were mixed in a lot of places. Both works but the
  MediaWiki coding conventions suggest that specific order.
* Things like String and Bool aren't objects and shouldn't be uppercase.
* Tried to fill missing types in "@param $var".
* Tried to fill missing descriptions in "@return type" when I could.
* Removed duplicate descriptions if a @see is sufficend.
* Removed useless descriptions ("isUsefull returns true if usefull").
* Removed useless @return void.
* Replaces mixed[] with array (does have the exact same meaning).
* Tried to find better replacements for "varargs", phpDocumentor
  suggest $var,...
* Order should be @since, @param, @throws, @return, @see. This is the
  order Doxygen renders this.

There is always more to do but I think this is already much better
than before. Please feel free to put more change sets on top of mine
or request more changes by adding comments.

Change-Id: I05262ce06caabf79f68772302524ac91bbead1c6
2014-03-06 11:17:41 +01:00
Siebrand Mazeland
f077c4b1d6 Update formatting
Change-Id: I18aff576262479c9bb1c56eb8e1d1aaae200e4b1
2014-02-06 09:27:05 +01:00
Brad Jorsch
d8b1b79ea4 Move redirect rendering into WikitextContent
There's no good reason for everything that wants to render a page to
have to test whether the page is a redirect and then call
Article::viewRedirect to get the fancy rendering instead of using the
ParserOutput. This logic can easily be moved into
WikitextContent::getParserOutput so callers can just use the
returned ParserOutput.

At the same time, we can handle "#REDIRECT [[File:Foo]]" and
"#REDIRECT [[Category:Foo]]" the way people expect, by recording the
link in pagelinks rather than imagelinks/categorylinks (although this
means fixing ImagePage's bug about assuming anything in imagelinks that
is a redirect is a redirect to the image too).

And we can finally fix bug 14323, too.

Bug: 14323
Bug: 17259
Bug: 27621
Bug: 42642
Bug: 50488
Change-Id: Id44d566a7ca35a1b9579d0c0e947877c980b0686
Followup: I1c7582d1bf7ec4184a45b00154e3dd5b39dd444b
Followup: I3653b608941813a73281f4f0545bea2487d43964
2014-01-07 09:18:22 -05:00
Siebrand Mazeland
5bec2e90d1 Update documentation and break long lines
Also remove some superfluous newlines.

Change-Id: I904d6ddeb976434708d5a22df9e8abd2e6f60a6c
2013-11-20 06:02:37 +01:00
Siebrand Mazeland
3bbe32d6e9 Update formatting
Change-Id: Ieee4747cf2401d0d89a497a7637d32348192f481
2013-11-19 22:26:16 +01:00
Ori.livneh
6ec90a1acd Revert "Introducing ContentGetParserOutput hook."
This change removed getHtml(), but not the call to it from fillParserOutput.
It has a few other issues that I'll flag in-line after deploying the revert.

This reverts commit fda090a7e7

Bug: 49398
Change-Id: Idcef8d4cedc7c03f72bc1743e0f89cc5ed4ad7a7
2013-06-10 19:13:00 +00:00
daniel
fda090a7e7 Introducing ContentGetParserOutput hook.
This hooks allows extensions to override the normal model-specific rendering
of page content. A typical use would be to provide syntax highlighting for
pages that contain scripts. In that sense, ContentGetParserOutput is a
generalization of the old ShowRawCssJs hook.

Change-Id: Ibfb2cbefea44eeee9f2a027f47e7721bf177ba0f
2013-06-04 15:57:04 +00:00
umherirrender
6f79eef473 Fixed spacing around parenthesis in includes
Change-Id: Ie8adc00f4ee8ecec4554e584c18d5d2073415397
2013-04-28 15:50:07 +00:00
umherirrender
978bb31c5e Add missing wfProfileOut before throwing an exception
Change-Id: I1d830da0597f19efd0b2ae48642389975e736e23
2013-04-08 18:37:24 +00:00
umherirrender
926d2ee143 Remove spaces between parentheses in function calls
Change-Id: If8ec665a01b566fa5189dfcc810b2d9a17f371e1
2013-03-17 16:13:22 +01:00
Tyler Anthony Romeo
4dcc7961df Fixed @param tags to conform with Doxygen format.
Doxygen expects parameter types to come before the
parameter name in @param tags. Used a quick regex
to switch everything around where possible. This
only fixes cases where a primitve variable (or a
primitive followed by other types) is the variable
type. Other cases will need to be fixed manually.

Change-Id: Ic59fd20856eb0489d70f3469a56ebce0efb3db13
2013-03-11 13:15:01 -04:00
umherirrender
be90ce07b3 fix some spacing
Change-Id: I93f0a87ba7129bc336083e7289247d3150feb606
2013-02-04 19:54:07 +00:00
Alexandre Emsenhuber
ddf601f7d3 Improve documentation of content handler stuff
- Split file and class documentation
- Add some missing file/class descriptions
- Add missing @ingroup Content

Change-Id: I7f7e3056570ca13a92f36a408c9b961c938f09a1
2012-12-20 20:44:47 +01:00
Platonides
2e518fb0bf Add missing wfProfileOut()
Change-Id: Id9c4958aa6659d66bb3486d17186424fbd9b5758
2012-12-06 23:03:25 +01:00
Antoine Musso
9362bb6c56 miscellaneous doxygen warnings
* @licence -> @license
* Protects inline HTML by using double quotes, our inline comments uses
  elements such as <h1> or <firstnameLastname@gmail.com>
* Commands in lowercase (@TODO -> @todo, @NOTE -> @note)
* removes @abstract and @static since doxygen detects them from PHP
  code.
* various undocumented function parameters
* typos in parameters declarations

Change-Id: I62ad6fc124c355bf31acc780b9614a59cf79a421
2012-10-22 14:00:08 +02:00
daniel
f4a1242db8 (Bug 41169) Apply rtrim on on preSaveTransfrom.
Wikitext should not have trailing whitespace.

Change-Id: I75eb1c4bef7217ec2b7440594e3fc4b68dc3c022
2012-10-18 19:40:29 +01:00
jeroendedauw
506456c138 Added docu headers to content(handler) files
Change-Id: I9981698a5e4d79db89892ce3f3e007dd5aee5fd1
2012-10-16 20:04:32 +02:00
Tim Starling
16f25691ea Fix WikitextContent::getSection() for missing sections
Make WikitextContent::getSection() return false when the section is
missing, as per the documented behaviour for Content::getSection(). Fix
a test so that it doesn't generate a PHP fatal error if getSection()
returns false.

Should fix the current Jenkins build failure:

https://integration.mediawiki.org/ci/job/MediaWiki-Tests-Misc/6989/testReport/junit/%28root%29/WikitextContentTest__testGetSection/testGetSection_with_data_set__2/

Change-Id: Ifa85f8eed50943d8ece32555d06b3e989077da46
2012-10-15 11:49:28 +11:00
daniel
bb51a58e57 Cleanup of Wikidata branch.
This cleans up several issues raised in comments to I3b2dad3a,
mostly style and merge artifacts.

Change-Id: I99f5e300a671db1353db151cd187ffd2e4478d03
2012-10-08 17:34:47 +02:00
daniel
c546fae8ed merge latest master into Wikidata branch
Change-Id: Id4e0f40c03679c13d8934a6add99b5cd86d0437d
2012-10-08 13:58:54 +02:00
daniel
7db9491d89 set mediawiki version number
Change-Id: I3479776bd3bb25c4d75d07e62ede2ad989025c5b
2012-10-05 15:03:24 +02:00
daniel
fe27182d64 Use canonical parser options per default
Change-Id: I2cbfaab2e15d9a1c1061f9ea31c7a8ebbeffdbd0
2012-10-04 13:00:05 +02:00
daniel
2b1016eb9d Split Content.php into one file per class.
Change-Id: Ib49d9ec729613dcc43d38d46cb133ff9df459d79
2012-09-24 22:51:53 +02:00