Merge pull request #49 from creative-commoners/pulls/2.0/fix-relation-getter

FIX getFieldsForObj does not return relation classes in hasField() check
This commit is contained in:
Robbie Averill 2018-02-08 17:11:43 +13:00 committed by GitHub
commit b59d956143
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
6 changed files with 11 additions and 17 deletions

View File

@ -301,7 +301,9 @@ abstract class DataFormatter
if (is_array($this->customFields)) {
foreach ($this->customFields as $fieldName) {
// @todo Possible security risk by making methods accessible - implement field-level security
if ($obj->hasField($fieldName) || $obj->hasMethod("get{$fieldName}")) {
if (($obj->hasField($fieldName) && !is_object($obj->getField($fieldName)))
|| $obj->hasMethod("get{$fieldName}")
) {
$dbFields[$fieldName] = $fieldName;
}
}

View File

@ -2,11 +2,8 @@
namespace SilverStripe\RestfulServer\Tests\Stubs;
use SilverStripe\RestfulServer\Tests\Stubs\RestfulServerTestPage;
use SilverStripe\RestfulServer\Tests\Stubs\RestfulServerTestAuthor;
use SilverStripe\RestfulServer\Tests\Stubs\RestfulServerTestAuthorRating;
use SilverStripe\ORM\DataObject;
use SilverStripe\Dev\TestOnly;
use SilverStripe\ORM\DataObject;
class RestfulServerTestAuthor extends DataObject implements TestOnly
{

View File

@ -2,9 +2,8 @@
namespace SilverStripe\RestfulServer\Tests\Stubs;
use SilverStripe\RestfulServer\Tests\Stubs\RestfulServerTestAuthor;
use SilverStripe\ORM\DataObject;
use SilverStripe\Dev\TestOnly;
use SilverStripe\ORM\DataObject;
class RestfulServerTestAuthorRating extends DataObject implements TestOnly
{

View File

@ -2,12 +2,10 @@
namespace SilverStripe\RestfulServer\Tests\Stubs;
use SilverStripe\RestfulServer\Tests\Stubs\RestfulServerTestPage;
use SilverStripe\RestfulServer\Tests\Stubs\RestfulServerTestAuthor;
use SilverStripe\Security\Permission;
use SilverStripe\ORM\DataObject;
use SilverStripe\Security\PermissionProvider;
use SilverStripe\Dev\TestOnly;
use SilverStripe\ORM\DataObject;
use SilverStripe\Security\Permission;
use SilverStripe\Security\PermissionProvider;
/**
* Everybody can view comments, logged in members in the "users" group can create comments,

View File

@ -2,10 +2,8 @@
namespace SilverStripe\RestfulServer\Tests\Stubs;
use SilverStripe\RestfulServer\Tests\Stubs\RestfulServerTestAuthor;
use SilverStripe\RestfulServer\Tests\Stubs\RestfulServerTestComment;
use SilverStripe\ORM\DataObject;
use SilverStripe\Dev\TestOnly;
use SilverStripe\ORM\DataObject;
class RestfulServerTestPage extends DataObject implements TestOnly
{

View File

@ -2,9 +2,9 @@
namespace SilverStripe\RestfulServer\Tests\Stubs;
use SilverStripe\Security\Permission;
use SilverStripe\ORM\DataObject;
use SilverStripe\Dev\TestOnly;
use SilverStripe\ORM\DataObject;
use SilverStripe\Security\Permission;
use SilverStripe\Security\PermissionProvider;
class RestfulServerTestSecretThing extends DataObject implements TestOnly, PermissionProvider