Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Need to manually publish individual elements before saving the page #1278

Open
2 tasks done
nlighteneddesign opened this issue Nov 20, 2024 · 7 comments
Open
2 tasks done

Comments

@nlighteneddesign
Copy link

nlighteneddesign commented Nov 20, 2024

Module version(s) affected

5.3.1

Description

We recently updated to silverstripe 5.

After that we need to click the three dots and click publish on an element before saving the page or the content will not publish to the page.

Previously if we added a new block (or several) we could just add the content and hit save or publish.

Additionally the save button does not detect changes in elements.
Previously it would turn green when you changed an element.

How to reproduce

I do not know the relevant piece of code for reproduction, but here is one of our elements.

<?php

use DNADesign\Elemental\Models\BaseElement;
use SilverStripe\Forms\TextField;
use SilverStripe\Forms\CheckboxField;
use SilverStripe\Forms\HTMLEditor\HTMLEditorField;

class ContentBlock extends BaseElement {
    private static $searchable_fields = [
        'Content' => [
            'field' => HTMLEditorField::class,
            'filter' => 'PartialMatchFilter',
        ],
    ];

    private static $db = [
        'Content' => 'HTMLText',
        'AnchorID' => 'Text',
        'Unpublish' => 'Text',
    ];

    private static $singular_name = 'Content';
    private static $plural_name = 'Content';

    private static $description = 'Creates a general content block.';

    public function getCMSFields() {
        $fields = parent::getCMSFields();

        $content = HTMLEditorField::create('Content', 'Content');
        $content->setRows(6);
        $content->setDescription(implode('', [
            '<strong>Shortcodes for use in the rich text editor:</strong><br />',
            '<strong>CTA shortcode format:</strong> <code>[cta text="<em>link text</em>" ',
            'size="<em>small|large</em>" color="<em>blue|red</em>" ',
            'url="<em>url</em>" /]</code><br />',
            '<strong>CTA shortcode example:</strong> <code>[cta text="Learn about" size="large" ',
            'color="blue" url="https://sample.org/about/" /]</code>'
        ]));

        $anchor = TextField::create('AnchorID', 'Anchor Link Slug', '');
        $anchor->setDescription(implode('', [
            '<strong>This must be a HTML-friendly name that is unique to this page.</strong> ',
            'Do not include spaces or special characters.'
        ]));

        $unpublish = CheckboxField::create('Unpublish', 'Unpublish Block', '');
	    $unpublish->setDescription('Check this box to hide this block from the published page.');
 
        $fields->addFieldsToTab(
            'Root.Main',
            [
                $content,
                $anchor,
            ]
        );

        // Modify the Title field label to indicate it will not render on the website
        // It is joined with another checkbox field in the BaseElement class, so removing and re-adding here
        $fields->removeByName('Title');
        $title = TextField::create('Title', 'Title – for CMS use only (does not render on website)');
        $fields->addFieldToTab('Root.Main', $title, 'Content');

        $fields->addFieldToTab('Root.Main', $unpublish, 'Content');

        return $fields;
    }

    public function getType() {
        return 'Content';
    }

    public function forTemplate($holder = true) {
        return $this->renderWith('Blocks/ContentBlock');
    }
}

Possible Solution

No response

Additional Context

We also have elemental search enabled.

Validations

  • Check that there isn't already an issue that reports the same bug
  • Double check that your reproduction steps work in a fresh installation of silverstripe/installer (with any code examples you've provided)
@nlighteneddesign
Copy link
Author

It works in 5.2

composer/ca-bundle                        1.5.3              Lets you find a path to th...
composer/installers                       2.3.0              A multi-framework Composer...
cweagans/composer-patches                 1.7.3              Provides a way to patch Co...
defuse/php-encryption                     2.4.0              Secure PHP Encryption Library
dnadesign/silverstripe-elemental          5.2.0              Elemental pagetype and col...
doctrine/lexer                            3.0.1              PHP Doctrine Lexer parser ...
dorsetdigital/silverstripe-canonical      2.0.0              Adds a simple canonical ta...
egulias/email-validator                   4.0.2              A library for validating e...
embed/embed                               4.4.13             PHP library to retrieve pa...
guzzlehttp/guzzle                         7.9.2              Guzzle is a PHP HTTP clien...
guzzlehttp/promises                       2.0.4              Guzzle promises library
guzzlehttp/psr7                           2.7.0              PSR-7 message implementati...
heyday/silverstripe-menumanager           4.3.0              Allows complex menu manage...
intervention/image                        2.7.2              Image handling and manipul...
jonom/focuspoint                          5.0.0              Smarter automatic image cr...
jonom/silverstripe-betternavigator        6.1.0              Front-end utility menu for...
league/csv                                9.18.0             CSV data manipulation made...
league/flysystem                          3.29.1             File storage abstraction f...
league/flysystem-local                    3.29.0             Local filesystem adapter f...
league/mime-type-detection                1.16.0             Mime-type detection for Fl...
m1/env                                    2.2.0              Env is a lightweight libra...
marcj/topsort                             2.0.0              High-Performance TopSort/D...
masterminds/html5                         2.9.0              An HTML5 parser and serial...
ml/iri                                    1.1.4              IRI handling for PHP
ml/json-ld                                1.2.1              JSON-LD Processor for PHP
monolog/monolog                           3.8.0              Sends your logs to files, ...
nikic/php-parser                          4.19.4             A PHP parser written in PHP
oscarotero/html-parser                    0.1.8              Parse html strings to DOMD...
paragonie/constant_time_encoding          2.7.0              Constant-time Implementati...
paragonie/random_compat                   9.99.100           PHP 5.x polyfill for rando...
platformsh/config-reader                  2.4.1              Small helper to access Pla...
psr/cache                                 3.0.0              Common interface for cachi...
psr/clock                                 1.0.0              Common interface for readi...
psr/container                             2.0.2              Common Container Interface...
psr/event-dispatcher                      1.0.0              Standard interfaces for ev...
psr/http-client                           1.0.3              Common interface for HTTP ...
psr/http-factory                          1.1.0              PSR-17: Common interfaces ...
psr/http-message                          1.1                Common interface for HTTP ...
psr/log                                   3.0.2              Common interface for loggi...
psr/simple-cache                          3.0.0              Common interfaces for simp...
ralouphie/getallheaders                   3.0.3              A polyfill for getallheaders.
sebastian/diff                            4.0.6              Diff implementation
silverstripe/admin                        2.2.14             SilverStripe admin interface
silverstripe/asset-admin                  2.2.4              Asset management for the S...
silverstripe/assets                       2.2.5              SilverStripe Assets component
silverstripe/campaign-admin               2.2.1              SilverStripe campaign admi...
silverstripe/cms                          5.2.5              The SilverStripe Content M...
silverstripe/config                       2.1.1              SilverStripe configuration...
silverstripe/errorpage                    2.2.2              ErrorPage component for Si...
silverstripe/event-dispatcher             1.0.1              Publish and subscribe to e...
silverstripe/framework                    5.2.22             The SilverStripe framework
silverstripe/graphql                      5.2.3              GraphQL server for SilverS...
silverstripe/login-forms                  5.2.0              A collection of templates ...
silverstripe/mfa                          5.3.0              Enable multi-factor authen...
silverstripe/mimevalidator                3.1.0              Checks uploaded file conte...
silverstripe/recipe-cms                   5.2.0              SilverStripe recipe for fu...
silverstripe/recipe-core                  5.2.0              SilverStripe framework-onl...
silverstripe/recipe-plugin                2.0.1              Helper plugin to install S...
silverstripe/redirectedurls               3.0.0              Provides a system for user...
silverstripe/reports                      5.2.3              Reports module for SilverS...
silverstripe/session-manager              2.2.2              Allow users to manage and ...
silverstripe/siteconfig                   5.2.2              Site wide settings adminis...
silverstripe/totp-authenticator           5.2.0              A TOTP authenticator for u...
silverstripe/vendor-plugin                2.0.3              Allows vendor modules to e...
silverstripe/versioned                    2.2.2              SilverStripe Versioned com...
silverstripe/versioned-admin              2.2.3              SilverStripe versioned adm...
silverstripers/elemental-search           dev-master 8e77a6e Full text search for eleme...
sminnee/callbacklist                      0.1.1              PHP class that manages a l...
spomky-labs/otphp                         11.3.0             A PHP library for generati...
symbiote/silverstripe-gridfieldextensions 4.1.0              A collection of useful gri...
symfony/cache                             6.4.14             Provides extended PSR-6, P...
symfony/cache-contracts                   3.5.0              Generic abstractions relat...
symfony/config                            6.4.14             Helps you find, load, comb...
symfony/console                           6.4.15             Eases the creation of beau...
symfony/deprecation-contracts             3.5.0              A generic function and con...
symfony/dom-crawler                       6.4.13             Eases DOM navigation for H...
symfony/event-dispatcher                  6.4.13             Provides tools that allow ...
symfony/event-dispatcher-contracts        3.5.0              Generic abstractions relat...
symfony/filesystem                        6.4.13             Provides basic utilities f...
symfony/finder                            6.4.13             Finds files and directorie...
symfony/mailer                            6.4.13             Helps sending emails
symfony/mime                              6.4.13             Allows manipulating MIME m...
symfony/polyfill-ctype                    1.31.0             Symfony polyfill for ctype...
symfony/polyfill-intl-grapheme            1.31.0             Symfony polyfill for intl'...
symfony/polyfill-intl-idn                 1.31.0             Symfony polyfill for intl'...
symfony/polyfill-intl-normalizer          1.31.0             Symfony polyfill for intl'...
symfony/polyfill-mbstring                 1.31.0             Symfony polyfill for the M...
symfony/polyfill-php83                    1.31.0             Symfony polyfill backporti...
symfony/service-contracts                 3.5.0              Generic abstractions relat...
symfony/string                            7.1.8              Provides an object-oriente...
symfony/translation                       6.4.13             Provides tools to internat...
symfony/translation-contracts             3.5.0              Generic abstractions relat...
symfony/validator                         6.4.15             Provides tools to validate...
symfony/var-exporter                      7.1.6              Allows exporting any seria...
symfony/yaml                              6.4.13             Loads and dumps YAML files
ua-parser/uap-php                         3.9.14             A multi-language port of B...
unclecheese/display-logic                 3.0.0              Allows assignment of condi...
undefinedoffset/sortablegridfield         2.2.0              Adds drag and drop functio...
webonyx/graphql-php                       15.18.1            A PHP port of GraphQL refe...
wilr/silverstripe-googlesitemaps          3.1.0              SilverStripe support for t...

@nlighteneddesign
Copy link
Author

5.3 show

composer/ca-bundle                        1.5.3              Lets you find a path to th...
composer/installers                       2.3.0              A multi-framework Composer...
cweagans/composer-patches                 1.7.3              Provides a way to patch Co...
defuse/php-encryption                     2.4.0              Secure PHP Encryption Library
dnadesign/silverstripe-elemental          5.3.1              Elemental pagetype and col...
doctrine/lexer                            3.0.1              PHP Doctrine Lexer parser ...
dorsetdigital/silverstripe-canonical      2.0.0              Adds a simple canonical ta...
egulias/email-validator                   4.0.2              A library for validating e...
embed/embed                               4.4.12             PHP library to retrieve pa...
guzzlehttp/guzzle                         7.9.2              Guzzle is a PHP HTTP clien...
guzzlehttp/promises                       2.0.4              Guzzle promises library
guzzlehttp/psr7                           2.7.0              PSR-7 message implementati...
heyday/silverstripe-menumanager           4.3.0              Allows complex menu manage...
intervention/image                        2.7.2              Image handling and manipul...
jonom/focuspoint                          5.0.0              Smarter automatic image cr...
jonom/silverstripe-betternavigator        6.1.0              Front-end utility menu for...
league/csv                                9.18.0             CSV data manipulation made...
league/flysystem                          3.29.1             File storage abstraction f...
league/flysystem-local                    3.29.0             Local filesystem adapter f...
league/mime-type-detection                1.16.0             Mime-type detection for Fl...
m1/env                                    2.2.0              Env is a lightweight libra...
marcj/topsort                             2.0.0              High-Performance TopSort/D...
masterminds/html5                         2.9.0              An HTML5 parser and serial...
ml/iri                                    1.1.4              IRI handling for PHP
ml/json-ld                                1.2.1              JSON-LD Processor for PHP
monolog/monolog                           3.8.0              Sends your logs to files, ...
nikic/php-parser                          4.19.4             A PHP parser written in PHP
oscarotero/html-parser                    0.1.8              Parse html strings to DOMD...
paragonie/constant_time_encoding          2.7.0              Constant-time Implementati...
paragonie/random_compat                   9.99.100           PHP 5.x polyfill for rando...
platformsh/config-reader                  2.4.1              Small helper to access Pla...
psr/cache                                 3.0.0              Common interface for cachi...
psr/clock                                 1.0.0              Common interface for readi...
psr/container                             2.0.2              Common Container Interface...
psr/event-dispatcher                      1.0.0              Standard interfaces for ev...
psr/http-client                           1.0.3              Common interface for HTTP ...
psr/http-factory                          1.1.0              PSR-17: Common interfaces ...
psr/http-message                          1.1                Common interface for HTTP ...
psr/log                                   3.0.2              Common interface for loggi...
psr/simple-cache                          3.0.0              Common interfaces for simp...
ralouphie/getallheaders                   3.0.3              A polyfill for getallheaders.
sebastian/diff                            4.0.6              Diff implementation
silverstripe/admin                        2.2.14             SilverStripe admin interface
silverstripe/asset-admin                  2.2.4              Asset management for the S...
silverstripe/assets                       2.2.5              SilverStripe Assets component
silverstripe/campaign-admin               2.2.1              SilverStripe campaign admi...
silverstripe/cms                          5.2.5              The SilverStripe Content M...
silverstripe/config                       2.1.1              SilverStripe configuration...
silverstripe/errorpage                    2.2.2              ErrorPage component for Si...
silverstripe/event-dispatcher             1.0.1              Publish and subscribe to e...
silverstripe/framework                    5.2.22             The SilverStripe framework
silverstripe/graphql                      5.2.3              GraphQL server for SilverS...
silverstripe/login-forms                  5.2.2              A collection of templates ...
silverstripe/mfa                          5.3.0              Enable multi-factor authen...
silverstripe/mimevalidator                3.1.0              Checks uploaded file conte...
silverstripe/recipe-cms                   5.2.0              SilverStripe recipe for fu...
silverstripe/recipe-core                  5.2.0              SilverStripe framework-onl...
silverstripe/recipe-plugin                2.0.1              Helper plugin to install S...
silverstripe/redirectedurls               3.0.0              Provides a system for user...
silverstripe/reports                      5.2.3              Reports module for SilverS...
silverstripe/session-manager              2.2.2              Allow users to manage and ...
silverstripe/siteconfig                   5.2.2              Site wide settings adminis...
silverstripe/totp-authenticator           5.3.0              A TOTP authenticator for u...
silverstripe/vendor-plugin                2.0.3              Allows vendor modules to e...
silverstripe/versioned                    2.2.2              SilverStripe Versioned com...
silverstripe/versioned-admin              2.2.3              SilverStripe versioned adm...
silverstripers/elemental-search           dev-master 8e77a6e Full text search for eleme...
sminnee/callbacklist                      0.1.1              PHP class that manages a l...
spomky-labs/otphp                         11.3.0             A PHP library for generati...
symbiote/silverstripe-gridfieldextensions 4.1.0              A collection of useful gri...
symfony/cache                             6.4.14             Provides extended PSR-6, P...
symfony/cache-contracts                   3.5.0              Generic abstractions relat...
symfony/config                            6.4.14             Helps you find, load, comb...
symfony/console                           6.4.14             Eases the creation of beau...
symfony/deprecation-contracts             3.5.0              A generic function and con...
symfony/dom-crawler                       6.4.13             Eases DOM navigation for H...
symfony/event-dispatcher                  6.4.13             Provides tools that allow ...
symfony/event-dispatcher-contracts        3.5.0              Generic abstractions relat...
symfony/filesystem                        6.4.13             Provides basic utilities f...
symfony/finder                            6.4.13             Finds files and directorie...
symfony/mailer                            6.4.13             Helps sending emails
symfony/mime                              6.4.13             Allows manipulating MIME m...
symfony/polyfill-ctype                    1.31.0             Symfony polyfill for ctype...
symfony/polyfill-intl-grapheme            1.31.0             Symfony polyfill for intl'...
symfony/polyfill-intl-idn                 1.31.0             Symfony polyfill for intl'...
symfony/polyfill-intl-normalizer          1.31.0             Symfony polyfill for intl'...
symfony/polyfill-mbstring                 1.31.0             Symfony polyfill for the M...
symfony/polyfill-php83                    1.31.0             Symfony polyfill backporti...
symfony/service-contracts                 3.5.0              Generic abstractions relat...
symfony/string                            7.1.6              Provides an object-oriente...
symfony/translation                       6.4.13             Provides tools to internat...
symfony/translation-contracts             3.5.0              Generic abstractions relat...
symfony/validator                         6.4.14             Provides tools to validate...
symfony/var-exporter                      7.1.6              Allows exporting any seria...
symfony/yaml                              6.4.13             Loads and dumps YAML files
ua-parser/uap-php                         3.9.14             A multi-language port of B...
unclecheese/display-logic                 3.0.0              Allows assignment of condi...
undefinedoffset/sortablegridfield         2.2.0              Adds drag and drop functio...
webonyx/graphql-php                       15.18.0            A PHP port of GraphQL refe...
wilr/silverstripe-googlesitemaps          3.1.0              SilverStripe support for t...

@kinglozzer
Copy link
Member

kinglozzer commented Nov 22, 2024

I just quickly tested with your example block in a project running 5.3, and it works as expected. I would note that I haven’t installed the same packages (e.g. elemental-search) but at a glance I don’t think any of the packages listed would affect this behaviour.

Does your example block exhibit the buggy behaviour if it’s the only block on the page?

@kinglozzer
Copy link
Member

For reference, the 5.3+ behaviour seems to be that upon clicking save on the page, each individual block is saved first and then the page save is submitted after that. It might be worth opening web inspector to see if the saves for the individual blocks are being triggered correctly, it should look something like this (e.g. editing one block):

Screenshot 2024-11-22 at 16 32 13

266 is the block ID which is saved first, then 189 is the page ID which is saved after the response is received from the block save.

@nlighteneddesign
Copy link
Author

It is buggy even with just one block on the page.

@k-coidan
Copy link

k-coidan commented Nov 29, 2024

Can confirm this is happening on new SS 5.3.* projects as well SS5 projects upgraded to 5.3.*

@kinglozzer
Copy link
Member

One case where this happens is when changetracking doesn’t fire properly. For example, one site we upgraded uses adrhumphreys/silverstripe-textdropdownfield in-place of the default elemental title field:

  • 5.2 behaviour - when editing the text or changing the dropdown, the changetracking fires and makes the page save/publish buttons green. Then when saving/publishing, the element data is POST-ed with the page content
  • 5.3 behaviour - no changetracking fires, so the updated content isn't POST-ed. I’d note that changetracking doesn’t visibly fire in 5.3 at all, but I’ll open a separate issue for that

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

No branches or pull requests

3 participants