Commit Graph

490 Commits

Author SHA1 Message Date
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
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
3108dea2c2 Removing deprecated DataList::limit() arguments
Use 2 arguments, the first being limit and the second offset instead.
2012-11-15 14:43:18 +13:00
Sean Harvey
68bb74820a Removing join() on DataList/DataQuery
Use leftJoin() or innerJoin() instead
2012-11-15 14:43:18 +13:00
Sean Harvey
5c983a25f0 emove deprecated StringField::Lower() and Upper() methods
Use LowerCase() and UpperCase() instead
2012-11-15 14:43:16 +13:00
Sean Harvey
9e7bdb3e93 Removing deprecated Text::EscapeXML(), use DBField->XML() instead 2012-11-15 14:43:16 +13:00
Sean Harvey
4c3b804fa5 Remove deprecated ComponentSet, use ManyManyList or HasManyList instead 2012-11-15 14:43:12 +13:00
Sean Harvey
0a046af932 Remove deprecated DataObjectDecorator, use DataExtension instead 2012-11-15 14:43:12 +13:00
Sean Harvey
a371db4300 Remove deprecated DataObjectSet, use DataList or ArrayList instead 2012-11-15 14:43:12 +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
Justin Martin
d24b586830 NEW: Enable multiple image manipulation back-ends on the Image class 2012-11-03 19:38:09 -07: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
Simon Welsh
123a742872 Merge pull request #920 from TheFrozenFire/feature-SSListEach
API: Add new method "each" to SS_List
2012-11-03 02:10:23 -07:00
Simon Welsh
5a793990d8 Merge pull request #921 from TheFrozenFire/bug-DataObjectCreated
BUG: DataObject::write overwrites Created on first write
2012-11-03 02:08:35 -07:00
Justin Martin
f2a709d849 BUG: DataObject::write overwrites Created on first write 2012-11-02 20:37:17 -07:00
Justin Martin
26e5afc0c4 NEW: Add new method "each" to SS_List and core implementors thereof 2012-11-02 18:21:02 -07:00
Simon Welsh
8a0f234acf Merge pull request #870 from chillu/pulls/datalist-filterany
NEW DataList->filterAny()
2012-11-02 16:17:48 -07:00
Justin Martin
a651d730f2 BUG: DataObject::__construct() now accepts stdClass for $record 2012-11-01 16:57:07 -07:00
Ingo Schommer
efabde1416 Merge remote-tracking branch 'origin/3.0'
Conflicts:
	admin/css/screen.css
	admin/scss/_style.scss
	security/Member.php
2012-10-30 17:52:49 +01:00
Sean Harvey
ac489509be BUG Fixing "+" characters being replaced with whitespace
SS_HTMLValue::getContent() uses urldecode() on the content returned
by saveHTML() -- this was done to fix encoded HTML entities like
square brackets, which are used by shortcodes. Unfortunately, this
also removes valid characters like "+" from the content.

This fixes it so square bracket entities are decoded *only*, and
leaves everything else as-is.
2012-10-24 14:44:14 +13:00
Simon Welsh
bedb579b07 Merge branch '3.0' 2012-10-23 15:21:20 +13:00
icecaster
8a7f9ede97 fixed empty string always on scaffolded enum fields 2012-10-17 12:30:05 +13:00
Mateusz Uzdowski
8eb0fa91bd API Add the ability to query if the schema update is in progress.
The specific situation where this is useful is where populateDefaults on
DataObjects needs to query the database. This will break the dev/build
when it tries to create the object via singleton - the query will not be
able to be executed if the table is not there or its schema has changed.

For an example of such use case see Translatable::populateDefaults.
2012-10-17 11:45:21 +13:00
Ingo Schommer
1181ba089a Merge remote-tracking branch 'origin/3.0'
Conflicts:
	.travis.yml
2012-10-16 10:26:04 +02:00
Will Rossiter
9eb4af37bf Merge pull request #878 from chillu/pulls/alternative-db-session
BUG Using Session::set() for DB::set_alternative_database_name()
2012-10-15 22:34:05 -07:00
Sean Harvey
a171c7e4b0 BUG Fixing regression in 26d70d6fca with formatted output in SS_HTMLValue
If formatOutput is set to TRUE, then the regexes in getContent()
will not match the newlines, and the output will include html, body
and meta tags. Introduce a few new tests to ensure the output is
correct, and fix the regex.
2012-10-16 11:59:30 +13:00
Ingo Schommer
35da873ad9 BUG Using Session::set() for DB::set_alternative_database_name()
Setting session directly through $_SESSION relies on
session_autostart which might not be set on every environment,
and isn't consistent with other framework use.
2012-10-15 20:40:38 +02:00
Sean Harvey
f6a90467e4 Merge branch '3.0' 2012-10-15 10:10:01 +13:00
Ingo Schommer
5be3a4c35a NEW DataList->filterAny() 2012-10-12 15:24:25 +02: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
Simon Welsh
c49f7566c3 API Allow use of :not, :nocase and :case modifiers to SearchFilters.
More modifiers can be added to each class as desired.
2012-10-10 10:26:47 +13:00
Simon Welsh
2faf7d112d API Allow using SearchFilters in DataList::exclude() 2012-10-09 14:47:22 +13:00
Ingo Schommer
fb5e488103 Line length fixes 2012-10-03 18:11:31 +02: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
323fd4aa0f FIX: Fixed ef81318aea for PostgreSQL by quoting fields. 2012-10-03 15:34:39 +13:00
Sam Minnee
4e1b6af10f Fixed long line. 2012-10-03 15:15:21 +13:00
Ingo Schommer
ef81318aea BUG Retaining join extraFields on ManyManyList->add() 2012-10-03 14:58:28 +13: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
Sean Harvey
e4ab02e1c3 Merge branch '3.0' 2012-09-27 10:39:31 +12:00
Sean Harvey
92e62ebb91 Merge pull request #812 from chillu/pull/sitetree-meta-removal
Removed SiteTree.MetaTitle and MetaKeywords usage
2012-09-24 21:15:20 -07:00
Sean Harvey
0b17e0036a BUG Fixing percent encoding issues with saveHTML 2012-09-23 22:28:42 +12:00
Ingo Schommer
5df519c6b5 Removed SiteTree.MetaTitle and MetaKeywords usage 2012-09-21 11:31:24 +02:00
Simon Welsh
6d696d506f API Allow subgroups in the WHERE clause of a Data/SQLQuery
Adds three extra methods to Data/SQLQuery query that allow for starting
a disjunctive subgroup, a conjunctive subgroup and for ending a subgroup.

Database::sqlWhereToString() now builds up the WHERE clause one by one
instead of with a straight implode. Uses a stack to know which conenctive
to use.
2012-09-21 14:59:47 +12: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
e44a3558dd Merge pull request #793 from halkyon/htmlvalue_parsing_fixes
BUG HtmlEditorField doesn't save HTML fragments in HTMLValue correctly
2012-09-20 02:09:36 -07:00
Ingo Schommer
e2f073f38a Method visibility according to coding conventions 2012-09-20 10:46:59 +02:00
Sean Harvey
26d70d6fca BUG HtmlEditorField doesn't save HTML fragments in HTMLValue correctly
The issue was raised in #7628, where an anchor tag was being changed from
<a name="anchor"></a> to <a name="anchor"/> by SS_HTMLValue, when
HtmlEditorField::saveInto() parses the HTML fragments.

This is because SS_HTMLValue uses DOMDocument::saveXML(), which is fine
for saving an XML document, but not suitable for HTML. This fix changes
that to use DOMDocument::saveHTML() instead.
Note that we can't use the parameter to saveHTML() for selecting a single
node only, as that's only supported in PHP 5.3.6+, SilverStripe 3.0 supports
PHP 5.3.2 as a minimum. The workaround for this shortcoming is to replace
unncessary output by DOMDocument with a regular expression.
2012-09-19 11:39:01 +12:00
Sam Minnée
95dbad6195 Merge pull request #796 from stozze/3.0-bugfix
BUGFIX Fix to prevent unintended results from getComponentsQuery(...)
2012-09-17 18:26:44 -07:00
Sam Minnée
651f45e0e4 Merge pull request #782 from tractorcow/3.0-index-generation-fixes
FIXED: Generation of table indexes
2012-09-16 23:43:17 -07: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
Ingo Schommer
b0fc1cb16a Merge branch '3.0.2' into 3.0 2012-09-12 11:05:50 +02:00
Hamish Friedlander
df5a9e087d FIX Cache ClassName enum so we dont query DB every call 2012-09-12 11:14:59 +12:00
Damian Mooyman
30e15d11a7 FIXED: Generation of tables with fulltext indexes now no longer incorrectly thinks that all fulltext indexes have changed.
ADDED: Test cases correctly checking for changes (and no changes) to the data model for both fields and indexes.
FIXED: References to indexes throughough the code that probably should have quoted field names. This prevents a lot of 'spam' during dev build. This includes an updated FulltextSearchable test case.
2012-09-11 12:53:08 +12:00
Ingo Schommer
1088d044c5 Merge remote-tracking branch 'origin/3.0'
Conflicts:
	.travis.yml
2012-09-07 17:21:41 +02:00
Simon Welsh
a6f3e9f9eb Corrects replacement method name in deprecation notice. 2012-09-04 15:25:53 +12:00
Ingo Schommer
fb6efb9d21 BUG Calling extraStatics() with args (regression from fa37c448) 2012-09-02 13:55:35 +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
Simon Welsh
78fdcc580b API DataList->leftJoin()/innerJoin() args no longer escaped
The table name in the join was being escaped, though table
names aren't escaped anywhere else. This breaks
namespaced classes, which rely on unescaped backslashes.
2012-08-29 11:54:42 +02:00
Hamish Friedlander
cc2e250719 NEW Allow querying if a field exists on a table 2012-08-29 15:08:48 +12:00
Ingo Schommer
a8f335360b Merge remote-tracking branch 'origin/3.0' 2012-08-27 09:25:59 +02:00
Sean Harvey
674b52b4f7 Merge pull request #734 from silverstripe-rebelalliance/trac/7799
API Reverse config extra statics control flow
2012-08-26 14:24:05 -07:00
Sam Minnee
f1c021ff22 Merge branch '3.0' 2012-08-23 12:56:17 +12:00
Sam Minnee
87685eefdd BUGFIX: Fix Versioned's stage_unique mode on PostgreSQL. 2012-08-23 12:56:06 +12:00
Sam Minnee
824afffd2e Merge branch '3.0' 2012-08-23 12:39:41 +12:00
Sam Minnee
ed0341e82f BUGFIX: Ensure that subtracting a sorted DataList works. 2012-08-23 12:38:54 +12:00
Sam Minnee
296ee1fa0f BUGFIX: Add double quotes to index columns for more reliable DB-schema management. 2012-08-23 12:38:44 +12:00
Sam Minnee
dd302a68a7 BUGFIX: Ensure that all_versions are sorted explicitly for better cross-db behaviour. 2012-08-23 12:38:37 +12:00