mirror of
https://github.com/silverstripe/silverstripe-framework
synced 2024-10-22 14:05:37 +02:00
MINOR: Several changes merged from branches/2.4
git-svn-id: svn://svn.silverstripe.com/silverstripe/open/modules/sapphire/trunk@112060 467b73ca-7a2a-4603-9d3b-597d59a354a9
This commit is contained in:
parent
6c3bcc356d
commit
890ac94a6a
@ -640,7 +640,7 @@ abstract class Object {
|
|||||||
$this->class = get_class($this);
|
$this->class = get_class($this);
|
||||||
|
|
||||||
// Don't bother checking some classes that should never be extended
|
// Don't bother checking some classes that should never be extended
|
||||||
static $notExtendable = array('Object', 'ViewableData', 'DataObject', 'RequestHandler');
|
static $notExtendable = array('Object', 'ViewableData', 'RequestHandler');
|
||||||
|
|
||||||
if($extensionClasses = ClassInfo::ancestry($this->class)) foreach($extensionClasses as $class) {
|
if($extensionClasses = ClassInfo::ancestry($this->class)) foreach($extensionClasses as $class) {
|
||||||
if(in_array($class, $notExtendable)) continue;
|
if(in_array($class, $notExtendable)) continue;
|
||||||
|
@ -506,8 +506,6 @@ class DataObject extends ViewableData implements DataObjectInterface, i18nEntity
|
|||||||
* Called by Object::__construct() once per class.
|
* Called by Object::__construct() once per class.
|
||||||
*/
|
*/
|
||||||
function defineMethods() {
|
function defineMethods() {
|
||||||
if($this->class == 'DataObject') return;
|
|
||||||
|
|
||||||
parent::defineMethods();
|
parent::defineMethods();
|
||||||
|
|
||||||
// Define the extra db fields - this is only necessary for extensions added in the
|
// Define the extra db fields - this is only necessary for extensions added in the
|
||||||
@ -521,6 +519,8 @@ class DataObject extends ViewableData implements DataObjectInterface, i18nEntity
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if($this->class == 'DataObject') return;
|
||||||
|
|
||||||
// Set up accessors for joined items
|
// Set up accessors for joined items
|
||||||
if($manyMany = $this->many_many()) {
|
if($manyMany = $this->many_many()) {
|
||||||
foreach($manyMany as $relationship => $class) {
|
foreach($manyMany as $relationship => $class) {
|
||||||
|
@ -720,6 +720,48 @@ abstract class SS_Database {
|
|||||||
return $text;
|
return $text;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Function to return an SQL datetime expression that can be used with the adapter in use
|
||||||
|
* used for querying a datetime in a certain format
|
||||||
|
* @param string $date to be formated, can be either 'now', literal datetime like '1973-10-14 10:30:00' or field name, e.g. '"SiteTree"."Created"'
|
||||||
|
* @param string $format to be used, supported specifiers:
|
||||||
|
* %Y = Year (four digits)
|
||||||
|
* %m = Month (01..12)
|
||||||
|
* %d = Day (01..31)
|
||||||
|
* %H = Hour (00..23)
|
||||||
|
* %i = Minutes (00..59)
|
||||||
|
* %s = Seconds (00..59)
|
||||||
|
* %U = unix timestamp, can only be used on it's own
|
||||||
|
* @return string SQL datetime expression to query for a formatted datetime
|
||||||
|
*/
|
||||||
|
abstract function formattedDatetimeClause($date, $format);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Function to return an SQL datetime expression that can be used with the adapter in use
|
||||||
|
* used for querying a datetime addition
|
||||||
|
* @param string $date, can be either 'now', literal datetime like '1973-10-14 10:30:00' or field name, e.g. '"SiteTree"."Created"'
|
||||||
|
* @param string $interval to be added, use the format [sign][integer] [qualifier], e.g. -1 Day, +15 minutes, +1 YEAR
|
||||||
|
* supported qualifiers:
|
||||||
|
* - years
|
||||||
|
* - months
|
||||||
|
* - days
|
||||||
|
* - hours
|
||||||
|
* - minutes
|
||||||
|
* - seconds
|
||||||
|
* This includes the singular forms as well
|
||||||
|
* @return string SQL datetime expression to query for a datetime (YYYY-MM-DD hh:mm:ss) which is the result of the addition
|
||||||
|
*/
|
||||||
|
abstract function datetimeIntervalClause($date, $interval);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Function to return an SQL datetime expression that can be used with the adapter in use
|
||||||
|
* used for querying a datetime substraction
|
||||||
|
* @param string $date1, can be either 'now', literal datetime like '1973-10-14 10:30:00' or field name, e.g. '"SiteTree"."Created"'
|
||||||
|
* @param string $date2 to be substracted of $date1, can be either 'now', literal datetime like '1973-10-14 10:30:00' or field name, e.g. '"SiteTree"."Created"'
|
||||||
|
* @return string SQL datetime expression to query for the interval between $date1 and $date2 in seconds which is the result of the substraction
|
||||||
|
*/
|
||||||
|
abstract function datetimeDifferenceClause($date1, $date2);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -295,7 +295,9 @@ class SiteTree extends DataObject implements PermissionProvider,i18nEntityProvid
|
|||||||
*/
|
*/
|
||||||
public static function page_type_classes() {
|
public static function page_type_classes() {
|
||||||
$classes = ClassInfo::getValidSubClasses();
|
$classes = ClassInfo::getValidSubClasses();
|
||||||
if($baseClassIndex = array_search('SiteTree', $classes)) unset($classes[$baseClassIndex]);
|
|
||||||
|
$baseClassIndex = array_search('SiteTree', $classes);
|
||||||
|
if($baseClassIndex !== FALSE) unset($classes[$baseClassIndex]);
|
||||||
|
|
||||||
$kill_ancestors = array();
|
$kill_ancestors = array();
|
||||||
|
|
||||||
@ -1396,9 +1398,6 @@ class SiteTree extends DataObject implements PermissionProvider,i18nEntityProvid
|
|||||||
// This will have the affect of preserving the versioning
|
// This will have the affect of preserving the versioning
|
||||||
$this->migrateVersion($this->Version);
|
$this->migrateVersion($this->Version);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
parent::onBeforeWrite();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
function syncLinkTracking() {
|
function syncLinkTracking() {
|
||||||
|
@ -42,7 +42,12 @@ class MemberAuthenticator extends Authenticator {
|
|||||||
"Member",
|
"Member",
|
||||||
"\"" . Member::get_unique_identifier_field() . "\" = '$SQL_user' AND \"Password\" IS NOT NULL"
|
"\"" . Member::get_unique_identifier_field() . "\" = '$SQL_user' AND \"Password\" IS NOT NULL"
|
||||||
);
|
);
|
||||||
$result = ($member) ? $member->checkPassword($RAW_data['Password']) : false;
|
|
||||||
|
if($member) {
|
||||||
|
$result = $member->checkPassword($RAW_data['Password']);
|
||||||
|
} else {
|
||||||
|
$result = new ValidationResult(false, _t('Member.ERRORWRONGCRED'));
|
||||||
|
}
|
||||||
|
|
||||||
if($member && !$result->valid()) {
|
if($member && !$result->valid()) {
|
||||||
$member->registerFailedLogin();
|
$member->registerFailedLogin();
|
||||||
|
@ -10,6 +10,10 @@ class DataObjectDecoratorTest extends SapphireTest {
|
|||||||
'DataObjectDecoratorTest_MyObject',
|
'DataObjectDecoratorTest_MyObject',
|
||||||
);
|
);
|
||||||
|
|
||||||
|
protected $requiredExtensions = array(
|
||||||
|
'DataObject' => array( 'DataObjectDecoratorTest_AppliedToDO' ),
|
||||||
|
);
|
||||||
|
|
||||||
function testOneToManyAssociationWithDecorator() {
|
function testOneToManyAssociationWithDecorator() {
|
||||||
// Fails in RestfulServerTest
|
// Fails in RestfulServerTest
|
||||||
// Error: Object::__call() Method 'RelatedObjects' not found in class 'RestfulServerTest_Comment'
|
// Error: Object::__call() Method 'RelatedObjects' not found in class 'RestfulServerTest_Comment'
|
||||||
@ -141,6 +145,17 @@ class DataObjectDecoratorTest extends SapphireTest {
|
|||||||
$this->assertNotNull($member->dbObject('Website'));
|
$this->assertNotNull($member->dbObject('Website'));
|
||||||
$this->assertType('Varchar', $member->dbObject('Website'));
|
$this->assertType('Varchar', $member->dbObject('Website'));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function testDecoratorCanBeAppliedToDataObject() {
|
||||||
|
$do = new DataObject();
|
||||||
|
$mo = new DataObjectDecoratorTest_MyObject();
|
||||||
|
|
||||||
|
$this->assertTrue($do->hasMethod('testMethodApplied'));
|
||||||
|
$this->assertTrue($mo->hasMethod('testMethodApplied'));
|
||||||
|
|
||||||
|
$this->assertEquals("hello world", $mo->testMethodApplied());
|
||||||
|
$this->assertEquals("hello world", $do->testMethodApplied());
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
class DataObjectDecoratorTest_Member extends DataObject implements TestOnly {
|
class DataObjectDecoratorTest_Member extends DataObject implements TestOnly {
|
||||||
@ -287,6 +302,12 @@ class DataObjectDecoratorTest_Faves extends DataObjectDecorator implements TestO
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
class DataObjectDecoratorTest_AppliedToDO extends DataObjectDecorator implements TestOnly {
|
||||||
|
public function testMethodApplied() {
|
||||||
|
return "hello world";
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
DataObject::add_extension('DataObjectDecoratorTest_MyObject', 'DataObjectDecoratorTest_Ext1');
|
DataObject::add_extension('DataObjectDecoratorTest_MyObject', 'DataObjectDecoratorTest_Ext1');
|
||||||
DataObject::add_extension('DataObjectDecoratorTest_MyObject', 'DataObjectDecoratorTest_Ext2');
|
DataObject::add_extension('DataObjectDecoratorTest_MyObject', 'DataObjectDecoratorTest_Ext2');
|
||||||
DataObject::add_extension('DataObjectDecoratorTest_MyObject', 'DataObjectDecoratorTest_Faves');
|
DataObject::add_extension('DataObjectDecoratorTest_MyObject', 'DataObjectDecoratorTest_Faves');
|
||||||
|
@ -685,6 +685,12 @@ class SiteTreeTest extends SapphireTest {
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function testPageTypeClasses() {
|
||||||
|
$classes = SiteTree::page_type_classes();
|
||||||
|
$this->assertNotContains('SiteTree', $classes, 'Page types do not include base class');
|
||||||
|
$this->assertContains('Page', $classes, 'Page types do contain subclasses');
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**#@+
|
/**#@+
|
||||||
|
@ -247,6 +247,9 @@ class SecurityTest extends FunctionalTest {
|
|||||||
$this->assertTrue(is_object($attempt));
|
$this->assertTrue(is_object($attempt));
|
||||||
$this->assertEquals($attempt->Status, 'Failure');
|
$this->assertEquals($attempt->Status, 'Failure');
|
||||||
$this->assertEquals($attempt->Email, 'wronguser@silverstripe.com');
|
$this->assertEquals($attempt->Email, 'wronguser@silverstripe.com');
|
||||||
|
$this->assertNotNull(
|
||||||
|
$this->loginErrorMessage(), 'An invalid email returns a message.'
|
||||||
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
function testSuccessfulLoginAttempts() {
|
function testSuccessfulLoginAttempts() {
|
||||||
|
Loading…
Reference in New Issue
Block a user