Commit graph

18 commits

Author SHA1 Message Date
TChin
47adb6d65a Refactor global variables to use MediaWikiServices instead
Automatically refactors wg prefixed globals to use MediaWikiServices config using Rector. Doesn't include files that set globals or files that fail CI.

Rector Gist: https://gist.github.com/tchin25/7cc54f6d23aedef010b22e4dfbead228

* This patch uses a modified source code rector library for our specific use case and the rector will have different effects without it.

A writeup for future reference is here: https://meta.wikimedia.org/wiki/User:TChin_(WMF)/Using_Rector_On_MediaWiki

Change-Id: I1a691f01cd82e60bf41207d32501edb4b9835e37
2022-01-10 13:55:53 -05:00
Roman Stolar
a68e641f9d Move Content::getParserOutput & AbstractContent::fillParserOutput to ContentHandler
Update/Create override classes of ContentHandler.
Soft-deprecate and remove method from Content and classes that override them.

Bug: T287158
Change-Id: Idfcfbfe1a196cd69a04ca357281d08bb3d097ce2
2021-09-29 13:10:51 +03:00
Roman Stolar
42442e01ff Move Content::preloadTransform to ContentHandler
Update ContentTransformer to access ContentHandler::preLoadTransform through the service.
Prepare object to hold a data that required for ContentHandler::preLoadTranform params.

This is a fully backwards compatible change.
We are doing hard deprecation via MWDebug::detectDeprecatedOverride.

However, with the ContentHandler calling Content and
Content calling ContentHandler, it doesn't matter whether
callers use Content or ContentHandler. This will allow us
to naturally convert all callers.

Bug: T287157
Change-Id: I89537e1e7d24c6e15252b2b51890a0bd81ea3e6b
2021-08-17 15:17:34 +00:00
Petr Pchelko
bf438e8c87 Support deprecated Content::preSaveTransform override
If an exctension ContentHandler overrides one of the
subclasses of the core ContentHandler, for example
TextContentHandler, when switching calls we no longer
call deprecated Content::preSaveTransform for the
extension Content model.

Bug: T288191
Change-Id: Ie7edc97be9098f3cd188949bd37943c37a0b65ff
2021-08-05 08:56:47 -07:00
Petr Pchelko
b782a7e66d Move Content::preSaveTransform to ContentHandler
Create ContentTransformer to access ContentHandler::preSaveTransform through the service.
Prepare object to hold a data that required for ContentHandler::preSaveTranform params.

This will require making a semi-backwards-incompatible
change no matter what, we don't really have a great way
of hard-deprecating overriding methods.

However, with the ContentHandler calling Content and
Content calling ContentHandler, and with the ProxyContent
trick to stop infinite recursion, it doesn't matter whether
callers use Content or ContentHandler. This will allow us
to naturally convert all callers. But won't really allow
hard-deprecation.

Bug: T287156
Change-Id: If6a2025868ceca3a3b6f11baec39695e47292e40
2021-07-29 18:06:02 +03:00
Kunal Mehta
3cb341b185 content: Use "::class" when overriding TextContent::getContentClass()
Change-Id: Iea03d2cd24fdb90253145a8abfefe9f8a09e46cd
2016-08-12 21:16:37 -07: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
Kunal Mehta
ad9f14d662 Support redirects in JavaScriptContent
When a JavaScript page is moved, a "redirect" in the form of
mw.loader.load(...) will be left behind, so any other
JavaScript loading the page that way will still work, albeit
with an extra HTTP request.

This also implements Content::getRedirectTarget(), so redirects
are marked properly in the database, and users viewing them
are redirected properly. A magic "/* #REDIRECT */" comment
must be in front of the mw.loader.load call. This is done so
that pages which currently are just one mw.loader.load call
aren't turned into redirects.

Bug: 71200
Bug: 33973
Change-Id: I10fdff087a901da56fad64531f0e382f90ebcf37
2015-07-20 15:36:49 +00:00
Timo Tijhof
de7cc2c11e content: Minor clean up to make JsonContent match other classes
Compared to JavaScriptContentHandler:

* Add missing license header.
* Add @ingroup.
* Move class description to @class.

Change-Id: I88c6e231756ce9f6d0d3aa2cb2bb80848c8bc5b9
2014-12-02 00:38:01 +00:00
Yuri Astrakhan
3a28ee5acb CSS/JSON/JavaScript ContentHandler refactoring
* All content handlers that deal with code/data tend to have
English as their page language & pageview language, so moved common
code to the abstract CodeContentHandler class.

* Renamed JSONContent & JSONContentHandler into JsonContent*

Change-Id: I46819a0572ef5becc211d0d82471ff7102edaa3c
2014-09-15 08:24:15 +00: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
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
5bec2e90d1 Update documentation and break long lines
Also remove some superfluous newlines.

Change-Id: I904d6ddeb976434708d5a22df9e8abd2e6f60a6c
2013-11-20 06:02:37 +01: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
Ori Livneh
71cdd2a9eb JavaScriptContentHandler: Fix typo in comment block (actual: 'CSS'; intended: 'JS')
Change-Id: Iaef21f0c864222aee7c970012e8163741d6310ca
2012-11-20 00:57:44 +01:00
Antoine Musso
42a8daaf5a (bug 26280) all files should have GPL header
MediaWiki is licensed under GPL so we should really add the header to
our PHP code unless reusing code licensed differently.

Tested using:
  ack-grep --php -L 'This program is free software' \
    includes/ maintenance/ mw-config/ resources/ skins/

Output the following files:
 includes/ExternalEdit.php (public domain)

Various other licenses:
 includes/json/Services_JSON.php
 includes/libs/CSSMin.php
 includes/libs/IEContentAnalyzer.php
 includes/libs/JavaScriptMinifier.php
 includes/libs/jsminplus.php
 includes/normal/Utf8Case.php
 includes/objectcache/MemcachedClient.php

File autogenerated from a GPL file and Unicode data:
 includes/ZhConversion.php

A few lines coming from stack overflow:
 maintenance/mwdoc-filter.php

Message files do not have any license :-/

Change-Id: I214a988edfa9e2dfcc762612a0f7d47eee8bcb74
2012-11-18 15:34:00 +01:00
jeroendedauw
bccf2755d4 Moved ContentHandler deriving classes into their own files for better discoverability and more manageable line count per file
Change-Id: I37db53e1d1420e61d3af4566322bcdba85ec778b
2012-10-16 20:20:43 +02:00