Call getAfterPortlet() Through Skin in MediaWiki Templates

MediaWiki removed BaseTemplate::getAfterPortlet() after deprecating it. In a custom template class, obtain the current Skin object and call getAfterPortlet() on that object. Do not add a replacement method that recreates the removed hook behavior.

Last updated: November 22, 2026.

<?php

final class CandyTemplate extends BaseTemplate
{
    private function getAfterPortletContent(string $name): string
    {
        return $this->getSkin()->getAfterPortlet($name);
    }
}

Use the returned string where the template already renders content after that portlet. Keep the skin’s existing escaping and wrapper markup: the Skin method returns the hook output but does not add the wrapper that the old BaseTemplate helper supplied.

Why the method disappeared

A current upgrade report shows a custom skin failing with “Call to undefined method” after moving from MediaWiki 1.39 to 1.43. MediaWiki’s 1.35 release notes deprecated BaseTemplate::getAfterPortlet() in favor of Skin::getAfterPortlet(). The 1.40 release notes record the old BaseTemplate methods as removed.

The important distinction is the receiver. Inside a class that extends BaseTemplate, $this is the template, not the Skin. Calling $this->getAfterPortlet($name) therefore fails once the compatibility method is gone. $this->getSkin() retrieves the object that owns the supported method.

Update the complete rendering path

Search the custom skin for both getAfterPortlet and renderAfterPortlet. Replace each call according to what the surrounding code expects; do not perform a blind text replacement if the old helper also supplied HTML wrapping. The retired BaseTemplateAfterPortlet hook was removed in MediaWiki 1.40, so extensions that register that hook must migrate to SkinAfterPortlet separately.

Clear MediaWiki caches, load pages containing each sidebar portlet and inspect the generated markup. Test anonymous and logged-in views because available portlets can differ. Test the change on a backup or staging copy before replacing production skin files. Keep the custom skin under version control, compare it with a maintained skin on the target MediaWiki branch, and review every deprecation reported before the next major upgrade rather than waiting for removed APIs to become fatal errors.

Related Web Cheat Sheet guides

Sergey Kornilov

Sergey Kornilov