Commit graph

1242 commits

Author SHA1 Message Date
jenkins-bot
f311f96e98 Merge "Use config instead of globals for OutputPage" 2014-08-23 20:21:44 +00:00
jenkins-bot
d4bd78dbfb Merge "OutputPage: addParserOutput*() family doesn't need to take a reference" 2014-08-23 19:59:49 +00:00
Bartosz Dziewoński
4bb54bbe30 OutputPage: addParserOutput*() family doesn't need to take a reference
We never assign to the variable, only call some (mutating) methods on
the object. With PHP 5 we don't need to pass this by reference.

The functions that evolved into this family were originally added in
r12337, back then we probably still ran on PHP 4 or something.

Change-Id: Ib4ab141ca6d803f9df0351b1f65c7e9955c37d57
2014-08-23 19:48:27 +00:00
umherirrender
5dfeff23ae Use config instead of globals for OutputPage
Change-Id: I5e0ebc173631d1d1052de7ccee4ef839c7c1767f
2014-08-23 10:52:41 +02:00
umherirrender
dfb1976bd5 Pass config to ResourceLoader from OutputPage
Change-Id: Iae99ab65a254fc3fe3acac764a068470f99af1c4
2014-08-22 22:13:16 +02:00
Kevin Israel
dd5c1b7fb7 Title::getContentModel(): load from DB if necessary
Also don't cast $model to int in LinkCache::addGoodLinkObj(); content
model IDs are non-numeric strings, not integers, so that field was
always populated with the value 0. Because 0 is a falsy value, this
caused subsequent calls to Title::getContentModel() to return the
default model rather than the correct one.

Also (hopefully) fixed every single query that could cause a
LinkCache entry to be added without the content model.

Bug: 69789
Change-Id: I94f06baf406afa538cd2b10139598442f9fc6759
2014-08-20 19:44:17 -04:00
umherirrender
3b2b6a2773 Add missing @param to function docs
Change-Id: I47fa96a976f55a1a93cb75397285edb8c7f4cd8a
2014-08-14 20:22:52 +02:00
jenkins-bot
c54bcbc5b9 Merge "resourceloader: Wrap only=script responses in "if(window.mw)"" 2014-08-13 00:50:10 +00:00
Timo Tijhof
9272bc6c47 resourceloader: Wrap only=script responses in "if(window.mw)"
We currently have a few legacy requests to the load.php end point
that bypass the ResourceLoader client by coding a request to
load.php via a "<script src>" directly. Most prominently the
request for the 'site' wiki module (aka MediaWiki:Common.js).

Remove the manual wrapping of embedded private modules as this
is now taken are of by ResourceLoader::makeModuleResponse itself.

Misc:
* Mark "jquery" and "mediawiki" as Raw modules. While the startup
  module had this already, these didn't. Without this, they'd
  get the conditional wrap – which would be a problem since mediawiki.js
  can't be conditional on 'window.mw' for that file defines that
  namespace itself.
* Strip the cache-key comment in the unit tests because the hash
  no longer matches and using the generic 'wiki' dbname was breaking
  DB queries.
* Relates to bug 63587.
* See also 05d0f6fefd which expands the reach of the non-JS
  environment to IE6 and helped expose this bug.

Change-Id: Icf6ede09b51ce212aa70ff6be4b341762ec75b4d
2014-08-12 23:20:42 +00:00
Kunal Mehta
cb3a240bfa Add $query parameter to OutputPage::addBacklinkSubtitle
Change-Id: If6145b5512657bbd9e165b0c614e5061615c294d
2014-08-07 09:22:57 +01:00
umherirrender
473b7d925e Fixed docs
- Use short form of boolean
- Use capital at begin of doc text

Change-Id: Ic5afacfa7298b1938d3b45ffd0cac5ce01f2f9db
2014-08-04 12:00:15 +02:00
jenkins-bot
8c6e9e5f2f Merge "Enforce array type hinting in OutputPage.php" 2014-08-01 19:08:16 +00:00
withoutaname
923f94f691 Change addCategoryLinks() to use array_fill_keys
Previously it used an ugly array_combine hack.

Change-Id: I6bc4fb5cfffda468c61037588ebb4399b5121db5
2014-07-30 20:36:02 +00:00
Brad Jorsch
7c35170ede SECURITY: Copy prevent-clickjacking between OutputPage and ParserOutput
Special page transclusion returns an OutputPage, whose metadata is
copied into the ParserOutput, and then later back into an OutputPage.
The "preventClickjacking" flag should be part of that metadata.

Bug: 65778
Change-Id: I17d2720fb94bb383a92059e5adbf6c16ee3e9ef4
2014-07-30 20:26:58 +02:00
jenkins-bot
46343ca0dd Merge "Check whether TYPE_COMBINED modules are allowed to be included in the page" 2014-07-30 13:45:20 +00:00
Kunal Mehta
5518d3ac02 Check whether TYPE_COMBINED modules are allowed to be included in the page
With the introduction of the OutputPageScriptsForBottomQueue hook,
modules loaded through it are TYPE_COMBINED, which
OutputPage::makeResourceLoaderLink was not checking on whether
or not it was safe to include them.

Change-Id: I33f39a5643b3d05db5a89e62fa6c86d437dea143
2014-07-30 01:23:19 +00:00
Legoktm
5ad871239d Revert "Add OutputPageScriptsForBottomQueue hook"
After some discussion with Roan, it turns out this
hook is unnecessary. The proper solution is to use
addModuleScripts/addModuleStyles instead of a 
plain addModules.

This reverts commit e7361de181.

Bug: 68712
Change-Id: Iadbff5f7fbbc5a08d6336674b12315967f45591d
2014-07-30 00:25:24 +00:00
Reedy
8bc72b70df Collapse nested if statements
Change-Id: I1cecfe5884edb98c8ad0a441f4d82288d597f631
2014-07-28 14:55:13 +00:00
umherirrender
e10ab8747f Fix param doc of OutputPage::setHTMLTitle
Method also accept Message object

Change-Id: I3a5254a3776f0215667e64ff9d01d60b80375aca
2014-07-27 15:22:03 +00:00
umherirrender
1c68a1ee86 Cleanup some docs (includes/*.php)
- 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: I783e4dbfe5f6f98b32b9a03ccf6439e13e132bcc
2014-07-24 19:42:24 +02:00
umherirrender
4ee680a8b3 Fixed spacing
- Removed spaces after not operator (!)
- Removed spaces inside array index
- use tab as indent instead of spaces
- Add newline at end of file
- Removed spaces after casts

Change-Id: I9ba17c4385fcb43d38998d45f89cf42952bc791b
2014-07-24 11:53:04 +02:00
withoutaname
d606322c83 Enforce array type hinting in OutputPage.php
Change-Id: I2b37a95e517e120471c709823ea319f60165be0e
2014-07-22 19:49:30 -07:00
Reedy
82814aa74e Call to a member function getText() on a non-object
Bug: 68394
Change-Id: I78a9cd940fed9134263f086af89c15b5777b57fc
2014-07-22 20:18:07 +01:00
Kunal Mehta
e7361de181 Add OutputPageScriptsForBottomQueue hook
This allows for extensions to add specific modules into the bottom
queue.

Bug: 62602
Change-Id: Ifccac7889e80b2f674cd54bb4ad3e53c6aa1dfa1
2014-07-20 02:16:00 +02:00
Kunal Mehta
126fb8d157 OutputPage: Support foreign module sources in makeResourceLoaderLink
To do so, created ResourceLoader::createLoaderURL(), which takes a
ResourceLoaderContext object. ResourceLoader::makeLoaderURL() was
deprecated.

While reviewing usage of the old function, many of the callers only
differed by one or two parameters from their respective
ResourceLoaderContext object. To simplify that use case, I created
DerivativeResourceLoaderContext, based of off DerivativeContext for
IContextSource.

Change-Id: I961c641ab953153057be3e3b8cf6c07435e9a0b0
2014-07-19 23:44:00 +00:00
umherirrender
301a7f3d1d Remove unused global declarations
Change-Id: I05a9bc5c0c0447c045714a445b0ed44f001db1dc
2014-07-19 22:44:54 +02:00
Chad Horohoe
6d73b42d59 Remove AjaxAddScript hook
Has been obsolete since the introduction of ResourceLoader and
is unused by any extension in Git.

Change-Id: Ia8ce6a0f1c5d46811897bd75670a3d5ea76caf7d
2014-07-16 18:49:36 -07:00
umherirrender
01e6c38615 Remove OutputPage::isUserJsAllowed() (deprecated since 1.18)
Change-Id: Ib56d22f49f229cb91b938b70e386d50c1e38e927
2014-07-09 01:41:19 +02:00
umherirrender
b18d8d7e01 Remove OutputPage::getStatusMessage() (deprecated since 1.18)
Also removed a comment where the method was mentioned.

Change-Id: I802f0f41e107a1d677fb899f6e09ea31df3c4e6f
2014-07-09 01:41:18 +02:00
umherirrender
b98d9efe77 Remove deprecated Skin::makeGlobalVariablesScript
And make OutputPage::getJSVars private per documentation.
Also adjust some comments.

Change-Id: Ia6484654754dd4782dda1d8c1e140cdb7a6f1115
2014-07-08 22:26:47 +00:00
Alexandre Emsenhuber
b025e69891 Don't use isset() to check for null
Those two member variables are always defined.

Change-Id: I7d1b9319bb1ce212f730a0568961eefb963fc7df
2014-07-01 19:17:02 +02:00
jenkins-bot
ddeadfc49b Merge "Prevent OutputPage::addWikiText and friends from causing UNIQ fails" 2014-06-26 09:25:19 +00:00
Brian Wolff
4e6b0e4f4d Prevent OutputPage::addWikiText and friends from causing UNIQ fails
If you transclude a special page, OutputPage::addWikiText can cause
problems. This prevents that from happening, by using a new object
if currently in a parsing operation.

Bug: 14562
Bug: 65826
Change-Id: I7c38fa9e2fbd270e45f73f522612451e77ab8cbb
2014-06-25 15:16:14 -03:00
Kevin Israel
1402236c4b Remove use of OutputPage::addParserOutputNoText()
Simply clicking "Show preview" on the edit page triggered a deprecation
warning.

Also removed the wfDeprecated() call from the method, which is still used
in a few WMF-deployed extensions without a corresponding open change.

Follows-up e8f1fede77.

Change-Id: I2cfdc84b92cf13478b9f462028d525e4ec14fdf2
2014-06-24 04:53:44 -04:00
Bartosz Dziewoński
e8f1fede77 OutputPage: Add addParserOutputContent() for more fine-grained control
We previously had addParserOutput(), which added everything and did
some other magic, and addParserOutputNoText() which, as the same says,
added everything but the text.

I renamed addParserOutputNoText() to addParserOutputMetadata() and
created two more functions:

* addParserOutputText(): This is almost identical to adding the raw
  HTML, but calls the OutputPageBeforeHTML hook like other
  addParserOutput*() methods.

* addParserOutputContent(): Like addParserOutputText(), but also adds
  the ResourceLoader modules and variables associated with the parser
  output. This is important especially for some extensions like
  TemplateData or SyntaxHighlight which add styles to the page to
  enhance the display.

Change-Id: Iead541886fd1ccdbdf1cb06af71b34cd04644985
2014-06-20 19:31:17 +00:00
Jack Phoenix
6849fde6cb Apparently for certain (API) requests $this->getTitle() doesn't return a valid Title.
Usually these are API siteinfo requests (api.php?action=query&meta=siteinfo). In that case, this code used to produce a fatal ("Call to a member function getPageLanguage() on a non-object").

Change-Id: Ifb6f99fe554890ff2719220f58d1b6c1a7a95ddc
2014-06-11 23:00:24 +03:00
Daniel Friesen
0f6609447e Drop support for old skins that don't use head element
These skins have been obsolete since 1.16 and aren't supported well at this point.
This deprecates those skins and begins deprecation of the creation of <head> contents
with only chunks of OutputPage stuff. The entire head should be created by OutputPage.

This also deprecates some old methods responsible for returning raw chunks of html for the head:
* getScript
* getHeadItems

Output of HeadItems is also tweaked. Previously there was no newline added
after each item, now there is. Most of the callers of addHeadItem don't use
their own newline and as a result end up on one line.

Change-Id: I13e25cc8d8fc3aa682f23b019a2fda0e809a5f64
2014-05-31 15:30:19 +02:00
Adam Roses Wight
6bfe8bc13a opportunity to reuse Title::getEditURL()
This will be helpful if we want to make changes to the edit URL in the future.

Change-Id: I6e877d23b041a2bd1672ae804e06bf6a52e16c9f
2014-05-19 10:06:42 +00:00
Bartosz Dziewoński
c3aa5ef597 Create Parser::stripOuterParagraph to avoid code duplication
We've had the logic for stripping the outer <p/> element in three
separate places. The version in OutputPage was missing the '$' at the
end of the regex, that was most likely a mistake caused by the
duplication.

Also, extend the logic in order not to generate invalid HTML if the
input contains more than one <p/> tag. Added tests for this and the
previous behaviour.

https://www.mail-archive.com/mediawiki-api@lists.wikimedia.org/msg03188.html

Change-Id: I6bb3597898324556df912a23a7ffc9ff250b8f58
2014-05-15 12:20:19 -04:00
Siebrand Mazeland
df49428b90 Pass php-strict for OutputPage
Change-Id: Ia5d03277fff543ca672dc8efc7eaaeca4888ac23
2014-05-11 16:50:02 +00:00
Matthew Flaschen
44287314f8 Change X-UA-Compatible from <meta> tag to HTTP header
Derk-Jan Hartman suggested this to remove a HTML validation error.  As he
noted, the HTTP header is also more effective, since it works on
intranets, and is not sensitive to ordering issues within the <head>.

See http://stackoverflow.com/questions/6156639 .

Bug: 62885
Change-Id: I2214abcb1badbbaca48427a31d1218c9db9a6af7
2014-04-30 03:44:04 +00:00
Bartosz Dziewoński
59002d8935 Consistently use '@deprecated since <version>'
Variants included 'in <version>', 'as of <version>' and just the
version number.

Some @deprecated annotations do not have the version number at all,
I want to hunt them down separately.

Change-Id: I8208c6097098f4735d4f51bc42254675f1f27f6d
2014-04-15 22:18:19 +02:00
umherirrender
829886b10a Fixed some @params documentation
Swapped some "$var type" to "type $var" or added missing types
before the $var. Changed some other types to match the more common
spelling. Makes beginning of some text in captial.

Change-Id: I64e8cfe478cb0ba438f40b0631d6e9049cdab567
2014-04-14 12:59:19 +00:00
umherirrender
725d9d125d Removed unneeded spaces and colons in @param and friends
Also swapped some "$var type" to "type $var" or added missing types
before the $var. Changed some other types to match the more common
spelling. Makes beginning of some text in captial.

Change-Id: Ic36c8c7820a6c2d603f1138130670c6bf6a1ca59
2014-04-08 16:02:49 +00:00
umherirrender
23fab68274 Fix spacing after @param and friends in comments
Searched for:
\@(param|return|throws|since|deprecated|access|todo|var)[ \t]{2,}

Change-Id: Icce22ba9fe0635455691ca58d9872d618151f346
2014-04-05 20:02:29 +00:00
Timo Tijhof
0088c506bb resourceloader: Refactor module links output
Changes:

* Removed hardcoded logic in OutputPage regarding modules
  being "enabled".
  Previously we would always output state=loading and use
  $wgAllowUserJs (and others) to decide whether to output
  state=ready or makeResourceLoaderLink.

  Now, we no longer unconditionally output state=loading and
  simply always call makeResourceLoaderLink. That method takes
  care of checking whether modules are enabled and non-empty
  and returns state=ready when that is the case.

  This cleans up cases where the duplicated and incomplete logic
  in OutputPage thought the module was non-empty but turned out
  to be empty and thus would output both state=loading and later
  state=ready for the same module.

* Clean up documentation for makeResourceLoaderLink (inconsistent
  ordering of type hint and $var, and @return was missing the fact
  that the returned html can also contain <link>).

* makeResourceLoaderLink now returns an array of html and module
  states. This allows the consumer of this method to combine the
  states in 1 larger script tag on top of multiple
  makeResourceLoaderLink calls (e.g. one state script followed
  by multiple <script src=load.php>).
  This isn't to reduce html output, but to make sure we inform
  mw.loader about modules before the <script src=load.php>.
  If we were to mix/alternate the state script and load.php
  requests (which are blocking in html), it is possible for those
  scripts to request other modules. We need to prevent duplicate
  loading of modules we already know are going to be requested
  by the HTML output futher down.

* Removed spurious new line.

Example of change in HTML output:

* The output has been reduced from:
  - loader.state( site: loading, user: loading, user.groups: loading )
  - loader.load( .. )
  - <script src="load.php?modules=site ..">
  - loader.state( user: ready, user.groups: ready )

  to:
  - loader.state( site: loading, user: ready, user.groups: ready )
  - loader.load( .. )
  - <script src="load.php?modules=site ..">

Change-Id: I91754ce5fae3d05b4bfa7372372eba81ee2fc579
2014-04-04 01:57:29 +00:00
jenkins-bot
2e09c35678 Merge "Suppress section edit links with action=render" 2014-03-26 18:23:01 +00:00
Alexandre Emsenhuber
153abd52fd Correct the destination of checkLastModified debug messages
- OutputPage: if $wgCachePages is set to false, then it can be shown
  back to the user
- AjaxResponder: don't send back to the user (for consistency with the
  other calls to wfDebug(), and this can't be displayed to the user)

Change-Id: I17794016cfaef65ee3df3b82ceb8cb3a32ac7c67
2014-03-14 22:33:21 +00:00
MaxSem
65caa90c19 Suppress section edit links with action=render
action=render is often used to pull the rendered HTML of an article
for inclusion in a different context. More often than not, the edit
links are not desired in that context.

This reverts commit a04b5d5dcb
and redoes Iab02cbd42f2f93f0f5264a74691ae1b84f296f12.

Bug: 19415
Change-Id: I26213653c017c2e19a6f6799f3ea0676ff8524d1
2014-03-12 18:27:01 +00:00
umherirrender
542d2e8a90 Add ParserOutput::addJsConfigVars
The OutputPage has variables for modules, moduleScripts, moduleStyles,
moduleMessages and the config vars, but the ParserOutput is missing the
last one.

With ParserOutput::addJsConfigVars it is possible to add scripts and it
config vars at one place and have not use the MakeGlobalVariablesScript
hook or other ways to get the needed javascript variable in the output.

Change-Id: I6ad61cca76805f6b9d76e053c98c7509c323d5da
2014-02-16 20:35:49 +00:00