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

SiteTree won't write new versions if only a field named 'Status' is changed #2455

Closed
kinglozzer opened this issue Jul 10, 2019 · 5 comments
Closed

Comments

@kinglozzer
Copy link
Member

kinglozzer commented Jul 10, 2019

Please don’t ask how much time I wasted because of this bug 😭😂

<?php

class MyPage extends Page
{
    private static $db = [
        'Status' => 'Varchar(255)'
    ];

    public function getCMSFields()
    {
        $this->beforeUpdateCMSFields(function (FieldList $fields) {
            $fields->addFieldToTab('Root.Main', TextField::create('Status'));
        });

        return parent::getCMSFields();
    }

    public function onAfterPublish()
    {
        die('you will never get this, a-la-la-la-la');
    }
}

Make changes to the value of status, onAfterPublish() won’t be called. The only time it’ll be called is if you also make a change to another field’s value as well. There are other issues this bug causes, but this is the easiest to reproduce.

The cause is this line:

$fieldsIgnoredByVersioning = array('HasBrokenLink', 'Status', 'HasBrokenFile', 'ToDo', 'VersionID', 'SaveCount');
.

I’m not sure if we should just remove that whole code block, but at the very least we should remove Status from the array as it’s no longer a field on SiteTree (it hasn’t been since 2.4). We should also remove ToDo, VersionID and SaveCount.

PRs

@michalkleiner
Copy link
Contributor

How much time did you waste?

@kinglozzer
Copy link
Member Author

$hoursWasted += 1;

PR: #3002

@GuySartorelli GuySartorelli self-assigned this Sep 11, 2024
kinglozzer added a commit to kinglozzer/silverstripe-cms that referenced this issue Sep 12, 2024
kinglozzer added a commit to kinglozzer/silverstripe-cms that referenced this issue Sep 12, 2024
GuySartorelli added a commit that referenced this issue Sep 12, 2024
FIX: Remove legacy fields which prevent page publish (fixes #2455)
@GuySartorelli
Copy link
Member

PR merged. This will be automatically tagged by GitHub Actions.

@madmatt
Copy link
Member

madmatt commented Sep 12, 2024

var_dump($hoursWasted);

@kinglozzer
Copy link
Member Author

int(probably 1 hour for each year since i opened this 🤦‍♂️)

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