Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 16 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
6 changes: 5 additions & 1 deletion src/Controllers/ShortcodableAdminController.php
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}

Expand Down
6 changes: 5 additions & 1 deletion src/Shortcodable.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

namespace Shortcodable;

use LogicException;
use SilverStripe\Core\ClassInfo;
use SilverStripe\Core\Config\Config;
use SilverStripe\Core\Config\Configurable;
Expand Down Expand Up @@ -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);
Expand Down