Commit Graph

401 Commits

Author SHA1 Message Date
Ingo Schommer
79cf1faf53 Merge remote-tracking branch 'origin/2.4' into 3.0
Conflicts:
	README.md
	composer.json
	docs/en/installation/from-source.md
	docs/en/misc/contributing.md
	model/Database.php
2013-05-17 00:37:30 +02:00
Sam Minnee
eb583c5f14 NEW: Added DataObject::getQueriedDatabaseFields() as faster alternative to toMap()
API: CompositeDBField::setValue() may be passed an object as its second argument, in addition to array.

These changes provide a 15% - 20% performance improvement, and as such justify an small API change in the 3.0 branch. It will likely affect anyone who has created their own composite fields, which is fortunately not all that common.
2013-04-21 13:39:11 +12:00
Ingo Schommer
933fbf8ea4 l10n key to make "yes" and "no" translatable (see #1749) 2013-04-12 01:11:24 +02:00
Ingo Schommer
e26090a840 Avoid double encoding Date->Formati18n()
See https://github.com/silverstripe/sapphire/pull/1314
Thanks to @ivoba
2013-04-09 11:04:45 +02:00
Sam Minnée
a6929f11b2 Merge pull request #1185 from chillu/pulls/augment-lazy-versioned
Versioned lazy loading fixes (backport from 3.1)
2013-04-08 16:04:50 -07:00
Joseph Madden
df4d7428fa FIX Saving of custom meta tags (fixes #8288)
This should allow custom meta tags to be saved in the admin panel.

Also, if you use html5 video or audio the source sub tag
would have been stripped two these are all the tags that may be empty
and are valid.
2013-04-02 12:02:56 +02:00
Ingo Schommer
dd6f33ab37 FIX Respect tree node limits, fix search result node display
- Renamed $minNodeCount to more accurate $nodeCountThreshold
- The $minNodeCount attribute wasn't properly respected
during actual querying, so SilverStripe would always traverse
the entire tree (and load all objects into memory),
before then marking nodes as "unexpanded", which prevents
them from actually being rendered.
- Fixes nodes on search results to be expanded by default
- Fixes nodes on search results to correctly ajax-expand
2013-03-19 00:05:14 +01:00
Ingo Schommer
0c6ac1960e Fixed whitespace usage 2013-02-18 15:43:52 +01:00
Ingo Schommer
92458d9f43 Fixed line lengths 2013-02-18 14:41:49 +01:00
Julian Seidenberg
10199f908a 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:28:42 +01:00
jean
e2bf9649f3 FIX 7934 When lazy loading fields respect version of the record 2013-02-14 14:27:44 +01:00
Ingo Schommer
a1beda14d1 Removed explicit pass-by-ref in DataExtension->validate()
Same fix as be97535b for 3.1. Makes the method signature
more consistent with other DataExtension methods,
and comply with its subclass implementation in
Hierarchy->validate(). See accbd7f1e2 for more comments.
2013-02-06 19:00:23 +01:00
Daniel Hensby
f0621cdd91 FEATURE: Added ability to query size of Varchar
This allows a developer to programatically access the size of the DB Varchar field. This allows us to be a bit more DRY and to define the size in one place and limit TextFields to the same value
2013-02-05 18:41:11 +00:00
Ingo Schommer
accbd7f1e2 Revert "FIX: Strict error warnings on DataExtension"
This reverts commit 1960df8bc3.

Revert "FIX: validate doesn't take var by reference"
This reverts commit 866bb0713b.

@ajshort has changed the method signatures in 1f6f7f08. While it wasn't explicitly noted in the commit message, I think its a good change - objects like a FieldList are always passed by reference in PHP, no need to declare that behaviour.
2013-02-04 17:23:11 +01:00
Michael Andrewartha
866bb0713b FIX: validate doesn't take var by reference
Got a bit carried away, validate doesn't take the var by reference
2013-02-04 12:42:39 +00:00
Michael Andrewartha
1960df8bc3 FIX: Strict error warnings on DataExtension
PHP is throwing strict error warnings when overriding the
updateCMSFields and other functions in custom DataExtensions due to
the fact that the abstract class doesn't declare the variables should
be passed by reference
2013-02-04 12:37:53 +00:00
ajshort
fd71a3d55e Consistently exposed ManyManyList information through getters. 2013-01-31 15:21:46 +01:00
Sam Minnee
c4dde9022d NEW: Allow hashes to be passed as ArrayList items; the will be turned into ArrayData objects. 2013-01-29 18:03:49 +01:00
Sam Minnee
1e1df8c43e BUGFIX: Improved detection of empty HTMLText fields. 2013-01-29 18:03:47 +01:00
Mateusz Uzdowski
7026a488e6 BUGFIX: for date manipulation use the SS_Datetime::now, otherwise it does not respect the mock date. 2013-01-29 17:23:23 +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
Ingo Schommer
4f39af1a85 Merge pull request #1090 from sminnee/fix-get-one-case
FIX: Fix DataObject::get_one() when the classname is passed with imprope...
2013-01-11 01:42:29 -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
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
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
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
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
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
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
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
fc5dd2994c Add codesniffer that ensures indentation is with tabs. 2012-12-12 00:12:11 +13: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
Simon Elvery
205ee42110 BUGFIX Make sure a message is set on ValidationException objects. 2012-12-05 12:18:36 +10: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
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
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
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
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
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
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
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
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