CustomHeaderPlugin failed to handle the hook TemplateManager in OJS 3.5.x

Hello,

This is with reference to PHP NOTICE: CustomHeaderPlugin failed to handle the hook TemplateManager in OJS 3.5.0-3

The error messages continued in 3.5.0-4 despite saving the settings form for Custom Header Plugin in all Journals that have enabled the Plugin.

I finally fixed the issue by modifying plugins/generic/customHeader/CustomHeaderPlugin.php as thus

115     /**
116      * Register the CustomHeader script tag
117        NB 11/06/2026 added ) ?? '', // <--- Add this part
118        NB 28/06/2026 added ) ?? '' // <--- Add this part
119      */
120     public function displayTemplateHook(string $hookName, array $params)
121     {
122         if (!$this->injected) {
123             $this->injected = true;
124             $templateMgr =& $params[0];
125             $request = Application::get()->getRequest();
126             $context = $request->getContext();
127             $templateMgr->addHeader(
128                 'custom',
129                 $this->getSetting($context ? $context->getId() : PKPApplication::SITE_CONTEXT_ID, 'content') ?? ''
130             );
131             $templateMgr->addHeader(
132                 'custombackend',
133                 $this->getSetting(
134                     $context ? $context->getId() : PKPApplication::SITE_CONTEXT_ID,
135                     'backendContent'
136                 ) ?? '',
137                 ['contexts' => ['backend']]
138             );
139         }
140         return false;
141     }

Thanks,
Nason

Hi @Nason_Bimbe,

Can you include the full error message?

Regards,
Alec Smecher
Public Knowledge Project Team

Hi @asmecher,

Here is the error message

[Wed Dec 31 00:25:33.996539 2025] [php:notice] [pid 335212:tid 335212] [client X.X.X.X:54139] Plugin APP\\plugins\\generic\\customHeader\\CustomHeaderPlugin failed to handle the hook TemplateManager::display\nTypeError: PKP\\template\\PKPTemplateManager::addHeader(): Argument #2 ($header) must be of type string, null given, called in plugins/generic/customHeader/CustomHeaderPlugin.php on line 129 and defined in lib/pkp/classes/template/PKPTemplateManager.php:627\nStack trace:\n#0 plugins/generic/customHeader/CustomHeaderPlugin.php(129): PKP\\template\\PKPTemplateManager->addHeader()\n#1 [internal function]: APP\\plugins\\generic\\customHeader\\CustomHeaderPlugin->displayTemplateHook()\n#2 /lib/pkp/classes/plugins/Hook.php(164): call_user_func_array()\n#3 lib/pkp/classes/plugins/Hook.php(132): PKP\\plugins\\Hook::run()\n#4 pkp/classes/template/PKPTemplateManager.php(1487): PKP\\plugins\\Hook::call()\n#5 lib/pkp/pages/dashboard/PKPDashboardHandler.php(288): PKP\\template\\PKPTemplateManager->display()\n#6

Thanks,
Nason

Hi @Nason_Bimbe,

This is a duplicate of this issue:

Regards,
Alec Smecher
Public Knowledge Project Team

Thanks @asmecher,

I will take a look at my code if I am using an old version of the plugin and will update accordingly.

Regards,
Nason