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

Cannot use with populate #10

Open
wernerkrauss opened this issue Jan 22, 2016 · 1 comment
Open

Cannot use with populate #10

wernerkrauss opened this issue Jan 22, 2016 · 1 comment

Comments

@wernerkrauss
Copy link

Hi, when trying to add Blocks using populate (https://github.com/dnadesign/silverstripe-populate) it crashes:

  • Creating faq (ContentSectionBlock)
    ERROR [User Error]: Uncaught SS_DatabaseException: Couldn't run query:

SELECT MAX("SortOrder")
FROM "Block"
WHERE "ParentID" =

Somehow the Parent relation is added after creating it first?

Changing Block::onBeforeWrite to

if (!$this->exists() && !$this->SortOrder && $this->ParentID) {

fixes this problem locally.

@bummzack
Copy link
Owner

Interesting. So when you populate the blocks, you don't set their parent-id? How do you establish the relation to the pages?

The problem with your fix is, that it will probably never write the sortorder, since once the Block is written the $this->exists() check will return true.

I guess it makes more sense to reduce the check to SortOrder and ParentID then…

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

2 participants