Merge branch '3.2' into 3

This commit is contained in:
Robbie Averill 2019-04-15 15:23:13 +12:00
commit 1d775aa664
7 changed files with 95 additions and 14 deletions

View File

@ -2,10 +2,6 @@ sudo: false
language: php
env:
global:
- COMPOSER_ROOT_VERSION="4.0.x-dev"
matrix:
include:
- php: 5.6
@ -15,6 +11,8 @@ matrix:
- php: 7.1
env: DB=MYSQL INSTALLER_VERSION=4.2.x-dev PHPUNIT_COVERAGE_TEST=1
- php: 7.2
env: DB=MYSQL INSTALLER_VERSION=4.3.x-dev PHPUNIT_TEST=1
- php: 7.3
env: DB=MYSQL INSTALLER_VERSION=4.x-dev PHPUNIT_TEST=1
before_script:

View File

@ -17,6 +17,8 @@ use SilverStripe\Forms\NumericField;
use SilverStripe\ORM\DataList;
use SilverStripe\ORM\DataObject;
use SilverStripe\ORM\DB;
use SilverStripe\ORM\HasManyList;
use SilverStripe\ORM\ManyManyList;
use SilverStripe\ORM\SS_List;
use SilverStripe\ORM\UnsavedRelationList;
use SilverStripe\Security\Group;

View File

@ -106,12 +106,16 @@ class BlogController extends PageController
public function getCurrentProfile()
{
$urlSegment = $this->request->param('URLSegment');
if ($urlSegment) {
$filter = URLSegmentFilter::create();
// url encode unless it's multibyte (already pre-encoded in the database)
// see https://github.com/silverstripe/silverstripe-cms/pull/2384
if (!$filter->getAllowMultibyte()) {
$urlSegment = rawurlencode($urlSegment);
}
return Member::get()
->filter('URLSegment', $filter->filter($urlSegment))
->filter('URLSegment', $urlSegment)
->first();
}
@ -263,9 +267,14 @@ class BlogController extends PageController
$tag = $this->request->param('Tag');
if ($tag) {
$filter = URLSegmentFilter::create();
// url encode unless it's multibyte (already pre-encoded in the database)
// see https://github.com/silverstripe/silverstripe-cms/pull/2384
if (!$filter->getAllowMultibyte()) {
$tag = rawurlencode($tag);
}
return $dataRecord->Tags()
->filter('URLSegment', [$tag, $filter->filter($tag)])
->filter('URLSegment', $tag)
->first();
}
return null;
@ -285,9 +294,8 @@ class BlogController extends PageController
if ($this->isRSS()) {
return $this->rssFeed($this->blogPosts, $category->getLink());
} else {
return $this->render();
}
return $this->render();
}
$this->httpError(404, 'Not Found');
@ -309,9 +317,14 @@ class BlogController extends PageController
$category = $this->request->param('Category');
if ($category) {
$filter = URLSegmentFilter::create();
// url encode unless it's multibyte (already pre-encoded in the database)
// see https://github.com/silverstripe/silverstripe-cms/pull/2384
if (!$filter->getAllowMultibyte()) {
$category = rawurlencode($category);
}
return $dataRecord->Categories()
->filter('URLSegment', [$category, $filter->filter($category)])
->filter('URLSegment', $category)
->first();
}
return null;

View File

@ -16,6 +16,7 @@ use SilverStripe\Forms\ToggleCompositeField;
use SilverStripe\ORM\ArrayList;
use SilverStripe\ORM\FieldType\DBDatetime;
use SilverStripe\ORM\FieldType\DBHTMLText;
use SilverStripe\ORM\ManyManyList;
use SilverStripe\ORM\SS_List;
use SilverStripe\ORM\UnsavedRelationList;
use SilverStripe\Security\Group;
@ -25,7 +26,6 @@ use SilverStripe\Security\Security;
use SilverStripe\TagField\TagField;
use SilverStripe\Versioned\Versioned;
use SilverStripe\View\ArrayData;
use SilverStripe\View\Parsers\ShortcodeParser;
use SilverStripe\View\Requirements;
/**

View File

@ -23,14 +23,14 @@ class BlogFunctionalTest extends FunctionalTest
public function testBlogWithMultibyteUrl()
{
$result = $this->get('آبید');
$result = $this->get(rawurlencode('آبید'));
$this->assertEquals(200, $result->getStatusCode());
}
public function testMemberProfileWithMultibyteUrlAndName()
{
$result = $this->get('آبید/profile/عبّاس-آبان');
$result = $this->get(rawurlencode('آبید') . '/profile/' . rawurlencode('عبّاس-آبان'));
$this->assertEquals(200, $result->getStatusCode());
$this->assertContains('My Blog Post', $result->getBody());
@ -38,7 +38,7 @@ class BlogFunctionalTest extends FunctionalTest
public function testMemberProfileWithMultibyteUrlAndEnglishName()
{
$result = $this->get('آبید/profile/bob-jones');
$result = $this->get(rawurlencode('آبید') . '/profile/bob-jones');
$this->assertEquals(200, $result->getStatusCode());
$this->assertContains('My Blog Post', $result->getBody());

View File

@ -0,0 +1,39 @@
<?php
namespace SilverStripe\Blog\Tests\Model;
use SilverStripe\Core\Config\Config;
use SilverStripe\Dev\FunctionalTest;
use SilverStripe\i18n\i18n;
use SilverStripe\View\Parsers\URLSegmentFilter;
class BlogControllerFunctionalTest extends FunctionalTest
{
protected static $fixture_file = 'BlogControllerFunctionalTest.yml';
protected static $use_draft_site = true;
protected function setUp()
{
Config::modify()->set(URLSegmentFilter::class, 'default_allow_multibyte', true);
i18n::set_locale('fa_IR');
parent::setUp();
}
public function testGetCategoriesWithMultibyteUrl()
{
$result = $this->get('my-blog/category/' . rawurlencode('آبید'));
$this->assertEquals(200, $result->getStatusCode());
$this->assertContains('آبید', $result->getBody());
}
public function testGetTagsWithMultibyteUrl()
{
$result = $this->get('my-blog/tag/' . rawurlencode('برتراند'));
$this->assertEquals(200, $result->getStatusCode());
$this->assertContains('برتراند', $result->getBody());
}
}

View File

@ -0,0 +1,29 @@
SilverStripe\Blog\Model\BlogCategory:
category_a:
Title: آبید
URLSegment: آبید
SilverStripe\Blog\Model\BlogTag:
tag_a:
Title: برتراند
URLSegment: برتراند
SilverStripe\Blog\Model\Blog:
blog_a:
URLSegment: my-blog
Title: My Blog
Categories:
- =>SilverStripe\Blog\Model\BlogCategory.category_a
Tags:
- =>SilverStripe\Blog\Model\BlogTag.tag_a
SilverStripe\Blog\Model\BlogPost:
blogpost_a:
Title: My Blog Post
URLSegment: آبیدآبید
PublishDate: 2017-08-01 00:00:00
Parent: =>SilverStripe\Blog\Model\Blog.blog_a
Categories:
- =>SilverStripe\Blog\Model\BlogCategory.category_a
Tags:
- =>SilverStripe\Blog\Model\BlogTag.tag_a