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

I can't get this module to work #36

Open
sunnysideup opened this issue Oct 18, 2019 · 3 comments
Open

I can't get this module to work #36

sunnysideup opened this issue Oct 18, 2019 · 3 comments

Comments

@sunnysideup
Copy link
Contributor

sunnysideup commented Oct 18, 2019

This module seems to be fundamentally broken.

You can replicate it like this:

  1. go to https://demo.silverstripe.org/admin/pages/

  2. add the following to the about page HTMLField using the source code editor:

<div class="leftAlone ss-htmleditorfield-file embed" data-url="https://vimeo.com/event/15595" data-shortcode="embed">
    <img class="placeholder" src="pic.ng" width="1280" height="720" />
</div>
  1. the page now throws a 500 error:
    https://user-images.githubusercontent.com/167154/67129986-93143980-f25c-11e9-8240-ec5bba6e7411.png

https://user-images.githubusercontent.com/167154/67130278-49781e80-f25d-11e9-9a85-bce96d0b72d4.png

As you can see the Error does not look anything like it is supposed to.

I have found the same issue on my own sites. When I save the Error Page, it does not write to the assets folder.

@tractorcow
Copy link
Contributor

tractorcow commented Oct 21, 2019

I've noticed the error page static file issue; The reason is that it only writes to the static file on publish, and only if it doesn't exist yet (i.e. it won't overwrite an outdated static file).

In a ChangeSet, if a page has no changes, ErrorPage::publishSingle() is never called, and no static page is written. This means saving an unchanged page in the CMS doesn't publish this file.

    /**
     * When an error page is published, create a static HTML page with its
     * content, so the page can be shown even when SilverStripe is not
     * functioning correctly before publishing this page normally.
     *
     * @return bool True if published
     */
    public function publishSingle()
    {
        if (!parent::publishSingle()) {
            return false;
        }
        return $this->writeStaticPage();
    }

A second issue is during dev/build, the static page is only written if missing (never updated).

// Ensure this page has cached error content
        $success = true;
        if (!$page->hasStaticPage()) {
            // Update static content
            $success = $page->writeStaticPage();
        } elseif ($pageExists) {
            // If page exists and already has content, no alteration_message is displayed
            return;
        }

My fix is to override requireDefaultRecords() and implement a custom static builder.

/**
     * @throws ValidationException
     */
    public function requireDefaultRecords()
    {
        parent::requireDefaultRecords();
        $this->buildErrorPage();
    }

full gist https://gist.github.com/tractorcow/2145af6cdedd6f8d3c9a8f5f46e2bf7d

@sunnysideup
Copy link
Contributor Author

Thank you.

Can we fix this properly in the module? I am happy to make a pull request.

@michalkleiner
Copy link
Contributor

@sunnysideup still keen to provide a PR?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

5 participants