-
Notifications
You must be signed in to change notification settings - Fork 74
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.0 Compatability #125
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.
One small question - appears to be a functional change rather than upgrade and looks like it would gobble some errors.
src/Services/QueuedJobService.php
Outdated
@@ -680,7 +681,7 @@ public function runJob($jobId) | |||
} | |||
} catch (Exception $e) { | |||
// okay, we'll just catch this exception for now | |||
$this->getLogger()->error($e->getMessage()); | |||
$this->getLogger()->debug($e->getMessage()); |
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 have you changed the level of these messages?
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 had done so after reading https://docs.silverstripe.org/en/4/developer_guides/debugging/error_handling/
However I misread it as "debug and warn" should be through logger and "user_error" for errors.
Have been running through some tests manually and have found a couple of bugs that don't look to be covered by tests. Working through those now. |
Date fields weren't updated. Updating these and adding tests for checking correct dates. |
…orm date/time submission
Fixes #126 |
Fixes #122 |
use SilverStripe\QueuedJobs\Services\QueuedJobService; | ||
|
||
// stub class to be able to call init from an external context | ||
class TestQJService extends QueuedJobService |
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.
These stubs should probably implement SilverStripe\Dev\TestOnly
(I know they didn't before)
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.
If I add "TestOnly" to these objects, the tests fail as SapphireTest ignores buildings the database for these objects.
https://github.com/silverstripe/silverstripe-framework/blob/master/src/Dev/SapphireTest.php#L1173
tests/ScheduledExecutionTest.php
Outdated
@@ -118,9 +125,10 @@ public function testScheduledExecutionInterval() | |||
} | |||
} | |||
|
|||
|
|||
class TestScheduledDataObject extends DataObject implements TestOnly | |||
class TestScheduledDataObject extends DataObject |
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.
Add test only back
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.
If I add "TestOnly" to these objects, the tests fail as SapphireTest ignores buildings the database for these objects.
https://github.com/silverstripe/silverstripe-framework/blob/master/src/Dev/SapphireTest.php#L1173
And the DB table is required due to the write occuring in the test
https://github.com/brettt89/silverstripe-queuedjobs/blob/compat-4.0/tests/ScheduledExecutionTest.php#L33
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.
Sounds like a bug to me!
tests/ScheduledExecutionTest.php
Outdated
*/ | ||
protected $usesDatabase = true; | ||
|
||
/** | ||
* {@inheritDoc} | ||
* @var array | ||
*/ | ||
protected $extraDataObjects = array( |
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 should be protected static $extra_dataobjects
…ataObjects to extra_dataobjects static variable
@sminnee @robbieaverill Have updated tests to correctly implement TestOnly. Warnings in tests are due to expected errors thrown by QueuedJobs. |
OK those warnings block merge. We'll need to think of a better way of handling these. Perhaps the tests need to mock in a logger than can pick up these issues and validate that they have appeared? |
Yeah, you can push a NullHandler from monolog to the logger from the setUp method so it won't default to logging these to the terminal. We could also push mocked handlers instead with expectations on how the methods getting called, but that's possibly not within the scope of the specific unit tests that exist. |
@sminnee @robbieaverill Have pushed a NullHandler onto the ErrorHandler using Injector. PHPUnit is not reporting them as "Warnings", however the messages are still appearing in the output. Is that going to be an issue? |
It makes it look broken, which inhibits all future dev, so yes I think we want to sort it out. |
Are you sure that the messages are, in fact, benign? |
src/QJUtils.php
Outdated
@@ -5,6 +5,7 @@ | |||
use SilverStripe\Core\Convert; | |||
use SilverStripe\Core\Injector\Injector; | |||
use SilverStripe\ORM\DB; | |||
use Monolog\Logger; |
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.
Is this used in the class?
@@ -5,7 +5,6 @@ sudo: false | |||
language: php | |||
|
|||
php: | |||
- 5.5 |
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.
May as well add 7.1 while you're there
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.
Added in commit 2af7805
@sminnee Have updated QueuedJobsTest to catch errors and check that expected errors exist after specific tests. Have confirmed that errors are expected as it is testing how the system reacts after failure. @robbieaverill Have removed reference to Monologger/Logger and added tests for 7.1 |
@sminnee did Brett's last update resolve the issue you had? |
Yeah I'm happy with this now — no gunk in the test output. I'd note that we probably don't need so many build configs and that the following should be sufficient:
There's a finite number of concurrent builds across all |
Update module to be compatible with SilverStripe 4.0