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.0 Compatability #125

Merged
merged 21 commits into from
May 2, 2017
Merged

SilverStripe 4.0 Compatability #125

merged 21 commits into from
May 2, 2017

Conversation

brettt89
Copy link

Update module to be compatible with SilverStripe 4.0

Copy link

@sminnee sminnee left a 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.

@@ -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());
Copy link

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?

Copy link
Author

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.

@brettt89
Copy link
Author

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.

@brettt89
Copy link
Author

Date fields weren't updated. Updating these and adding tests for checking correct dates.

@edlinklater
Copy link

Fixes #126

@brettt89
Copy link
Author

Fixes #122

use SilverStripe\QueuedJobs\Services\QueuedJobService;

// stub class to be able to call init from an external context
class TestQJService extends QueuedJobService
Copy link
Contributor

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)

Copy link
Author

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

@@ -118,9 +125,10 @@ public function testScheduledExecutionInterval()
}
}


class TestScheduledDataObject extends DataObject implements TestOnly
class TestScheduledDataObject extends DataObject
Copy link
Contributor

Choose a reason for hiding this comment

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

Add test only back

Copy link
Author

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

Copy link
Contributor

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!

*/
protected $usesDatabase = true;

/**
* {@inheritDoc}
* @var array
*/
protected $extraDataObjects = array(
Copy link

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

@brettt89
Copy link
Author

@sminnee @robbieaverill Have updated tests to correctly implement TestOnly.

Warnings in tests are due to expected errors thrown by QueuedJobs.

@sminnee
Copy link

sminnee commented Apr 24, 2017

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?

@robbieaverill
Copy link
Contributor

robbieaverill commented Apr 24, 2017

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.

@brettt89 brettt89 closed this Apr 24, 2017
@brettt89 brettt89 reopened this Apr 24, 2017
@brettt89
Copy link
Author

brettt89 commented Apr 24, 2017

@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?

@sminnee
Copy link

sminnee commented Apr 24, 2017

It makes it look broken, which inhibits all future dev, so yes I think we want to sort it out.

@sminnee
Copy link

sminnee commented Apr 24, 2017

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;
Copy link
Contributor

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
Copy link
Contributor

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

Copy link
Author

Choose a reason for hiding this comment

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

Added in commit 2af7805

@brettt89
Copy link
Author

@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

@nyeholt
Copy link
Contributor

nyeholt commented Apr 27, 2017

@sminnee did Brett's last update resolve the issue you had?

@sminnee
Copy link

sminnee commented Apr 27, 2017

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:

  • PHP 5.6 + MYSQL
  • PHP 7.0 + PGSQL
  • PHP 7.1 + MYSQL

There's a finite number of concurrent builds across all github.com/silverstripe-australia runs so it's good to keep your job counts in check. ;-)

@robbieaverill
Copy link
Contributor

Assuming this PR fixes #122 (it's noted above as doing so, and the builds pass so I assume that's true) then it replaces #123 too (also replaced by #124). I've closed #123.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

Successfully merging this pull request may close these issues.

None yet

6 participants