Commit Graph

119 Commits

Author SHA1 Message Date
Ingo Schommer
3334eafcb1 API Marked statics private, use Config API instead (#8317)
See "Static configuration properties are now immutable, you must use Config API." in the 3.1 change log for details.
2013-03-24 17:20:53 +01:00
g4b0
4bd235be8b Removed code "ad personam" 2013-02-28 16:50:53 +01:00
Julian Seidenberg
f931b8d326 API Data corruption on Versioned due to lazy loading
Lazy loading no longer loads fields from the versions table when querying. This could lead to incorrect data being displayed if the data on the object and the version it pointed to did not match.

API methods to allow setting of the context of the query that generated the DataObject on that object (used by the lazy loading mechanism to correctly query the Stage, Live, or Versions tables)

See https://github.com/silverstripe/sapphire/pull/1178 for context.
2013-02-14 14:18:10 +01:00
Zauberfisch
54237d5b10 NEW Return $this on setters in DataObject 2013-02-13 18:18:37 +01:00
Ingo Schommer
d289016bc3 DataObject on*() callbacks now consistently invoke on subclasses as well
Before this was only possible for some specific ones, like onBeforeWrite.
This excludes any callbacks with augment*() or update*() naming,
since these are assumed to be on extension only, with a corresponding
base method available on the class itself (e.g. "updateCMSFields()"
vs "getCMSFields()").
2013-02-05 23:28:09 +01:00
Kirk Mayo
e1e64839e2 BUG: Replaced extendedSQL/buildSQL with DataList as per ticket 8183
BUG: Correcting the4 case of a function

Corrcting the case of a function

BUG: replaced deprecated extendedSQL call with DataList->where
2013-01-24 10:36:16 +13:00
Ingo Schommer
c11b3918fc Merge remote-tracking branch 'origin/3.0' into 3.1
Conflicts:
	admin/css/screen.css
	admin/scss/_style.scss
	core/PaginatedList.php
	email/Mailer.php
2013-01-21 11:14:57 +01:00
Ingo Schommer
3a1df46743 Merge pull request #1055 from stojg/bug-relField
BUG Calling DataObject::relField() on a object with an empty relation list
2013-01-11 07:09:55 -08:00
Sam Minnee
f4efaeefa7 FIX: Fix DataObject::get_one() when the classname is passed with improper casing. 2013-01-11 12:20:57 +13:00
Ingo Schommer
f07ad307e4 API Removed non-functional $join argument from DataObject::get() and other APIs
See 68bb74820
2013-01-09 18:28:55 +01:00
Stig Lindqvist
22efd3848e BUG Calling DataObject::relField() on a object with an empty relation list
This causes a 'Fatal error: Call to a member function hasMethod() on a non-object'.

This can happen when displaying a field in a gridfield on a belongs_to relationship.
2012-12-19 16:47:07 +13:00
Hamish Friedlander
27113f82c3 API Make DataList and ArrayList immutable
In 3.0 there was some confusion about whether DataLists and ArrayLists
were mutable or not. If DataLists were immutable, they'd return the result, and your code
would look like

  $list = $list->filter(....);

If DataLists were mutable, they'd operate on themselves, returning nothing, and your code
would look like

 $list->filter(....);

This makes all DataLists and ArrayList immutable for all _searching_ operations.
Operations on DataList that modify the underlying SQL data store remain mutating.

- These functions no longer mutate the existing object, and if you do not capture the value
returned by them will have no effect:

  ArrayList#reverse
  ArrayList#sort
  ArrayList#filter
  ArrayList#exclude

  DataList#dataQuery (use DataList#alterDataQuery to modify dataQuery in a safe manner)
  DataList#where
  DataList#limit
  DataList#sort
  DataList#addFilter
  DataList#applyFilterContext
  DataList#innerJoin
  DataList#leftJoin
  DataList#find
  DataList#byIDs
  DataList#reverse

- DataList#setDataQueryParam has been added as syntactic sugar around the most common
cause of accessing the dataQuery directly - setting query parameters

- RelationList#setForeignID has been removed. Always use RelationList#forForeignID
when querying, and overload RelationList#foreignIDList when subclassing.

- Relatedly,the protected variable RelationList->foreignID has been removed, as the ID is
now stored on a query parameter. Use RelationList#getForeignID to read it.
2012-12-14 13:30:35 +13:00
Simon Welsh
b0121b541c Add codesniffer that ensures indentation is with tabs. 2012-12-12 17:33:31 +13:00
Simon Welsh
fc5dd2994c Add codesniffer that ensures indentation is with tabs. 2012-12-12 00:12:11 +13:00
Simon Welsh
bbc4443af7 NEW: Allows setting of has_many and many_many relations before writing
Adds a new wrapper list, UnsavedRelationList, that maintains the relations until
writing, where it is converted into the correct RelationList.
2012-11-28 09:37:08 +13:00
jean
fbfff8df28 FIX 7934 When lazy loading fields respect version of the record 2012-11-27 17:31:45 +01:00
Ingo Schommer
15a687f1e7 Merge remote-tracking branch 'origin/3.0' 2012-11-23 15:31:08 +01:00
Ingo Schommer
aa72425e84 Fixed PHPUnit assertions for incomplete tests in core
Avoid PHPUnit throwing "test didn't run any assertions"
notices in PHP. If nothing else, it keeps test output
looking less broken by default, making it more likely
that actual errors do get noticed.
2012-11-23 15:16:39 +01:00
Ingo Schommer
c55c7c33f8 Merge branch '3.0'
Conflicts:
	admin/code/CMSProfileController.php
	composer.json
	tests/model/DataObjectTest.php
2012-11-22 23:51:28 +01:00
Sean Harvey
e1c5f084ad Removing deprecated container class argument to DataObject::get() 2012-11-15 14:43:20 +13:00
Sean Harvey
3a198c32d5 Removing deprecated DataObject::databaseFields() and customDatabaseFields()
Use database_fields() and custom_database_fields() instead
2012-11-15 14:43:19 +13:00
Sean Harvey
e4088feb46 Removing deprecated instance_get_one() and instance_get()
Use DataList API instead
2012-11-15 14:43:19 +13:00
Sean Harvey
a8d779b4de Removing deprecated DataObject::buildDataObjectSet()
Use DataList API instead
2012-11-15 14:43:19 +13:00
Sean Harvey
dde820d87d Extend deprecation of DataObject::Aggregate() and RelationshipAggregate() 2012-11-15 14:43:19 +13:00
Sean Harvey
0db33f7f04 Removing DataObject::buildSQL() and extendedSQL(), use DataList instead 2012-11-15 14:43:19 +13:00
Sean Harvey
651d4b3d41 Removing DataObject::getAllFields(), use toMap() instead 2012-11-15 14:43:18 +13:00
Sean Harvey
5f852ae7bc Removing deprecated DataObject::setComponent()
This is not used internally any longer
2012-11-15 14:43:18 +13:00
Sean Harvey
f69c2b0495 Improve performance of DataObject::db() with caching
In a usual CMS request, DataObject::db() is called potentially
thousands of times, calling Config::get() constantly for the same
uninherited statics, which is slow. This improves performance
by caching those into DataObject::$_cache_db
2012-11-08 10:38:16 +13:00
Sean Harvey
fdcd7a2e60 Fixing performance of DataObject::custom_database_fields()
On sites with lots of modules, and pages with plenty of database
queries, DataObject::custom_database_fields() can be called
thousands of times, and slow down page render times. This fixes
it so the fields are cached by class in a static variable, and
are cleared when reset() is called on the DataObject.
2012-11-07 17:23:36 +13:00
Simon Welsh
d8c920285c Merge pull request #917 from TheFrozenFire/feature-DataObjectFromStdClass
API: DataObject::__construct() now accepts stdClass for $record
2012-11-03 02:16:07 -07:00
Justin Martin
f2a709d849 BUG: DataObject::write overwrites Created on first write 2012-11-02 20:37:17 -07:00
Justin Martin
a651d730f2 BUG: DataObject::__construct() now accepts stdClass for $record 2012-11-01 16:57:07 -07:00
Sean Harvey
f6a90467e4 Merge branch '3.0' 2012-10-15 10:10:01 +13:00
Sean Harvey
bc345803d5 BUG Fixing model not being set before populateDefaults()
In cases where a getter on a DataObject calls getComponent() or
other relational getter, $this->model won't have been set at
this point, and a fatal error is triggered.

This fixes it so $this->model is set *before* populateDefaults()
in DataObject::__construct() and the getters can operate normally.
2012-10-12 09:57:11 +13:00
Ingo Schommer
56f7ce1dcf Merge remote-tracking branch 'origin/3.0'
Conflicts:
	control/Cookie.php
	control/Director.php
	control/HTTPResponse.php
	model/Database.php
	model/MySQLDatabase.php
	model/SQLQuery.php
	view/Requirements.php
	view/SSViewer.php
2012-10-03 16:16:19 +02:00
Sam Minnee
1f7fc1f76a FIX Remove instances of lines longer than 120c
The entire framework repo (with the exception of system-generated files) has been amended to respect the 120c line-length limit.  This is in preparation for the enforcement of this rule with PHP_CodeSniffer.
2012-09-30 17:18:13 +13:00
Simon Welsh
1e629f4585 Merge branch '3.0'
Conflicts:
	control/Cookie.php
	control/Director.php
	dev/Profiler.php
	view/Requirements.php
2012-09-21 14:56:56 +12:00
Ingo Schommer
e2f073f38a Method visibility according to coding conventions 2012-09-20 10:46:59 +02:00
Sean Harvey
9c2be0f025 Merge branch '3.0' 2012-09-17 15:16:52 +12:00
stozze
499b7c9ff9 BUGFIX Fix to prevent unintended results from getComponentsQuery(...)
Wrapped $filter inside parentheses to prevent unintended results if $filter contains "OR".
2012-09-14 18:31:37 +03:00
Hamish Friedlander
df5a9e087d FIX Cache ClassName enum so we dont query DB every call 2012-09-12 11:14:59 +12:00
Ingo Schommer
1088d044c5 Merge remote-tracking branch 'origin/3.0'
Conflicts:
	.travis.yml
2012-09-07 17:21:41 +02:00
Sam Minnée
57ad36e11d Merge pull request #750 from silverstripe-rebelalliance/open/5971
FIX If ClassName read from DB doesnt exist, dont break
2012-08-29 22:48:31 -07:00
Hamish Friedlander
2f00884e79 FIX If ClassName read from DB doesnt exist, dont break
We know the subclass of a record by its ClassName value, but code changes
might have meant that class no longer exists. We used to just break,
but this patch overrides the apparent value of ClassName to be
one that exists in that situation
2012-08-30 11:02:50 +12:00
Ingo Schommer
f070f971cf BUG Allow custom getters in summaryFields() (fixes #7788)
Regression from ca1d38dffd
2012-08-29 13:42:29 +02:00
Ingo Schommer
4598cc02aa Merge pull request #659 from ajshort/instance-search-filters
BUG: Allow using instances for search filters.
2012-08-16 13:07:35 -07:00
Ingo Schommer
ca1d38dffd BUG Localize DataObject->summaryFields() 2012-08-10 00:14:02 +02:00
Hamish Friedlander
367c49d6b1 API DataObject#relField now checks for method on model before property 2012-07-27 14:44:38 +12:00
Hamish Friedlander
36c8fc2e93 Merge pull request #660 from silverstripe-rebelalliance/trac/7673
API Prep ArrayList, DataList, forForeignID for immutability in 3.1 per 7673
2012-07-22 21:30:53 -07:00
Hamish Friedlander
b7691077cf API Prep forForeignID for immutability in 3.1 per 7673 2012-07-23 10:31:47 +12:00