IN T313409 we added code to support backwards compatibility with gadgets adding portlet links to #p-namespaces and set the intention this would be removed in MediaWiki 1.40. That deadline has long passed and we are now starting to see visual issues with code using the backwards compatibility method.
Per https://www.mediawiki.org/w/index.php?title=Stable_interface_policy/Frontend&safemode=1#How_providers_should_communicate_changes_to_consumers we're now removing that support.
After this change, impacted gadgets and user scripts will stop appending links alongside the talk and article tabs in Vector 2022 and may throw JavaScript errors if the return value of addPortletLink has not been checked. We will patch any issues that arise due to the latter.
Migration notes
Before:
mw.util.addPortletLink('p-namespaces', '#', 'text')
After:
var link = mw.util.addPortletLink('p-namespaces', '#', 'text'); if (!link) { mw.util.addPortletLink('p-associated-pages', '#', 'text') }