Commit graph

1388 commits

Author SHA1 Message Date
Timo Tijhof
9b6ee1da59 resourceloader: Remove only=messages
This isn't needed.

* Deprecate 'modulemessages' API, return empty result and warning.
* Remove half-implemented only=templates.

Change-Id: Ia6c87d687c6670b3ebf24251572191732651e8f5
2015-05-13 20:17:35 +01:00
Bartosz Dziewoński
9e5c3e9521 Use ResourceLoaderImageModule to serve icons for OOjs UI
Benefits:
* Full per-language icons support. Icons that differ for each language
  (such as the 'Bold' icon) will now always display correctly
  according to user interface language, even on old browsers.
* MediaWiki UI icons support. When the 'mediawiki.ui.icon' module is
  loaded, you can use syntaxes such as below to display any OOUI icons
  (from the packs that were loaded) without involving OOUI itself.
    <div class="mw-ui-icon mw-ui-icon-before mw-ui-icon-check">OK</div>
    <div class="mw-ui-icon mw-ui-icon-after mw-ui-icon-check">OK</div>
    <div class="mw-ui-icon mw-ui-icon-element mw-ui-icon-check">OK</div>

Summary of changes:
* Resources.php:
  * Remove icons CSS files. Include image data JSON files instead.
  * Split the images from 'oojs-ui.styles' module to separate ones.
* OutputPage: Update enableOOUI() method for newly split modules.
* ResourceLoaderImageModule: Make it possible to load image data from
  a JSON file.
* update-oojs-ui.sh: Copy source files rather than distribution for
  icon packs.

This is not an improvement when it comes to code quality, though :(
Issues include some nasty code duplication, using "source code" (image
definitions) from OOUI rather than just distribution files, and hacky
methods to load image data from JSON files live.

Bug: T92551
Change-Id: Id369ecaec7048dcf68ba1e4df748362760533782
2015-04-28 13:48:30 +00:00
Timo Tijhof
9838eeb6f2 resourceloader: Add ResourceLoader::makeInlineScript utility and use it
Plucked from the e86e5f846 which got reverted.

Change-Id: I4bba3f3c31c5181867378ae174537429b49a50df
2015-04-20 19:45:27 +00:00
jenkins-bot
c0cb60d6c8 Merge "SECURITY: Don't execute another user's CSS or JS on preview" 2015-04-01 17:31:57 +00:00
Ori Livneh
1b146857e3 OutputPage: Tiny tweak to jQuery.ready inline script
Changing 'window.jQuery && jQuery.ready()' to 'if ( window.jQuery )
jQuery.ready()' means no *<![CDATA[*/ /*]]>* is required (because we
got rid of the ampersands). It's also more readable and more consistent
with if(window.mw).

Change-Id: I28262efb978c085e732b40f9dc5ddb1bda5c4376
2015-04-01 17:03:54 +00:00
Brad Jorsch
ff95a95437 SECURITY: Don't execute another user's CSS or JS on preview
Someone could theoretically try to hide malicious code in their user
common.js and then trick an admin into previewing it by asking for help.

Bug: T85855
Change-Id: I5a7a75306695859df5d848f6105b81bea0098f0a
2015-04-01 09:55:52 -07:00
Ori.livneh
2b6eb60ce5 Revert "Optimize order of styles and scripts"
The patch did not improve performance. I'd like to think that the increased
control over when inline scripts are executed makes the patch worthwhile
regardless, but that is post hoc justification and possibly a bit of personal
ego. Krinkle agrees that we may use some of the ideas in this patch in the
future but he thinks we're better off not heading down this path before we
have a better sense of where we're going, and I trust his judgment.

This reverts commit e86e5f8460.

Change-Id: I151f74a41dd664b5a0aa5cfd99fcc95e2686a1e6
2015-03-25 04:40:46 +00:00
Ori Livneh
e86e5f8460 Optimize order of styles and scripts
The current ordering of scripts and stylesheets in <head> causes all major
browsers to serialize and defer requests that could be performed in parallel.

The problem is that external stylesheets are loaded before inline scripts. As
Steven Souders explains, "all major browsers preserve the order of CSS and
JavaScript. The stylesheet has to be fully downloaded, parsed, and applied
before the inline script is executed. And the inline script must be executed
before the remaining resources can be downloaded. Therefore, resources that
follow a stylesheet and inline script are blocked from downloading."[1]

In other words: the browser could start loading body images, but it refuses to
do that until it has executed inline scripts in head. And it refuses to execute
those scripts until the external CSS is downloaded, parsed and applied. You can
see the effect of this in this image, showing the request waterfall for
[[en:Gothic Alphabet]]: [2]. Notice how no images were requested before the
browser had finished processing the three load.php requests at the top.

To fix this, we want to move the inline scripts above the external CSS. This is
a little bit tricky, because the inline scripts depend on mw.loader, which is
loaded via an external script. If we move the external script so that it too is
above the external stylesheet, we force the browser to serialize requests,
because the browser will not retrieve the external CSS until it has retrieved
and executed the external JS code. So what we want is to move the inline
scripts above the external stylesheet, but keep the external script (which the
inline scripts depend on) below the external stylesheet.

We can do this by wrapping the inline script code in a closure (which binds
'mw') and enqueuing the closure in a global array which will be processed by
the startup module at just the right time.

Net result: external CSS and JS is retrieved in parallel, retrieval of images
(and other external assets) is unblocked, but the order in which code is
evaluated remains the same.

[1]: <http://www.stevesouders.com/blog/2009/05/06/positioning-inline-scripts/>
[2]: <http://people.wikimedia.org/~ori/enwiki-waterfall.png> (excerpted from
 <http://www.webpagetest.org/result/150316_0C_7MB/1/details/>.

Change-Id: I98d383a6299ffbd10210431544a505338ca8643f
2015-03-17 03:10:49 +01:00
jenkins-bot
6630d3c7e0 Merge "Use underscores in help links" 2015-03-12 14:56:31 +00:00
umherirrender
507902203a Use underscores in help links
Replace spaces by underscore to build correct links to wiki pages. IE11
will show %20 for spaces. Also use urlencode to make the url safe.

Follow-Up: I2934b1708a0d207dcf3d940264f140613646f203
Change-Id: I5ef08441406e96aa9749476af0a81fc11fa4e4d6
2015-03-12 14:43:22 +00:00
Timo Tijhof
3ed7b27f7b OutputPage: Condition-wrap the <script> for 'user.groups'
Follows-up 9d390a09cd. It already wraps the only=script requests
for 'site' and 'user', but forgot about 'user.groups' which is
not 'scripts' but 'combined' (as regular module requests).

That request responds with mw.loader.implement whih will be absent
if the environment is unsupported.

With normal module requests, this is naturally covered by those
requests not being fired from mw.loader in the first place but
with hardcoded requests like these the condition wrap with
document.write is unfortunately required in the current reality.

Change-Id: Ib3a7378d0c44e601760fbbc5174da09bd7b7f492
2015-03-11 19:33:24 +00:00
Federico Leva
6ab33238a2 Don't require JavaScript for addHelpLink styles
And avoid wfMessage.
Followup to 376c0a13df

Bug: T45591
Change-Id: I2f02c2a4db609356ff8be30f260490d19f3226d1
2015-03-07 18:59:35 +01:00
jenkins-bot
5907e840cc Merge "Add top help link to MediaWiki.org in several pages via indicator" 2015-03-04 16:15:53 +00:00
Nemo bis
376c0a13df Add top help link to MediaWiki.org in several pages via indicator
All the chosen targets are translatable public domain help pages
on MediaWiki.org. Mostly special pages and actions for privileged
users for now.

Adapted from the Translate extension, credit to Niklas Laxström
(TranslateUtils::addSpecialHelpLink).

Depends on 6f5b29ff4e, whose commit
message has a typo addIndicator() instead of setIndicator().

Bug: T45591
Change-Id: I2934b1708a0d207dcf3d940264f140613646f203
2015-03-04 10:59:03 +01:00
Aaron Schulz
4111ff0dc3 Removed obsolete "containsOldMagic" code
Change-Id: Id225347e0599a6f79b30b0793cce7d97daed46f2
2015-02-15 14:41:49 -08:00
jenkins-bot
2f17fff894 Merge "Add OutputPage::enableOOUI() to set up OOUI stuff when needed" 2015-01-28 23:33:50 +00:00
YuviPanda
4a9840e271 Add option to output referrer policy meta tag
Bug: T87276
Change-Id: I9ea4797c4d292cd4565f47b88e605b4e7afdb1d1
2015-01-20 17:21:13 -08:00
Bartosz Dziewoński
b4255eab0b Add OutputPage::enableOOUI() to set up OOUI stuff when needed
Initialize OOUI theme and set OOUI element directionality, load
necessary RL modules.

Bug: T85767
Change-Id: I9aa430969e4250bd2bd6c396b6133a35ca5bf46b
2015-01-16 15:10:57 -08:00
Federico Leva
b28cdb98f0 Typofix in wrapWikiMsg() comment, smoother sentence
Change-Id: Ic0ebc94cec68ee1515d4c98d49b26a6f9148e95e
2015-01-15 19:54:39 +00: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
Timo Tijhof
ba50b32556 SpecialJavaScriptTest: Add export feature
Add an 'export' subpage to SpecialJavaScriptTest which allows
one to request a self-sufficient JavaScript payload that will
bootstrap a ResourceLoader client and load the test suites.

This is needed for using Karma (which only loads JavaScript,
no full html pages). As such elements from the Skin and OutputPage
will not exist. While all QUnit tests in MediaWiki core and
most extensions I've seen already use #qunit-fixture, this is
now required. This to prevent leakage of elements from one
test to another, but it also prevents tests from depending
on elements provided by the server.

While the Karma setup is still in the pipeline (might land before
this commit loses WIP status), for now this can be tested via
the 'Special:JavaScriptTest/qunit/plain' subpage.

Refactor:
* Use HTTP status code 404 in the response for "noframework".
* Simplify HTML footprint by using <div id="qunit"> instead of
  hardcoding the full structure. This feature was added to QUnit
  since v1.3.0 (Feb 2012), we're using v1.14.0 (Jan 2014).
  QUnit's header is automatically derived from document.title.
* Remove redundant addModules() for 'test.mediawiki.qunit.testrunner'.
  This is already added by default.
* Move allowClickjacking() call so that it applies to other modes
  as well. The exported javascript needs to have wgBreakFrame set
  to false so that test runners can frame it.
* Change mediawiki.special.javaScriptTest to not depend on QUnit.
  It caused QUnit to load on error pages. And in theory the page
  is suited for other frameworks and shouldn't load QUnit this way.

Bug: T74063
Change-Id: I3d4d0df43bb426d9579eb0349b8b5477281a7cfc
2015-01-05 17:59:33 +00:00
gladoscc
e4701c646c Document OutputPage::$mPreventClickjacking
Change-Id: I3b4f967743c810c5cbef094b3e30807cf0a668ca
2015-01-01 22:24:27 +11:00
Reedy
4d9143c7f5 Add lots of @throws
Change-Id: I09d0c13070f966fcf23d2638d8fc1328279a5995
2014-12-24 13:49:20 +00:00
Ricordisamoa
12dec5d85d Fix some stuttering in comments and documentation
Change-Id: I9c0088b9aab37335203cad45a1d6fa8ac3f43321
2014-12-17 19:44:10 +00: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
umherirrender
7da1cbc78c Fix backlink for RevertAction
RevertAction::getDescription cannot set subtitle on OutputPage,
because the subtitle on OutputPage gets cleared before the
result of getDescription is added and than the subtitle is gone.

Refactored the code for building the backlink into a static function
and use it.

Change-Id: Iedad0b8e040035a9a10a0b140d2322357e6b539a
2014-12-05 14:28:18 +00:00
Kunal Mehta
0406f3d61b OutputPage: Add accessors for some protected properties
Bug: T76168
Change-Id: Iee11c217b6b0d35acfdfac916814521acda2b1a4
2014-12-03 09:40:15 -08:00
jenkins-bot
7cfeed5ad6 Merge "Expose ID of relevant page in JS variables" 2014-11-19 04:01:50 +00:00
Kunal Mehta
b2bb4f8bf2 Make allowing site-wide styles on restricted special pages a config option
This mostly reverts commit 614d7e5c27.

Many wikis use MediaWiki:Common.css and associated pages to create a
custom "theme" for their wiki, which would no longer load on login
or preference pages, creating an inconsistent UI.

This re-adds the difference in module origin for different types
(styles, scripts, etc.), and now OutputPage::disallowUserJs()
checks the value of the "AllowSiteCSSOnRestrictedPages" config setting
to determine whether to allow site-wide CSS styles or not.

By default this feature is disabled to be secure by default.

Bug: 71621
Change-Id: I1bf4dd1845b6952c3985e179fbea48181ffb8907
2014-11-07 14:50:33 -08:00
Alex Monk
650aa90f38 Expose ID of relevant page in JS variables
Bug: 53774
Change-Id: I06cd037804daba59e4f42e3be5f2883a82fcaa27
2014-11-03 23:41:32 +00:00
Bartosz Dziewoński
6f5b29ff4e Implement page status indicators
Page status indicators are icons (or short text snippets) usually
displayed in the top-right corner of the page, outside of the main
content. Basically, <indicator name="foo">[[File:Foo.svg|20px]]</indicator>
may be used on a page to place the icon in the indicator area. They
are also known as top icons, page icons, heading icons or title icons.

I found the discussion on bug 23796 highly illuminating. I suggest
that everyone read it before suggesting different design choices.

I spent some time with a thesaurus pondering the name. "Emblems" and
"badges" were also considered, but the former has a much more limited
meaning and the latter is already taken by Wikidata, with a similar
but subtly different feature set. I am not aware of any naming
conflicts ;) besides new talk page message "indicator" (used by core
and Echo in some documents) and OOjs UI indicators (tiny icons like
the arrow on a dropdown form element), which shouldn't be confusing.

Potential use cases include:
* "Lock" indicators for page protection levels
* Featured/good article indicators
* Redirect shortcuts display ("WP:VPT")
* Links to help/manual for special pages
* Coordinates?… or globe icon for inline pop-up maps

Design features:
* Skin-customizable. Skins can fully control where and how indicators
  are shown, or may just do <?php echo $this->getIndicators(); ?> to
  output the default structure. By default they are not shown at all.
* Extension-customizable. Extensions can call ParserOutput::addIndicator()
  to insert an indicator from one of the numerous parser hooks.
* Wiki-customizable. In addition to just using the parser functions,
  on-wiki styles and scripts can use the provided classes and ids
  (.mw-indicator, #mw-indicator-<name>) to customize their display.

Design limitations:
* Every indicator must have a unique identifier (name). It's not
  possible to create arrays, or to have several indicators with the
  same name. In case of duplicates, the latest occurrence of the
  parser function wins.
* Indicators are displayed ordered by their names (and not occurrence
  order). This ensures consistency across pages and provides a simple
  means of ordering or grouping them.
* Indicators are not stored, tracked or accessible outside of
  ParserOutput (in particular they're not in the page_props table).
  They are intended to merely reflect the content or metadata that is
  already present on the page, and not be data themselves. If you ever
  think you need to list pages with a given status indicator, instead
  figure out what it means and use the appropriate tracking category,
  special page report, already existing page_prop, or other means.

Corresponding patch in Vector: I90a8ae15ac8275d084ea5f47b6b2684d5e6c7412.
I'll implement support in the other three skins included in the tarball
and document it on mediawiki.org after this is merged.

Bug: 23796
Change-Id: I2389ff9a5332a2b1d033eb75f0946e5241cfaaf4
2014-10-17 15:49:15 -07:00
umherirrender
ce08326cda Break long lines
Change-Id: I8d4e883058c21023273df88439cd145888833115
2014-10-14 19:30:43 +00:00
umherirrender
0eaa6b5334 Use config for $wgLanguageCode in OutputPage.php
Follow-Up: I5e0ebc173631d1d1052de7ccee4ef839c7c1767f
Change-Id: Idd7fab9f8bf47fc303b5923327da67905e12e527
2014-10-10 14:58:03 +02:00
Kevin Israel
95954ab86c Deprecate OutputPage::rateLimited()
Change-Id: I140e6af9dde090b9f8611e7b53a650061f2e84eb
2014-10-07 12:35:59 +02:00
Kevin Israel
202db653c3 Deprecate OutputPage::readOnlyPage()
Also, as this method is never called with an argument in any Gerrit-hosted
extension, shortened it to just `throw new ReadOnlyError;` on the assumption
that the removed portion was only left in for EditPage.

Change-Id: Icc2fc166b155eac548dfd5f3e67b0b1f92ef90d3
2014-10-07 12:34:56 +02:00
jenkins-bot
8fc9ade3a8 Merge "Added some profiling calls" 2014-10-02 21:18:41 +00:00
Timo Tijhof
614d7e5c27 SECURITY: OutputPage: Remove separation of css and js module allowance
* No longer segment module origin allowance by an "only=" content
type. Both can be sensitive security-wise and there's no valid
use case for allowing CSS anywhere you want to disallow JS. Both
can significantly impact the user interface and cause unintended
actions to be taken on the user's behalf, or desired actions to
be made practically impossible.

* While at it, also remove the ability to set the module allowance
directly. The reduceAllowedModuleOrigin method is all we need.
I couldn't find usage or mention of setAllowedModules() in
mediawiki-core nor in any other Wikimedia-hosted repository.

Bug: 70672
Change-Id: I308e794daca27a9380c67be350f8ab51f9c2de34
2014-10-01 22:48:29 +02:00
Aaron Schulz
6f7292ad29 Added some profiling calls
Change-Id: Icb024c86e86a030fdea874cf5aa47fd0329e6133
2014-10-01 10:14:27 -07:00
umherirrender
df24b7209d Fixed spacing
- Added newline at end of file
- Removed double spaces/newlines
- Added space after if/function and parentheses/brackets
- Removed space before comma/cast
- Fixed indent of some lines

Change-Id: I29867ffdffdfb7d2b56997e9393497c7dc12f7d3
2014-09-29 20:46:19 +02:00
Bartosz Dziewoński
4c01f8b2bc Make "/*@noflip*/ /*@embed*/" annotation work without CSSJanus hacks
This reverts most of commit 2d842f1425,
leaving only the test added in it, and reimplements the same
functionality better.

Instead of stripping /*@noflip*/ annotations in CSSJanus, which is
incompatible with other implementations that preserve it, extend
CSSMin to allow other CSS comments to be present before the
rule-global @embed annotation. (This required making the regex logic
in it even worse than it was, but it's actually slightly less terrible
than I expected it would be. Good thing we have tests!)

Bug: 69698
Change-Id: I58603ef64f7d7cdc6461b34721a4d6b15f15ad79
2014-09-23 22:47:54 +00:00
Timo Tijhof
9d390a09cd resourceloader: Condition-wrap the HTML tag instead of JS response
Follows-up 9272bc6c47, 03c503da22, 1e063f6078.

One can't wrap arbitrary JavaScript in an if-statement and have
its inner-body mean exactly the same.

Certain statements are only allowed in the top of a scope (such
as hoisted function declarations). These are not allowed inside
a block. They're fine in both global scope and local function
scope, but not inside an if-block of any scope.

The ECMAScript spec only describes what is an allowed token.
Any unexpected token should result in a SyntaxError.

Chrome's implementation (V8) allows function declarations in
blocks and hoists them to *outside* the condition. Firefox's
SpiderMonkey silently ignores the statement. Neither throw a
SyntaxError.

Rgular ResourceLoader responses only contain mw.loader.implement()
and mw.loader.state() call which could be wrapped without issues.
However such responses don't need wrapping as they're only made
by mediawiki.js (in which case mw is obviously loaded). The
wrapping is for legacy scripts that execute in the global scope.

For those, let's wrap the script tag itself (instead of the
response). That seems like the most water-tight and semantically
correct solution.

Had to bring in $isRaw from ResourceLoader.php, else the startup
module would have been wrapped as well (added regression test).

Bug: 69924
Change-Id: Iedda0464f734ba5f7a884726487f6c7e07d444f1
2014-09-09 15:54:16 +00:00
Timo Tijhof
5553be79b9 OutputPage: Restore ResourceLoader condition wrap for embedded modules
Follows-up 9272bc6c47, 03c503da22.

* In 9272bc6c47, the condition wrap was removed from
  OutputPage for no reason. This went unnnoticed as I had also
  accidentally made the cond wrap in makeModuleResponse apply
  to both only=scripts and regular (faux) responses, such as by
  OutputPage embedding private modules.

* In 03c503da22, the latter bug was fixed, thus exposing the former.

This wrapper belongs in OutputPage, not in ResourceLoader. It's
OutputPage making the loader request. And just like in other places,
it's the "client"'s responsibility to ensure the request is either not
made or wrapped appropriately.

The test for "private module (only=scripts)" could be removed but
I'll keep it so we can see how this changes in the future. It's
a case that can't ever happen, but if it would, it currently gets
a double condition wrapper, which is fine.

Change-Id: Id333e4958ed769831fabca02164c1e8505962d57
2014-09-02 11:05:13 +02:00
jenkins-bot
08e50bcecd Merge "Make "/*@noflip*/ /*@embed*/" annotation work" 2014-08-29 19:45:06 +00:00
Tim Starling
91d8a51825 Don't send rel=canonical to variant-neutral page
This has been the subject of multiple complaints from Google, it
apparently prevents them from properly indexing the variant-specific
pages. Instead, send the variant-independent link as rel=alternate
hreflang=x-default, which is recommended by Google as the preferred way
of specifying "auto-redirecting homepages" in this help page:

https://support.google.com/webmasters/answer/189077?hl=en

Send rel=alternate links unconditionally, since that is also recommended
by that help page: "each language page must identify all language
versions, including itself".

Remove $wgCanonicalLanguageLinks since it would be rather pointless and
poorly named if it only controlled rel=alternate links.

Bug: 52429
Change-Id: Ic75717f6e4ac1f73aa600c2e1bdb9c60e607edb4
2014-08-26 14:38:40 -07:00
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
Bartosz Dziewoński
2d842f1425 Make "/*@noflip*/ /*@embed*/" annotation work
To do it, just remove /*@noflip*/ annotations in CSSJanus after
we're done processing. They are not needed anymore and some obscure
interactions with CSSMin logic for preserving comments caused
`/*@noflip*/ /*@embed*/ background-image: url(…)` not to work
correctly (it would not be embedded).

This also requires us to always do CSSJanus processing, even when we
don't need flipping, to consistently handle the annotations.
I'm not entirely sure if this is worth it, but I still greatly prefer
doing it to documenting this stupid limitation. :)

Bug: 69698
Change-Id: I311b12b08b2dff9d45efb584db08cf4a11318f59
2014-08-18 17:40:51 +02: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
Alexandre Emsenhuber
f09172d9b8 Put line breaks after each element in OutputPage::headElement()
Change-Id: I4e7715a354e9d599fb2c77c09ac72a55462aaa5d
2014-02-06 15:15:42 +01:00
Alexandre Emsenhuber
a7a0883019 Enhance the destination control parameter of wfDebug() and wfDebugLog()
- The parameter is now a string, making is more understandable than
  boolean values
- It takes the same values in both wfDebug() and wfDebugLog() (except
  for 'private' which is only used in the latter)
- This adds a new possibility to wfDebugLog() to log the message either
  on the specific log or the general one, but not to the debug toolbar
- Old boolean values are still recognised for backward compatibility
- Also send the messages passed to wfDebugLog() to the debug toolbar
  when they are written to a specific log and not restricted to logs
- Updated the calls of and wfDebug() and wfDebugLog() with the last
  parameter to change it into a string
- Renamed MWDebug::sendWarning() to MWDebug::sendMessage() and added
  $group parameter to it; will not break anything since that method
  is marked as private
- Changed the call to wfDebug() from MWDebug::sendMessage() to use
  wfDebugLog() with 'log' as thrid parameter, so that those messages
  can be logged separately from the main log and they don't show up
  a second time on the "debug log" tab of the debug toolbar

Change-Id: I1be09d4c1d3408ed5b26a5db02691c17c0ec0926
2014-02-04 19:56:24 +00:00
Matthew Flaschen
527f9eeb85 Document OutputPage->mDoNothing
Change-Id: Id1d30ec29fb219a95532432cd8fc76209f3baa8f
2014-01-30 12:11:33 -08:00
Dereckson
601d65b201 OutputPage::showErrorPage raises a notice if arguments are incoherent
The method has the following signature:
OutputPage::showErrorPage( $title, $msg, $params = array() )

$msg can be a string or a Message object.

If it's a string, a Message object is built, with $params as parameters.
If it's a Message object, $params is ignored.

The core now triggers a notice in the case a call is made with $msg an instance
of Message object, and a (non-empty array) $params argument is given.

Change-Id: I227a416f088fc1acd6a04345ed0e24d06f967ecc
2014-01-29 17:06:01 +01:00
Dereckson
8ee0ef4a7c Improve OutputPage::showErrorPage method documentation
- Added the most usual case of call
- Fixed the incoherence between -Object and -Obj

Change-Id: I81207f4ef46a43529974e3ada194f2948a1e9017
2014-01-29 15:37:10 +00:00
yaron
f30c062cbf Fix to avoid IE "compatibility view"
Bug: 25378
Bug: 49548
Bug: 54343
Change-Id: I1e94128e8578e3ac3ab7a64bbc0431a454085d02
2013-12-23 21:41:58 +00:00
dr0ptp4kt
36983d11fb Add support for skins to set attributes of <html> element.
* Useful for device/profile-specific stuff (e.g., manifests)

Change-Id: I65f4d3454ae52a25fe4c6e9f2119129425b3de7a
2013-12-18 10:43:11 -08:00
01tonythomas
3f0b8c88c3 Removed 'Disable browser page caching" user preference
It is  a very advanced user preference with little usage and is often misleading.
Updated Release Note.

Bug: 52809
Change-Id: I43f6205df53c7a38717c60a2d7d144307feb58a4
2013-12-07 14:02:44 +05:30
Parent5446
1fe3b4a9d2 Revert "Add $robotPolicy parameter to SpecialPage::setHeaders()"
This reverts commit 8c7541da3b.

Bug: 57883
Change-Id: I582088528286ff34da164fa4457dd203f11df7ef
2013-12-02 21:20:11 +00:00
tisane
8c7541da3b Add $robotPolicy parameter to SpecialPage::setHeaders()
Also fix docs for OutputPage::setRobotPolicy()

Bug: 57764
Change-Id: I8b780ca349a2f5d18e857ed707f682d19be0054c
2013-12-02 19:26:21 +00:00
umherirrender
0bc583af2c Move closing parenthesis from multi line if and function to own line
The Line continuation Coding conventions prefers the closing parenthesis
on the same line than the beginning curly braces. This is done for ifs
and functions.
Also move some boolean operator from the end of a line to the beginning
and changed some indentation to make the condition hopefully better
readable.

Change-Id: Id0437b06bde86eb5a75bc59eefa19e7edb624426
2013-12-01 21:39:00 +01:00
jenkins-bot
b8a720c5e6 Merge "Use 'pagetitle' in content language" 2013-11-27 19:49:00 +00:00
Brad Jorsch
a04b5d5dcb Revert "Suppress section edit links with action=render"
This reverts commit 2248021997.

That revision caused section edit links to be shown on views of old
revisions. See comments there for suggestions on reimplementing it.

Change-Id: Ie65e3de84b44866e4ab1fc222a365cb3a9180ee1
2013-11-22 09:56:20 -05:00
Jack Phoenix
e501186d01 New getHTML() method for QuickTemplate to get the HTML of a template.
OutputPage's addTemplate() is now a wrapper around QuickTemplate.

This allows more flexible usage of templated HTML, as
required by some third-party extensions.

Change-Id: I943e8e50438c716b7b56d2f908da38a4bf73d9e2
2013-11-21 13:38:31 +02:00
Siebrand Mazeland
c142126fc7 Use 'pagetitle' in content language
It often happens that wiki sysops want to change it site wide, especially
when they want to change the format (eg, have {{SITENAME}} removed, or
replace the hyphen with a middot).

Bug: 48701
Change-Id: Iaf00fca1e89ae022c348c4fa0de32b998d7921a1
2013-11-12 09:36:57 +01:00
Bartosz Dziewoński
2248021997 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.

Bug: 19415
Change-Id: Iab02cbd42f2f93f0f5264a74691ae1b84f296f12
2013-11-09 02:01:23 +01:00
umherirrender
7127c1792b Add "wgRelevantUserName" from skin to mw.config
A skin can have a relevant user, then some help links in the sidebar
are shown. When a user want extend this informationen with userjs, he
has to parse the existing items or the title param of the url to get the
name of the user for which this help links are shown. Having the name as
javascript variable makes it easier to add more links in the sidebar.

Change-Id: I17a75902b6e739d5149d332b6a94a6568b79501f
2013-11-05 17:59:05 +01:00
jenkins-bot
8cabb5f777 Merge "Make TOC hideable" 2013-10-24 19:22:32 +00:00
Tim Starling
d1bc243f65 Remove all instances of the word "iff"
It's elitist mathematical jargon. In all cases dealt with here, it adds
no additional meaning compared to "if", beyond what was already obvious
from context. Thus, its only purpose is to smugly demonstrate that the
author attended their second-year mathematics classes, at the expense of
causing confusion for everyone who doesn't have such a background.

If you really think you need to convey extra information beyond what
"if" gives you, the English language contains plenty of devices for doing
so, without resorting to neologisms.

Change-Id: Iae21095d02ec2935c10e94f532235c2671c115b1
2013-10-23 10:56:54 -07:00
Max Semenik
21c1c7d025 Make TOC hideable
Currently, if an extension doesn't want a TOC, it has to remove it manually.
This change wraps the TOC in markers that make it easy to remove it in ParserOutput
on demand without fragmenting the parser cache with stuff like "use/not use TOC".

Change-Id: I2889bcb9eb999c9049601e92440132118e1a8a41
2013-10-18 17:47:47 +04:00
Ori Livneh
8920372686 OutputPage->getJSVars: Maintain symmetry between JS & PHP vars
The function is more difficult to read than it need be by dint of some things
two names. I can't be the only one who finds 'wgCurRevisionId' => $latestRevID
ugly, right? Anyhow, lots of JS code depends on the JS variable names, whereas
the PHP variables exist only in the scope of that method, so it's clear that
it's the PHP names that should be brought in line.

Change-Id: Ibddd5d2fc8d75e0ade18ff3433714d52605f2911
2013-09-27 11:42:03 +02:00
jenkins-bot
123d4122c8 Merge "Add wgRevisionId variable to ResourceLoader" 2013-09-26 02:43:26 +00:00
csteipp
365137e704 Vary on forceHTTPS cookie
Varnish seems to be returning the cached version of pages for users
after they have logged in over https, but access an http page. This
seems to occure because only the forceHTTPS cookie is sent on the
request, but varnish doesn't vary the cache based on that cookie.

Bug: 54513
Change-Id: Ia97ed80622191669ee5ca37af809d307bbdb61ae
2013-09-25 15:42:02 -07:00
parent5446
7fa7b71eb3 Add wgRevisionId variable to ResourceLoader
mw.config provides wgCurRevisionId, which has the latest
revision number. This adds wgRevisionId, which indicates
the revision number currently being viewed. This is useful
when looking at old revisions.

Bug: 51594
Change-Id: Ie0d00f3a9a8af8533ab28204b5bb483a0092c710
2013-09-24 19:34:42 -04:00
MatmaRex
250caa19a0 Remove 'mediawiki.legacy.wikiprintable' module
It's a relic of simpler times, no longer used by any core skin. The
'mediawiki.legacy.commonPrint' module can be used instead.
(SkinTemplate-based skins do it automatically.)

* The 'mediawiki.legacy.wikiprintable' module has been removed.
* The skins/common/wikiprintable.css file has been deleted.
* Skin#commonPrintStylesheet has been deprecated; its return value is
  ignored.

Dependency: I96e66ff8905416bea906d40cdd72ba646399191b
Change-Id: Icbcebc8f539f7786d037b717d262684e9931aca6
2013-09-16 17:31:58 +00:00
jenkins-bot
edb4ed713c Merge "No spaces after (casts)" 2013-09-04 18:14:05 +00:00
MatmaRex
df8ec1e216 No spaces after (casts)
Also removed some unnecessary ones. I think I've caught them all.

The spaceless version already appears in core ~300 times (after
accounting for false positives when grepping). Some consistency would
be nice.

Change-Id: I607655b5f4366e66dc78730d5fd2f57ed8776cae
2013-09-04 20:05:43 +02:00
Matthew Flaschen
ab44291204 Remove dead code
Accidentally left in dabbbc7d2a

Change-Id: I58e65ca7ad23d00992f66f3bcee879e662b62ef0
2013-08-31 01:57:33 -04:00
Timo Tijhof
7627cf6175 mw.config: Add wgIsRedirect
Change-Id: I6e365f20b513ded10ede51d4b34de0736653a3dc
2013-07-23 21:11:31 +02:00
Matthew Flaschen
0bbc358951 Add wgIsProbablyEditable for editability based on quickUserCan.
It uses quickUserCan like SkinTemplate, for performance reasons.

Bug: 43790
Change-Id: I2f77b69624cc1a4cd74c8178eea53681f3f2b107
2013-07-04 05:18:49 +00:00
Liangent
423f550009 Fix various language tags used in Html attribs to use wfBCP47()
Change-Id: I823ffacf5a55e53d6ab5383c1a42a9199d56f11d
2013-06-30 17:37:12 +00:00
Brion VIBBER
b2f25fe60d Merge "Kill <meta name="keywords" content="..."> in a blazing fire." 2013-06-10 15:53:15 +00:00
Alex Monk
ce4bcce3b7 Merge "Followup mistake in I82711cee" 2013-06-10 15:13:16 +00:00
Daniel Friesen
f1d2386af2 Kill <meta name="keywords" content="..."> in a blazing fire.
meta-keywords is completely and totally useless. It has absolutely no effect
on search engine and no-one uses it anymore. Time to euthanize it.

There isn't a single user of OutputPage::addKeywords inside any extension
inside of Gerrit. So I'm just deleting this method without a deprecation.

Change-Id: I188755521dcde3a9e191975d1ae3cabf7a5d67cd
2013-06-08 06:30:54 -07:00
Daniel Friesen
a4ce59a4a0 Followup If21705c2, Shorten remaining urls to the whatwg HTML spec.
Finish up with the /specs/web-apps/current-work/multipage/ urls that
haven't been updated to /html/.

Change-Id: I4dbee0477eea440b0e8f113b1d393c6e0c739c4c
2013-06-08 04:48:01 -07:00
Daniel Friesen
49677c4ca9 Followup mistake in I82711cee
Can't believe the fact the @deprecated has the wrong version number
made it through our review process.

Change-Id: If9beea75bb909484b242c1c4cb787fef8f6501d3
2013-06-08 04:02:49 -07:00
MatmaRex
1965df8df3 Remove the $wgHandheldForIPhone config variable entirely
It only really made sense in pair with $wgHandheldStyle, and that has
been removed in Ia8d79b4a.

Remove irrelevant tests, adjust still relevant ones.

Change-Id: I7c24128f7b148d0244538ad95bb60bf09ec4b5cb
2013-06-04 21:53:47 +02:00
jrobson
aa015eba26 Give skin more control of OutputPage modules
Remove addDefaultModules from OutputPage
Instead only enforce mediawiki.page.startup

Add a method getDefaultModules which groups modules
by type allowing a skin to tweak

Change-Id: I89d529f0378d90af0fe0a5adea5d5dbdca83a86e
2013-05-28 16:50:49 +00:00
Daniel Friesen
072d516848 Deprecate OutputPage::out.
OutputPage is supposed to be a container for output. It should NOT be used as a replacement for echo.

Only one seemingly unmaintained extension uses this method.
This method is deprecated now and should be removed in the next release.

Change-Id: I82711cee7204604a47cfbb5e4496b4cc737a837c
2013-05-17 15:08:54 +00:00
Daniel Friesen
a57e1da5da OutputPage: Move our <meta charset="...> so it's placed above the title
It's recommended for the meta charset to be placed before the <title> since
<title> contains text which is inside the character set defined by the meta charset.

Use of meta charset inside XHTML also seems to be redundant, not recommended,
and is very likely completely ignored.

Change-Id: I335b0598a9615540dc5e917682508b4a8d32d96e
2013-05-16 22:57:42 -07:00
Daniel Friesen
97caae596d Drop support for XHTML 1.0
* $wgHtml5 = false; is now ignored completely.
* $wgDocType and $wgDTD have been removed.
* $wgXhtmlDefaultNamespace is now ignored.
* XHTML5 will be output if $wgMimeType is set to an XML mime type (according to HTML5's rules).
* For backwards compatibility with extensions $wgHtml5 and $wgXhtmlDefaultNamespace are set
  in Setup.php but depending on them is deprecated.

Change-Id: Iad9634e2ee420b5a3bbffe550421fde4fa1819b0
2013-05-15 23:09:25 -07:00
Timo Tijhof
1bd0d43f7f OutputPage: Guard jQuery.ready() against absence of jQuery
We already wrap usage of global "mediaWiki" in a condition
for window.mw (see method
ResourceLoader::makeLoaderConditionalScript) because:
1) The startup module blacklists certain
   browsers in which we won't load jquery+mediawiki.
2) It might have failed to load (for whatever reason).

Adding guard for window.jQuery for the same reasons.

Follows-up Ic3d0c937268d09, which caused a TypeError
'ready of undefined not a function' in browsers where
jquery+mediawiki isn't loaded by the startup module.

Change-Id: I9dcd8d347c6b00efe207d031a480e5b85bf78936
2013-05-14 23:09:57 +02:00
Alexandre Emsenhuber
7053baca03 Remove "will be removed in ..." comments
All of them are wrong, since 1.20 is out for a while now, and
these methods are still here.

Change-Id: I3b59b61490c9aea5252e25623b0b282295dcc3f6
2013-05-11 22:04:21 +02:00
umherirrender
cbc4fd7a5b print is not a function
Removed parenthesis after print

Change-Id: I1343872de7aa7c64952a3d86a63aaa091e46bda3
2013-05-09 20:06:03 +02:00
jenkins-bot
9cc02e7087 Merge "mw.config: Add wgPageContentModel for content model of current page" 2013-05-07 20:53:20 +00:00
umherirrender
7ced06d8d8 mw.config: Add wgPageContentModel for content model of current page
This field of the page table can be useful to determine the
corrosponding model for a page.

Change-Id: I0525ad764540b213b2697e1e9e64f7da73f6cf83
2013-05-07 20:34:11 +00:00
kaldari
bc34b5867a Adding GetNewMessagesAlert hook and wgUserNewMsgRevisionId JS global
This hook allows extensions to disable or modify the new messages
alert ('orange bar of doom') while still allowing the user_newtalk
table to be updated.

The wgUserNewMsgRevisionId JS global allows gadgets and extensions
to create their own new message alerts on the client side.

I also threw in a few comment updates for good measure!

See also Echo change I3f35a56b which utilizes this.

Bug: 47962
Change-Id: I2105bdd2bcd5b27f6f36ec8d8fa7fa99d60a2d82
2013-05-04 20:21:41 -07:00
MatmaRex
e60f36bc03 Clean up the class building logic in OutputPage
Build the classes using an array that is finally imploded, instead of
concatenating strings repeatedly.

Change-Id: I2a09282d5ba33f131a4311c58e49dab5eefce418
2013-04-30 07:45:08 +02:00
Timo Tijhof
0a000d5cf4 Call jQuery.ready() before </body>
mw.loader defaults to async=false. Overridden when $.isReady=true
or a mw.loader call sets async=true.

The problem is in calls to mw.loader.load that are not in
the HTML output but occur *before* the DOMContentReady event.

In those cases we want to use async (creating a script tag)
instead of synchronous (document.write) because in Firefox
DOMContentReady is emitted some time after it is no longer safe
to use document.write (bug 47457).

This also optimises the dom ready event cross-browser.

Bug: 34542
Bug: 47457
Change-Id: Ic3d0c937268d0943d2f770f3ca18bcf4e1eed346
2013-04-29 21:47:24 +02:00
daniel
8e7150b549 (bug 45535) Hook for changing language links.
This adds a new hook called LanguageLinks which is called
whenever a list of language links is returned to the user.
This gives extensions the option to manipulate the links
on the fly.

Note that this change only covers the language links used
in OutputPage and by ApiParse. Adapting ApiQueryLangLinks is
left as a follow-up task.

As explained on bugzilla, this is a precondition to
allowing Wikibase/Wikidata to update languagelinks without
forcing a (redundant) re-parse of the page content.

This change also introduces the notion of link flags that
can be used to associate flags with language links. This
will be integrated with ParserOutput and OutputPage in a
follow-up.

Change-Id: Iaec0faa131413a291fc8f77496e4f371addb3b99
2013-04-29 09:13:47 -04:00
umherirrender
c0d61543b2 Pass array to Title::getLocalURL instead of an urlencoded string
This makes code easier to read and the urlencode is done inside
getLocalURL or friends

Change-Id: I21b988890356d11835eedba12a90a347bf0905b2
2013-04-27 08:22:01 +00:00
umherirrender
dbd0b590e9 else if -> elseif
Also fixed some spacing while at it
Added some braces for one line statements

Change-Id: Iebfa2b17091509daabc76248121c7763e2295d20
2013-04-17 16:52:47 +02:00
Aaron Schulz
3082af5472 Account for $wgSquidMaxage in OutputPage::checkLastModified().
* This deals with the fact that seldom edited pages can end up cached
  with very stale resource (JS/CSS) references since the response to
  IMS GET requests will be 304 Not Modified if page_touched is ancient.
  When squid revalidates its stale cache it will keep getting 304s and
  renewing the TTL on the stale cache.

Bug: 44570
Change-Id: I3889f300012aeabd37e228653279ad19b296e4ae
2013-04-16 06:53:10 +00:00
umherirrender
97234cc884 Added spaces before and removed spaces after 'array'
Fix some other spacing while at it

Change-Id: I13f81533eaf40e06c13cf377c0f08ef5cef01d00
2013-04-14 21:57:46 +02:00