Hi!
I could use some help looking over extensions.
Since the ContentHandler stuff has been merged into the core, several much-used functions and hooks have been deprecated. I have tried to find and replace all calls in core, but a lot of extensions are still using the old stuff. They will still work for all text-based content, but will generate a ton of warnings, and will fail tests (and make core tests fail).
I have already posted updates for three extensions on gerrit:
* Gadgets: I3d28a3b8 * TitleBacklist: Ib3a00d89 * SpamBlacklist: I72d9ad58
So, it would be great if you (yes, you!) could help out by looking for deprecated stuff in extensions. Grep for it and/or set $wgDevelopmentWarnings to true on your wiki. Run test cases. See what causes warnings, and fix them.
Most prominently, the following functions have been deprecated:
* WikiPage::getText() was replaced by WikiPage::getContent() * Revision::getText() was replaced by Revision::getContent() * Article::getContent() was replaced by WikiPage::getContent()
The new functions all return Content objects instead of text.
Similarly, the ArticleSaveComplete hook and several more have been replaced by hooks that use Content objects instead of page text.
Please have a look at docs/contenthandler.txt for an overview of the architecture and a list of deprecated hooks.
-- daniel
PS: I'm unsure what level of backwarsd compatibility is desired for extensions. I have tried to by B/C in the SpamBlacklist extension, but didn't care about it for TitleBlacklist and Gadgets... could fix that, if it's required.
On 10 October 2012 16:52, Daniel Kinzler daniel@brightbyte.de wrote:
Hi!
I could use some help looking over extensions.
What is the difference between "$content instanceof TextContent" and "$title->getContentModel() === CONTENT_MODEL_WIKITEXT"? -Niklas
Hey,
What is the difference between "$content instanceof TextContent" and
"$title->getContentModel() === CONTENT_MODEL_WIKITEXT"? -Niklas
The former will be true for any content deriving from TextContent, which currently includes WikitextContent, JavaScriptContent, CssContent and RevisionTestModifyableContent. The later will only be true for WikitextContent.
Cheers
-- Jeroen De Dauw http://www.bn2vs.com Don't panic. Don't be evil. --
On Wed, Oct 10, 2012 at 6:52 AM, Daniel Kinzler daniel@brightbyte.de wrote:
Since the ContentHandler stuff has been merged into the core, several much-used functions and hooks have been deprecated. I have tried to find and replace all calls in core, but a lot of extensions are still using the old stuff. They will still work for all text-based content, but will generate a ton of warnings, and will fail tests (and make core tests fail).
I'm very worried about converting all of the extensions to use new APIs now. If it turns out we need to revert ContentHandler, this will make the revert that much more difficult.
I'd rather we remove deprecation warnings for the newly deprecated APIs.
Rob
On Wed, 10 Oct 2012 14:37:47 -0700, Rob Lanphier robla@wikimedia.org wrote:
On Wed, Oct 10, 2012 at 6:52 AM, Daniel Kinzler daniel@brightbyte.de wrote:
Since the ContentHandler stuff has been merged into the core, several much-used functions and hooks have been deprecated. I have tried to find and replace all calls in core, but a lot of extensions are still using the old stuff. They will still work for all text-based content, but will generate a ton of warnings, and will fail tests (and make core tests fail).
I'm very worried about converting all of the extensions to use new APIs now. If it turns out we need to revert ContentHandler, this will make the revert that much more difficult.
I'd rather we remove deprecation warnings for the newly deprecated APIs.
Rob
So use a conditional to check for the contenthandler classses/methods.
This is not a good idea. We should wait until the ContentHandler branch is fully QAd and we are sure it will not be reverted before converting extensions over to using it.
*--* *Tyler Romeo* Stevens Institute of Technology, Class of 2015 Major in Computer Science www.whizkidztech.com | tylerromeo@gmail.com
On Wed, Oct 10, 2012 at 10:47 PM, Daniel Friesen <daniel@nadir-seen-fire.com
wrote:
On Wed, 10 Oct 2012 14:37:47 -0700, Rob Lanphier robla@wikimedia.org wrote:
On Wed, Oct 10, 2012 at 6:52 AM, Daniel Kinzler daniel@brightbyte.de
wrote:
Since the ContentHandler stuff has been merged into the core, several much-used functions and hooks have been deprecated. I have tried to find and replace all calls in core, but a lot of extensions are still using the old stuff. They will still work for all text-based content, but will generate a ton of warnings, and will fail tests (and make core tests fail).
I'm very worried about converting all of the extensions to use new APIs now. If it turns out we need to revert ContentHandler, this will make the revert that much more difficult.
I'd rather we remove deprecation warnings for the newly deprecated APIs.
Rob
So use a conditional to check for the contenthandler classses/methods.
-- ~Daniel Friesen (Dantman, Nadir-Seen-Fire) [http://daniel.friesen.name]
______________________________**_________________ Wikitech-l mailing list Wikitech-l@lists.wikimedia.org https://lists.wikimedia.org/**mailman/listinfo/wikitech-lhttps://lists.wikimedia.org/mailman/listinfo/wikitech-l
What is wrong with making extensions work right now both with and without it?
Hey,
What is wrong with making extensions work right now both with and without
it?
+1. I don't see any harm done in adding such conditional checks, and they solve the problem at hand. We probably want to add them in any case, unless breaking compatibility with MediaWiki older then 1.21 is acceptable.
Cheers
-- Jeroen De Dauw http://www.bn2vs.com Don't panic. Don't be evil. --
11 Октябрь 2012 г. 15:53:42 пользователь Jeroen De Dauw (jeroendedauw@gmail.com) написал:
Hey,
What is wrong with making extensions work right now both with and without
it?
+1. I don't see any harm done in adding such conditional checks, and they solve the problem at hand. We probably want to add them in any case, unless breaking compatibility with MediaWiki older then 1.21 is acceptable.
Also, it would be great, if WMF selected some old version of MediaWiki as LTS (Long Time Support) so extensions would be required to work with it. Currently that could be 1.17, first version which got ResourceLoader. Dmitriy
Hey,
Also, it would be great, if WMF selected some old version of MediaWiki as
LTS (Long Time Support) so extensions would be required to work with it. Currently that could be 1.17, first version which got ResourceLoader.
My observation is that most WMF maintained extensions are not maintained with much regard to backwards compatibility but with a lot of effort being put in replacing use of deprecated code usage quickly. They thus tend to have compatibility broken early after MediaWiki releases. I'd be semi-surprised to find a single one that is still compatible with 1.17 at this point.
Cheers
-- Jeroen De Dauw http://www.bn2vs.com Don't panic. Don't be evil. --
Dmitriy Sintsov.
11 Октябрь 2012 г. 16:13:02 пользователь Jeroen De Dauw (jeroendedauw@gmail.com) написал:
Hey,
Also, it would be great, if WMF selected some old version of MediaWiki as LTS (Long Time Support) so extensions would be required to work with it. Currently that could be 1.17, first version which got ResourceLoader.
My observation is that most WMF maintained extensions are not maintained with much regard to backwards compatibility but with a lot of effort being put in replacing use of deprecated code usage quickly. They thus tend to have compatibility broken early after MediaWiki releases. I'd be semi-surprised to find a single one that is still compatible with 1.17 at this point.
What's so major is preventing new extensions from running in 1.17? Page actions in separate classes? Router? Are these major obstacles?
Dmitriy
On 10.10.2012 23:37, Rob Lanphier wrote:
I'm very worried about converting all of the extensions to use new APIs now. If it turns out we need to revert ContentHandler, this will make the revert that much more difficult.
I'd rather we remove deprecation warnings for the newly deprecated APIs.
Ok. I discussed this a bit with Tim, and we came to the following conclusion:
* Don't update the extensions for a while. But make sure we do eventually. * Disable the deprecation warnings for now by using ContentHandler::deprecated() instead of wfDeprecated(), so we have a single place to enable or disable these warnings. * Define MW_SUPPORTS_CONTENT_HANDLER for easy B/C switches in extensions.
-- daniel
On 10/11/2012 09:56 AM, Daniel Kinzler wrote:
On 10.10.2012 23:37, Rob Lanphier wrote:
I'm very worried about converting all of the extensions to use new APIs now. If it turns out we need to revert ContentHandler, this will make the revert that much more difficult.
I'd rather we remove deprecation warnings for the newly deprecated APIs.
Ok. I discussed this a bit with Tim, and we came to the following conclusion:
- Don't update the extensions for a while. But make sure we do eventually.
- Disable the deprecation warnings for now by using ContentHandler::deprecated() instead of wfDeprecated(), so we have a single place to enable or disable these warnings.
- Define MW_SUPPORTS_CONTENT_HANDLER for easy B/C switches in extensions.
-- daniel
Wikitech-l mailing list Wikitech-l@lists.wikimedia.org https://lists.wikimedia.org/mailman/listinfo/wikitech-l
I think instead of using individual constant, we should finally introduce a Capabilities class.
It should have a single static method, has(), which indicates whether a certain capability is registered within the system. At the beginning, capabilities will be listed as static members of that class, but we may do something more clever at the future.
I would also suggest that we introduce a policy of adding a capability for any new hook we add. Or we could parse docs/hooks.txt in order to avoid duplication (probably moving it somewhere).
Finally, backporting that interface into previous versions of MediaWiki might be a good idea.
—Victor.
Wouldn't it be simpler to just compare the Wikimedia version? if version < 1.21 { Don't use ContentHandler }
*--* *Tyler Romeo* Stevens Institute of Technology, Class of 2015 Major in Computer Science www.whizkidztech.com | tylerromeo@gmail.com
On Thu, Oct 11, 2012 at 1:03 PM, Victor Vasiliev vasilvv@gmail.com wrote:
On 10/11/2012 09:56 AM, Daniel Kinzler wrote:
On 10.10.2012 23:37, Rob Lanphier wrote:
I'm very worried about converting all of the extensions to use new APIs now. If it turns out we need to revert ContentHandler, this will make the revert that much more difficult.
I'd rather we remove deprecation warnings for the newly deprecated APIs.
Ok. I discussed this a bit with Tim, and we came to the following conclusion:
- Don't update the extensions for a while. But make sure we do eventually.
- Disable the deprecation warnings for now by using
ContentHandler::deprecated() instead of wfDeprecated(), so we have a single place to enable or disable these warnings.
- Define MW_SUPPORTS_CONTENT_HANDLER for easy B/C switches in extensions.
-- daniel
______________________________**_________________ Wikitech-l mailing list Wikitech-l@lists.wikimedia.org https://lists.wikimedia.org/**mailman/listinfo/wikitech-lhttps://lists.wikimedia.org/mailman/listinfo/wikitech-l
I think instead of using individual constant, we should finally introduce a Capabilities class.
It should have a single static method, has(), which indicates whether a certain capability is registered within the system. At the beginning, capabilities will be listed as static members of that class, but we may do something more clever at the future.
I would also suggest that we introduce a policy of adding a capability for any new hook we add. Or we could parse docs/hooks.txt in order to avoid duplication (probably moving it somewhere).
Finally, backporting that interface into previous versions of MediaWiki might be a good idea.
—Victor.
______________________________**_________________ Wikitech-l mailing list Wikitech-l@lists.wikimedia.org https://lists.wikimedia.org/**mailman/listinfo/wikitech-lhttps://lists.wikimedia.org/mailman/listinfo/wikitech-l
On Thu, Oct 11, 2012 at 10:03 AM, Victor Vasiliev vasilvv@gmail.com wrote:
I think instead of using individual constant, we should finally introduce a Capabilities class.
It should have a single static method, has(), which indicates whether a certain capability is registered within the system. At the beginning, capabilities will be listed as static members of that class, but we may do something more clever at the future.
I would also suggest that we introduce a policy of adding a capability for any new hook we add. Or we could parse docs/hooks.txt in order to avoid duplication (probably moving it somewhere).
I think this is a good idea. The case for that is here: http://martinfowler.com/bliki/FeatureToggle.html
Gotta love an article that starts with "Imagine you are releasing into production every two weeks..." :)
Some bikeshedding: I'm a little concerned with using the term "Capabilities", since I generally hear that term more frequently in designing software security models: http://en.wikipedia.org/wiki/Capability-based_security
Rob
On Thu, Oct 11, 2012 at 1:25 PM, Rob Lanphier robla@wikimedia.org wrote:
Some bikeshedding: I'm a little concerned with using the term "Capabilities", since I generally hear that term more frequently in designing software security models: http://en.wikipedia.org/wiki/Capability-based_security
How about Feature? I was thinking something like:
Feature::required( "Foo" ) -- for a hard fail if the feature doesn't exist Feature::desired( "Foo" ) -- for conditional behavior if a feature exists
-Chad
Hey,
Interesting idea. A few suggestions:
* Having static methods to access this is nice and convenient, but perhaps we can make a singleton with instance methods such as hasFeature and static methods such as "has" that then just do "return self::singleton()->hasFeature()"
* Having an array with string keys seems way more flexible and extendible then having static (or even non-static) members. It'd be pretty bad if the system did not allow for extensions to register present features.
How about Feature? I was thinking something like:
Feature::required( "Foo" ) -- for a hard fail if the feature doesn't exist Feature::desired( "Foo" ) -- for conditional behavior if a feature exists
+1, although I'd tweak the names a bit:
* Feature::require( 'foo' ) - throws an error or whatever when not present * Feature::has( 'cheesburger' ) - returns a boolean
The first name is still not ideal though. I'd expect "required" to return a boolean. But then again, "require" can be interpreted as loading the feature.
Cheers
-- Jeroen De Dauw http://www.bn2vs.com Don't panic. Don't be evil. --
On 12/10/12 04:03, Victor Vasiliev wrote:
I think instead of using individual constant, we should finally introduce a Capabilities class.
It should have a single static method, has(), which indicates whether a certain capability is registered within the system. At the beginning, capabilities will be listed as static members of that class, but we may do something more clever at the future.
I would also suggest that we introduce a policy of adding a capability for any new hook we add. Or we could parse docs/hooks.txt in order to avoid duplication (probably moving it somewhere).
Finally, backporting that interface into previous versions of MediaWiki might be a good idea.
Then you would have to load a capability map with potentially hundreds of entries at registration time, despite the fact that on most requests, most of the hooks will never be called. It seems inefficient to me. At least with the current system, the number of support constants is small (4-5).
-- Tim Starling
I do not think, design-wise, this is a good idea. In addition to what Tim said, extensions would become needlessly complex if we started accounting for every possible MediaWiki feature that's added in a given release. *--* *Tyler Romeo* Stevens Institute of Technology, Class of 2015 Major in Computer Science www.whizkidztech.com | tylerromeo@gmail.com
On Thu, Oct 11, 2012 at 8:33 PM, Tim Starling tstarling@wikimedia.orgwrote:
On 12/10/12 04:03, Victor Vasiliev wrote:
I think instead of using individual constant, we should finally introduce a Capabilities class.
It should have a single static method, has(), which indicates whether a certain capability is registered within the system. At the beginning, capabilities will be listed as static members of that class, but we may do something more clever at the future.
I would also suggest that we introduce a policy of adding a capability for any new hook we add. Or we could parse docs/hooks.txt in order to avoid duplication (probably moving it somewhere).
Finally, backporting that interface into previous versions of MediaWiki might be a good idea.
Then you would have to load a capability map with potentially hundreds of entries at registration time, despite the fact that on most requests, most of the hooks will never be called. It seems inefficient to me. At least with the current system, the number of support constants is small (4-5).
-- Tim Starling
Wikitech-l mailing list Wikitech-l@lists.wikimedia.org https://lists.wikimedia.org/mailman/listinfo/wikitech-l
On 10/11/2012 10:30 PM, Tyler Romeo wrote:
I do not think, design-wise, this is a good idea. In addition to what Tim said, extensions would become needlessly complex if we started accounting for every possible MediaWiki feature that's added in a given release.
Not every possible, only those of interest to extensions.
—Victor.
On 10/11/2012 08:33 PM, Tim Starling wrote:
Then you would have to load a capability map with potentially hundreds of entries at registration time, despite the fact that on most requests, most of the hooks will never be called. It seems inefficient to me. At least with the current system, the number of support constants is small (4-5).
-- Tim Starling
We can cache them. If we use APC, an individual call to Capabilities::has() should take about 5 to 6 μs.
—Victor.
12 Октябрь 2012 г. 7:23:19 пользователь Victor Vasiliev (vasilvv@gmail.com) написал:
On 10/11/2012 08:33 PM, Tim Starling wrote:
Then you would have to load a capability map with potentially hundreds of entries at registration time, despite the fact that on most requests, most of the hooks will never be called. It seems inefficient to me. At least with the current system, the number of support constants is small (4-5).
-- Tim Starling
We can cache them. If we use APC, an individual call to Capabilities::has() should take about 5 to 6 μs.
Shouldn't class_exists( 'ResourceLoader' ) or class_exists( 'ContentHandler' ) be enough for most of tasks? One even can use Reflection to check for particular changes of mentioned classes introduced in newer versions.
Of course the compatibility to something really old (let's say 1.14) is not desired. Dmitriy
wikitech-l@lists.wikimedia.org