Compare commits

...

39 Commits
2 ... 3.2.0-rc1

Author SHA1 Message Date
Guy Sartorelli 49cc58109c
FIX Don't use deprecated usage of get_class() (#103) 2024-03-20 12:19:26 +13:00
github-actions bb0c48dae5 Merge branch '3.1' into 3 2024-03-03 22:44:45 +00:00
github-actions 756d493c2e Merge branch '2' into 3.1 2024-03-03 22:44:44 +00:00
github-actions 331f9692cf Merge branch '3.1' into 3 2024-02-15 11:15:35 +00:00
Guy Sartorelli 935e1dabc3
Merge pull request #96 from dnadesign/fix/type-error-when-null
Make sureHtmlDiff::compareHTML is not passed null values
2024-02-13 11:55:45 +13:00
Alexandre Saelens c10085c99e FIX: Make sureHtmlDiff::compareHTML is not passed null values 2024-02-13 11:43:41 +13:00
github-actions 7a5a91924d Merge branch '3.1' into 3 2024-02-08 11:14:53 +00:00
github-actions b9ee99d56b Merge branch '2' into 3.1 2024-02-08 11:14:52 +00:00
Guy Sartorelli ded20d177b
MNT Run module-standardiser (#98) 2024-02-02 14:09:53 +13:00
Guy Sartorelli b7b4ff8fbd
ENH Add generic types (#94) 2024-01-19 10:58:29 +13:00
Guy Sartorelli 5071f0e449
MNT Run module-standardiser (#93) 2023-12-21 16:30:58 +13:00
github-actions 7366b96e03 Merge branch '3.1' into 3 2023-10-26 11:15:00 +00:00
Guy Sartorelli c19d901123
Merge pull request #92 from creative-commoners/pulls/3.1/remove-todo
MNT Remove TODO comments
2023-10-20 10:38:38 +13:00
Sabina Talipova 58e03f8ab2 MNT Remove TODO comments 2023-10-10 14:46:19 +13:00
Guy Sartorelli 9b688adbef
Merge branch '3.0' into 3 2023-08-30 11:56:05 +12:00
Guy Sartorelli 7172dde88e
Merge pull request #89 from creative-commoners/pulls/3.0/module-standardiser-1693279131
MNT Run module-standardiser
2023-08-29 17:15:23 +12:00
Steve Boyd 814734c51a MNT Run module-standardiser 2023-08-29 15:18:51 +12:00
github-actions 3f7a840aa8 Merge branch '3.0' into 3 2023-08-24 11:15:05 +00:00
github-actions 03be22fb48 Merge branch '2' into 3.0 2023-08-24 11:15:03 +00:00
Guy Sartorelli 8efb5908b7
Merge pull request #87 from creative-commoners/pulls/3/module-standardiser-1691550505
MNT Run module-standardiser
2023-08-15 12:27:13 +12:00
Steve Boyd 7c637cc7dc MNT Run module-standardiser 2023-08-14 15:50:25 +12:00
Steve Boyd 0748333f00 Merge branch '3.0' into 3 2023-06-16 12:18:36 +12:00
Steve Boyd c0b557f282 Merge branch '2' into 3.0 2023-06-16 12:18:25 +12:00
Guy Sartorelli 8190fe8579
Merge pull request #85 from creative-commoners/pulls/3/tx-1686703654
ENH Update translations
2023-06-14 15:17:59 +12:00
Steve Boyd 2450e85c87 ENH Update translations 2023-06-14 12:47:34 +12:00
Steve Boyd 492de75e60 Merge branch '3.0' into 3 2023-05-04 13:29:07 +12:00
Guy Sartorelli d24f2fa031
Merge branch '2' into 3.0 2023-04-27 14:19:02 +12:00
Sabina Talipova dd625a8683
Merge pull request #84 from creative-commoners/pulls/3.0/cms5-readme
DOC Update README.md for CMS 5
2023-04-24 14:58:37 +12:00
Guy Sartorelli a51c30fb0f
DOC Update README.md for CMS 5 2023-04-19 17:01:17 +12:00
Steve Boyd 27a64657e0 Merge branch '3.0' into 3 2023-03-30 12:47:31 +13:00
Steve Boyd f00a204f6d Merge branch '2' into 3.0 2023-03-30 12:47:22 +13:00
Steve Boyd 89f030cfad Merge branch '3.0' into 3 2023-03-08 11:54:55 +13:00
Steve Boyd eb3283662c Merge branch '2' into 3.0 2023-03-08 11:54:42 +13:00
Steve Boyd 4f773a79d1 Merge branch '3.0' into 3 2023-03-02 16:45:47 +13:00
Sabina Talipova 002fbf766c
FIX Replace Diff class to HtmlDiff (#80) 2023-02-13 15:51:20 +13:00
Sabina Talipova a753712806
API Remove deprecated code (#78) 2023-01-25 13:51:11 +13:00
Maxime Rainville a1eac8de23
Merge pull request #79 from creative-commoners/pulls/3/remove-legacy-upgrader
MNT Remove legacy upgrader config
2023-01-23 10:05:55 +13:00
Steve Boyd 4e0d5ec409 MNT Remove legacy upgrader config 2023-01-20 16:05:31 +13:00
Sabina Talipova 9b92ba8d6c
DEP PHP Support in CMS5 (#77) 2023-01-10 13:24:13 +13:00
17 changed files with 225 additions and 78 deletions

1
.github/ISSUE_TEMPLATE.md vendored Normal file
View File

@ -0,0 +1 @@
<!-- Blank templates are for use by maintainers only! If you aren't a maintainer, please go back and pick one of the issue templates. -->

72
.github/ISSUE_TEMPLATE/1_bug_report.yml vendored Normal file
View File

@ -0,0 +1,72 @@
name: 🪳 Bug Report
description: Tell us if something isn't working the way it's supposed to
body:
- type: markdown
attributes:
value: |
We strongly encourage you to [submit a pull request](https://docs.silverstripe.org/en/contributing/code/) which fixes the issue.
Bug reports which are accompanied with a pull request are a lot more likely to be resolved quickly.
- type: input
id: affected-versions
attributes:
label: Module version(s) affected
description: |
What version of _this module_ have you reproduced this bug on?
Run `composer info` to see the specific version of each module installed in your project.
If you don't have access to that, check inside the help menu in the bottom left of the CMS.
placeholder: x.y.z
validations:
required: true
- type: textarea
id: description
attributes:
label: Description
description: A clear and concise description of the problem
validations:
required: true
- type: textarea
id: how-to-reproduce
attributes:
label: How to reproduce
description: |
⚠️ This is the most important part of the report ⚠️
Without a way to easily reproduce your issue, there is little chance we will be able to help you and work on a fix.
- Please, take the time to show us some code and/or configuration that is needed for others to reproduce the problem easily.
- If the bug is too complex to reproduce with some short code samples, please reproduce it in a public repository and provide a link to the repository along with steps for setting up and reproducing the bug using that repository.
- If part of the bug includes an error or exception, please provide a full stack trace.
- If any user interaction is required to reproduce the bug, please add an ordered list of steps that are required to reproduce it.
- Be as clear as you can, but don't miss any steps out. Simply saying "create a page" is less useful than guiding us through the steps you're taking to create a page, for example.
placeholder: |
#### Code sample
```php
```
#### Reproduction steps
1.
validations:
required: true
- type: textarea
id: possible-solution
attributes:
label: Possible Solution
description: |
*Optional: only if you have suggestions on a fix/reason for the bug*
Please consider [submitting a pull request](https://docs.silverstripe.org/en/contributing/code/) with your solution! It helps get faster feedback and greatly increases the chance of the bug being fixed.
- type: textarea
id: additional-context
attributes:
label: Additional Context
description: "*Optional: any other context about the problem: log messages, screenshots, etc.*"
- type: checkboxes
id: validations
attributes:
label: Validations
description: "Before submitting the issue, please make sure you do the following:"
options:
- label: Check that there isn't already an issue that reports the same bug
required: true
- label: Double check that your reproduction steps work in a fresh installation of [`silverstripe/installer`](https://github.com/silverstripe/silverstripe-installer) (with any code examples you've provided)
required: true

View File

@ -0,0 +1,35 @@
name: 🚀 Feature Request
description: Submit a feature request (but only if you're planning on implementing it)
body:
- type: markdown
attributes:
value: |
Please only submit feature requests if you plan on implementing the feature yourself.
See the [contributing code documentation](https://docs.silverstripe.org/en/contributing/code/#make-or-find-a-github-issue) for more guidelines about submitting feature requests.
- type: textarea
id: description
attributes:
label: Description
description: A clear and concise description of the new feature, and why it belongs in core
validations:
required: true
- type: textarea
id: more-info
attributes:
label: Additional context or points of discussion
description: |
*Optional: Any additional context, points of discussion, etc that might help validate and refine your idea*
- type: checkboxes
id: validations
attributes:
label: Validations
description: "Before submitting the issue, please confirm the following:"
options:
- label: You intend to implement the feature yourself
required: true
- label: You have read the [contributing guide](https://docs.silverstripe.org/en/contributing/code/)
required: true
- label: You strongly believe this feature should be in core, rather than being its own community module
required: true
- label: You have checked for existing issues or pull requests related to this feature (and didn't find any)
required: true

8
.github/ISSUE_TEMPLATE/config.yml vendored Normal file
View File

@ -0,0 +1,8 @@
blank_issues_enabled: true
contact_links:
- name: Security Vulnerability
url: https://docs.silverstripe.org/en/contributing/issues_and_bugs/#reporting-security-issues
about: ⚠️ We do not use GitHub issues to track security vulnerability reports. Click "open" on the right to see how to report security vulnerabilities.
- name: Support Question
url: https://www.silverstripe.org/community/
about: We use GitHub issues only to discuss bugs and new features. For support questions, please use one of the support options available in our community channels.

39
.github/PULL_REQUEST_TEMPLATE.md vendored Normal file
View File

@ -0,0 +1,39 @@
<!--
Thanks for contributing, you're awesome! ⭐
Please read https://docs.silverstripe.org/en/contributing/code/ if you haven't contributed to this project recently.
-->
## Description
<!--
Please describe expected and observed behaviour, and what you're fixing.
For visual fixes, please include tested browsers and screenshots.
-->
## Manual testing steps
<!--
Include any manual testing steps here which a reviewer can perform to validate your pull request works correctly.
Note that this DOES NOT replace unit or end-to-end tests.
-->
## Issues
<!--
List all issues here that this pull request fixes/resolves.
If there is no issue already, create a new one! You must link your pull request to at least one issue.
-->
- #
## Pull request checklist
<!--
PLEASE check each of these to ensure you have done everything you need to do!
If there's something in this list you need help with, please ask so that we can assist you.
-->
- [ ] The target branch is correct
- See [picking the right version](https://docs.silverstripe.org/en/contributing/code/#picking-the-right-version)
- [ ] 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](https://docs.silverstripe.org/en/contributing/code/#commit-messages)
- [ ] The PR follows our [contribution guidelines](https://docs.silverstripe.org/en/contributing/code/)
- [ ] Code changes follow our [coding conventions](https://docs.silverstripe.org/en/contributing/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

View File

@ -1,10 +1,10 @@
name: Keepalive
on:
workflow_dispatch:
# The 8th of every month at 11:50am UTC
# At 9:45 PM UTC, on day 18 of the month
schedule:
- cron: '50 11 8 * *'
- cron: '45 21 18 * *'
workflow_dispatch:
jobs:
keepalive:

17
.github/workflows/merge-up.yml vendored Normal file
View File

@ -0,0 +1,17 @@
name: Merge-up
on:
# At 11:10 AM UTC, only on Thursday
schedule:
- cron: '10 11 * * 4'
workflow_dispatch:
jobs:
merge-up:
name: Merge-up
# Only run cron on the silverstripe account
if: (github.event_name == 'schedule' && github.repository_owner == 'silverstripe') || (github.event_name != 'schedule')
runs-on: ubuntu-latest
steps:
- name: Merge-up
uses: silverstripe/gha-merge-up@v1

View File

@ -1,12 +0,0 @@
mappings:
VersionFeed: SilverStripe\VersionFeed\VersionFeed
VersionFeed_Controller: SilverStripe\VersionFeed\VersionFeedController
VersionFeedSiteConfig: SilverStripe\VersionFeed\VersionFeedSiteConfig
CachedContentFilter: SilverStripe\VersionFeed\Filters\CachedContentFilter
ContentFilter: SilverStripe\VersionFeed\Filters\ContentFilter
RateLimitFilter: SilverStripe\VersionFeed\Filters\RateLimitFilter
\VersionFeed\Filters\CachedContentFilter: SilverStripe\VersionFeed\Filters\CachedContentFilter
\VersionFeed\Filters\ContentFilter: SilverStripe\VersionFeed\Filters\ContentFilter
\VersionFeed\Filters\RateLimitFilter: SilverStripe\VersionFeed\Filters\RateLimitFilter
VersionFeedFunctionalTest: SilverStripe\VersionFeed\Tests\VersionFeedFunctionalTest
VersionFeedTest: SilverStripe\VersionFeed\Tests\VersionFeedTest

View File

@ -1,4 +1,4 @@
Copyright (c) 2017, SilverStripe Limited
Copyright (c) 2017, Silverstripe Limited
All rights reserved.
Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met:

View File

@ -7,15 +7,11 @@
The module creates an RSS feed on each page with their change history, as well as one for the entire site.
## Requirements
* Silverstripe ^4
**Note:** For a Silverstripe 3.x compatible version, please use [the 1.x release line](https://github.com/silverstripe/silverstripe-versionfeed/tree/1.2).
## Installation
Install with composer by running `composer require silverstripe/versionfeed` in the root of your Silverstripe project.
```sh
composer require silverstripe/versionfeed
```
## Usage

View File

@ -16,14 +16,16 @@
}
],
"require": {
"php": "^7.4 || ^8.0",
"silverstripe/cms": "^4",
"silverstripe/versioned": "^1",
"silverstripe/siteconfig": "^4"
"php": "^8.1",
"silverstripe/cms": "^5",
"silverstripe/versioned": "^2",
"silverstripe/siteconfig": "^5"
},
"require-dev": {
"phpunit/phpunit": "^9.5",
"squizlabs/php_codesniffer": "^3.0"
"phpunit/phpunit": "^9.6",
"squizlabs/php_codesniffer": "^3",
"silverstripe/standards": "^1",
"phpstan/extension-installer": "^1.3"
},
"autoload": {
"psr-4": {
@ -33,4 +35,4 @@
},
"minimum-stability": "dev",
"prefer-stable": true
}
}

3
phpstan.neon.dist Normal file
View File

@ -0,0 +1,3 @@
parameters:
paths:
- src

View File

@ -9,7 +9,7 @@ use SilverStripe\Core\Config\Config;
*/
class CachedContentFilter extends ContentFilter
{
/**
* Enable caching
*
@ -17,20 +17,20 @@ class CachedContentFilter extends ContentFilter
* @var boolean
*/
private static $cache_enabled = true;
public function getContent($key, $callback)
{
$cache = $this->getCache();
// Return cached value if available
$cacheEnabled = Config::inst()->get(get_class(), 'cache_enabled');
$cacheEnabled = Config::inst()->get(self::class, 'cache_enabled');
$result = (isset($_GET['flush']) || !$cacheEnabled)
? null
: $cache->get($key);
if ($result) {
return $result;
}
// Fallback to generate result
$result = parent::getContent($key, $callback);
$lifetime = Config::inst()->get(ContentFilter::class, 'cache_lifetime') ?: null;

View File

@ -2,7 +2,6 @@
namespace SilverStripe\VersionFeed;
use SilverStripe\Dev\Deprecation;
use SilverStripe\CMS\Model\SiteTreeExtension;
use SilverStripe\Core\Config\Config;
use SilverStripe\Forms\CheckboxField;
@ -12,12 +11,15 @@ use SilverStripe\ORM\ArrayList;
use SilverStripe\ORM\DataObject;
use SilverStripe\ORM\FieldType\DBField;
use SilverStripe\SiteConfig\SiteConfig;
use SilverStripe\View\Parsers\Diff;
use SilverStripe\View\Parsers\HtmlDiff;
use SilverStripe\CMS\Model\SiteTree;
use SilverStripe\Versioned\Versioned_Version;
/**
* @extends Extension<SiteTree&static>
*/
class VersionFeed extends SiteTreeExtension
{
private static $db = array(
'PublicHistory' => 'Boolean(true)'
);
@ -69,7 +71,7 @@ class VersionFeed extends SiteTreeExtension
* @param int $highestVersion Top version number to consider.
* @param int $limit Limit to the amount of items returned.
*
* @returns ArrayList List of cleaned records.
* @return ArrayList<Versioned_Version> List of cleaned records.
*/
public function getDiffList($highestVersion = null, $limit = 100)
{
@ -80,7 +82,7 @@ class VersionFeed extends SiteTreeExtension
$qLimit = (int)$limit + 1;
$versions = $this->owner->Versions(
"\"WasPublished\"='1' AND \"CanViewType\" IN ('Anyone', 'Inherit') $offset",
"\"SiteTree\".\"LastEdited\" DESC, \"SiteTree\".\"ID\" DESC",
"\"LastEdited\" DESC, \"ID\" DESC",
$qLimit
);
@ -95,7 +97,7 @@ class VersionFeed extends SiteTreeExtension
if (isset($previous)) {
// Produce the diff fields for use in the template.
if ($version->Title != $previous->Title) {
$diffTitle = Diff::compareHTML($version->Title, $previous->Title);
$diffTitle = HtmlDiff::compareHTML($version->Title ?? '', $previous->Title ?? '');
$version->DiffTitle = DBField::create_field('HTMLText', null);
$version->DiffTitle->setValue(
@ -108,7 +110,7 @@ class VersionFeed extends SiteTreeExtension
}
if ($version->Content != $previous->Content) {
$diffContent = Diff::compareHTML($version->Content, $previous->Content);
$diffContent = HtmlDiff::compareHTML($version->Content ?? '', $previous->Content ?? '');
$version->DiffContent = DBField::create_field('HTMLText', null);
$version->DiffContent->setValue('<div>'.$diffContent.'</div>');
@ -157,7 +159,7 @@ class VersionFeed extends SiteTreeExtension
* Return a single diff representing this version.
* Returns the initial version if there is nothing to compare to.
*
* @return DataObject|null Object with relevant fields diffed.
* @return Versioned_Version|null Object with relevant fields diffed.
*/
public function getDiff()
{
@ -169,32 +171,12 @@ class VersionFeed extends SiteTreeExtension
return null;
}
/**
* Compile a list of changes to the current page, excluding non-published and explicitly secured versions.
*
* @deprecated 2.0.0 Use VersionFeed::getDiffList() instead
*
* @param int $highestVersion Top version number to consider.
* @param boolean $fullHistory Set to true to get the full change history, set to false for a single diff.
* @param int $limit Limit to the amount of items returned.
*
* @returns ArrayList List of cleaned records.
*/
public function getDiffedChanges($highestVersion = null, $fullHistory = true, $limit = 100)
{
Deprecation::notice('2.0.0', 'Use VersionFeed::getDiffList() instead');
return $this->getDiffList(
$highestVersion,
$fullHistory ? $limit : 1
);
}
public function updateSettingsFields(FieldList $fields)
{
if (!$this->owner->config()->get('changes_enabled')) {
return;
}
// Add public history field.
$fields->addFieldToTab(
'Root.Settings',
@ -224,8 +206,7 @@ class VersionFeed extends SiteTreeExtension
public function getSiteRSSLink()
{
// TODO: This link should be from the homepage, not this page.
if (Config::inst()->get(get_class(), 'allchanges_enabled')
if (Config::inst()->get(self::class, 'allchanges_enabled')
&& SiteConfig::current_site_config()->AllChangesEnabled
) {
return $this->owner->Link('allchanges');
@ -234,7 +215,7 @@ class VersionFeed extends SiteTreeExtension
public function getDefaultRSSLink()
{
if (Config::inst()->get(get_class(), 'changes_enabled') && $this->owner->PublicHistory) {
if (Config::inst()->get(self::class, 'changes_enabled') && $this->owner->PublicHistory) {
return $this->owner->Link('changes');
}
}

View File

@ -11,25 +11,29 @@ use SilverStripe\ORM\DB;
use SilverStripe\Security\Member;
use SilverStripe\ORM\ArrayList;
use SilverStripe\CMS\Model\SiteTree;
use SilverStripe\Control\Controller;
use SilverStripe\Core\Convert;
use SilverStripe\View\Requirements;
use SilverStripe\Core\Extension;
use SilverStripe\VersionFeed\Filters\ContentFilter;
/**
* @extends Extension<Controller&static>
*/
class VersionFeedController extends Extension
{
private static $allowed_actions = array(
'changes',
'allchanges'
);
/**
* Content handler
*
* @var ContentFilter
*/
protected $contentFilter;
/**
* Sets the content filter
*
@ -39,7 +43,7 @@ class VersionFeedController extends Extension
{
$this->contentFilter = $contentFilter;
}
/**
* Evaluates the result of the given callback
*
@ -114,7 +118,6 @@ class VersionFeedController extends Extension
AND ("PublicHistory" IS NULL OR "PublicHistory" = \'1\')
ORDER BY "LastEdited" DESC LIMIT ' . $limit);
$lastChange = $latestChanges->record();
$latestChanges->rewind();
if ($lastChange) {
// Cache the diffs to remove DOS possibility.
@ -164,7 +167,7 @@ class VersionFeedController extends Extension
$rss->setTemplate('Page_allchanges_rss');
return $rss->outputToBrowser();
}
/**
* Generates and embeds the RSS header link for the page-specific version rss feed
*/
@ -173,7 +176,7 @@ class VersionFeedController extends Extension
if (!Config::inst()->get(VersionFeed::class, 'changes_enabled') || !$this->owner->PublicHistory) {
return;
}
RSSFeed::linkToFeed(
$this->owner->Link('changes'),
_t(
@ -195,7 +198,7 @@ class VersionFeedController extends Extension
) {
return;
}
// RSS feed to all-site changes.
$title = Convert::raw2xml($this->linkToAllSitesRSSFeedTitle());
$url = $this->owner->getSiteRSSLink();

View File

@ -7,13 +7,15 @@ use SilverStripe\Forms\CheckboxField;
use SilverStripe\Forms\FieldGroup;
use SilverStripe\Forms\FieldList;
use SilverStripe\ORM\DataExtension;
use SilverStripe\SiteConfig\SiteConfig;
/**
* Allows global configuration of all changes
*
* @extends DataExtension<SiteConfig>
*/
class VersionFeedSiteConfig extends DataExtension
{
private static $db = array(
'AllChangesEnabled' => 'Boolean(true)'
);
@ -26,7 +28,7 @@ class VersionFeedSiteConfig extends DataExtension
{
$labels['AllChangesEnabled'] = _t(__CLASS__ . '.ALLCHANGESLABEL', 'Make global changes feed public');
}
public function updateCMSFields(FieldList $fields)
{
if (!Config::inst()->get(VersionFeed::class, 'allchanges_enabled')) {

View File

@ -175,7 +175,7 @@ class VersionFeedFunctionalTest extends FunctionalTest
$titles = array_map(function ($item) {
return (string)$item->title;
}, $xml->xpath('//item') ?? []);
// TODO Unclear if this should contain the original version
$this->assertContains('Changed: Page1', $titles);
$this->assertNotContains('Changed: Page2', $titles);
@ -184,7 +184,7 @@ class VersionFeedFunctionalTest extends FunctionalTest
$titles = array_map(function ($item) {
return (string)$item->title;
}, $xml->xpath('//item') ?? []);
// TODO Unclear if this should contain the original version
$this->assertNotContains('Changed: Page1', $titles);
$this->assertContains('Changed: Page2', $titles);
}