mirror of
https://github.com/silverstripe/silverstripe-framework
synced 2024-10-22 14:05:37 +02:00
API CHANGE #2698 ajshort: URL handler only passes control to subclasses of RequestHandlingData
git-svn-id: svn://svn.silverstripe.com/silverstripe/open/modules/sapphire/trunk@64951 467b73ca-7a2a-4603-9d3b-597d59a354a9
This commit is contained in:
parent
ae0bbfb2c0
commit
672ca89c0b
@ -330,7 +330,7 @@ class HTTPRequest extends Object implements ArrayAccess {
|
||||
if($varRequired && !isset($this->dirParts[$i])) return false;
|
||||
|
||||
$arguments[$varName] = isset($this->dirParts[$i]) ? $this->dirParts[$i] : null;
|
||||
if($part == '$Controller' && !class_exists($arguments['Controller'])) {
|
||||
if($part == '$Controller' && (!class_exists($arguments['Controller']) || !is_subclass_of($arguments['Controller'], 'RequestHandlingData'))) {
|
||||
return false;
|
||||
}
|
||||
|
||||
|
@ -2632,7 +2632,7 @@ class DataObject extends ViewableData implements DataObjectInterface {
|
||||
* which could cause horrible bugs.
|
||||
*/
|
||||
public static function set_context_obj($obj) {
|
||||
if($obj && self::$context_obj) user_error("Dataobject::set_context_obj called when there is already a context.", E_USER_WARNING);
|
||||
if($obj && self::$context_obj) user_error("Dataobject::set_context_obj passed " . $obj->class . "." . $obj->ID . " when there is already a context: " . self::$context_obj->class . '.' . self::$context_obj->ID, E_USER_WARNING);
|
||||
self::$context_obj = $obj;
|
||||
}
|
||||
|
||||
|
@ -865,7 +865,10 @@ class SiteTree extends DataObject {
|
||||
'';
|
||||
|
||||
$count = 1;
|
||||
while(class_exists($this->URLSegment) || DataObject::get_one("SiteTree", "URLSegment = '$this->URLSegment' $idFilter")) {
|
||||
while (
|
||||
(class_exists($this->URLSegment) && is_subclass_of($this->URLSegment, 'RequestHandlingData')) ||
|
||||
DataObject::get_one("SiteTree", "URLSegment = '$this->URLSegment' $idFilter")
|
||||
) {
|
||||
$count++;
|
||||
$this->URLSegment = ereg_replace('-[0-9]+$','', $this->URLSegment) . "-$count";
|
||||
}
|
||||
|
@ -12,6 +12,7 @@ class SiteTreeTest extends SapphireTest {
|
||||
* - Turns things into lowercase-hyphen-format
|
||||
* - Generates from Title by default, unless URLSegment is explicitly set
|
||||
* - Resolves duplicates by appending a number
|
||||
* - renames classes with a class name conflict
|
||||
*/
|
||||
function testURLGeneration() {
|
||||
$expectedURLs = array(
|
||||
@ -23,6 +24,8 @@ class SiteTreeTest extends SapphireTest {
|
||||
'product2' => 'another-product',
|
||||
'product3' => 'another-product-2',
|
||||
'product4' => 'another-product-3',
|
||||
'object' => 'object',
|
||||
'controller' => 'controller-2'
|
||||
);
|
||||
|
||||
foreach($expectedURLs as $fixture => $urlSegment) {
|
||||
|
@ -23,6 +23,10 @@ Page:
|
||||
Title: Another Product
|
||||
contact:
|
||||
Title: Contact Us
|
||||
object:
|
||||
Title: Object
|
||||
controller:
|
||||
Title: Controller
|
||||
|
||||
ErrorPage:
|
||||
404:
|
||||
|
Loading…
Reference in New Issue
Block a user