Skip to content

[1.20] Migrate to the new core service worker extension point - #105

Open
luke- wants to merge 1 commit into
developfrom
enh/core-1.20-service-worker-event
Open

luke- wants to merge 1 commit into
developfrom
enh/core-1.20-service-worker-event

Conversation

@luke-

@luke- luke- commented Sep 11, 2026

Copy link
Copy Markdown
Contributor

Requires HumHub core 1.20 — do not merge before humhub/humhub#8453 has landed and 1.20 is available.

Why

HumHub 1.20 moves the PWA endpoints out of the web module into the core namespace (humhub/humhub#8453). ServiceWorkerController and its public $additionalJs property are gone, so the way this module extended the service worker no longer exists.

This fails silently. The handler stays registered on a class that no longer exists and is simply never called — no error, no warning. The Firebase service worker logic just disappears from /sw.js and web push stops working.

Change

// config.php — before
['humhub\modules\web\pwa\controllers\ServiceWorkerController', Controller::EVENT_INIT, [Events::class, 'onServiceWorkerControllerInit']],
// after
[ServiceWorkerService::class, ServiceWorkerService::EVENT_BUILD_SCRIPT, [Events::class, 'onBuildServiceWorkerScript']],
// Events.php — before
public static function onServiceWorkerControllerInit($event): void
{
    /** @var ServiceWorkerController $controller */
    $controller = $event->sender;
    // ...
    $controller->additionalJs .= (new ServiceWorkerService($module))->getJs();
}

// after
public static function onBuildServiceWorkerScript(ServiceWorkerScriptEvent $event): void
{
    // ...
    $event->append((new ServiceWorkerService($module))->getJs());
}

The driver guard (hasConfiguredWebDriver()) and the generated JavaScript are unchanged — only the hook moves.

These were the only two references to humhub\modules\web in the module; a stale docblock in services/ServiceWorkerService.php pointing at the old handler is updated too.

Version

Continues the HumHub 1.20 line as 2.4.x, matching the pattern documented in the changelog ("Continue the HumHub 1.19 line as 2.3.x; the 2.2.x line remains on HumHub 1.18"):

  • version 2.3.0 → 2.4.0
  • humhub.minVersion 1.19 → 1.20

2.3.x stays on HumHub 1.19.

Verification

The new extension point is covered on the core side by ServiceWorkerServiceTest::testModulesCanAppendTheirOwnScript, which pins exactly this contract. This module has no test suite, so the change is verified by review and by php-cs-fixer (clean against the shared config).

🤖 Generated with Claude Code

https://claude.ai/code/session_01E2SUrd2fGkf6GZY9Xcd8qN

HumHub 1.20 moves the PWA endpoints out of the web module into the core
namespace (humhub/humhub#8453). ServiceWorkerController and its public
$additionalJs property are gone, so the way this module extended the service
worker no longer exists:

    ['humhub\modules\web\pwa\controllers\ServiceWorkerController',
     Controller::EVENT_INIT, [Events::class, 'onServiceWorkerControllerInit']]
    -> $controller->additionalJs .= $js;

Script assembly now lives in humhub\services\ServiceWorkerService, which
raises a class level event modules append to:

    [ServiceWorkerService::class, ServiceWorkerService::EVENT_BUILD_SCRIPT,
     [Events::class, 'onBuildServiceWorkerScript']]
    -> $event->append($js);

Without this the module does not fail - the handler is registered on a class
that no longer exists and is simply never called, so the Firebase service
worker logic silently disappears from /sw.js and web push stops working.

Continues the 1.20 line as 2.4.x; 2.3.x stays on HumHub 1.19.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01E2SUrd2fGkf6GZY9Xcd8qN
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant