Skip to content

ServerKit is a lightweight, modern server control panel for managing web applications, databases, and services on your VPS or dedicated server. Built with Python/Flask backend and React frontend.

refactor(wordpress): decouple core from the in-tree extension

Juan Denis72eaba34f23f
diff --git a/.gitignore b/.gitignore
index 4e2ce3d3..0ffd0364 100644
--- a/.gitignore
+++ b/.gitignore
@@ -191,6 +191,7 @@ backend/app/plugins/serverkit-mail/
backend/app/plugins/serverkit-remote-access/
backend/app/plugins/serverkit-status/
backend/app/plugins/serverkit-tramo/
+backend/app/plugins/serverkit-wordpress/
frontend/src/plugins/serverkit-analytics/
frontend/src/plugins/serverkit-crowdsec/
frontend/src/plugins/serverkit-dns-server/
@@ -200,6 +201,7 @@ frontend/src/plugins/serverkit-gui/
frontend/src/plugins/serverkit-k8s/
frontend/src/plugins/serverkit-mail/
frontend/src/plugins/serverkit-tramo/
+frontend/src/plugins/serverkit-wordpress/
/graphify-out
# Extension release signing keys (private halves — never commit; see scripts/sign-extension.mjs)
diff --git a/backend/app/__init__.py b/backend/app/__init__.py
index c8eea017..47ae9049 100644
--- a/backend/app/__init__.py
+++ b/backend/app/__init__.py
@@ -164,12 +164,14 @@ def create_app(config_name=None):
# Register blueprints - PHP
from app.api.php import php_bp
app.register_blueprint(php_bp, url_prefix='/api/v1/php')
- # WordPress moved into the bundled, default-installed `serverkit-wordpress`
- # extension (#38). Its blueprints (wordpress / wordpress_sites /
- # environment_pipeline, keeping the /api/v1/wordpress[/projects|/pipelines]
- # prefixes per D9, incl. the /pipelines alias) are registered from the
- # extension by the plugin loader — seeded as a flagship in create_app. The old
- # `wordpress` module toggle is retired; the plugin status guard is the gate.
+ # WordPress is the standalone `serverkit-wordpress` extension (plan 52
+ # Phase 5 — it left the tree into its own repo and installs from the
+ # registry; the setup wizard offers it from the bundled index entry).
+ # Its blueprints (wordpress / wordpress_sites / environment_pipeline,
+ # keeping the /api/v1/wordpress[/projects|/pipelines] prefixes per D3,
+ # incl. the /pipelines alias) are registered from the extension by the
+ # plugin loader when installed. The old `wordpress` module toggle is
+ # retired; the plugin status guard is the gate.
# Register blueprints - Python
from app.api.python import python_bp
diff --git a/backend/app/api/apps.py b/backend/app/api/apps.py
index 0a828286..8447f826 100644
--- a/backend/app/api/apps.py
+++ b/backend/app/api/apps.py
@@ -2487,11 +2487,14 @@ def create_app_db_snapshot(app_id):
return err
from app.models.wordpress_site import DatabaseSnapshot
from app.services.db_sync_service import DatabaseSyncService
- from app.services.wordpress_bridge import wordpress_env_service
- WordPressEnvService = wordpress_env_service()
site = _wp_site_for_app(app)
if not site:
return jsonify({'error': 'This application is not a WordPress site'}), 400
+ # Resolve the extension only once we know this IS a WordPress site — with
+ # serverkit-wordpress uninstalled a non-WP app must get the 400, not an
+ # import error (plan 52 Phase 5 graceful absence).
+ from app.services.wordpress_bridge import wordpress_env_service
+ WordPressEnvService = wordpress_env_service()
data = request.get_json() or {}
result = DatabaseSyncService.create_snapshot(
db_name=site.db_name,
diff --git a/backend/app/jobs/builtin_handlers.py b/backend/app/jobs/builtin_handlers.py
index 9587f07f..d6d0a548 100644
--- a/backend/app/jobs/builtin_handlers.py
+++ b/backend/app/jobs/builtin_handlers.py
@@ -177,8 +177,6 @@ def _prune_old_health_checks():
def check_update_schedules():
from app.models.wordpress_site import WordPressSite, WordPressUpdateRun
- from app.services.wordpress_bridge import wp_update_service
- WpUpdateService = wp_update_service()
from datetime import datetime
import json as _json
@@ -190,6 +188,17 @@ def check_update_schedules():
sites = WordPressSite.query.filter(WordPressSite.auto_update_schedule.isnot(None)).all()
if not sites:
return
+
+ # Resolve the extension's update service only when scheduled WP sites
+ # actually exist — with serverkit-wordpress uninstalled there is nothing
+ # to run, and the bridge would raise (plan 52 Phase 5 graceful absence).
+ from app.services.wordpress_bridge import wp_update_service
+ try:
+ WpUpdateService = wp_update_service()
+ except Exception as e:
+ logger.warning(f'WP update schedules exist but the WordPress extension '
+ f'is not installed; skipping: {e}')
+ return
now = datetime.utcnow()
for site in sites:
try:
diff --git a/backend/app/services/plugin_service.py b/backend/app/services/plugin_service.py
index 330a5a40..3204fc37 100644
--- a/backend/app/services/plugin_service.py
+++ b/backend/app/services/plugin_service.py
@@ -62,16 +62,22 @@ BUILTIN_EXTENSIONS_DIR = os.environ.get(
# (handled one-shot in extension_migration), a flagship is seeded in-place — no
# file copy — its backend loads straight from builtin-extensions/ and its frontend
# is pre-bundled (D5). A user uninstall records a marker so it stays gone.
-FLAGSHIP_SLUGS = ['serverkit-wordpress', 'serverkit-cloudflare-ops']
+#
+# serverkit-wordpress GRADUATED from this list in plan 52 Phase 5: it left the
+# tree into its own repo and now distributes through the registry (the
+# k8s/tramo model — bundled index entry + GitHub release zip), offered during
+# onboarding via RECOMMENDED_EXTENSIONS_BY_USE_CASE. Its uninstall-marker
+# semantics are preserved (the settings key machinery below is untouched), so
+# a user who uninstalled WP before the extraction is never re-seeded.
+FLAGSHIP_SLUGS = ['serverkit-cloudflare-ops']
_FLAGSHIP_UNINSTALLED_KEY = 'extensions.flagship_uninstalled'
# Wizard-optional flagships (plan 47): offered — not force-installed — during
-# onboarding. On a FRESH install (setup wizard not yet completed) the boot-time
-# seeder skips these so the panel stays lean; the wizard installs them only when
-# their use case is picked. Existing installs (setup already completed) keep the
-# prior always-seeded behavior — zero regression. cloudflare-ops is NOT here: it
-# is route-only (no sidebar item) and stays seeded for the CF connection surface.
-WIZARD_OPTIONAL_FLAGSHIP_SLUGS = ['serverkit-wordpress']
+# onboarding. Currently EMPTY: WordPress (the only member) left the tree in
+# plan 52 Phase 5 and is now a registry extension the wizard offers like any
+# other recommendation. The machinery stays — a future in-tree flagship that
+# should be wizard-optional goes here.
+WIZARD_OPTIONAL_FLAGSHIP_SLUGS = []
def _ensure_builtin_backend_importable(slug):
diff --git a/backend/app/services/wordpress_bridge.py b/backend/app/services/wordpress_bridge.py
index 371267cc..d98c0190 100644
--- a/backend/app/services/wordpress_bridge.py
+++ b/backend/app/services/wordpress_bridge.py
@@ -1,28 +1,19 @@
"""Importlib bridge to the ``serverkit-wordpress`` extension backend.
-WordPress ships as a bundled, default-installed, uninstallable extension (D4).
-Its backend lives in ``builtin-extensions/serverkit-wordpress/backend/`` and is
-loaded as the *dashed* package ``app.plugins.serverkit-wordpress``. Because the
-slug contains a dash it can never be reached with a normal ``import`` statement
-(``import app.plugins.serverkit-wordpress`` is a SyntaxError), so the handful of
-core call sites that still reach into the WordPress stack go through this bridge,
-which resolves modules with ``importlib`` on a *string* path — dash-safe.
-
-Loadability is uniform across prod / dev / test:
-
-* **Copy-installed** (``app/plugins/serverkit-wordpress`` exists) — the ordinary
- path-based finder resolves it, same as any marketplace plugin.
-* **In-place** (dev checkout, the test suite, or a fresh boot *before* the
- flagship seed row is created) — we register the builtin backend directory in
- ``sys.modules`` as the package via ``spec_from_file_location`` with
- ``submodule_search_locations`` pointing at it, so both submodule and relative
- imports inside the extension resolve. **No file copy is required.** This is
- what makes a dashed, default-installed package loadable everywhere.
-
-During the two-speed migration window the bridge also falls back to the legacy
-core location (``app.services.<module>``) so callers can be re-pointed *before*
-the physical move lands without breaking. Once the files move, the extension
-path wins and the fallback is simply never reached.
+WordPress is a standalone extension (plan 52 Phase 5 — own repo, registry
+install). Its backend loads as the *dashed* package
+``app.plugins.serverkit-wordpress``. Because the slug contains a dash it can
+never be reached with a normal ``import`` statement
+(``import app.plugins.serverkit-wordpress`` is a SyntaxError), so the handful
+of core call sites that still reach into the WordPress stack go through this
+bridge, which resolves modules with ``importlib`` on a *string* path —
+dash-safe.
+
+With the extension registry-installed, its backend copy under
+``backend/app/plugins/serverkit-wordpress/`` resolves as an ordinary
+subpackage. With it NOT installed, the bridge raises a clear
+``WordPressExtensionMissingError`` — callers either guard with try/except
+(lazy WP-context paths) or check before calling.
"""
import importlib
@@ -30,14 +21,14 @@ SLUG = 'serverkit-wordpress'
PKG = f'app.plugins.{SLUG}'
-def ensure_loadable():
- """Make ``app.plugins.serverkit-wordpress`` importable, in-place if needed.
+class WordPressExtensionMissingError(RuntimeError):
+ """The serverkit-wordpress extension is not installed/active."""
+
- Delegates to the canonical in-place loader in ``plugin_service`` (shared with
- the flagship boot path). Idempotent and cheap after the first call. Returns
- ``True`` if the package is (now) importable, ``False`` if the extension isn't
- present on disk at all (in which case callers fall back to the legacy core
- location during the migration window).
+def ensure_loadable():
+ """Make ``app.plugins.serverkit-wordpress`` importable if the extension is
+ installed. Idempotent and cheap after the first call. Returns ``True`` if
+ the package is (now) importable, ``False`` when the extension is absent.
"""
from app.services.plugin_service import _ensure_builtin_backend_importable
return _ensure_builtin_backend_importable(SLUG)
@@ -46,15 +37,15 @@ def ensure_loadable():
def load(module_name):
"""Import a module from the extension backend (e.g. ``'wordpress_service'``).
- Falls back to the legacy core location during the migration window.
+ Raises WordPressExtensionMissingError when the extension isn't installed.
+ A genuine ImportError inside the extension propagates unchanged.
"""
if ensure_loadable():
- try:
- return importlib.import_module(f'{PKG}.{module_name}')
- except ImportError:
- pass
- # Two-speed fallback: the file may still live in core (pre-move).
- return importlib.import_module(f'app.services.{module_name}')
+ return importlib.import_module(f'{PKG}.{module_name}')
+ raise WordPressExtensionMissingError(
+ f'the serverkit-wordpress extension is not installed '
+ f'(needed for app.plugins.{SLUG}.{module_name}); '
+ f'install it from the Marketplace')
def get(module_name, attr):