Skip to content

Commit

Permalink
Merge remote-tracking branch 'origin/4.0' into 4.1
Browse files Browse the repository at this point in the history
  • Loading branch information
Damian Mooyman committed Mar 13, 2018
2 parents 856e899 + da5e73c commit 625f7b4
Show file tree
Hide file tree
Showing 10 changed files with 157 additions and 143 deletions.
219 changes: 108 additions & 111 deletions .upgrade.yml

Large diffs are not rendered by default.

11 changes: 10 additions & 1 deletion docs/en/02_Developer_Guides/09_Security/05_Rate_Limiting.md
Expand Up @@ -44,6 +44,15 @@ Director:
'MyController//$Action/$ID/$OtherID': '%$MyRateLimitedController'
```

Or if you want to apply your middleware to a specific route:

```yml
SilverStripe\Control\Director:
rules:
special/section:
Controller: %$MyRateLimitedController
```

## Applying rate limiting across an entire application

If you'd like to add rate limiting to an entire application (ie: across all routes) then you'll need to define your rate
Expand All @@ -69,4 +78,4 @@ Add the following to your config.yml:
SilverStripe\Control\Director:
rules:
'Security//$Action/$ID/$OtherID': SilverStripe\Security\Security
```
```
6 changes: 3 additions & 3 deletions docs/en/02_Developer_Guides/10_Email/index.md
Expand Up @@ -154,12 +154,12 @@ Configuration of those properties looks like the following:
**mysite/_config.php**

```php
use SilverStripe\Control\Director;
use SilverStripe\Control\Email\Email;
use SilverStripe\Core\Config\Config;
if(Director::isLive()) {
Config::inst()->update('Email', 'bcc_all_emails_to', "client@example.com");
Config::modify()->set(Email::class, 'bcc_all_emails_to', "client@example.com");
} else {
Config::inst()->update('Email', 'send_all_emails_to', "developer@example.com");
Config::modify()->set(Email::class, 'send_all_emails_to', "developer@example.com");
}
```

Expand Down
3 changes: 2 additions & 1 deletion src/Forms/FileUploadReceiver.php
Expand Up @@ -188,8 +188,9 @@ public function setValue($value, $record = null)
// Filter items by what's allowed to be viewed
$filteredItems = new ArrayList();
$fileIDs = array();
/** @var File $file */
foreach ($items as $file) {
if ($file->exists() && $file->canView()) {
if ($file->isInDB() && $file->canView()) {
$filteredItems->push($file);
$fileIDs[] = $file->ID;
}
Expand Down
1 change: 0 additions & 1 deletion src/Forms/FormField.php
Expand Up @@ -7,7 +7,6 @@
use SilverStripe\Control\RequestHandler;
use SilverStripe\Core\ClassInfo;
use SilverStripe\Core\Convert;
use SilverStripe\Dev\Deprecation;
use SilverStripe\ORM\DataObject;
use SilverStripe\ORM\DataObjectInterface;
use SilverStripe\ORM\FieldType\DBField;
Expand Down
22 changes: 12 additions & 10 deletions src/Logging/DetailedErrorFormatter.php
Expand Up @@ -31,16 +31,18 @@ public function format(array $record)
}
}

$trace = debug_backtrace();

// Filter out monolog plumbing from the trace
// If the context file & line isn't found in the trace, then the trace is most likely
// call to the fatal error handler and is not useful, so exclude it entirely
$i = $this->findInTrace($trace, $context['file'], $context['line']);
if ($i !== null) {
$context['trace'] = array_slice($trace, $i);
} else {
$context['trace'] = null;
if (!isset($context['trace'])) {
$trace = debug_backtrace();

// Filter out monolog plumbing from the trace
// If the context file & line isn't found in the trace, then the trace is most likely
// call to the fatal error handler and is not useful, so exclude it entirely
$i = $this->findInTrace($trace, $context['file'], $context['line']);
if ($i !== null) {
$context['trace'] = array_slice($trace, $i);
} else {
$context['trace'] = null;
}
}
}

Expand Down
2 changes: 1 addition & 1 deletion src/ORM/FieldType/DBText.php
Expand Up @@ -198,7 +198,7 @@ public function ContextSummary(
$keywords = Convert::raw2xml($keywords);

// Find the search string
$position = (int) mb_stripos($text, $keywords);
$position = empty($keywords) ? 0 : (int) mb_stripos($text, $keywords);

// We want to search string to be in the middle of our block to give it some context
$position = max(0, $position - ($characters / 2));
Expand Down
3 changes: 2 additions & 1 deletion src/Security/Member.php
Expand Up @@ -946,8 +946,9 @@ public function onAfterDelete()
{
parent::onAfterDelete();

//prevent orphaned records remaining in the DB
// prevent orphaned records remaining in the DB
$this->deletePasswordLogs();
$this->Groups()->removeAll();
}

/**
Expand Down
26 changes: 12 additions & 14 deletions src/Security/MemberAuthenticator/ChangePasswordHandler.php
Expand Up @@ -115,21 +115,19 @@ public function changepassword()
}
// Show a friendly message saying the login token has expired
if ($token !== null && $member && !$member->validateAutoLoginToken($token)) {
$message = [
'Content' => DBField::create_field(
'HTMLFragment',
_t(
'SilverStripe\\Security\\Security.NOTERESETLINKINVALID',
'<p>The password reset link is invalid or expired.</p>'
. '<p>You can request a new one <a href="{link1}">here</a> or change your password after'
. ' you <a href="{link2}">logged in</a>.</p>',
[
'link1' => $this->link('lostpassword'),
'link2' => $this->link('login')
]
)
$message = DBField::create_field(
'HTMLFragment',
_t(
'SilverStripe\\Security\\Security.NOTERESETLINKINVALID',
'<p>The password reset link is invalid or expired.</p>'
. '<p>You can request a new one <a href="{link1}">here</a> or change your password after'
. ' you <a href="{link2}">logged in</a>.</p>',
[
'link1' => $this->link('lostpassword'),
'link2' => $this->link('login')
]
)
];
);

return [
'Content' => $message,
Expand Down
7 changes: 7 additions & 0 deletions tests/php/ORM/DBTextTest.php
Expand Up @@ -263,6 +263,13 @@ public function providerContextSummary()
'schön',
// check UTF8 support
'both <mark>schön</mark> and können...',
],
[
'both schön and können have umlauts',
21,
'',
// check non existant search term
'both schön and können...',
]


Expand Down

0 comments on commit 625f7b4

Please sign in to comment.