Commit Graph

615 Commits

Author SHA1 Message Date
Serge Latyntcev 0cf5d4cbe2 Merge branch '4.3' into 4.4 2019-10-18 15:58:13 +13:00
Serge Latyntcev 46b9530d88 PSR2 linting fixes 2019-10-18 15:31:39 +13:00
Michal Kleiner bcbf90a837 NEW Introduce supported database transaction mode check 2019-09-16 14:44:15 +12:00
Robbie Averill aa6b244db9 Merge branch '4.4' into 4 2019-09-13 18:11:46 -07:00
Robbie Averill 592ab6abc1 Merge branch '4.3' into 4.4 2019-09-13 18:11:34 -07:00
Maxime Rainville 591b88a9bc BUG Allow infinite loop when calling DataObject::writeComponent() recursively 2019-09-10 14:15:28 +12:00
Robbie Averill 45f86658ca Merge branch '4.4' into 4 2019-08-14 09:31:05 +12:00
Robbie Averill 4b44272367 Merge branch '4.3' into 4.4 2019-08-14 09:30:53 +12:00
Robbie Averill d63e4b520c Merge branch '4.2' into 4.3 2019-08-14 09:30:41 +12:00
Will Rossiter 82cc8b40a4 Create SearchContext via Injector (#9156) 2019-08-01 14:39:58 +12:00
UndefinedOffset 40cd66852e BUGFIX: Fixed issue where multiple relationship sort order columns would be lost in favor of only the last relationship column in the sort order 2019-07-26 11:54:10 -03:00
Simon Gow 22b514c421 #9114 - DBText::ContextSummary() cuts line breaks
ContextSummary() was cutting the HTML which was added by nl2br because
it expected plain text elements as it's stripping and replacing text.
Instead this fix changes the behaviour to apply the nl2br after the text
changes have been made. That way we can't cut anything in the middle of
a HTML tag, but new lines, or paragraphs are replaced by BRs after,
should they exist.

- Added tests to ensure text is not cut in the middle of a sentence.
- Added test to ensure that <br>'s are added in the correct place should
the summary span between new lines.
2019-07-19 12:43:20 +12:00
Serge Latyntcev 29a663c65d Merge branch '4.4' into 4 2019-07-15 09:24:49 +12:00
Serge Latyntcev d667d64f13 Merge branch '4.3' into 4.4 2019-07-15 09:18:17 +12:00
Guy Marriott ec66d366d2
NEW: Deprecated PDO in favour of native drivers (#9052)
NEW: Deprecated PDO in favour of native drivers
2019-07-08 12:41:13 +12:00
Robbie Averill 844d2ef134 NEW DBDate and DBDatetime now support modify() with a strtotime() style adjustment string (#9105) 2019-07-05 15:57:23 +12:00
Sam Minnee 404366909e FIX: Fix MysqlStatement::rewind()
Its implementation is more naive than Query’s and leads to unnecessary
seek()ing. This causes issues with the previous commit.
2019-07-03 14:28:31 +12:00
Sam Minnee 96e7914f23 FIX: Fix MySQLQuery::seek() and Query::rewind() to fix repeated iteration
API: Query::seek() and Query::rewind() no longer return a value.

Although breaking an API inside a patch release may seem odd, this in
fact is correcting a long-standing bug in our implementation of 
Iterator::rewind(), so I think it’s appropriate.

https://github.com/silverstripe/silverstripe-framework/issues/9097
2019-07-03 09:20:05 +12:00
Guy Marriott 59ba9a717d
FIX Allow extensions to update form scaffolding on DataObjects 2019-06-28 16:11:16 +12:00
Guy Marriott aeefb920e1
Allow displaying partial/full query message for debugging (#9020)
Allow displaying partial/full query message for debugging
2019-06-28 15:15:33 +12:00
Robbie Averill c76d3a5db1 FIX Protect against undefined index when using nullifyEmpty option 2019-06-26 09:26:36 +12:00
Sam Minnee 27ace03273 NEW: Deprecated PDO in favour of native drivers
https://github.com/silverstripe/silverstripe-framework/issues/8598
2019-06-11 16:17:30 +12:00
Robbie Averill 00fd74a0a1 Merge branch '4.4' into 4
# Conflicts:
 #	src/Dev/Tasks/MigrateFileTask.php
2019-05-30 09:36:42 +12:00
Robbie Averill 14673ffd0a Merge branch '4.3' into 4.4 2019-05-30 09:35:26 +12:00
Robbie Averill 188698dcee Merge branch '4.2' into 4.3 2019-05-30 09:35:17 +12:00
shoosah 80e4886c3f Add getter and change visibility for whitelist_array property 2019-05-28 14:15:12 +12:00
shoosah d740998463 Improve displayQuery and benchmarkQuery functions and whitelist_array variable 2019-05-28 12:00:05 +12:00
shoosah d684c69f09 Allow displaying partial/full query message for debugging 2019-05-28 12:00:05 +12:00
Guy Marriott 350888bf50 NEW Adding a shuffle method to ArrayList (#8984)
* NEW Adding a shuffle method to ArrayList

* API Add shuffle to DataList for ArrayList parity
2019-05-16 09:26:11 +12:00
Aaron Carlino 3f1479edbb
BUGFIX: DataQuery overwriting _SortColumn selects (#8974)
* BUGFIX: DataQuery overwriting _SortColumn selects

* FIX DataQuery _SortColumn handling
2019-05-15 11:42:10 +12:00
Maxime Rainville 8ee50d2ba7 API Remove DataObjectSchema::getFieldMap() (#8960)
Introduced as a less public API in https://github.com/silverstripe/silverstripe-assets/pull/227
2019-05-06 12:33:23 +12:00
Guy Marriott 82c8225502
Merge branch '4.3' into 4.4 2019-05-03 09:45:25 +12:00
Serge Latyntcev 3d777cfb8a Backward compatible behaviour for SQLConditionalExpression::getJoins 2019-05-02 15:39:36 +12:00
Andre Kiste 0c6c57f1ef Add `getFieldMap` method to retrieve a list of all fields for any giv… (#8892)
* Add `getFieldMap` method to retrieve a list of all fields for any given class

* Add `TagsToShortcodeTask` to upgrading guide

Adding after the file migration part as this is where it makes the most sense to run it.

* `getFieldMap` accepts an array

* Move to `DataObjectSchema`

* Add `HTMLVarchar` to documentation
Minor refactoring

* Add test for checking that `subclassesfor` works without the base class
Add test `DataObjectSchema::getFieldMap` returns the correct array

* Remove cms dependency
2019-04-30 10:43:14 +12:00
Robbie Averill 8c6bf7ce53 Merge branch '4.3' into 4.4 2019-04-21 11:09:25 +12:00
Robbie Averill 523456ae09
Merge pull request #8921 from creative-commoners/pulls/4.3/threshold-count-in-sql
FIX Calculate threshold condition with SQL rather than PHP
2019-04-21 01:25:24 +12:00
Guy Marriott 80ad336e97 NEW Add API to create a generator from a DataList (#8931) 2019-04-18 15:31:41 +12:00
Aaron Carlino c63eecc3e1 Merge branch '4.3' into 4 2019-04-18 11:57:36 +12:00
Guy Marriott da1af3d8b0
FIX Postgres booleans should return as int for consistency 2019-04-17 15:15:17 +12:00
Guy Marriott 9d6b5048a6 FIX Table aliases are retained on base tables in queries built using SQLConditionalExpression (#8918)
* Adding failing test for base table aliases using SQLSelect

* FIX Retain table aliases applied to the base table on queries

* FIX Move the trimmed alias outside of the condition so we can use it within the condition
2019-04-16 15:40:09 +12:00
Guy Marriott 7fd6e14423
Adding comment about the === 't' condition for supporting postgres 2019-04-16 12:10:13 +12:00
Guy Marriott a48beac845
FIX Calculate threshold condition with SQL rather than PHP
This is a performance fix. Modern SQL engines can avoid counting a whole result set (potentially thousands of records) when you are only interested if the count exceeds a threshold.
2019-04-15 16:48:44 +12:00
Sheila Bañez 63360f8048 BUG Replace substr with mb_substr to get the correct position 2019-04-15 16:38:52 +12:00
Robbie Averill 2c971eea83 Merge branch '4.3' into 4 2019-04-11 11:37:47 +12:00
Robbie Averill f2f28586d9 Merge branch '4.2' into 4.3 2019-04-11 11:37:34 +12:00
Robbie Averill 116ea12783 Merge branch '4.1' into 4.2 2019-04-11 11:37:22 +12:00
Robbie Averill f4a6115ee6 Merge branch '4.0' into 4.1 2019-04-11 11:36:40 +12:00
Robbie Averill 8a06682e31 Merge branch '4.3' into 4
# Conflicts:
 #	src/ORM/Connect/DBSchemaManager.php
2019-04-11 11:24:17 +12:00
Robbie Averill 55cbacca86 Merge branch '4.2' into 4.3
# Conflicts:
 #	src/Forms/GridField/GridFieldLevelup.php
 #	src/includes/constants.php
2019-04-11 11:21:42 +12:00
Loz Calver 594af77134 FIX: prevent unnecessary field alterations for enums with empty defaults 2019-04-05 16:17:41 +01:00
Sam Minnee c9c7c0c825 FIX: Fix PDO cached statement column coercion
NEW: Add PDOStatementHandle class that is now what PDOQuery expects
2019-04-05 15:11:21 +13:00
Sam Minnee 45e1fcaf30 FIX: Correct type coercion of MySQL 2019-04-05 15:11:21 +13:00
Sam Minnee adb6e9eb8d FIX: Perform type coercion on PDO-based MySQL and SQLite connections
It turns out that this is needed for decimal values on MySQL and all
values on SQLite
2019-04-05 15:05:42 +13:00
Jonathon Menz fae19c16b5 FIX has_one File form scaffolding
Only allow selection of a single file when scaffolding has_one File relationship (fixes #8862)
2019-03-26 09:50:59 -07:00
Damian Mooyman 83ec0b69fa
BUG Resolve issue where schema changes between enum / non-enum types 2019-03-26 14:16:05 +13:00
Loz Calver 8483a9644c
Merge pull request #8874 from johannesx75/fix-pdoconnector-generatedid-type-2
Fix PDOConnector GeneratedID return type
2019-03-22 09:09:23 +00:00
Daniel Hensby 6d4d332448
Merge pull request #8830 from ntd/pr7
Fix #8829: mention get_one does not escape field names
2019-03-21 14:38:34 +00:00
Johannes Hammersen e1190e33d2 Fix PDOConnector GeneratedID return type 2019-03-21 09:26:14 +01:00
Damian Mooyman 6b450395ce API Allow empty arraylists to be typed (#8866)
* API Allow empty arraylists to be typed

* PHPCBF fixes
2019-03-20 11:46:35 +13:00
Bernard Hamlin 8d1a238e97 Add option to leave Temp DB when exiting 2019-03-19 14:37:13 +13:00
Nicola Fontana 252397d8d1 Fix #8829: mention get_one does not escape field names 2019-03-08 08:20:47 +01:00
Dan Hensby 765d1568ab
Merge branch '4.3' into 4 2019-03-06 11:04:50 +00:00
Dan Hensby a8605b04e0
Merge branch '4.2' into 4.3 2019-03-06 11:04:14 +00:00
Guy Marriott f8f6983773
Merge pull request #8793 from wilr/pulls/orm-exception
Throw error message when searchable_field does not return a object
2019-03-06 08:50:50 +13:00
Damian Mooyman d1396b7dfe
BUG Fix writeBaseRecord with unique indexes
Fixes #6819
2019-02-27 16:40:12 +13:00
Maxime Rainville 11b9429c34 Merge branch '4.3' into 4 2019-02-27 12:14:51 +13:00
Maxime Rainville 651d537196 Merge branch '4.2' into 4.3 2019-02-27 12:13:24 +13:00
Maxime Rainville ed013fcfbb Merge branch '4.1' into 4.2 2019-02-27 12:12:39 +13:00
Maxime Rainville ac53f77115 Merge branch '4.0' into 4.1 2019-02-27 12:11:47 +13:00
Maxime Rainville 9a59f2f57d BUG Renable the ability to do dynamic assignment with DBField 2019-02-22 11:08:43 +13:00
Robbie Averill 3e90fdf42f Merge branch '4.3' into 4 2019-02-19 08:41:05 +07:00
Robbie Averill ed74549c4f Merge branch '4.2' into 4.3 2019-02-19 08:39:59 +07:00
Robbie Averill 79e44b42fa Merge branch '4.1' into 4.2 2019-02-19 08:37:07 +07:00
Robbie Averill cb7f15a681 Merge branch '4.0' into 4.1 2019-02-19 08:36:41 +07:00
Aaron Carlino 09c539e1c3 Merge branch '4.3' into 4 2019-02-19 12:21:24 +13:00
Maxime Rainville 25bba49923 [SS-2018-021] Fix potential SQL vulnerability in non-scalar value hyrdation 2019-02-19 12:20:24 +13:00
Robbie Averill 7a508af387
Merge pull request #8795 from creative-commoners/pulls/4.3/improve-foreign-key-form-field-scaffolding
FIX Caching the result of counting a foreign list for performance
2019-02-12 15:56:11 +07:00
Maxime Rainville 95505db7d6 [SS-2018-021] Fix potential SQL vulnerability in non-scalar value hyrdation 2019-02-12 21:08:09 +13:00
Maxime Rainville fd90cf6ceb [SS-2018-021] Fix potential SQL vulnerability in non-scalar value hyrdation 2019-02-12 20:44:17 +13:00
Guy Marriott 0ac43ce025
FIX Caching the result of counting a foreign list for performance 2019-02-12 15:28:03 +13:00
Will Rossiter d4f6ff98c8 Throw error message when searchable_field does not return a object
While upgrading 4.2 to 4.3 the behaviour of GridFieldFilterHeader has changed (example code: https://gist.github.com/wilr/7c59f577e1d072eb66e4c0c84cba6732).

This patch doesn’t affect the behaviour (since the explict object is a better API) but it makes upgrading easier to identify the field.
2019-02-12 09:39:27 +13:00
Loz Calver 7c5b73881b FIX: Prevent null->null being flagged as a value change (fixes #8774) 2019-02-06 13:24:18 +13:00
Ingo Schommer a78573b517 DOC Clarify DataObject->update() use 2019-02-04 20:47:27 +13:00
Guy Marriott f918dcd36a
FIX Escape wildcard characters when matching database name in databaseExists 2019-01-30 09:31:13 +13:00
Aaron Carlino ab116cd5d9 Merge branch '4.1' into 4.2 2018-12-12 15:56:53 +13:00
Robbie Averill 74698af402 [SS-2018-020] Ensure that table names are escaped to prevent possible SQL injection 2018-12-11 20:57:18 +13:00
Robbie Averill 8bd747d12a [SS-2018-020] Ensure that table names are escaped to prevent possible SQL injection 2018-12-11 20:56:55 +13:00
Robbie Averill fecedc2d98 [SS-2018-020] Ensure that table names are escaped to prevent possible SQL injection 2018-12-11 20:56:40 +13:00
Robbie Averill 48bd335648 [SS-2018-020] Ensure that table names are escaped to prevent possible SQL injection 2018-12-11 20:55:58 +13:00
Loz Calver 3f8551df41
Merge pull request #8462 from sminnee/nondestructive-enum
FIX: Make all enums non-destructive, not just ClassName
2018-11-28 16:42:12 +01:00
Guy Marriott b2dd22fb50
Merge pull request #8506 from creative-commoners/pulls/4.3/all-the-unit-tests
NEW Adding a stack more unit tests for logging and some form fields
2018-11-11 10:31:24 +13:00
Sam Minnee bd5a815909 FIX: Make all enums non-destructive, not just ClassName
This change also renders a portion of DBSchemaManager irrelevant, that
destructively “fixes” old values. This is in keeping with the
non-destructive principle of dev/build, and some suggestions to move
away from enum fields altogether.

Fixes https://github.com/silverstripe/silverstripe-framework/issues/1387
2018-11-10 12:10:25 +13:00
Robbie Averill 0f2eebe5d4 NEW Change to variadic calls in ListDecorator and add unit tests 2018-11-09 13:59:14 +02:00
Sam Minnee 0cc39af382 DOC: Added documentation for strict type changes 2018-11-09 11:08:36 +13:00
Sam Minnee 2615399535 FIX: Use PDO’s built-in transaction support in MySQLDatabase. 2018-11-09 10:31:19 +13:00
Sam Minnee 0111b98b18 FIX: Ensure that types are preserved fetching from database
This ensures that numeric fields appear in PHP as int/float values
rather than strings, which allows the development of more type-safe PHP
code.

This doesn’t work on the legacy mysql driver and this will now throw
a notice-level error. It requires mysqlnd.
2018-11-09 10:31:19 +13:00
Sam Minnee 67fe41d00b FIX: Ensure that repeated setting/unsetting doesn’t corrode forceChange() 2018-11-05 23:09:24 +13:00
Sam Minnee 5bb2d9484a FIX: Update “original” DataObject data to be the content of the last write
FIX: Compare to original when determining fields changes

This fixes a number of edge-case issues relating to change detection.

Fixes #8443
Fixes #3821
Fixes #4561
2018-11-05 23:09:24 +13:00
Sam Minnée 536e2d6835
Merge pull request #8511 from jmfederico/patch-1
Update comment about locks in MySQL
2018-11-05 22:32:18 +13:00
Michael Strong 55f95b7bc8 BUGFIX many many through not sorting by join table (#8534)
* BUGFIX many many through not sorting by join table

* #8534 added docs to support many many sorting fix

* #8534 added test cases for many_many default sorting
2018-11-01 14:17:15 +13:00
Michael Strong 7086f2ea3a BUGFIX many many through not sorting by join table (#8534)
* BUGFIX many many through not sorting by join table

* #8534 added docs to support many many sorting fix

* #8534 added test cases for many_many default sorting
2018-11-01 13:42:27 +13:00
Robbie Averill b02a6fa02d FIX Replace usage of Convert JSON methods with json_encode 2018-10-28 21:15:29 +00:00
Federico Jaramillo Martínez e9bffe4020
Update comment about locks in MySQL
MySQL 5.7.5 and newer allow for multiple lock form the same session. This information is now reflected in the comment.
2018-10-22 22:33:16 -05:00
bergice a28e2e183e BUG: Fix enum filter in Search component from adding `Any` as a filter
Fixes #702
2018-10-19 17:05:12 +13:00
Robbie Averill 437e53f2fe NEW Some minor refactoring of the PDO and MySQLi connectors
Some small performance optimisations (not using callables in loops, switch strval for string
casting), Config call updates and replace call_user_func_array with direct variadic call.
Also removes some redundant else statements after returns.
2018-10-17 12:54:42 +02:00
Robbie Averill c18e9b1298
Merge pull request #8439 from sminnee/consistent-limit
FIX: Make ArrayList::limit() consistent with DataList::limit()
2018-10-16 12:05:11 +02:00
Robbie Averill 516267ed46
Merge pull request #8470 from kinglozzer/suf-fixing-the-suffix
FIX: Re-instate missing SS_DATABASE_SUFFIX functionality (fixes #7966)
2018-10-12 23:11:54 +02:00
Loz Calver 26f2044533
Merge pull request #8437 from sminnee/faster-cleartable-ss4
FIX: Use DELETE FROM instead of TRUNCATE for clearTable
2018-10-11 12:32:31 +02:00
Loz Calver ee21c42011 FIX: Re-instate missing SS_DATABASE_SUFFIX functionality (fixes #7966) 2018-10-11 10:50:56 +01:00
Sam Minnee 4740346ed8 FIX: Make ArrayList::limit() consistent with DataList::limit()
This makes it easier to swap one fo the other without code breaking.
Since it’s strictly a removed API, I’ve opted to throw a deprecation
note in SS4 rather than throwing an InvalidArgumentException.

Fixes #2949
2018-10-11 21:05:20 +13:00
Loz Calver e829ad78b1
Merge pull request #8429 from sminnee/fix-2950
FIX: Throw deprecation on limit=0
2018-10-08 15:11:52 +02:00
Robbie Averill 98568262f2 Fixed phpcs violations 2018-10-05 16:07:33 +02:00
Sam Minnee 0fc06e51e5 FIX: Drop seconds from DBDatetime::Nice() to restore SS3 behaviour.
Note that the medium date format depends on locale, with en_NZ being
resolutely numeric. I’ve updated the test to verify a couple of locales
to make this more obvious.

Fixes #8121
2018-10-04 14:51:24 +13:00
Sam Minnee 638e6ec281 FIX: Throw deprecation notice on limit=0
The SS4 behaviour of limit=0 is unlikely to be the SS5 behaviour.
To clear the limit limit=null is recommended.

In addition, there’s a bit tighter type maintenance in the internal
limit data (ensure things are int).

Fixes #2950.
2018-10-04 10:38:15 +13:00
Robbie Averill ee24413c30 Merge branch '4.2' into 4 2018-10-03 15:28:05 +02:00
Robbie Averill b0871ebd75
Merge pull request #8417 from creative-commoners/pulls/4.3/many-many-through-sorting-tests
Add more list sorting tests and fix many many through sorting
2018-10-03 13:30:20 +02:00
Robbie Averill d2b646cc13
Merge pull request #8286 from wilr/patches/mysql-create-table-issue
Check database has table before altering.
2018-10-03 13:24:59 +02:00
Robbie Averill 79f9d6b733
Merge pull request #8428 from sminnee/fix-2636
FIX: Don’t change state in ArrayList::getIterator()
2018-10-03 13:11:39 +02:00
Sam Minnee 0cc72c91ad FIX: Use DELETE FROM instead of TRUNCATE for clearTable
clearTable is mainly used for clearing data between tests. In this case,
there are very few or zero records, and DELETE FROM is quicker than
TRUNCATE, which works by deleting and recreating the table.

This materially speeds up test execution, at least on MySQL.

Cherry-pick of SS3 ae9ab22a8f
2018-10-03 13:40:00 +13:00
Robbie Averill 5a20bb5e20 Revert "FIX: Use DELETE FROM instead of TRUNCATE for clearTable"
This reverts commit 79c2b5ad42.
2018-10-02 14:35:10 +02:00
Robbie Averill 2ca089bcce
Merge pull request #8433 from sminnee/faster-cleartable
FIX: Use DELETE FROM instead of TRUNCATE for clearTable
2018-10-02 10:43:54 +02:00
Sam Minnee 79c2b5ad42 FIX: Use DELETE FROM instead of TRUNCATE for clearTable
clearTable is mainly used for clearing data between tests. In this case,
there are very few or zero records, and DELETE FROM is quicker than
TRUNCATE, which works by deleting and recreating the table.

This materially speeds up test execution, at least on MySQL.

Implemented in SS3 at 815da76b056a716c8831d22bbf93528912cbcb28
2018-10-02 18:00:38 +13:00
Sam Minnee f2cbc1dfbb FIX: Don’t use USE_FRM in MySQL repair. Fixes #6300.
USE_FRM is a sufficiently dangerous option that it should require
manual DBA activity to carry out.

See http://dev.mysql.com/doc/refman/5.7/en/repair-table.html for more
info.
2018-10-02 10:48:47 +13:00
Sam Minnee ad87890b2e FIX: Don’t change state in ArrayList::getIterator()
This prevents the map-to-ArrayData conversion from changing object
state and making the result of toArray() non-deterministic.

Fixes #2636. Other solutions were suggested on that ticket, but there is
no way of putting special code in for a SSViewer-specific iterator, and
having object state pre-emptively converted to ArrayData would
be an SS5-level change.
2018-10-02 09:56:09 +13:00
Robbie Averill ac1fe5e9d5 FIX joinClass's default_sort is used when nothing else has been set already 2018-09-28 15:39:24 +02:00
Robbie Averill 4d14e9b6b1
Merge pull request #8421 from creative-commoners/pulls/4.3/psr-5-deprecations
Update deprecation PHPDocs to be PSR-5 compliant
2018-09-28 14:18:54 +02:00
Robbie Averill e4768e44b0 Use splat over call_user_func_array and reduce calls to func_get_args() 2018-09-28 12:32:20 +02:00
Robbie Averill f842ee2eec Update deprecation PHPDocs to be PSR-5 compliant
See: https://github.com/php-fig/fig-standards/blob/master/proposed/phpdoc-tags.md#55-deprecated
2018-09-28 10:49:14 +02:00
Robbie Averill 1b0293d8c5 Replace array syntax, use some strict comparison and remove unnecessary elseif 2018-09-27 17:37:37 +02:00
Robbie Averill adb4d1f92d MINOR Reduce some code complexity, update array syntax and injected SQLSelect etc 2018-09-27 16:40:23 +02:00
Robbie Averill f5929d87e0 DOCS Update do blocks for DataQuery::having() to reflect correct input types 2018-09-25 17:46:42 +02:00
Sam Minnée 5b7a84141b NEW: Add Hierarchy::prepopulate_numchildren_cache() (#8380)
* NEW: Add Hierarchy::prepopulate_numchildren_cache()
API: Hierarchy::stageChildren() customisations must be applied to the base class and not include record-specific behaviour.

Adds the ability to prepopulate the cache for Hierarchy::numChildren()
in a batch.

Note that this optimisation means that stageChildren() is not called on
each record in order to calculate numChildren(). This means that the
structure of the stageChildren() query must be the same for all records
and the behaviour cannot be customised only for a subclass of the base
data class. For example, apply your customisations to SiteTree and not
a subclass.

This is an useful part of optimising the query count on tree generation.
See https://github.com/silverstripe/silverstripe-framework/issues/8379

* NEW: Add Hierarchy::prepopulateTreeDataCache()

This provides a more extensible way of preopulating caches for optimised
tree generation.

Fixes https://github.com/silverstripe/silverstripe-framework/issues/8391
2018-09-25 12:25:23 +12:00
Sam Minnee 40dde226fd NEW: Add ?showqueries=backtrace
This variant of showqueries will include a backtrace after each query.
This is extremely verbose but can be helpful when diagnosing where
queries have come from.

This is something that I have frequently added as a local hack on my
environment, I figured that exposing it as a formal feature would be
useful.
2018-09-19 14:28:40 +12:00
Robbie Averill 373a8afeb5 Merge branch '4.2' into 4 2018-09-06 13:26:46 +02:00
Robbie Averill 270aba4007 Merge branch '4.1' into 4.2 2018-09-06 13:26:31 +02:00
Robbie Averill b6ff21f72a Merge branch '4.0' into 4.1 2018-09-06 13:26:13 +02:00
Guy Marriott 610f17282f
DOCS Updating DataObject config documentation 2018-08-29 14:53:05 +12:00
Maxime Rainville dd3379e68f
Merge pull request #8075 from creative-commoners/pulls/4.0/remap-polymorphics
FIX Polymorphic relationship class columns have obsolete class names remapped
2018-08-28 17:03:39 +12:00
Robbie Averill d651d0fbfc FIX Use base class (not remapping target class) when looking up whether object is versioned 2018-08-28 14:15:02 +12:00
Robbie Averill 953153500d FIX Polymorphic relationship class columns have obsolete class names remapped 2018-08-15 10:40:51 +12:00
Daniel Hensby d0598c02c5
Merge branch '4.2' into 4 2018-07-30 11:07:15 +01:00
Daniel Hensby ec5640cbd9
Merge tag '4.2.0' into 4.2
Release 4.2.0
2018-07-30 11:04:57 +01:00
Will Rossiter 9ec77ab9d3 Check database has table before altering.
Work around to prevent several issues with silverstripe-framework#4451 and cwp#0031726.

Throws a LogicException if the table does not exist.
2018-07-30 13:14:03 +12:00
Mark Muller e154aa170c
Make removeDuplicates() chainable
Added the return to allow removeDuplicates to be chained.
2018-07-24 13:50:37 +01:00
Ingo Schommer 0f5420b6a5
Removed unused classes 2018-07-23 19:09:11 +01:00
Daniel Hensby cc0320b2a7
Merge branch '4.2' into 4 2018-07-23 17:42:43 +01:00
Daniel Hensby 793aafae91
FIX Transaction depth should error if not implemented by child classes 2018-07-23 14:03:20 +01:00
Robbie Averill 1048520fbe
Restore check for zero or negative transaction nesting 2018-07-23 14:01:22 +01:00
Daniel Hensby cbdf547c1b
Address feedback 2018-07-23 14:01:22 +01:00
Damian Mooyman 8ea3bb36a0
Maybe fix it? 2018-07-23 14:01:21 +01:00
Damian Mooyman 225e61dc67
BUG FIx manual resetDBSchema() calls breaking the database 2018-07-23 14:01:21 +01:00
Damian Mooyman 95bcac796a
ENHANCEMENT Ensure test DB is flushed on either DDL or transaction-disabled tests
Fixes #8182
2018-07-23 14:01:20 +01:00
Daniel Hensby b984959170
Merge branch '4.1' into 4.2 2018-07-23 13:30:49 +01:00
Daniel Hensby 1a634f5ba6
Merge pull request #8244 from altwohill/column-not-distinct
Make column query not distinct
2018-07-16 13:01:32 +01:00
Al Twohill 3292a8b773
NEW Add `columnUnique` API SS_List classes. 2018-07-16 12:16:17 +01:00
Al Twohill 91068c23b5
FIX Make column query not distinct
When selecting a column, it doesn't  make sense to have it distinct.

As an alternative, the API could be changed to give the end user the option
(eg `->column($field, $distinct = false)`)
However if we did that, we would need to make sure we do something
similar with `SilverStripe\ORM\UnsavedRelationList` to ensure consistency.
2018-07-16 11:38:41 +01:00
Robbie Averill d122995652 FIX Duplicate config values for cascade_duplicates no longer duplicate their duplicates
Previously you could define identical values for this config prop via a DataExtension and on the base
class, resulting in double duplication
2018-07-16 12:04:56 +12:00
Harsh Chokshi 6af736a9e1 Change DBCurrency scaffolded form field to CurrencyField (fixes #8246)
Add test ensuring DBCurrency scaffolds CurrencyField
2018-07-09 10:57:01 +12:00
Luke Edwards fbf30ee747 Message reflect previous return type change 2018-07-04 10:55:20 +12:00
Luke Edwards 9ee84fd515 MINOR: DataObject->fieldLabels() will only return an array 2018-07-02 13:53:59 +12:00
Robbie Averill a39a221c4c Merge branch '4.2' into 4 2018-06-25 13:45:03 +12:00
Daniel Hensby 27b60ae989
FIX Transaction depth should error if not implemented by child classes 2018-06-21 14:26:21 +01:00
Robbie Averill df257686c1 Restore check for zero or negative transaction nesting 2018-06-20 14:46:50 +12:00
Daniel Hensby d8430f549d Address feedback 2018-06-20 14:46:50 +12:00
Damian Mooyman 6da72d686f Maybe fix it? 2018-06-20 14:46:50 +12:00
Damian Mooyman a116b5dad8 BUG FIx manual resetDBSchema() calls breaking the database 2018-06-20 14:46:50 +12:00
Damian Mooyman fbfd454d65 ENHANCEMENT Ensure test DB is flushed on either DDL or transaction-disabled tests
Fixes #8182
2018-06-20 14:46:50 +12:00
Daniel Hensby a7a45559f0
Merge pull request #8188 from gelysis/array-lib
Tweaks on the ArrayLib class
2018-06-19 15:06:39 +01:00
Aaron Carlino 05edb372f1 Revise per tractorcow review 2018-06-18 16:00:17 +12:00
jovenden b0863fee91 Ensure tables are properly named on dontRequireTable() 2018-06-18 16:00:17 +12:00
Andreas Gerhards 59fe36ba04 Tweaked the other flattening method as well, allowing keys to be preserved 2018-06-18 11:16:20 +12:00
Andreas Gerhards 1753bb2d07 Improved speed on the recursive array flattening 2018-06-18 10:37:20 +12:00
Andreas Gerhards f45cf75407 Implemented improved associative array check 2018-06-18 08:45:22 +12:00
Damian Mooyman 53dded8cff
API Remove @internal from new 4.2 methods 2018-06-15 13:14:42 +12:00
Robbie Averill 5fa5abf295 Merge branch '4.1' into 4
# Conflicts:
  #	src/Forms/DateField.php
2018-06-15 11:52:07 +12:00
Damian Mooyman b636587945
Respect semver and add tests 2018-06-15 11:04:12 +12:00
Damian Mooyman 310a259c5f
Add locale to Format
Fix up some regressions
2018-06-14 17:28:16 +12:00
Damian Mooyman 3ce8ab3adc
Improve handling of deprecated apis 2018-06-14 13:01:27 +12:00
Damian Mooyman 687d0a6af1
Refactor everything out of HTTP and into separate middlewares 2018-06-13 17:56:47 +12:00
Damian Mooyman 02ae2e7ed0
BUG Fix internal date formatting inheriting default locale
Fixes #8097
2018-06-13 13:32:11 +12:00
Daniel Hensby ec956a682d API Moving tests to use transactions 2018-06-13 09:35:45 +12:00
Damian Mooyman 77a45c0dbc
Merge remote-tracking branch 'origin/4.1' into 4
# Conflicts:
#	src/Forms/HTMLEditor/HTMLEditorSanitiser.php
#	src/ORM/DataObjectSchema.php
#	src/ORM/Queries/SQLSelect.php
#	src/View/Parsers/ShortcodeParser.php
2018-06-11 10:19:04 +12:00
Robbie Averill d842225df6 FIX Codesniffer style violations with comments 2018-06-11 09:55:18 +12:00
Daniel Hensby e260319823
Merge branch '4.0' into 4.1 2018-06-08 23:05:24 +01:00
Daniel Hensby e1450b5e82
Merge pull request #8147 from kinglozzer/mysql-pdo-attr
FIX: Only set MYSQL_ATTR_INIT_COMMAND when using mysql driver (fixes #8103)
2018-06-08 13:06:03 +01:00
Damian Mooyman 29f9b1c18f
Fix linting issues 2018-06-08 11:38:36 +12:00
Loz Calver 66f57bd4da FIX: Only set MYSQL_ATTR_INIT_COMMAND when using mysql driver (fixes #8103) 2018-06-07 10:26:00 +01:00
Damian Mooyman 0aa13da0d9
BUG Backport bugfix for belongs_many_many with many_many through.
Partial backport of #7928
Fixes #8131
2018-06-06 09:43:04 +12:00
Damian Mooyman 2510935b53
Merge pull request #8065 from dhensby/pulls/4/mmtl-jointable
NEW Add getJoinTable to MMTL
2018-06-01 10:33:46 +12:00
Robbie Averill e0993043f8 Merge branch '4.1' into 4 2018-05-30 15:08:39 +12:00
Robbie Averill c8b0bc0ad7 Merge branch '4.0' into 4.1
# Conflicts:
  #	src/ORM/DataObject.php
  #	tests/php/ORM/DataObjectDuplicationTest.php
  #	tests/php/ORM/DataObjectDuplicationTest/Class1.php
2018-05-30 14:52:07 +12:00
Robbie Averill ea16e28aa7 Merge branch '4.1' into 4 2018-05-28 18:33:56 +12:00
Robbie Averill 6d98a912c9 Merge branch 'heads/4.1.1' into 4.1 2018-05-28 18:26:20 +12:00
Robbie Averill 3a537bc745 Merge branch 'heads/4.0.4' into 4.0 2018-05-28 17:50:07 +12:00
Robbie Averill 722202fef4 Merge remote-tracking branch 'origin/4.0.4' into 4.1.1
# Conflicts:
  #	src/Control/Director.php
2018-05-24 15:41:11 +12:00
Daniel Hensby 1a57c7c1d0
NEW Add getJoinTable to MMTL 2018-05-14 11:19:24 +01:00
Robbie Averill cd716fb61b Switch check for is_string 2018-05-14 17:05:31 +12:00
Damian Mooyman 2e13ae746f [ss-2018-006] Prevent code execution in template value resolution 2018-05-14 17:05:31 +12:00
Daniel Hensby d5e2d3fa67
Merge branch '3.6' into 4.0 2018-05-01 21:47:17 +01:00
JorisDebonnet 1d3e83838d
Fix phpdoc for relation method (namespace) 2018-04-30 02:10:33 +02:00
UndefinedOffset d17f424541 Changed checked for UnsavedRelationList to ManyManyList 2018-04-18 12:15:16 -03:00
UndefinedOffset fe4b90edc0 FIX: Duplicating many_many relationships looses the extra fields in 4.0 2018-04-18 11:49:20 -03:00
Damian Mooyman be8287fef8 BUG Prevent failover / extensions interfering with composite field properties (#7988) 2018-04-06 14:48:24 +12:00
Damian Mooyman 5ff6874dbc
Merge remote-tracking branch 'origin/4.1' into 4 2018-04-04 17:38:26 +12:00
Damian Mooyman 99426cdb05
Merge remote-tracking branch 'origin/4.0' into 4.1 2018-04-04 17:36:45 +12:00
Damian Mooyman 878dc1f86d
BUG Change inverse polymorphic inference to silent-empty instead of explicit error 2018-03-29 09:38:07 +13:00
Andreas Lindahl dd44deacb4 Fix for "too few parameters" error when using DBMultiEnum 2018-03-28 16:42:12 +02:00
Damian Mooyman 257ff69e32 API Implement many_many through polymorphic (from only) (#7928)
* API Support many_many through polymorphic relations (from side only)
Fixes #7911
Fixes #3136

* Add extra docs and allow optional arguments

* ENHANCEMENT Enable quiet to be turned off

* BUG Fix issue with manymanythroughlist duplication
2018-03-22 10:26:25 +13:00
Daniel Hensby fb945690b1
Merge pull request #7875 from sminnee/devbuild-record-count
Suggested feature: dev/build record count
2018-03-14 14:26:49 +00:00
Daniel Hensby fd449618b2
Merge branch '4.1' into 4 2018-03-14 14:11:03 +00:00
Daniel Hensby ec6ff71107
Merge branch '4.0' into 4.1 2018-03-14 14:09:40 +00:00
Daniel Hensby d28a1b5cfc
Merge branch '3.6' into 4.0 2018-03-14 14:08:41 +00:00
Damian Mooyman 8b9c292509
Merge remote-tracking branch 'origin/4.1' into 4 2018-03-13 14:26:39 +13:00
Damian Mooyman 625f7b4eee
Merge remote-tracking branch 'origin/4.0' into 4.1 2018-03-13 14:26:18 +13:00
Damian Mooyman 4d424dd340
ENHANCEMENT get_by_id: alternate signature to allow MyDataObject::get_by_id($id) 2018-03-01 14:02:40 +00:00
Roman Schmid 40c2e299a0 Fix "mb_stripos(): Empty delimiter" warning when no search-keywords are given for `DBText::ContextSummary`.
Add unit-test to cover that case.
2018-03-01 11:39:30 +01:00
Daniel Hensby 9006daf20b
Cleaning up PR and adding tests 2018-02-28 13:31:56 +00:00
Joris Debonnet 559254407f
get_by_id: alternate signature to allow MyDataObject::get_by_id($id) 2018-02-28 13:09:12 +00:00
Daniel Hensby dace2f179d
Merge branch '4.1' into 4 2018-02-21 13:58:45 +00:00
Daniel Hensby c04ff8c55a
Merge branch '4.0' into 4.1 2018-02-21 13:40:30 +00:00
Damian Mooyman 0e26c06644
BUG Fix behaviour towards versioned but unstagable records 2018-02-20 12:20:18 +13:00
Sam Minnee a2143680e8 NEW: Add record count to dev/build output.
This small piece of metadata is intended to expose record counts to
developers as an information radiator: from time to time, SilverStripe
tables can get very large, and this exposes this information without
the developer seeking it out. 

It’s reasonable to expect that count(*) calls aren’t too time consuming,
even on large tables.

On a small test run, dev/build execution went from 3.85s to 3.98s (a 3%
or 130ms increase). Given the small relative impact it should be okay.
Where this is inappropriate, it can be disabled with a config setting.
2018-02-17 19:02:50 +13:00
Andrew Aitken-Fincham 00ff3ba4b2 ENHANCEMENT Make dropdownFieldThreshold configurable on DBForeignKey (#7789) 2018-02-13 10:32:55 +13:00
Daniel Hensby 16d3498a56
Merge branch '4.1' into 4 2018-02-12 10:26:07 +00:00
Daniel Hensby 7ec5fa2c8d
Merge branch '4.0' into 4.1 2018-02-09 15:19:15 +00:00
Daniel Hensby e298fcc345
Merge branch '3.6' into 4.0 2018-02-09 14:32:58 +00:00
Daniel Hensby d3278d5470 FIX Add Nested DB transaction support (#7848)
* TEST Prove nested transactions break

* Add nested transaction support
2018-02-09 10:28:32 +13:00
Andrew Aitken-Fincham 860fa2a05a API Add excludeAny() and tests for complicated excludes/filters (#7838) 2018-02-08 09:20:17 +13:00
Damian Mooyman db9aa2c5c7
BUG Fix regression in has_one getters breaking DataDifferencer 2018-02-05 16:16:07 +13:00
Damian Mooyman aa2c71424d
API Implement cascade_duplications
API Add DataObject::setComponent()
API Support unary components as getter and setter fields
API ManyManyList::add() now supports unsaved records
ENHANCEMENT Animal farm
2018-02-05 12:04:57 +13:00
Damian Mooyman 76d2db12b0
Merge pull request #7794 from kinglozzer/id-like-to-place-an-ordinal
NEW: Add support for ordinals in DBDate::Format()
2018-01-26 09:27:46 +13:00
Loz Calver fcf5022550 NEW: Add support for ordinals in DBDate::Format() 2018-01-25 09:41:06 +00:00
Damian Mooyman bca47029c4
Merge remote-tracking branch 'origin/4.0' into 4
# Conflicts:
#	src/Control/SimpleResourceURLGenerator.php
#	tests/php/Control/SimpleResourceURLGeneratorTest.php
2018-01-25 12:53:15 +13:00
Roman Schmid 6fafce766e Fixed Rfc3339 implementation of Date and Datetime 2018-01-24 16:58:12 +01:00
Damian Mooyman 3fce5372b0
DOC Fix phpdoc on ArrayList::limit
Fixes #7781
2018-01-24 10:18:15 +13:00
Damian Mooyman a3c52f901a
Merge remote-tracking branch 'origin/4.0' into 4
# Conflicts:
#	src/Core/TempFolder.php
#	src/ORM/DataObject.php
#	src/View/ThemeResourceLoader.php
#	src/includes/constants.php
#	tests/php/Control/SimpleResourceURLGeneratorTest.php
#	tests/php/Forms/HTMLEditor/HTMLEditorFieldTest.php
#	tests/php/View/RequirementsTest.php
2018-01-22 14:57:05 +13:00
Daniel Hensby db610aaf3b
Fixing string concat CS issues 2018-01-16 18:39:30 +00:00
Daniel Hensby 42511d8061
Merge pull request #7714 from @zanderwar 2018-01-16 15:43:18 +00:00
Daniel Hensby ebeaf3e40d
Merge branch '3' into 4 2018-01-16 11:47:39 +00:00
Daniel Hensby e4b936c7c7
Merge branch '4.0' into 4 2018-01-12 14:40:33 +00:00
Damian Mooyman ce07e4781e BUG Do database migrations before default records
Fixes #7703
2017-12-18 16:37:21 +13:00
Reece Alexander 9c91e9820e
Returns chainability in setValue from parent 2017-12-17 17:21:42 +10:00
Robbie Averill cd9695eda9
Merge pull request #7695 from open-sausages/pulls/4/versions-of-atlantis
Update framework docs / phpdoc for versioning changes
2017-12-17 16:33:59 +13:00
Daniel Hensby e4bf9a31ed
Merge branch '4.0' into 4 2017-12-14 21:20:11 +00:00
Damian Mooyman a50fd009ca Update PHPDoc 2017-12-14 15:08:32 +13:00
Damian Mooyman 529e341dbc
Merge pull request #7699 from open-sausages/pulls/4/html-in-security-msg
ENHANCEMENT Allow html in security failure message
2017-12-14 14:30:09 +13:00
Damian Mooyman 1c8576cee7
Linting cleanup 2017-12-14 14:18:41 +13:00
Damian Mooyman ed6561d9f5
BUG Fix incorrect merge of associative / non-associative summary fields
Fixes #7696
2017-12-14 14:17:19 +13:00
Damian Mooyman 8b1b9f022b
Fix linting issues 2017-12-14 13:50:52 +13:00
Damian Mooyman 2391af5ba7
Fix literal linting 2017-12-12 09:22:18 +13:00