silverstripe / silverstripe-framework

Silverstripe Framework, the MVC framework that powers Silverstripe CMS
https://www.silverstripe.org
BSD 3-Clause "New" or "Revised" License
721 stars 821 forks source link

Compare two page versions in history broken (with manymany relationship) #9839

Closed torleif closed 3 years ago

torleif commented 3 years ago

Affected Version

silverstripe/recipe-cms      4.7.0
cwp/cwp                      2.7.0 

The CMS/ framework is on 4.7. Note the CWP dependency is NOT required to reproduce the issue (explanation below)

Description

When comparing two versions of a page, you get a stuck SilverStripe spinner, this is because the AJAX request has returned a 500 error and no valid data is returned.

Expected behaviour: the difference between two pages in history will display a diff version.

image

I installed a fresh version of SilverStripe to confirm. I could reproduce the issue.

The following error is returned:

ERROR [Emergency]: Uncaught InvalidArgumentException: $content parameter needs to be a string or array IN GET /admin/historyviewer/schema/compareForm/1?RecordVersionFrom=2&RecordVersionTo=4&RecordClass=Page&RecordID=1 Line 170 in C:\Wnmp\sites\playground\vendor\silverstripe\framework\src\View\Parsers\Diff.php Source ====== 161: } 

The error is caused by a ManytoMany relationship being sent to the diff engine. We managed to "fix" it by returning an empty array instead of the exception inside the Diff.php file, but this is likely not an appropriate solution.

Steps to Reproduce

  1. install fresh SilverStripe instance
  2. install CWP (this is not requried - any manymany or manyone relationship is needed to break it. This is a module that adds Taxonomy to all page types which will break the diff view)
  3. navigate to CMS, save a page so you have a version to compare
  4. compare the page versions in the history tab. it will break.

This issue appeared in 4.7.

Cheddam commented 3 years ago

Thanks for the report, @torleif! This issue has been fixed in silverstripe/silverstripe-versioned-admin#197, and will be included in the next patch release of Silverstripe CMS.