-
Notifications
You must be signed in to change notification settings - Fork 6
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
Check and update for SS4 compatability #23
Check and update for SS4 compatability #23
Conversation
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.
Just a few small things :)
src/AkismetField.php
Outdated
* In this case, 'mollom_captcha_requested' session is set to true | ||
* so that Field() knows it's time to display captcha | ||
* @return boolean - true when Mollom confirms that the submission is ham (not spam) | ||
* - false when Mollom confirms that the submission is spam |
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.
But... but this is Akismet, not Mollom!
@tractorcow must have based it on the mollom module - which is now correctly archived, since:
End-of-Life Announcement: As of 2 April 2018, Acquia will no longer support or maintain the Mollom product. Learn More
license.md
Outdated
@@ -1,3 +1,5 @@ | |||
Revised BSD License | |||
|
|||
Copyright (c) 2016, Damian Mooyman |
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.
Not important, but could be 2017 ;)
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'd avoided doing this recently because it'll have to be updated again in a couple of weeks anyway =D
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, super unimportant :P
@@ -66,7 +74,7 @@ class AkismetSpamProtector implements SpamProtector | |||
|
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.
The code sniffer is complaining about the preceeding line (73) in that it begins with an underscore. Which is good, because otherwise I probably wouldn't have noticed that the Readme.md
notes that the configuration value is api_key
, not _api_key
. This will need altering too.
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.
That is to say, please remove the underscore ;)
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.
as above this comment is closed by the newer changes, effectively retaining the functionality on an instance basis rather than a static one, which is nicer.
tests/AkismetTest.php
Outdated
@@ -133,80 +144,3 @@ public function testProcessor() | |||
} | |||
} | |||
|
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.
Linter complains about 2 empty lines here, remove one :)
.travis.yml
Outdated
|
||
# Install composer dependencies | ||
- composer validate | ||
- composer require --no-update silverstripe/recipe-core:1.0.x-dev |
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.
You'll need this to be recipe-cms
in order to get tests to pass :)
a86d034
to
f9cf29b
Compare
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.
You sat here and watched me do this.
You know what to do ;)
.gitattributes
Outdated
@@ -4,3 +4,4 @@ | |||
/.gitignore export-ignore | |||
/.travis.yml export-ignore | |||
/.scrutinizer.yml export-ignore | |||
/codecov.yml |
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.
export-ignore
src/AkismetSpamProtector.php
Outdated
if (self::$_api_key) { | ||
return self::$_api_key; | ||
if (self::$api_key) { | ||
return self::$api_key; |
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 now that we've had a look at what the protected static $_api_key
was for, that we can just get rid of it entirely.
This simplifies the code in places like this, where this if
statement is now entirely unneeded.
@@ -126,7 +135,9 @@ public function validate($validator) | |||
'messageType' => 'error', | |||
)); | |||
$formName = $this->getForm()->FormName(); | |||
Session::set("FormInfo.{$formName}.errors", $errors); | |||
|
|||
$this->getForm()->sessionMessage($errorMessage, ValidationResult::TYPE_GOOD); |
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.
Noting here, this wasn't working so we marked the test as incomplete so we could fix it on its own after merge
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.
One minor comment :)
* | ||
* @var string | ||
*/ | ||
protected static $_api_key = null; |
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.
Can you add this back, just without the leading underscore?
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 defined as a private at the beginning of the class: https://github.com/creative-commoners/silverstripe-akismet/blob/ec0c41d598817e216a7a7c0467c7b3dbce5a0578/src/AkismetSpamProtector.php#L19-L25
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 :)
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.
Ok, this property has a different purpose by the looks of it, so we'll need to retain it.
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.
Following up, I see this is done on a different line as protected $apiKey = '';
, which is cool :)
ec0c41d
to
eea8364
Compare
eea8364
to
2c9e9f2
Compare
Ok so we've replaced the public static methods with an injectable service for AkismetSpamProtector, and defined the order of priority for API key definition as:
There's still the issue of the form validation message not showing up during the functional test, which we've marked as incomplete for now. The intention is to test this module when we check the spam protector module shortly (silverstripe/silverstripe-spamprotection#62). @tractorcow would you mind having a review of this pull request and see what you think? |
* | ||
* @var string | ||
*/ | ||
protected static $_api_key = null; |
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.
Following up, I see this is done on a different line as protected $apiKey = '';
, which is cool :)
@@ -66,7 +74,7 @@ class AkismetSpamProtector implements SpamProtector | |||
|
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.
as above this comment is closed by the newer changes, effectively retaining the functionality on an instance basis rather than a static one, which is nicer.
In progress.