r111168 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r111167‎ | r111168 | r111169 >
Date:17:00, 10 February 2012
Author:ialex
Status:reverted (Comments)
Tags:backcompat 
Comment:
GOOD BYE $wgArticle!
It was stated that it would be removed in 1.20 and we are in 1.20.
Modified paths:
  • /trunk/phase3/includes/Wiki.php (modified) (history)

Diff [purge]

Index: trunk/phase3/includes/Wiki.php
@@ -267,14 +267,6 @@
268268 $article = $this->initializeArticle();
269269 if ( is_object( $article ) ) {
270270 $pageView = true;
271 - /**
272 - * $wgArticle is deprecated, do not use it.
273 - * This will be removed entirely in 1.20.
274 - * @deprecated since 1.18
275 - */
276 - global $wgArticle;
277 - $wgArticle = $article;
278 -
279271 $this->performAction( $article );
280272 } elseif ( is_string( $article ) ) {
281273 $output->redirect( $article );

Follow-up revisions

RevisionCommit summaryAuthorDate
r111297Revert r111168 (removed of $wgArticle) since it seems that this is too early ...ialex14:38, 12 February 2012
r111342Give a warning when people use $wgArticle. Add's a class that can be used to ...bawolff00:19, 13 February 2012

Comments

#Comment by Reedy (talk | contribs)   18:40, 10 February 2012

Omgosh. Is that really it gone?

#Comment by Tbleher (talk | contribs)   18:23, 11 February 2012

Hmm, so how does one access article related information now?

I have the following simple code, and couldn't see how to port it to MW 1.20, despite searching for quite a while:

$wgHooks['SkinTemplateNavigation'][] = 'wfAlterEditPageLinkHook2';
function wfAlterEditPageLinkHook2( &$vector, &$links ) {
        global $wgTitle, $wgArticle;
        if( array_key_exists( 'edit', $links['views'] ) && $wgTitle->isContentPage() && $wgArticle !== null && $wgArticle->isCurrent() ){
                if( $wgTitle->exists() ) {
                        $links['views']['edit']['href'] = Title::newFromText( 'Spezial:Spiel_bearbeiten/'. $wgTitle->getPrefixedDBkey() )->getLocalUrl();
                } else {
                        $links['views']['edit']['href'] = Title::newFromText( 'Spezial:Neues_Spiel/'. $wgTitle->getPrefixedDBkey() )->getLocalUrl();
                }
        }
        return true;
}

(the code redirects the edit link to a special page, but only if the page viewed is the current version of the article).

Could you document how to do something like this when using MW 1.20? The best place to document this would probably be Manual:$wgArticle.

#Comment by RobLa-WMF (talk | contribs)   19:40, 11 February 2012

As much as I would love to see us ditch a lot of the globals, this is not the time to make this change. Please revert.

See this email for more: http://thread.gmane.org/gmane.science.linguistics.wikipedia.technical/58678

#Comment by Bawolff (talk | contribs)   03:14, 12 February 2012

If we really aren't going to kill this now ( Why exactly is this not the time. Will it ever be the time? ). Could we perhaps have a class similar to StubObject, that basically just issues a wfDeprecated warning the first time someone uses the global, to further discourage people from using the global.

#Comment by RobLa-WMF (talk | contribs)   04:23, 12 February 2012

We deprecated this less than a year ago (in r88588). This commit is doing nothing other than breaking things that might otherwise actually work, and there's no followup work with tangible end-user benefit that depends on this being gone. Most of the major Linux distros are still shipping a version of MediaWiki prior to this even being deprecated.

When will we ever remove this? When we need to. Certainly not before someone gets around to writing the documentation that Tbleher requested.

It would be just fine to throw deprecation errors upon use of this global, assuming there's a reasonable way to do that.

#Comment by Bawolff (talk | contribs)   18:49, 12 February 2012

Sorry, my original post here was kind of saying different things from what I intended to say. I took the statement "this is not the time to make this change" to mean not the time due to some short-term issues or something. I'm not opposed to leaving that in there for several more releases (especially because removing it doesn't provide any tangible benefits as you said), but if we were to remove it in 1.20, now would be the time, right at the start of 1.20 development.


I'll look into seeing if we can do wfDeprecated warnings for globals in some sort of sane way.

#Comment by Tbleher (talk | contribs)   09:26, 12 February 2012

At the very least there should be a list of all deprecated global variables, preferably in RELEASE-NOTES. Removed global variables should also be mentioned in the RELEASE-NOTES, as a breaking change.

I stumbled across this revision and it really caught me by surprise. I have a few extensions that use $wgArticle, they were written long before $wgArticle was deprecated. How should I have known that $wgArticle was deprecated? If I had not seen this commit by accident, I would probably have searched for a while why my extension didn't work anymore after upgrading to trunk.

Calling wfDeprecated sounds like a good idea, but there should also be a list of all deprecations, so it is easier to search for deprecated functions and globals in custom extensions.

From a deloper perspective, I can understand the impulse to remove old, deprecated code to make the code "cleaner". But please keep in mind that this makes it much harder to use your work outside of WMF.

#Comment by IAlex (talk | contribs)   14:39, 12 February 2012

Reverted in r111297 and I'm also going to expand the documentation.

#Comment by RobLa-WMF (talk | contribs)   18:53, 12 February 2012

Excellent, thanks iAlex!

Status & tagging log