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

Bugfix: Updating BlogPostFilter::augmentSQL to make use of modern Versioned methods. #727

Conversation

nathanbrauer
Copy link
Contributor

@nathanbrauer nathanbrauer commented Sep 9, 2023

This resolves a nuanced issue with some modules that rely upon get_draft_site_secured for draft previewing.

For example, without this fix, on an app with dnadesign/silverstripe-elemental and silverstripe/silverstripe-sharedraftcontent, a preview of a draft blog whose PublishDate is null or in the past works as expected, but if the PublishDate is in the future, none of the elemental elements will be visible in the preview. An update to BlogPostFilter is the only way to resolve the issue, and this fix serves to do just that.

This can be accepted into the 3.* base as a bugfix then safely merged into 4.* as well.

Editing my source branch is enabled for maintainers.

Fixes:

  1. Share link not working for new, unpublished BlogPost silverstripe-sharedraftcontent#112
  2. BUG version returned is representative of SiteTree or Page vs the actual class of the page silverstripe-sharedraftcontent#155

Attn: @muskie9

@nathanbrauer
Copy link
Contributor Author

Good morning! May I please get a status check on this pull request?

cc: @GuySartorelli

@GuySartorelli
Copy link
Member

Thank you for contributing! This PR is in our backlog to review when someone has some time to look at it.

Copy link
Contributor

@michalkleiner michalkleiner left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I've just looked at the code change, haven't done any testing.

The tests are passing and adding the extra condition seems to make the logic stronger, so I'd say it's ok from my perspective.

…sioned methods.

This resolves an issue with some modules that rely upon get_draft_site_secured, like Elemental and sharedraftcontent
@nathanbrauer nathanbrauer force-pushed the feature/update-for-versioned-1.12 branch from 7065eb2 to 7128123 Compare September 20, 2023 04:18
@nathanbrauer
Copy link
Contributor Author

Thank you, @michalkleiner. I just pushed up an update with your suggested alteration.

@sabina-talipova
Copy link
Contributor

sabina-talipova commented Sep 21, 2023

Hi @nathanbrauer,
Unfortunately, I could not reproduce initial issue in my local environment with the following steps:

  1. I create New Blog Post page.
  2. I add "Some content" into Content field
  3. I click "Save" button
  4. I click "Share" button
  5. I copied link from "Share draft content"
  6. I open incognito window and past copied link into address field
  7. I see "New Blog Post" and "Some content".

Probably, I need to do additional steps. Could you, please, provide steps that helps me to see problem.

Tested in CMS 4.13

Thank you in advance.

@GuySartorelli
Copy link
Member

@sabina-talipova This seems to specifically be a problem with relations - the example in both the PR description and the original issue mention using elemental blocks. Please try adding some elemental blocks to the blog page and see if that helps you reproduce the issue.

@sabina-talipova
Copy link
Contributor

  • I have the following Blog Post page:
<?php

namespace {

    use DNADesign\Elemental\Extensions\ElementalPageExtension;
    use DNADesign\Elemental\Models\ElementalArea;
    use SilverStripe\Blog\Model\BlogPost;

    class MyBlogPage extends BlogPost
    {
        private static $extensions = [
          ElementalPageExtension::class,
      ];
    }
}
  • I add Content Block
  • I add "Some content" in Content Field in Content Block
  • I click "Save"
  • I copy Share link
  • I open link in new Browser window
  • I see "Some content"
  • I open link in incognito window
  • I see error Uncaught Error: Call to a member function generateKey() on null
  • I apply PR
  • I run dev/build?flush
  • I repeat all steps and create new link
  • I see the same result as before
Screen.Recording.2023-09-21.at.2.03.36.PM.mov

@nathanbrauer
Copy link
Contributor Author

I'm a bit confused as to exactly how you have your environment set up. I'm unable to reproduce your results.

I stripped down one of our repositories to demonstrate/reproduce the problem and solution here:

Kazam_screencast_00000_150_compressed_mid.webm

I've applied this pull request's patch to two entirely different projects already successfully (different SS and PHP versions for each).

@sabina-talipova
Copy link
Contributor

@nathanbrauer, thank you for your help and patience. I had to delete and restart the container with the database. I see the problem. The solution works great.

@sabina-talipova sabina-talipova merged commit 4ca99d0 into silverstripe:3.12 Sep 25, 2023
12 checks passed
@sabina-talipova
Copy link
Contributor

sabina-talipova commented Sep 25, 2023

@nathanbrauer, thank you for your contribution. Nice solution!
PR merged. It will be automatically tagged.

@nathanbrauer nathanbrauer deleted the feature/update-for-versioned-1.12 branch September 25, 2023 23:22
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

Successfully merging this pull request may close these issues.

4 participants