Commit Graph

97 Commits

Author SHA1 Message Date
Michal Kleiner 21129b1624
Use short array syntax across the framework's codebase 2020-05-16 10:34:45 +01:00
Daniel Hensby 237b2d5f74
Convert array delcarations to short array syntax 2020-04-20 18:58:09 +01:00
Daniel Hensby 03239f9dcc
Merge pull request #9454 from open-sausages/pulls/4/myisam
NEW Allow InnoDB for FULLTEXT indexes
2020-04-14 11:50:45 +01:00
Ingo Schommer a50e15e5ee FIX Avoid VACUUM on test dbs in Postgres
The Postgres implementation was always faulty,
but the database exception was swallowed until
See https://github.com/silverstripe/silverstripe-framework/pull/9456.

Now that the the exception is only swallowed the first time,
the second recurrence will cause failing test execution.

This is a bit of an awkward fix, but the indirection "through" DataObject doesn't allow for anything else without changing public API surface.
The logic goes from TempDatabase to DBSchemaManager, then through the closure into DataObject->requireTable(),
then back into DBSchemaManager->requireTable(). And updateschema() is subclassed in SQLite3, making it difficult to add more arguments.

VACUUM is described as:

> VACUUM reclaims storage occupied by dead tuples. In normal PostgreSQL operation, tuples that are deleted or obsoleted by an update are not physically removed from their table; they remain present until a VACUUM is done. Therefore it's necessary to do VACUUM periodically, especially on frequently-updated tables.

https://www.postgresql.org/docs/9.1/sql-vacuum.html

Since test databases are short-lived, there's no reason to delete dead tuples, they'll be garbage collected when either the transaction is rolled back, or the database is destroyed after the test run.
2020-04-09 14:43:16 +12:00
Ingo Schommer 2c5deceeb4 FIX Filter out all FULLTEXT BOOLEAN chars
The query might still work depending on where these chars are placed,
but it seems weird to only remove *some* of the valid chars here.
See https://dev.mysql.com/doc/refman/5.6/en/fulltext-boolean.html

Note that the query runs both the actual boolean query with chars,
and then a separate relevance search without them.
2020-04-09 10:32:45 +12:00
Ingo Schommer 0215fdd262 DOC Clarify sanitisation in searchEngine() under boolean mode
This came up in https://github.com/silverstripe/silverstripe-cms/issues/1452, and wasn't fully addressed.
Either we allow boolean mode and all the constraints this brings around special character usage,
or we filter out those special characters, which makes boolean mode pointless.
You can't just pass arbitrary user input in a power-user function like this.
See https://dev.mysql.com/doc/refman/5.6/en/fulltext-boolean.html

Context: This used to work for some examples like "foo>*" under MyISAM,
presumably because it had a more lenient parser. InnoDB rightfully complains about this now.
2020-04-09 10:32:45 +12:00
Ingo Schommer c6b698cb02 NEW Allow InnoDB for FULLTEXT indexes
MyISAM used to be the only one to support it, now InnoDB has caught up.
Unless an engine is set specifically in create_table_options,
this will auto-convert existing MyISAM tables to InnoDb.

Fixes #9242
2020-04-09 10:32:45 +12:00
Ingo Schommer 052c5cbc38 BUG Infinite loops in TempDatabase (fixes #8902)
Ugly, but so is the original implementation that this works around (swallowing an exception to trigger functionality)
2020-04-08 13:58:02 +12:00
Michal Kleiner bcbf90a837 NEW Introduce supported database transaction mode check 2019-09-16 14:44:15 +12:00
Serge Latyntcev 29a663c65d Merge branch '4.4' into 4 2019-07-15 09:24:49 +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
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
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
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 da1af3d8b0
FIX Postgres booleans should return as int for consistency 2019-04-17 15:15:17 +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
Damian Mooyman 83ec0b69fa
BUG Resolve issue where schema changes between enum / non-enum types 2019-03-26 14:16:05 +13:00
Johannes Hammersen e1190e33d2 Fix PDOConnector GeneratedID return type 2019-03-21 09:26:14 +01:00
Bernard Hamlin 8d1a238e97 Add option to leave Temp DB when exiting 2019-03-19 14:37:13 +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
Guy Marriott f918dcd36a
FIX Escape wildcard characters when matching database name in databaseExists 2019-01-30 09:31:13 +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
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
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
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
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
Robbie Averill 98568262f2 Fixed phpcs violations 2018-10-05 16:07:33 +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
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
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
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
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
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