silverstripe-shortcodable icon indicating copy to clipboard operation
silverstripe-shortcodable copied to clipboard

Does not save to DB when template is empty

Open faloude opened this issue 7 years ago • 2 comments

Found out a strange reproducable error.

When the template which is used to render the shortcodable dataobject is empty, the shortcode will not be saved to the DB. When I type a simple 'Foo' in the template file, the bug vanishes.

public static function parse_shortcode($attributes, $content, $parser, $shortcode) {

    if (isset($attributes['id']) && $map = self::get()->byID($attributes['id'])) {
        return $map->customise($data)->renderWith('Map'); // Map.ss cannot be empty
    }
}

faloude avatar Nov 11 '17 18:11 faloude

Isn't that a good start to write a unit test that prooves this wrong behaviour?

wernerkrauss avatar Nov 12 '17 15:11 wernerkrauss

I've never written one before.

faloude avatar Nov 12 '17 18:11 faloude