Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

MINOR Fixes to method arguments in core classes for E_STRICT support.

API CHANGE Remove abstract static function and just use static functions
in Authenticator (PHP 5.3+ doesn't support abstract static functions)
  • Loading branch information...
commit e097f6e1a873615344ca027d2f953eea80bfc628 1 parent 86b805d
@halkyon halkyon authored halkyon committed
Showing with 93 additions and 85 deletions.
  1. +1 −1  admin/code/LeftAndMain.php
  2. +1 −1  admin/code/ModelAdmin.php
  3. +1 −1  core/manifest/ClassLoader.php
  4. +3 −3 filesystem/File.php
  5. +1 −1  filesystem/Folder.php
  6. +2 −2 forms/TreeDropdownField.php
  7. +1 −1  model/Aggregate.php
  8. +1 −1  model/DataExtension.php
  9. +2 −2 model/DataObject.php
  10. +3 −3 model/Hierarchy.php
  11. +2 −2 model/Image.php
  12. +1 −1  model/SQLQuery.php
  13. +1 −1  model/Versioned.php
  14. +1 −1  model/fieldtypes/Currency.php
  15. +1 −1  model/fieldtypes/Date.php
  16. +1 −1  model/fieldtypes/Datetime.php
  17. +1 −1  model/fieldtypes/HTMLText.php
  18. +6 −5 security/Authenticator.php
  19. +1 −1  security/Group.php
  20. +1 −1  security/Member.php
  21. +2 −2 security/PermissionRole.php
  22. +2 −2 tests/control/RequestHandlingTest.php
  23. +3 −1 tests/forms/FormScaffolderTest.php
  24. +2 −2 tests/forms/FormTest.php
  25. +6 −6 tests/forms/gridfield/GridFieldDetailFormTest.php
  26. +5 −5 tests/forms/uploadfield/UploadFieldTest.php
  27. +29 −24 tests/model/AggregateTest.php
  28. +3 −3 tests/model/DataDifferencerTest.php
  29. +1 −1  tests/security/GroupTest.php
  30. +5 −5 tests/security/MemberTest.php
  31. +3 −3 tests/view/SSViewerTest.php
View
2  admin/code/LeftAndMain.php
@@ -322,7 +322,7 @@ function init() {
SSViewer::set_theme(null);
}
- function handleRequest($request, DataModel $model) {
+ function handleRequest(SS_HTTPRequest $request, DataModel $model = null) {
$title = $this->Title();
$response = parent::handleRequest($request, $model);
View
2  admin/code/ModelAdmin.php
@@ -113,7 +113,7 @@ public function init() {
Requirements::javascript(SAPPHIRE_ADMIN_DIR . '/javascript/ModelAdmin.js');
}
- function getEditForm($id = null) {
+ function getEditForm($id = null, $fields = null) {
$list = $this->getList();
$exportButton = new GridFieldExportButton();
$exportButton->setExportColumns($this->getExportFields());
View
2  core/manifest/ClassLoader.php
@@ -85,4 +85,4 @@ public function classExists($class) {
return class_exists($class, false) || $this->getManifest()->getItemPath($class);
}
-}
+}
View
6 filesystem/File.php
@@ -319,7 +319,7 @@ function canDelete($member = null) {
* Returns the fields to power the edit screen of files in the CMS
* @return FieldList
*/
- function getCMSFields() {
+ function getCMSFields($params = null) {
// Preview
if($this instanceof Image) {
$formattedImage = $this->getFormattedImage('SetWidth', Image::$asset_preview_width);
@@ -816,8 +816,8 @@ function getAbsoluteSize(){
}
}
- public function flushCache() {
- parent::flushCache();
+ public function flushCache($persistant = true) {
+ parent::flushCache($persistant);
self::$cache_file_fields = null;
}
View
2  filesystem/Folder.php
@@ -406,7 +406,7 @@ public function updateFilesystem() {
* You can modify this FieldList by subclassing folder, or by creating a {@link DataExtension}
* and implemeting updateCMSFields(FieldList $fields) on that extension.
*/
- function getCMSFields() {
+ function getCMSFields($param = null) {
// Hide field on root level, which can't be renamed
if(!$this->ID || $this->ID === "root") {
$titleField = new HiddenField("Name");
View
4 forms/TreeDropdownField.php
@@ -343,7 +343,7 @@ function performReadonlyTransformation() {
class TreeDropdownField_Readonly extends TreeDropdownField {
protected $readonly = true;
- function Field() {
+ function Field($properties = array()) {
$fieldName = $this->labelField;
if($this->value) {
$keyObj = $this->objectForKey($this->value);
@@ -361,4 +361,4 @@ function Field() {
$field->setForm($this->form);
return $field->Field();
}
-}
+}
View
2  model/Aggregate.php
@@ -90,7 +90,7 @@ protected function query($attr) {
* This gets the aggregate function
*
*/
- public function XML_val($name, $args) {
+ public function XML_val($name, $args = null, $cache = false) {
$func = strtoupper( strpos($name, 'get') === 0 ? substr($name, 3) : $name );
$attribute = $args ? $args[0] : 'ID';
View
2  model/DataExtension.php
@@ -131,7 +131,7 @@ function canCreate($member) {
* @return array Returns a map where the keys are db, has_one, etc, and
* the values are additional fields/relations to be defined.
*/
- function extraStatics($class=null, $extension=null) {
+ function extraStatics($class = null, $extension = null) {
return array();
}
View
4 model/DataObject.php
@@ -2654,7 +2654,7 @@ public static function get_one($callerClass, $filter = "", $cache = true, $order
* When false will just clear session-local cached data
*
*/
- public function flushCache($persistant=true) {
+ public function flushCache($persistant = true) {
if($persistant) Aggregate::flushCache($this->class);
if($this->class == 'DataObject') {
@@ -3342,4 +3342,4 @@ function hasValue($field, $arguments = null, $cache = true) {
}
}
-}
+}
View
6 model/Hierarchy.php
@@ -674,12 +674,12 @@ function flushCache() {
self::$expanded = array();
self::$treeOpened = array();
}
-
- function reset() {
+
+ public static function reset() {
self::$marked = array();
self::$expanded = array();
self::$treeOpened = array();
}
-}
+}
View
4 model/Image.php
@@ -73,8 +73,8 @@ public function defineMethods() {
parent::defineMethods();
}
- function getCMSFields() {
- $fields = parent::getCMSFields();
+ function getCMSFields($params = null) {
+ $fields = parent::getCMSFields($params);
$urlLink = "<div class='field readonly'>";
$urlLink .= "<label class='left'>"._t('AssetTableField.URL','URL')."</label>";
View
2  model/SQLQuery.php
@@ -554,7 +554,7 @@ function filtersOnFK() {
* Return the number of rows in this query if the limit were removed. Useful in paged data sets.
* @return int
*/
- function unlimitedRowCount( $column = null) {
+ function unlimitedRowCount($column = null) {
// we can't clear the select if we're relying on its output by a HAVING clause
if(count($this->having)) {
$records = $this->execute();
View
2  model/Versioned.php
@@ -132,7 +132,7 @@ function augmentDataQueryCreation(SQLQuery &$query, DataQuery &$dataQuery) {
* Augment the the SQLQuery that is created by the DataQuery
* @todo Should this all go into VersionedDataQuery?
*/
- function augmentSQL(SQLQuery &$query, DataQuery &$dataQuery) {
+ function augmentSQL(SQLQuery &$query, DataQuery &$dataQuery = null) {
$baseTable = ClassInfo::baseDataClass($dataQuery->dataClass());
switch($dataQuery->getQueryParam('Versioned.mode')) {
View
2  model/fieldtypes/Currency.php
@@ -41,7 +41,7 @@ function Whole() {
else return $val;
}
- function setValue($value) {
+ function setValue($value, $record = null) {
$matches = null;
if(is_numeric($value)) {
$this->value = $value;
View
2  model/fieldtypes/Date.php
@@ -20,7 +20,7 @@
*/
class Date extends DBField {
- function setValue($value) {
+ function setValue($value, $record = null) {
if($value === false || $value === null || (is_string($value) && !strlen($value))) {
// don't try to evaluate empty values with strtotime() below, as it returns "1970-01-01" when it should be saved as NULL in database
$this->value = null;
View
2  model/fieldtypes/Datetime.php
@@ -25,7 +25,7 @@
*/
class SS_Datetime extends Date {
- function setValue($value) {
+ function setValue($value, $record = null) {
if($value === false || $value === null || (is_string($value) && !strlen($value))) {
// don't try to evaluate empty values with strtotime() below, as it returns "1970-01-01" when it should be saved as NULL in database
$this->value = null;
View
2  model/fieldtypes/HTMLText.php
@@ -136,7 +136,7 @@ public function scaffoldFormField($title = null, $params = null) {
return new HtmlEditorField($this->name, $title);
}
- public function scaffoldSearchField($title = null) {
+ public function scaffoldSearchField($title = null, $params = null) {
return new TextField($this->name, $title);
}
View
11 security/Authenticator.php
@@ -37,9 +37,8 @@
* @return bool|Member Returns FALSE if authentication fails, otherwise
* the member object
*/
- public abstract static function authenticate($RAW_data,
- Form $form = null);
-
+ public static function authenticate($RAW_data, Form $form = null) {
+ }
/**
* Method that creates the login form for this authentication method
@@ -49,7 +48,8 @@
* @return Form Returns the login form to use with this authentication
* method
*/
- public abstract static function get_login_form(Controller $controller);
+ public static function get_login_form(Controller $controller) {
+ }
/**
@@ -57,7 +57,8 @@
*
* @return string Returns the name of the authentication method.
*/
- public abstract static function get_name();
+ public static function get_name() {
+ }
public static function register($authenticator) {
self::register_authenticator($authenticator);
View
2  security/Group.php
@@ -59,7 +59,7 @@ function getAllChildren() {
*
* @return FieldList
*/
- public function getCMSFields() {
+ public function getCMSFields($params = null) {
Requirements::javascript(SAPPHIRE_DIR . '/javascript/PermissionCheckboxSetField.js');
$fields = new FieldList(
View
2  security/Member.php
@@ -1084,7 +1084,7 @@ public function memberNotInGroups($groupList, $memberGroups = null){
* @return FieldList Return a FieldList of fields that would appropriate for
* editing this member.
*/
- public function getCMSFields() {
+ public function getCMSFields($params = null) {
require_once('Zend/Date.php');
$fields = parent::getCMSFields();
View
4 security/PermissionRole.php
@@ -33,8 +33,8 @@ class PermissionRole extends DataObject {
static $plural_name = 'Roles';
- function getCMSFields() {
- $fields = parent::getCMSFields();
+ function getCMSFields($params = null) {
+ $fields = parent::getCMSFields($params);
$fields->removeFieldFromTab('Root', 'Codes');
$fields->removeFieldFromTab('Root', 'Groups');
View
4 tests/control/RequestHandlingTest.php
@@ -329,7 +329,7 @@ public function throwhttperror() {
$this->httpError(404, 'This page does not exist.');
}
- public function getViewer(){
+ public function getViewer($action) {
return new SSViewer('BlankPage');
}
}
@@ -384,7 +384,7 @@ function formactionInAllowedActions($data, $form = null) {
return 'formactionInAllowedActions';
}
- public function getViewer(){
+ public function getViewer($action = null) {
return new SSViewer('BlankPage');
}
View
4 tests/forms/FormScaffolderTest.php
@@ -128,11 +128,13 @@ class FormScaffolderTest_ArticleExtension extends DataExtension implements TestO
static $db = array(
'ExtendedField' => 'Varchar'
);
- function updateCMSFields(&$fields) {
+
+ function updateCMSFields(FieldList $fields) {
$fields->addFieldToTab('Root.Main',
new TextField('AddedExtensionField')
);
}
+
}
DataObject::add_extension('FormScaffolderTest_Article', 'FormScaffolderTest_ArticleExtension');
View
4 tests/forms/FormTest.php
@@ -468,7 +468,7 @@ function doSubmit($data, $form, $request) {
return $this->redirectBack();
}
- function getViewer(){
+ function getViewer($action = null) {
return new SSViewer('BlankPage');
}
@@ -505,7 +505,7 @@ function doSubmit($data, $form, $request) {
return $this->redirectBack();
}
- function getViewer(){
+ function getViewer($action = null) {
return new SSViewer('BlankPage');
}
}
View
12 tests/forms/gridfield/GridFieldDetailFormTest.php
@@ -140,8 +140,8 @@ class GridFieldDetailFormTest_Person extends DataObject implements TestOnly {
'Categories' => 'GridFieldDetailFormTest_Category'
);
- function getCMSFields() {
- $fields = parent::getCMSFields();
+ function getCMSFields($params = null) {
+ $fields = parent::getCMSFields($params);
// TODO No longer necessary once FormScaffolder uses GridField
$fields->replaceField('Categories',
Object::create('GridField', 'Categories', 'Categories',
@@ -162,8 +162,8 @@ class GridFieldDetailFormTest_PeopleGroup extends DataObject implements TestOnly
'People' => 'GridFieldDetailFormTest_Person'
);
- function getCMSFields() {
- $fields = parent::getCMSFields();
+ function getCMSFields($params = null) {
+ $fields = parent::getCMSFields($params);
// TODO No longer necessary once FormScaffolder uses GridField
$fields->replaceField('People',
Object::create('GridField', 'People', 'People',
@@ -184,8 +184,8 @@ class GridFieldDetailFormTest_Category extends DataObject implements TestOnly {
'People' => 'GridFieldDetailFormTest_Person'
);
- function getCMSFields() {
- $fields = parent::getCMSFields();
+ function getCMSFields($params = null) {
+ $fields = parent::getCMSFields($params);
// TODO No longer necessary once FormScaffolder uses GridField
$fields->replaceField('People',
Object::create('GridField', 'People', 'People',
View
10 tests/forms/uploadfield/UploadFieldTest.php
@@ -567,21 +567,21 @@ class UploadFieldTest_Record extends DataObject implements TestOnly {
class UploadFieldTest_FileExtension extends DataExtension implements TestOnly {
- function extraStatics() {
+ function extraStatics($class = null, $extension = null) {
return array(
'has_one' => array('Record' => 'UploadFieldTest_Record')
);
}
- function canDelete() {
+ function canDelete($member = null) {
if($this->owner->Name == 'nodelete.txt') return false;
}
- function canEdit() {
+ function canEdit($member = null) {
if($this->owner->Name == 'noedit.txt') return false;
}
- function canView() {
+ function canView($member = null) {
if($this->owner->Name == 'noview.txt') return false;
}
}
@@ -655,4 +655,4 @@ function submit($data, $form) {
}
-}
+}
View
53 tests/model/AggregateTest.php
@@ -73,13 +73,15 @@ function tearDown() {
* Test basic aggregation on a passed type
*/
function testTypeSpecifiedAggregate() {
+ $foo = $this->objFromFixture('AggregateTest_Foo', 'foo1');
+
// Template style access
- $this->assertEquals(DataObject::Aggregate('AggregateTest_Foo')->XML_val('Max', array('Foo')), 9);
- $this->assertEquals(DataObject::Aggregate('AggregateTest_Fab')->XML_val('Max', array('Fab')), 3);
+ $this->assertEquals($foo->Aggregate('AggregateTest_Foo')->XML_val('Max', array('Foo')), 9);
+ $this->assertEquals($foo->Aggregate('AggregateTest_Fab')->XML_val('Max', array('Fab')), 3);
// PHP style access
- $this->assertEquals(DataObject::Aggregate('AggregateTest_Foo')->Max('Foo'), 9);
- $this->assertEquals(DataObject::Aggregate('AggregateTest_Fab')->Max('Fab'), 3);
+ $this->assertEquals($foo->Aggregate('AggregateTest_Foo')->Max('Foo'), 9);
+ $this->assertEquals($foo->Aggregate('AggregateTest_Fab')->Max('Fab'), 3);
}
/* */
@@ -90,7 +92,7 @@ function testTypeSpecifiedAggregate() {
function testAutoTypeAggregate() {
$foo = $this->objFromFixture('AggregateTest_Foo', 'foo1');
$fab = $this->objFromFixture('AggregateTest_Fab', 'fab1');
-
+
// Template style access
$this->assertEquals($foo->Aggregate()->XML_val('Max', array('Foo')), 9);
$this->assertEquals($fab->Aggregate()->XML_val('Max', array('Fab')), 3);
@@ -106,13 +108,15 @@ function testAutoTypeAggregate() {
* @return unknown_type
*/
function testBaseFieldAggregate() {
+ $foo = $this->objFromFixture('AggregateTest_Foo', 'foo1');
+
$this->assertEquals(
- $this->formatDate(DataObject::Aggregate('AggregateTest_Foo')->Max('LastEdited')),
+ $this->formatDate($foo->Aggregate('AggregateTest_Foo')->Max('LastEdited')),
$this->formatDate(DataObject::get_one('AggregateTest_Foo', '', '', '"LastEdited" DESC')->LastEdited)
);
$this->assertEquals(
- $this->formatDate(DataObject::Aggregate('AggregateTest_Foo')->Max('Created')),
+ $this->formatDate($foo->Aggregate('AggregateTest_Foo')->Max('Created')),
$this->formatDate(DataObject::get_one('AggregateTest_Foo', '', '', '"Created" DESC')->Created)
);
}
@@ -122,13 +126,14 @@ function testBaseFieldAggregate() {
* Test aggregation takes place on the passed type & it's children only
*/
function testChildAggregate() {
-
+ $foo = $this->objFromFixture('AggregateTest_Foo', 'foo1');
+
// For base classes, aggregate is calculcated on it and all children classes
- $this->assertEquals(DataObject::Aggregate('AggregateTest_Foo')->Max('Foo'), 9);
+ $this->assertEquals($foo->Aggregate('AggregateTest_Foo')->Max('Foo'), 9);
// For subclasses, aggregate is calculated for that subclass and it's children only
- $this->assertEquals(DataObject::Aggregate('AggregateTest_Fab')->Max('Foo'), 9);
- $this->assertEquals(DataObject::Aggregate('AggregateTest_Fac')->Max('Foo'), 6);
+ $this->assertEquals($foo->Aggregate('AggregateTest_Fab')->Max('Foo'), 9);
+ $this->assertEquals($foo->Aggregate('AggregateTest_Fac')->Max('Foo'), 6);
}
/* */
@@ -145,35 +150,35 @@ function testCache() {
* Test cache is correctly flushed on write
*/
function testCacheFlushing() {
-
+ $foo = $this->objFromFixture('AggregateTest_Foo', 'foo1');
+ $fab = $this->objFromFixture('AggregateTest_Fab', 'fab1');
+
// For base classes, aggregate is calculcated on it and all children classes
- $this->assertEquals(DataObject::Aggregate('AggregateTest_Foo')->Max('Foo'), 9);
+ $this->assertEquals($fab->Aggregate('AggregateTest_Foo')->Max('Foo'), 9);
// For subclasses, aggregate is calculated for that subclass and it's children only
- $this->assertEquals(DataObject::Aggregate('AggregateTest_Fab')->Max('Foo'), 9);
- $this->assertEquals(DataObject::Aggregate('AggregateTest_Fac')->Max('Foo'), 6);
-
- $foo = $this->objFromFixture('AggregateTest_Foo', 'foo1');
+ $this->assertEquals($fab->Aggregate('AggregateTest_Fab')->Max('Foo'), 9);
+ $this->assertEquals($fab->Aggregate('AggregateTest_Fac')->Max('Foo'), 6);
+
$foo->Foo = 12;
$foo->write();
// For base classes, aggregate is calculcated on it and all children classes
- $this->assertEquals(DataObject::Aggregate('AggregateTest_Foo')->Max('Foo'), 12);
+ $this->assertEquals($fab->Aggregate('AggregateTest_Foo')->Max('Foo'), 12);
// For subclasses, aggregate is calculated for that subclass and it's children only
- $this->assertEquals(DataObject::Aggregate('AggregateTest_Fab')->Max('Foo'), 9);
- $this->assertEquals(DataObject::Aggregate('AggregateTest_Fac')->Max('Foo'), 6);
+ $this->assertEquals($fab->Aggregate('AggregateTest_Fab')->Max('Foo'), 9);
+ $this->assertEquals($fab->Aggregate('AggregateTest_Fac')->Max('Foo'), 6);
- $fab = $this->objFromFixture('AggregateTest_Fab', 'fab1');
$fab->Foo = 15;
$fab->write();
// For base classes, aggregate is calculcated on it and all children classes
- $this->assertEquals(DataObject::Aggregate('AggregateTest_Foo')->Max('Foo'), 15);
+ $this->assertEquals($fab->Aggregate('AggregateTest_Foo')->Max('Foo'), 15);
// For subclasses, aggregate is calculated for that subclass and it's children only
- $this->assertEquals(DataObject::Aggregate('AggregateTest_Fab')->Max('Foo'), 15);
- $this->assertEquals(DataObject::Aggregate('AggregateTest_Fac')->Max('Foo'), 6);
+ $this->assertEquals($fab->Aggregate('AggregateTest_Fab')->Max('Foo'), 15);
+ $this->assertEquals($fab->Aggregate('AggregateTest_Fac')->Max('Foo'), 6);
}
/* */
View
6 tests/model/DataDifferencerTest.php
@@ -62,8 +62,8 @@ class DataDifferencerTest_Object extends DataObject implements TestOnly {
'HasOneRelation' => 'DataDifferencerTest_HasOneRelationObject'
);
- function getCMSFields() {
- $fields = parent::getCMSFields();
+ function getCMSFields($params = null) {
+ $fields = parent::getCMSFields($params);
$choices = array(
'a' => 'a',
'b' => 'b',
@@ -103,4 +103,4 @@ function generateFormattedImage($format, $arg1 = null, $arg2 = null) {
// Skip aktual generation
return $gd;
}
-}
+}
View
2  tests/security/GroupTest.php
@@ -132,7 +132,7 @@ function testCollateAncestorIDs() {
class GroupTest_Member extends Member implements TestOnly {
- function getCMSFields() {
+ function getCMSFields($params = null) {
$groups = DataObject::get('Group');
$groupsMap = ($groups) ? $groups->map() : false;
$fields = new FieldList(
View
10 tests/security/MemberTest.php
@@ -591,29 +591,29 @@ protected function removeExtensions($extensions) {
}
class MemberTest_ViewingAllowedExtension extends DataExtension implements TestOnly {
- public function canView() {
+ public function canView($member = null) {
return true;
}
}
class MemberTest_ViewingDeniedExtension extends DataExtension implements TestOnly {
- public function canView() {
+ public function canView($member = null) {
return false;
}
}
class MemberTest_EditingAllowedDeletingDeniedExtension extends DataExtension implements TestOnly {
- public function canView() {
+ public function canView($member = null) {
return true;
}
- public function canEdit() {
+ public function canEdit($member = null) {
return true;
}
- public function canDelete() {
+ public function canDelete($member = null) {
return false;
}
View
6 tests/view/SSViewerTest.php
@@ -930,7 +930,7 @@ function obj($fieldName, $arguments=null, $forceReturnedObject=true, $cache=fals
}
- function XML_val($fieldName, $arguments = null) {
+ function XML_val($fieldName, $arguments = null, $cache = false) {
if(preg_match('/NotSet/i', $fieldName)) {
return '';
} else if(preg_match('/Raw/i', $fieldName)) {
@@ -940,7 +940,7 @@ function XML_val($fieldName, $arguments = null) {
}
}
- function hasValue($fieldName, $arguments = null) {
+ function hasValue($fieldName, $arguments = null, $cache = true) {
return (bool)$this->XML_val($fieldName, $arguments);
}
}
@@ -1021,4 +1021,4 @@ static function get_argmix() {
return 'z' . implode(':', $args) . 'z';
}
-}
+}
Please sign in to comment.
Something went wrong with that request. Please try again.