Commit Graph

326 Commits

Author SHA1 Message Date
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
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
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