Commit Graph

461 Commits

Author SHA1 Message Date
Ingo Schommer
f3c0669fec Merge remote-tracking branch 'origin/3.0' into 3.1
Conflicts:
	_config/uploadfield.yml
	css/UploadField.css
	forms/UploadField.php
	scss/UploadField.scss
	templates/UploadField.ss
	tests/forms/uploadfield/UploadFieldTest.php
2013-01-11 10:02:39 +01:00
Ingo Schommer
f922321287 ManyManyList->getExtraFields()
Needed for introspection for many_many relationships
without knowing the name of the relationship,
meaning we can't use DataObject->many_many_extraFields().
2013-01-10 22:35:20 +01: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
Ingo Schommer
79997477b3 Merge remote-tracking branch 'origin/3.0' into 3.1
Conflicts:
	model/DataList.php
2013-01-08 17:16:09 +01:00
Sean Harvey
baaa270ceb Merge pull request #1032 from halkyon/datalist_filter_docs
Improve class naming and docs for DataList::applyFilterContext()
2013-01-06 17:23:43 -08:00
g4b0
e53280c650 BUG SQLQuery::aggregate() with limit, groupBy and orderBy (fixes #8148) 2012-12-21 15:20:59 +01:00
Ingo Schommer
8ec3641e60 Merge remote-tracking branch 'origin/3.0' into 3.1
Conflicts:
	admin/javascript/LeftAndMain.FieldHelp.js
	lang/en.yml
	model/URLSegmentFilter.php
2012-12-21 15:04:17 +01:00
Sean Harvey
aa3b358469 Adding test for SortColumn to SQLQueryTest
Mostly for the benefit of MSSQLDatabase which is having problems
with subselects and alias functions.
2012-12-20 15:52:46 +13:00
Ingo Schommer
e4cb25b831 Merge pull request #1058 from chillu/pulls/remove-testsession
API Remove dev/tests/startsession etc, use new "testsession" module
2012-12-19 11:42:56 -08:00
Ingo Schommer
86940aa684 Made hyphen escaping clearer in FileNameFilter and URLSegmentFilter
Does not actually change behaviour, but ensures that the hyphen
is not interpreted as a range identifier should it be placed
between two characters which PCRE regards as "rangeable".
2012-12-19 17:30:28 +01:00
Ingo Schommer
2e1a5081fa API Remove dev/tests/startsession etc, use new "testsession" module
Removed commands: startsession, endsession, sessionloadyml, setdb, emptydb.
See https://github.com/silverstripe-labs/silverstripe-testsession
2012-12-19 16:05:37 +01:00
Mateusz Uzdowski
d5a1c3d99a BUG SS has problems handling + in URLs. Filter them out.
+ has a special meaning in the URLs so overall it's a good idea to
strip them out. Otherwise they would need to appear in their ugly url
encoded form "%2B".

Refer: http://open.silverstripe.org/ticket/7929
2012-12-18 09:44:47 +01:00
Damian Mooyman
b01b91ffc3 BUG When selecting stage_unique from Versioned the augmentSQL function would permanantly alter the DataQuery while doing a recursive augmentSQL. This fix correctly maintains the correct Versioned.mode so that subsequent calls to this function exhibit the same expected behaviour. 2012-12-18 10:11:30 +13:00
Damian Mooyman
6aa16e1f01 BUG Test case for versioned now correctly checks IDs returned from Versioned::get_including_deleted
BUG Issue with deleted records not being queried properly.
API DataQuery::expressionForField no longer requires a second parameter. Rather the query object is inferred from the DataQuery itself. This should improve consistency of use of this function.
2012-12-17 17:15:26 +13:00
Ingo Schommer
d13c53fda6 Merge remote-tracking branch 'origin/3.0' into 3.1
Conflicts:
	tests/model/DataQueryTest.php
2012-12-14 10:57:28 +01:00
Hamish Friedlander
bd59f842f0 FIX Make sure you can only remove items from a DataList that are actually in it 2012-12-14 13:30:36 +13:00
Hamish Friedlander
9979b11b59 FIX Make sure ArrayList#limit uses clone so for subclasses it returns instances of same subclass 2012-12-14 13:30:35 +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
Sean Harvey
c23df511cd Improve class naming and docs for DataList::applyFilterContext() 2012-12-14 12:06:25 +13:00
Ingo Schommer
c6b1d4aa6b API Storing alternative DB name in cookie rather than session
Session is not initialized by the time we need to use
the setting in DB::connect(). Cookie values get initialized
automatically for each request.

Tightened name format validation to ensure it can only
be used for temporary databases, rather than switching
the browser session to a different production database.

Encrypting token for secure cookie usage.
Added dev/generatesecuretoken to generate this token.
Not storing in YML config directly because of web access issues.
2012-12-13 23:21:48 +01:00
Ingo Schommer
7e4629073a NEW Date->Ago() with "less than a minute" support 2012-12-13 19:01:27 +01:00
Ingo Schommer
2e9b5e9221 Merge branch 'orm-join-bug' of git://github.com/stojg/sapphire into stojg-orm-join-bug 2012-12-12 15:53:19 +01: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
Ingo Schommer
e6e47cb35e API DB-specific comparisators in SearchFilter and DataList
Too many edge cases to leave this up to datalists,
particularly now that we introduced enforced
case sensitivity/insensitivity in the ORM APIs.
2012-12-11 12:04:48 +01:00
Andrew O'Neil
9d74c99e08 BUGFIX: ArrayList now discards keys of the array passed in and keeps the numerically indexed array sequential.
This fixes FirstLast and EvenOdd in templates, and makes ArrayList more consistent, as several methods already discarded the keys.
2012-12-11 10:12:00 +01:00
stojg
efa9ff9b08 API: Queries added by DataList::addInnerJoin() and DataList::leftJoin() come after the base joins, not before.
This bug will surface when using the ORM and adding an join to DataList
where a DataObject inherits another DataObject.

If you for example want to restrict the number of pages that only have a
related Staff object:

    $list = DataList::create('Page')
		->InnerJoin('Staff', '"Staff"."ID" = "Page"."StaffID");

This will create a SQL query where the INNER JOIN is before the
LEFT JOIN of Page and SiteTree in the resulting SQL string. In MySQL
and PostgreSQL this will create an invalid query.

This patch solves the problem by sorting the joins.
2012-12-11 11:04:29 +13:00
Ingo Schommer
fa84c2d705 Merge remote-tracking branch 'origin/3.0' 2012-12-10 17:50:43 +01:00
Simon Elvery
205ee42110 BUGFIX Make sure a message is set on ValidationException objects. 2012-12-05 12:18:36 +10:00
Ingo Schommer
a108f67476 Merge pull request #922 from simonwelsh/rellist-presave
NEW: Allows setting of has_many and many_many relations before writing
2012-12-04 01:25:15 -08:00
Ingo Schommer
fa2057bcd9 Merge remote-tracking branch 'origin/3.0'
Conflicts:
	search/FulltextSearchable.php
2012-11-30 14:25:06 +01:00
Ingo Schommer
3f67404a8a Revert "BUGFIX: ArrayList now discards keys of the array passed in and keeps the numerically indexed array sequential."
This reverts commit b6017a7c90.
It breaks SelectionGroup, and its most prominent usage,
the "add page" dialog.
2012-11-30 14:24:03 +01:00
João Martins
cc3e500f82 return $this, for do things like this: new DropdownField('XPTOName', 'XPTO Label', XPTOModel::get()->map("ID", "Name")->unshift(0,'- Select -'))
This does not break anything and makes things more natural
2012-11-30 01:37:36 +00: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
477cf6b793 Removing redundant DatabaseAdmin::testinstall()
The original intention of this method was to be a rewrite
check by the installer, but it doesn't belong in
DatabaseAdmin, nor is it used by the installer anymore,
since the rewrite test is done by the installer directly.
2012-11-22 17:07:28 +13:00
Sean Harvey
8168a7db09 Remove deprecated DBField::create(), use create_field() instead 2012-11-16 14:36:26 +13:00
Sean Harvey
b3d5b68019 Remove deprecated SQLQuery::setWhere() multiple arguments 2012-11-16 14:35:30 +13:00
Sean Harvey
a2bd378d46 Remove deprecated ArrayList::getRange(), use limit() instead 2012-11-16 14:35:05 +13:00
Damian Mooyman
76c63fe4a4 BUG Fixed issue with SQLQuery::lastRow crashing on empty set. Added test cases for lastRow and firstRow.
Quoted table / column names to make test cases work in postgres

BUG Fixed issue with SQLQuery::lastRow crashing on empty set. Added test cases for lastRow and firstRow.

Quoted table / column names to make test cases work in postgres

Merge branch '3.0-sqlquery-lastrow-fix' of github.com:tractorcow/sapphire into 3.0-sqlquery-lastrow-fix
2012-11-16 13:27:51 +13:00
Andrew O'Neil
b6017a7c90 BUGFIX: ArrayList now discards keys of the array passed in and keeps the numerically indexed array sequential.
This fixes FirstLast and EvenOdd in templates, and makes ArrayList more consistent, as several methods already discarded the keys.
2012-11-16 09:39:01 +13: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