Update/Create override classes of ContentHandler.
Soft-deprecate and remove method from Content and classes that override them.
Bug: T287158
Change-Id: Idfcfbfe1a196cd69a04ca357281d08bb3d097ce2
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
User::getBoolOption() is deprecated and should be replaced with UserOptionsLookup::getBoolOption()
Bug: T277600
Change-Id: Ife3c721237258d50852bbf764def74657cc70428
Test Plan:
* Logged-in, preview a change adding {{subst:CURRENTYEAR}}
to User:You/common.css, User:You/common.js and Main_Page.
* Observe that it expands to 2020 in all cases.
* Run `(new mw.Api).saveOption('pst-cssjs', '0')`
* Try again. Observe that the first two are now left unchanged.
Bug: T236828
Change-Id: Ic13e2ff3b90f0c3587cdb1e97fffcd96be650e0e
Instead of checking if the resulting $matches array is complete, we can
safely assume it is, as long as the preg_match() call returned a
non-false value.
Note that some of these used empty() before and are actually bogus
because of this! empty() considers the string "0" to be empty. In case
of a ==0== headline that's an actual bug.
I'm also removing the `= []` initialization before the preg_match.
I understand why it was added: to make it a little more obvious that the
variable is guaranteed to be initialized. But:
* This is guaranteed by the preg_match anyway.
* Neither initializing it with null or an empty array makes much sense
because the code below assumes so much more, e.g. that specific
elements exist, and are arrays. Again, these guarantees are all given
by the preg_match.
I find the additional initialization more distracting than helpful.
Change-Id: I22b192b59038d9fa51a7e6f04d8d76634ae3de73
For compliance with the new version of the table interface policy
(T255803).
This patch was created by an automated search & replace operation
on the includes/ directory.
Bug: T257789
Change-Id: If560596f5e1e0a3da91afc36e656e7c27f040968
This annotates classes that can safely be instantiated by
extensions, per the Stable Interface Policy.
Bug: T247862
Change-Id: Ia280f559874fc0750265ddeb7f831e65fd7d7d6a
getNativeData() is under-specified - callers can do nothing with the
value returned by getNativeData without knowing the concrete Content
class. And if they know the concrete class, they can and should use
a specialized getter instead, anyway.
Basically, getNativeData is overly generic, an example of polymorphism
done poorly. Let's fix it now.
Bug: T155582
Change-Id: Id2c61dcd38ab30416a25746e3680edb8791ae8e8
The regex in JavaScriptContent and CssContent was trying to pass
urlencoded stuff to Title::newFromText(), which would fail. Make sure we
urldecode it first.
Bug: T208264
Change-Id: I189c4c308da2875839ad8c1061332500f0e6d244
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
We need to be able to set a different content model via the
constructor, so make it an optional parameter.
Change-Id: I8b31084e0cfbcca1b3785176eac492d837e0cb0f
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
That function was clearly a bad idea, everyone should just use
getHtml() instead. It was supposed to allow extensions to extend
the content formatting process, but actually doesn't.
A better hook-based solution follows in separate commit I979e2438.
Split off from original I979e2438 and rebased with minor changes
(updated documentation comments, etc.).
Co-Authored-By: daniel <daniel.kinzler@wikimedia.de>
Co-Authored-By: Bartosz Dziewoński <matma.rex@gmail.com>
Change-Id: I76412f9d28bb145fb5975f59e538f6560e50472f
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
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
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
Added/removed spaces around logical/arithmetic operator
Reduced multiple empty lines to one empty line
Removed wrong tabs before comments at end of line
Removed too many spaces in assigments
Change-Id: I2bba4e72f9b5f88c53324d7b70e6042f1aad8f6b