From a227ddf036f90bdd79db2a1f644dd88d72d44ffc Mon Sep 17 00:00:00 2001 From: micschk Date: Tue, 3 Nov 2026 16:56:57 +0100 Subject: [PATCH 1/3] FIX placeholder for a deleted record falls back to the class singleton (#6) shortcodePlaceHolder() took the byID() result as is, so an ObjectID whose record no longer exists ended in a 500 (hasMethod() on null). The class singleton now answers, as it already did for a request without an ObjectID. Pair-programmed with my buddy Claude --- src/Controllers/ShortcodableAdminController.php | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/src/Controllers/ShortcodableAdminController.php b/src/Controllers/ShortcodableAdminController.php index bff4088..ab2000a 100644 --- a/src/Controllers/ShortcodableAdminController.php +++ b/src/Controllers/ShortcodableAdminController.php @@ -153,9 +153,13 @@ public function shortcodePlaceHolder($request) return; } + $object = null; if ($object_id && is_subclass_of($sc_class, DataObject::class)) { $object = $sc_class::get()->byID($object_id); - } else { + } + # No ObjectID, not a DataObject, or a record that no longer exists (deleted after the shortcode was + # inserted): the class singleton answers, so the editor gets a placeholder instead of a 500 (#6) + if (!$object) { $object = singleton($sc_class); } From bef3ca88b5e6e2819294989492c42326dc2062d7 Mon Sep 17 00:00:00 2001 From: micschk Date: Tue, 3 Nov 2026 16:57:18 +0100 Subject: [PATCH 2/3] FIX register_class() throws a LogicException instead of E_USER_ERROR (#5) PHP 8.4 deprecates passing E_USER_ERROR to trigger_error(). The message is unchanged. Behaviour change for a misconfigured site: a catchable LogicException instead of a fatal error. Pair-programmed with my buddy Claude --- src/Shortcodable.php | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/src/Shortcodable.php b/src/Shortcodable.php index b3e1369..2e32a32 100644 --- a/src/Shortcodable.php +++ b/src/Shortcodable.php @@ -2,6 +2,7 @@ namespace Shortcodable; +use LogicException; use SilverStripe\Core\ClassInfo; use SilverStripe\Core\Config\Config; use SilverStripe\Core\Config\Configurable; @@ -39,7 +40,10 @@ public static function register_class($class) $parseMethodName = Config::inst()->get($class, 'shortcode_callback') ?: 'parse_shortcode'; if (!singleton($class)->hasMethod($parseMethodName)) { - user_error("Failed to register \"$class\" with Shortcodable: missing/unconfigured shortcode parser method (looked for: $parseMethodName)", E_USER_ERROR); + # An exception rather than user_error(..., E_USER_ERROR): PHP 8.4 deprecates passing E_USER_ERROR to + # trigger_error() (#5). Same message; it still stops the request, on every request, until fixed. +// user_error("Failed to register \"$class\" with Shortcodable: missing/unconfigured shortcode parser method (looked for: $parseMethodName)", E_USER_ERROR); + throw new LogicException("Failed to register \"$class\" with Shortcodable: missing/unconfigured shortcode parser method (looked for: $parseMethodName)"); } // if (!$shortcode = Config::inst()->get($class, 'shortcode')) { // user_error("Registering \"$class\" with short classname as shortcode: missing \$shortcode config value", E_USER_NOTICE); From c835d2b4b3e28ea830d600675aab05b9ac3a2706 Mon Sep 17 00:00:00 2001 From: micschk Date: Tue, 3 Nov 2026 16:59:18 +0100 Subject: [PATCH 3/3] CHANGELOG 4.0.19 Pair-programmed with my buddy Claude --- CHANGELOG.md | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index f12c719..596e277 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -2,6 +2,22 @@ This file covers the 4.x line (Silverstripe 4 and 5). Later releases are documented on `main`. +## 4.0.19 (2026-11-03) + +### Fixed + +- **The placeholder of a shortcode whose record was deleted no longer ends in a 500** (#6). The + placeholder endpoint looked the `ObjectID` up with `byID()` and called a method on the result, which + is `null` once the record is gone. The class singleton now answers instead, as it already did for a + shortcode without an ID, so the editor shows a placeholder. + +### Changed + +- **A shortcodable class without its parser method throws a `LogicException`** (#5), with the same + message, instead of `user_error(..., E_USER_ERROR)`, which PHP 8.4 deprecates. + **Behaviour change:** on a misconfigured site this is now an uncaught (but catchable) exception + instead of a fatal error; every request still fails until the class is fixed. + ## 4.0.18 (2026-11-02) ### Security