mirror of
https://github.com/silverstripe/silverstripe-framework
synced 2024-10-22 14:05:37 +02:00
ENHANCEMENT: #5248 improved the handling of attaching invalid extensions to dataobjects.
git-svn-id: svn://svn.silverstripe.com/silverstripe/open/modules/sapphire/trunk@115174 467b73ca-7a2a-4603-9d3b-597d59a354a9
This commit is contained in:
parent
517a51194b
commit
0b54ce3450
@ -538,8 +538,13 @@ abstract class Object {
|
||||
|
||||
// load statics now for DataObject classes
|
||||
if(ClassInfo::is_subclass_of($class, 'DataObject')) {
|
||||
if(is_subclass_of($extensionClass, 'DataObjectDecorator')) {
|
||||
DataObjectDecorator::load_extra_statics($class, $extension);
|
||||
}
|
||||
else {
|
||||
user_error("$extensionClass cannot be applied to $class without being a DataObjectDecorator", E_USER_ERROR);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
@ -554,9 +559,23 @@ abstract class Object {
|
||||
// load statics now for DataObject classes
|
||||
if(is_subclass_of($class, 'DataObject')) {
|
||||
$extensions = Object::uninherited_static($class, 'extensions');
|
||||
if($extensions) foreach($extensions as $extension) {
|
||||
|
||||
if($extensions) {
|
||||
foreach($extensions as $extension) {
|
||||
$extensionClass = $extension;
|
||||
|
||||
if(preg_match('/^([^(]*)/', $extension, $matches)) {
|
||||
$extensionClass = $matches[1];
|
||||
}
|
||||
|
||||
if(is_subclass_of($extensionClass, 'DataObjectDecorator')) {
|
||||
DataObjectDecorator::load_extra_statics($class, $extension);
|
||||
}
|
||||
else {
|
||||
user_error("$extensionClass cannot be applied to $class without being a DataObjectDecorator", E_USER_ERROR);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -99,7 +99,7 @@ class RestfulServiceTest extends SapphireTest {
|
||||
}
|
||||
|
||||
function testHttpErrorWithoutCache() {
|
||||
$connection = new RestfulService(Director::absoluteBaseURL(), 0);
|
||||
$connection = new RestfulServiceTest_MockRestfulService(Director::absoluteBaseURL(), 0);
|
||||
$response = $connection->request('RestfulServiceTest_Controller/httpErrorWithoutCache?usetestmanifest=1&flush=1');
|
||||
|
||||
$this->assertEquals(400, $response->getStatusCode());
|
||||
@ -272,4 +272,3 @@ class RestfulServiceTest_MockRestfulService extends RestfulService {
|
||||
return $response;
|
||||
}
|
||||
}
|
||||
?>
|
||||
|
Loading…
Reference in New Issue
Block a user