Page MenuHomePhabricator

[1.44] Extending View class constructor is deprecated. Please use View.make
Closed, ResolvedPublicBUG REPORT

Description

This impacts any code making use of the mobile.startup module and extending the View class either via extends View or OO.inheritClass

Steps to replicate the issue (include links if applicable):

  • Go to page using unsupported code
  • Open developer console

What happens?:
You should see the message "[1.44] Extending View class constructor is deprecated. Please use View.make"

What should have happened instead?:

  • Please use the View.make function. An example is provided.

Software version (on Special:Version page; skip for WMF-hosted wikis like Wikipedia):

Other information (browser name/version, screenshots, etc.):

Requirement

Deprecation warning: Extending the View class constructor directly is deprecated as of MediaWiki 1.44. Developers should instead use the View.make method. Ensure that no deprecation warnings appear in the console when visiting affected pages, and verify correct usage of the updated function.

BDD

Feature: Remove deprecated use of View class constructor  

  Scenario: No deprecation warning when visiting page using updated View code  
    Given I visit a page that previously used the deprecated View constructor  
    When I open the developer console  
    Then no deprecation warning related to the View constructor is displayed  
    And the View.make function is used instead

Test Steps

Test Case 1: Verify no deprecation warning for View constructor

  1. Visit a page that previously used unsupported View constructor code. https://en.m.wikipedia.org/wiki/Special:Homepage#/homepage/suggested-edits
  2. Open the developer console.
  3. AC1: Confirm there is no warning stating: “[1.44] Extending View class constructor is deprecated. Please use View.make”.

QA Results - Beta

ACStatusDetails
1T381627#10696629

QA Results - Prod

ACStatusDetails
1T381627#10696688

Event Timeline

Restricted Application added a subscriber: Aklapper. · View Herald Transcript

Change #1100876 had a related patch set uploaded (by Jdlrobson; author: Jdlrobson):

[mediawiki/skins/MinervaNeue@master] Fix deprecation warnings in Minerva

https://gerrit.wikimedia.org/r/1100876

Change #1100877 had a related patch set uploaded (by Jdlrobson; author: Jdlrobson):

[mediawiki/extensions/ExternalGuidance@master] Fixes deprecation warnings in MTServiceInfo

https://gerrit.wikimedia.org/r/1100877

@santhosh RequestTitleForm while possible to fix up, seems a little complicated and might benefit from an extensive Vue rewrite..?

Sgs triaged this task as Medium priority.Dec 10 2024, 4:37 PM

This project is a candidate for sunsetting as per our last team discussions. So , I am not expecting any rewrite.

Change #1100877 merged by jenkins-bot:

[mediawiki/extensions/ExternalGuidance@master] MTServiceInfo: Remove usage of deprecated View class constructor

https://gerrit.wikimedia.org/r/1100877

This project is a candidate for sunsetting as per our last team discussions. So , I am not expecting any rewrite.

@santhosh can I delete the associated code now to unblock removal of this code (or alternatively break it if it's not in use anywhere)?

@santhosh: Could you please answer the last comment? Thanks in advance!

@Jdlrobson Apologies, I missed this notification.

Yes, please go ahead. No blocker from our side. I will follow up and keep Special:ExternalGuidance minimum functional. It barely get traffic.

Change #1125026 had a related patch set uploaded (by Santhosh; author: Santhosh):

[mediawiki/extensions/ExternalGuidance@master] Special:ExternalGuidance: Remove dependency on View class from MobileFrontEnd

https://gerrit.wikimedia.org/r/1125026

Change #1125026 merged by jenkins-bot:

[mediawiki/extensions/ExternalGuidance@master] Special:ExternalGuidance: Remove dependency on View class from MobileFrontEnd

https://gerrit.wikimedia.org/r/1125026

I believe this is now only blocked on the GrowthExperiments extension (specifically the MobileOverlay). I'm keen to drop support for View and Overlay inheritance as there are some subtle bugs that may be present in Growth code. @Sgs @KStoller-WMF
could we set up some time to pair on fixing this up?

Looks like we need to remove the class inheritance in the following file, replacing it with Overlay.make:
https://gerrit.wikimedia.org/g/mediawiki/extensions/GrowthExperiments/+/8feabf3e53e240071db8d1a6366b9a82b388940c/modules/ext.growthExperiments.Homepage.mobile/MobileOverlay.js#20

Good example for reference:

could we set up some time to pair on fixing this up?

Thanks for offering pairing support! We'll discuss and estimate this task next week and plan to pull it into our upcoming sprint.

Does the Overlay.make factory allow to set a preRender hook into the overlay? Or what would be an alternative? GrowthExperiments is using it to add extra options into the header (see ext.growthExperiments.Homepage.mobile/MobileOverlay.js#35).

It does yes. It's a factory function.

MobileOverlay will need to be updated to do something like this:

	module.exports = ( params ) => {
		const options = preRender( params );
		const view = postRender( options );
		return Overlay.make( options, view );
	}

Looking at your code it doesn't seem you are making use of any of the preRender of postRender functionality of Overlay.

the new postRender version would do something like return View.make( {}, [ $el ] ); and the new preRender function would simply return the modified options. Further refactoring is likely possible to make this code more readable.

I can walk you through it tomorrow and possibly get you started.

Change #1127884 had a related patch set uploaded (by Sergio Gimeno; author: Sergio Gimeno):

[mediawiki/extensions/GrowthExperiments@master] refactor(MobileOverlay): use View.make instead of extending class

https://gerrit.wikimedia.org/r/1127884

Test Steps

Status: ❌ FAIL
Environment: enwiki
OS: macOS
Browser: Chrome
Device: MS MBA

Test Case 1: Verify no deprecation warning for View constructor

  1. Visit a page that previously used unsupported View constructor code. https://en.m.wikipedia.org/wiki/Special:Homepage#/homepage/suggested-edits
  2. Open the developer console.
  3. ❌ AC1: Confirm there is no warning stating: “[1.44] Extending View class constructor is deprecated. Please use View.make”.

screenshot 131.png (1×1 px, 225 KB)

@Edtadros thanks this is expected. Work is still ongoing here by the Growth team and it's only partially fixed.

Change #1128901 had a related patch set uploaded (by Jdlrobson; author: Jdlrobson):

[mediawiki/extensions/MobileFrontend@master] Do not expose View and Overlay to external extensions

https://gerrit.wikimedia.org/r/1128901

Change #1127884 merged by jenkins-bot:

[mediawiki/extensions/GrowthExperiments@master] refactor(MobileOverlay): use View.make instead of extending class

https://gerrit.wikimedia.org/r/1127884

Sgs removed Sgs as the assignee of this task.Mar 19 2025, 2:20 PM

The GrowthExperiments change is now merged so it's testable in beta, will probably ride with next week's train unless there's a necessity to backport, I believe there isn't. Since there are ongoing changes attaxhed to the task from @Jdlrobson, I'm unassigning myself, and I created T389364 for the GrowthExperiments QA part if necessary.

Jdlrobson-WMF claimed this task.

Thank you! We can call this done now. I am not seeing the deprecation in https://en.m.wikipedia.beta.wmflabs.org/w/index.php?title=Special:Homepage#/homepage/suggested-edits

@Edtadros this should pass QA now :-)

Next up: T389436: Code cleanup: Remove stable API for extending Overlay and View classes

Thanks for your help prioritizing this work!

Test Steps

Status: ✅ PASS
Environment: beta
OS: macOS
Browser: Chrome
Device: MS

Test Case 1: Verify no deprecation warning for View constructor

  1. Visit a page that previously used unsupported View constructor code. https://en.m.wikipedia.org/wiki/Special:Homepage#/homepage/suggested-edits
  2. Open the developer console.
  3. ✅ AC1: Confirm there is no warning stating: “[1.44] Extending View class constructor is deprecated. Please use View.make”.

screenshot 222.png (957×1 px, 180 KB)

Test Steps

Status: ✅ PASS
Environment: enwiki
OS: macOS
Browser: Chrome
Device: MS

Test Case 1: Verify no deprecation warning for View constructor

  1. Visit a page that previously used unsupported View constructor code. https://en.m.wikipedia.org/wiki/Special:Homepage#/homepage/suggested-edits
  2. Open the developer console.
  3. ✅ AC1: Confirm there is no warning stating: “[1.44] Extending View class constructor is deprecated. Please use View.make”.

screenshot 223.png (1×1 px, 126 KB)