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

SilverStripe 4 compatibility #195

Merged
merged 7 commits into from
Jan 25, 2017

Conversation

robbieaverill
Copy link
Contributor

@robbieaverill robbieaverill commented Jan 17, 2017

Aside from the expected changes such as namespacing, there are some other changes made in this pull request to ensure the module works with the SS4 framework.

API changes

  • CommentList is removed and replaced with a polymorphic has_one relationship in the CommentsExtension
  • The default route is changed from /CommentingController/ to /comments/
  • RSS feed URLs include the class name which is not fully qualified. Until the framework has a more generic method for encoding and decoding this, CommentingController::encodeClassName and decodeClassName are added to swap \ for - to ensure they work
  • The BaseClass property of Comment is removed as it was conflicting with the concrete method DataObject::baseClass. Since SilverStripe 4.0, the faux poly-has-one CommentList is no longer required, so this property is removed and replaced with the native ParentClass that comes with the has_one: Parent
    • There is a migration task to both convert existing BaseClass values to FQ class names (since BaseClass != ClassName so not covered by DatabaseAdmin.classname_value_remapping, and move the value of the field to ParentClass (the new field). The numeric ParentID field has a different purpose semantically, but remains the same in terms of the public API.
    • The migration task can be run via sake dev/tasks/MigrateCommentParentsTask

Deprecations

  • Comment::getParent is deprecated, use Comment::Parent (has_one relationship) instead

Test/build changes

  • The CommentingControllerTest class has been updated to not automatically follow redirects unless specified to. This is to ensure that our assertions are accurate reflections of the code wherever possible
  • Removed the "FIXME" null assertions. Whatever they were (ghosts!) they're gone now.
  • Travis builds PHP 5.5 to 7.1 now

Questions

  • Is there a replacement for including i18n.js for the frontend?
  • Moderating comments (from the frontend) that are not instances of SiteTree does not with (Link() does not exist) - existing issue
  • @colymba's module still needs more work than I've done in terms of styling and admin grid functionality. Some of it is replaced with OOB functionality in SS4. I've applied a few bootstrap styles to some of it. How far do we go with it for this module, considering that it's blocking SilverStripe 4 compatibility silverstripe-blog#421? (Despite not being a literal dependency of it)

Things I didn't do


Blockers

Resolves #194

* Remove CommentList and replace with a polymorphic has_one relationship
* Tweaks for unit tests. Add tests for encode/decodeClassName.

before_install:
- pip install --user codecov

env:
global:
- DB=MYSQL CORE_RELEASE=3.1
- DB=MYSQL CORE_RELEASE=4
Copy link
Contributor

Choose a reason for hiding this comment

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

CORE_RELEASE needs to be a branch name (i.e. master) not 4.

@@ -1,6 +1,6 @@
<?php

Deprecation::notification_version('2.0', 'comments');
\SilverStripe\Dev\Deprecation::notification_version('2.0', 'comments');
Copy link
Contributor

Choose a reason for hiding this comment

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

Needs bumping to 3.0.

'CommentingController//$Action/$ID/$OtherID': 'CommentingController'
'PageComments/$Action/$ID/$OtherID': 'CommentingController'
'PageComments_Controller/$Action/$ID/$OtherID': 'CommentingController'
CommentingController//$Action/$ID/$OtherID: SilverStripe\Comments\Controllers\CommentingController
Copy link
Contributor

Choose a reason for hiding this comment

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

This is a duplicate route to the comments above. I suggest moving this to a unified route.

'PageComments_Controller/$Action/$ID/$OtherID': 'CommentingController'
CommentingController//$Action/$ID/$OtherID: SilverStripe\Comments\Controllers\CommentingController
PageComments/$Action/$ID/$OtherID: SilverStripe\Comments\Controllers\CommentingController
PageCommentsController/$Action/$ID/$OtherID: SilverStripe\Comments\Controllers\CommentingController
Copy link
Contributor

Choose a reason for hiding this comment

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

Do we need these two still?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Removed

/**
* @package comments
*/
class CommentsGridFieldBulkAction extends GridFieldBulkActionHandler
Copy link
Contributor

Choose a reason for hiding this comment

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

What's the value in this? Just use GridFieldBulkActionHandler.

{

/**
* {@inheritDoc}
Copy link
Contributor

Choose a reason for hiding this comment

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

{@inheritdoc} with nothing else is redundant; docs automatically inherit.

use SilverStripe\Forms\GridField\GridFieldDataColumns;

/**
* @package comments
Copy link
Contributor

Choose a reason for hiding this comment

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

I don't think we're doing @package anymore. Namespaces are enough.

@@ -66,7 +74,7 @@ public static function remove($class)
public static function has_commenting($class)
{
Deprecation::notice('2.0', 'Using Commenting::has_commenting is deprecated. Please use the config API instead');
Copy link
Contributor

Choose a reason for hiding this comment

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

Anything 2.0 deprecated can be removed.

@@ -414,7 +444,7 @@ public function getRssLink()
*/
public function getCommentRSSLink()
{
return Controller::join_links(Director::baseURL(), 'CommentingController/rss');
Copy link
Contributor

Choose a reason for hiding this comment

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

You can now do Director::absoluteLink('comments/rss') and it will automatically work with base url.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Updated - assumed you meant Director::absoluteURL

Copy link
Contributor

Choose a reason for hiding this comment

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

Ah yep. :)

public function run($request)
{
// Set the class names to fully qualified class names first
$remapping = Config::inst()->get('SilverStripe\\ORM\\DatabaseAdmin', 'classname_value_remapping');
Copy link
Contributor

Choose a reason for hiding this comment

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

You need a check to see if BaseClass is a field on Comment; If it's not skip the upgrade.

… tweaks to class names. Use Director::absoluteURL.
@robbieaverill
Copy link
Contributor Author

Thanks @tractorcow - I've updated with your comments and pushed

andrewandante and others added 2 commits January 19, 2017 13:23
This namespace changes once BulkManager gets updated to ss4.
FIX namespacing for BulkManager
@tractorcow
Copy link
Contributor

Tests don't pass due to issues upstream with the bulk editing tool dependency, but I think this should be merged, and we mark master as unstable for the time being.

@tractorcow tractorcow merged commit 19224d9 into silverstripe:master Jan 25, 2017
@robbieaverill robbieaverill deleted the feature/ss4-compat branch January 25, 2017 04:52
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.

3 participants