Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Throw exceptions when non Datasource classes are used as Datasources.
Using models as datasources can cause segmentation faults. Guard against that by checking types and raising exceptions early. Fixes #3694
- Loading branch information
Showing
3 changed files
with
14 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
3d4ebc0
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.
Ouch, that is not a very happy thing for me. I use tons of datasources that do not extend the base class :(
3d4ebc0
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 understand the related ticket correctly, he provided incorrect value for
datasource
key in config and coincidentally there was a model class loaded of the same name which got used as datasource instance. Is that right? This sounds like a pretty rare edge case.Given the fact that web services can be pretty varied in nature I am sure there must be others like @lorenzo who have made datasource class which don't extend the base class.
3d4ebc0
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 undoing this
3d4ebc0
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 didn't want to try and check for things like using a model/controller/helper/component/behavior. Right now the failure case is a segmentation fault. I'm open for other ways of fixing this though. Perhaps we can sniff a method?
3d4ebc0
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.
3d4ebc0
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 don't think that would solve the issue of doing:
And the app having a Model class, that may already be loaded.
3d4ebc0
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 checking that if
datasource
's value doesn't contain a/
it should end insource
?3d4ebc0
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 meant sth like:
3d4ebc0
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.
@ceeram That sounds promising.
3d4ebc0
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.
Made a pull request: #1176