-
Notifications
You must be signed in to change notification settings - Fork 105
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
SilverStripe 4 Compatibility #289
SilverStripe 4 Compatibility #289
Conversation
(cherry picked from commit 2f99e51)
(cherry picked from commit e201462)
- moving all phpunit tests into tests/php - moving all extensions from _config.php into config.yml and removing obsolete _config.php - moving GridFieldSubsiteDetailForm_ItemRequest into own file (cherry picked from commit ee02828)
call extension directly in test, as Versioned now is also applied to File and has this method
Updating config and i18n calls
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Epic work @Cheddam @wernerkrauss and everyone else involved! I've left a few comments, most are things that occur a lot throughout this pull request, so should be updated in bulk. If we can get this pull request to a point where the tests are at least running on Travis (not necessarily passing) then we can look at merging this as a basis then work incrementally in smaller, more manageable pull requests from then on.
@@ -4,6 +4,8 @@ language: php | |||
|
|||
sudo: false | |||
|
|||
sudo: false | |||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We should create a new Travis config to replace this, see silverstripe/silverstripe-taxonomy#36 for an example
@@ -0,0 +1,42 @@ | |||
<?php | |||
|
|||
namespace SilverStripe\Subsites\Admin; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ideally the file path would match the namespace for PSR-4, e.g. Admin
rather than admin
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
👍 for this, you can address this using git mv
to ensure the case sensitivity is emitted to the log.
I'd not even mind if you renamed 'code' to 'src' (new standard) as a means of addressing this, but the important thing is that it's PSR-4. :)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yeah, if you move code to src then you can also capitalise the subfolders at the same time. Otherwise you'll need to do something like git mv admin blah && git mv blah Admin
since it won't pick up the case change otherwise (at least on macOS anyway)
{ | ||
$form = parent::getEditForm($id, $fields); | ||
|
||
$grid = $form->Fields()->dataFieldByName(Subsite::class); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think this is likely a mistake - dataFieldByName expects a field name string which wouldn't be a FQCN. This could have been an upgrader tool error, but should be replaced with 'Subsite'
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is the fault of the upgrader;
You can put /** @skipUpgrade */
on either the line before this statement, or in the getEditForm PHPDoc to suppress the upgrader making this subsitution.
* Relax the access permissions, so anyone who has access to any CMS subsite can access this controller. | ||
* @param null $member |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It's better to type hint the expected type as well as, rather than the optional fallback e.g. @param Member|null $member
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
👍 to this.
@@ -8,11 +14,11 @@ public function controllerAugmentInit() | |||
{ | |||
if ($subsite = Subsite::currentSubsite()) { | |||
if ($theme = $subsite->Theme) { | |||
SSViewer::set_theme($theme); | |||
SSViewer::set_themes([$theme, SSViewer::DEFAULT_THEME]); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is an interesting situation, where in SS3 we would explicitly set the theme to a subsite's theme, but in SS4 we can use cascading/partial themes, so maybe we should just add_themes
instead of setting it to subsite theme + default. What do you think @Cheddam?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
How about moving this into getThemes() in the Subsite class, and user code can customise / modify this with an extension.
E.g.
public function getThemes()
{
$themes = [
$this->Theme,
SSViewer::DEFAULT_THEME,
];
// Allow usercode to customise themes for this subsite
$this->extend('updateThemes', $themes);
return $themes;
}
// ...
SSViewer::set_themes($subsite->getThemes());
@@ -136,24 +157,26 @@ public function testSubsiteVirtualPagesArentInappropriatelyPublished() | |||
$this->assertFalse($vp->IsModifiedOnStage); | |||
} | |||
|
|||
/** | |||
/** |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Above, switch doPublish for publishRecursive or publishSingle
{ | ||
Config::inst()->update('StaticPublisher', 'disable_realtime', true); | ||
Config::modify()->set('StaticPublisher', 'disable_realtime', true); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
probably needs a todo for static publisher namespacing
@@ -0,0 +1,87 @@ | |||
<?php |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
tests/php/SubsitesVirtualPageTest.yml
will need to have namespacing added to it
* Check that valid domains are accepted | ||
* | ||
* @dataProvider validDomains | ||
* @param $domain |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
missing type
{ | ||
$field = new WildcardDomainField('DomainField'); | ||
$this->assertTrue($field->checkHostname($domain), "Validate that {$domain} is a valid domain wildcard"); | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We should just combine these three tests into one - testDomains
with a dataprovider that also provides the expectation and message
@@ -0,0 +1,42 @@ | |||
<?php | |||
|
|||
namespace SilverStripe\Subsites\Admin; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
👍 for this, you can address this using git mv
to ensure the case sensitivity is emitted to the log.
I'd not even mind if you renamed 'code' to 'src' (new standard) as a means of addressing this, but the important thing is that it's PSR-4. :)
/** | ||
* Admin interface to manage and create {@link Subsite} instances. | ||
* | ||
* @package subsites |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
With namespaces, we prefer to dump all @package
and @subpackage
tags.
{ | ||
$form = parent::getEditForm($id, $fields); | ||
|
||
$grid = $form->Fields()->dataFieldByName(Subsite::class); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is the fault of the upgrader;
You can put /** @skipUpgrade */
on either the line before this statement, or in the getEditForm PHPDoc to suppress the upgrader making this subsitution.
* Relax the access permissions, so anyone who has access to any CMS subsite can access this controller. | ||
* @param null $member |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
👍 to this.
@@ -51,6 +67,7 @@ public function getResponseNegotiator() | |||
*/ | |||
public function SubsiteList() | |||
{ | |||
return $this->renderWith('SubsiteList'); | |||
return $this->renderWith('Includes/SubsiteList'); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please use [ 'type' => 'Includes', 'SubsiteList']
instead of baking the variant into the path.
I would also suggest you consider namespacing templates. E.g. templates\SilverStripe\Subsites\Controller\Includes\SubsiteXHRController_subsitelist.ss
. Then you could refer to the template using the below:
return $this->renderWith(['type' => 'Includes', self::class . '_subsitelist']);
/////////////////////////////////////////////////////////////////////////////////////////// | ||
// Querying | ||
|
||
/** | ||
* @param arary $params | ||
* @return void |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We don't need to explicitly declare voids.
"silverstripe/cms": "^4.0@dev" | ||
"silverstripe/framework": "~4.0", | ||
"silverstripe/cms": "~4.0", | ||
"silverstripe/asset-admin": "~1.0.0" | ||
}, | ||
"require-dev": { | ||
"phpunit/PHPUnit": "~4.8@stable" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Core phpunit has been upgraded to ^5.7
please. :)
"silverstripe/cms": "^4.0@dev" | ||
"silverstripe/framework": "~4.0", | ||
"silverstripe/cms": "~4.0", | ||
"silverstripe/asset-admin": "~1.0.0" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We prefer semver ^1.0
vs ~1.0.0
. Note that ^1.0
and ~1.0
are equivalent, but the former is preferred.
"silverstripe/cms": "^4.0@dev" | ||
"silverstripe/framework": "~4.0", | ||
"silverstripe/cms": "~4.0", | ||
"silverstripe/asset-admin": "~1.0.0" | ||
}, | ||
"require-dev": { | ||
"phpunit/PHPUnit": "~4.8@stable" | ||
}, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It turns out ^4@dev
doesn't actually have any effect; ^4
is fine.
"extra": { | ||
"branch-alias": { | ||
"dev-master": "2.0.x-dev" | ||
} | ||
}, | ||
"license": "BSD-3-Clause" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why was license removed?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It's duplicated, towards the top of the file
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ah true.
@Cheddam I can merge, but before then, could you please get a PHP needs to be changed from 5.5 to 5.6 and/or 7.x, and don't use travis support module anymore. |
I'll just merge this so we can start PRing to get this faster. |
This giant PR, in short, makes Subsites function on SilverStripe 4 Beta 2.
It does not include:
Shout out to @wernerkrauss for completing a significant portion of the work!