Merge branch '3'

This commit is contained in:
Daniel Hensby 2016-05-04 23:36:10 +01:00
commit b11bbffb7d
No known key found for this signature in database
GPG Key ID: E38EC566FE29EB66
7 changed files with 27 additions and 10 deletions

View File

@ -510,12 +510,10 @@ class Upload_Validator {
if ($category && isset($this->allowedMaxFileSize['[' . $category . ']'])) { if ($category && isset($this->allowedMaxFileSize['[' . $category . ']'])) {
return $this->allowedMaxFileSize['[' . $category . ']']; return $this->allowedMaxFileSize['[' . $category . ']'];
} }
}
return false;
} else {
return (isset($this->allowedMaxFileSize['*'])) ? $this->allowedMaxFileSize['*'] : false; return (isset($this->allowedMaxFileSize['*'])) ? $this->allowedMaxFileSize['*'] : false;
} }
}
/** /**
* Set filesize maximums (in bytes or INI format). * Set filesize maximums (in bytes or INI format).

View File

@ -72,6 +72,8 @@ class HeaderField extends DatalessField {
array( array(
'id' => $this->ID(), 'id' => $this->ID(),
'class' => $this->extraClass(), 'class' => $this->extraClass(),
'type' => null,
'name' => null
) )
); );
} }

View File

@ -13,8 +13,6 @@ use SilverStripe\Model\Relation;
* of $dataClass). Unsaved objects are then written when the list is saved * of $dataClass). Unsaved objects are then written when the list is saved
* into an instance of {@link RelationList}. * into an instance of {@link RelationList}.
* *
* Most methods that alter the list of objects throw LogicExceptions.
*
* @package framework * @package framework
* @subpackage model * @subpackage model
*/ */
@ -51,6 +49,8 @@ class UnsavedRelationList extends ArrayList implements Relation {
/** /**
* Create a new UnsavedRelationList * Create a new UnsavedRelationList
* *
* @param array $baseClass
* @param string $relationName
* @param string $dataClass The DataObject class used in the relation * @param string $dataClass The DataObject class used in the relation
*/ */
public function __construct($baseClass, $relationName, $dataClass) { public function __construct($baseClass, $relationName, $dataClass) {
@ -63,7 +63,8 @@ class UnsavedRelationList extends ArrayList implements Relation {
/** /**
* Add an item to this relationship * Add an item to this relationship
* *
* @param $extraFields A map of additional columns to insert into the joinTable in the case of a many_many relation * @param mixed $item
* @param array $extraFields A map of additional columns to insert into the joinTable in the case of a many_many relation
*/ */
public function add($item, $extraFields = null) { public function add($item, $extraFields = null) {
$this->push($item, $extraFields); $this->push($item, $extraFields);
@ -87,6 +88,7 @@ class UnsavedRelationList extends ArrayList implements Relation {
* Pushes an item onto the end of this list. * Pushes an item onto the end of this list.
* *
* @param array|object $item * @param array|object $item
* @param array $extraFields
*/ */
public function push($item, $extraFields = null) { public function push($item, $extraFields = null) {
if((is_object($item) && !$item instanceof $this->dataClass) if((is_object($item) && !$item instanceof $this->dataClass)
@ -165,6 +167,8 @@ class UnsavedRelationList extends ArrayList implements Relation {
* Remove the items from this list with the given IDs * Remove the items from this list with the given IDs
* *
* @param array $items * @param array $items
* @param array $items
* @return $this
*/ */
public function removeMany($items) { public function removeMany($items) {
$this->items = array_diff($this->items, $items); $this->items = array_diff($this->items, $items);
@ -255,7 +259,7 @@ class UnsavedRelationList extends ArrayList implements Relation {
/** /**
* Returns a copy of this list with the relationship linked to the given foreign ID. * Returns a copy of this list with the relationship linked to the given foreign ID.
* @param $id An ID or an array of IDs. * @param int|array $id An ID or an array of IDs.
*/ */
public function forForeignID($id) { public function forForeignID($id) {
$class = singleton($this->baseClass); $class = singleton($this->baseClass);

View File

@ -275,9 +275,12 @@ class Security extends Controller implements TemplateGlobalProvider {
$form = $me->LoginForm(); $form = $me->LoginForm();
$form->sessionMessage($message, 'warning'); $form->sessionMessage($message, 'warning');
Session::set('MemberLoginForm.force_message',1); Session::set('MemberLoginForm.force_message',1);
$formText = $me->login(); $loginResponse = $me->login();
if($loginResponse instanceof SS_HTTPResponse) {
return $loginResponse;
}
$response->setBody($formText); $response->setBody((string)$loginResponse);
$controller->extend('permissionDenied', $member); $controller->extend('permissionDenied', $member);
@ -502,7 +505,7 @@ class Security extends Controller implements TemplateGlobalProvider {
* For multiple authenticators, Security_MultiAuthenticatorLogin is used. * For multiple authenticators, Security_MultiAuthenticatorLogin is used.
* See getTemplatesFor and getIncludeTemplate for how to override template logic * See getTemplatesFor and getIncludeTemplate for how to override template logic
* *
* @return string Returns the "login" page as HTML code. * @return string|SS_HTTPResponse Returns the "login" page as HTML code.
*/ */
public function login() { public function login() {
// Check pre-login process // Check pre-login process

View File

@ -0,0 +1,3 @@
---
Name: emptyconfig
---

View File

@ -187,6 +187,13 @@ class UploadTest extends SapphireTest {
$retrievedSize = $v->getAllowedMaxFileSize('txt'); $retrievedSize = $v->getAllowedMaxFileSize('txt');
$this->assertEquals(4096, $retrievedSize, 'Max file size check on instance values failed (instance extension set check)'); $this->assertEquals(4096, $retrievedSize, 'Max file size check on instance values failed (instance extension set check)');
// Check a wildcard max file size against a file with an extension
$v = new UploadTest_Validator();
$v->setAllowedMaxFileSize(2000);
$retrievedSize = $v->getAllowedMaxFileSize('.jpg');
$this->assertEquals(2000, $retrievedSize, 'Max file size check on instance values failed (wildcard max file size)');
Config::unnest(); Config::unnest();
} }