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

Make sureHtmlDiff::compareHTML is not passed null values #96

Merged
merged 1 commit into from
Feb 12, 2024

Conversation

alex-dna
Copy link
Contributor

@alex-dna alex-dna commented Jan 23, 2024

Description

When a record is saved without a title or content, when viewing the RSS changes feed, a type error occurs.

Uncaught TypeError: SilverStripe\View\Parsers\HtmlDiff::compareHtml(): Argument #1 ($from) must be of type array|string, null given, called in /var/www/html/vendor/silverstripe/versionfeed/src/VersionFeed.php on line 110

Manual testing steps

I first encountered the issue with Elemental, after saving an element without a title.
But it should be the case for any page too (although it is less likely to save a page without title through the CMS).
Easiest way to reproduce is to temper with database if possible, set a page record version title or content to NULL, then visit the page URL/changes.

Issues

Pull request checklist

  • The target branch is correct
  • All commits are relevant to the purpose of the PR (e.g. no debug statements, unrelated refactoring, or arbitrary linting)
    • Small amounts of additional linting are usually okay, but if it makes it hard to concentrate on the relevant changes, ask for the unrelated changes to be reverted, and submitted as a separate PR.
  • The commit messages follow our commit message guidelines
  • The PR follows our contribution guidelines
  • Code changes follow our coding conventions
  • This change is covered with tests (or tests aren't necessary for this change)
  • Any relevant User Help/Developer documentation is updated; for impactful changes, information is added to the changelog for the intended release
  • CI is green

Copy link
Member

@GuySartorelli GuySartorelli left a comment

Choose a reason for hiding this comment

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

Hi,

Thank you for your contribution.
I notice you removed the template from the PR description - I've added it back. Please fill this in, as it makes it easier for us to review your PR.

src/VersionFeed.php Outdated Show resolved Hide resolved
@GuySartorelli
Copy link
Member

Can you please fill in the full PR template? #96 (review)

@GuySartorelli
Copy link
Member

There are a couple of things to change which are pointed out in the checklist - in the interest of getting things moving along I'll point them out instead of asking you to go through the checklist again :p

Please make changes accordingly:

  1. Please target the 3.1 branch so that this can be released as a patch (otherwise it'll need to wait until April)
    You may need to reset your commits afterward
  2. I won't block merging for this, but if you could squash your commits and use the FIX prefix in the commit message, that would be great.

@alex-dna alex-dna force-pushed the fix/type-error-when-null branch from 89cbe69 to 22e3181 Compare January 30, 2024 23:52
@alex-dna alex-dna changed the base branch from 3 to 3.1 January 30, 2024 23:52
@GuySartorelli
Copy link
Member

@alex-dna You've pulled through some commits from the 3 branch that still need to be reset. Can you please reset your commits? I'd do it for you, but when you created the PR it seems you must have unticked the box that lets me update this PR.

@alex-dna alex-dna force-pushed the fix/type-error-when-null branch from 22e3181 to c10085c Compare February 12, 2024 22:44
@alex-dna
Copy link
Contributor Author

@GuySartorelli Sorry about that, I've reset the commits. I'm not sure where the box to let you update the PR is, when I'll make sure I don't untick it inadvertently next time.

Copy link
Member

@GuySartorelli GuySartorelli left a comment

Choose a reason for hiding this comment

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

Looks good to me. Thanks for your patience!

@GuySartorelli GuySartorelli merged commit 935e1da into silverstripe:3.1 Feb 12, 2024
9 checks passed
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.

2 participants