0.3
Pre-release
Pre-release
Tests
Unit and integration tests have been added, they cover 100% of the current code.
Sadly, we're stuck with PHPUNIT 7.5.20 because of WP’s test suite 😢.
AbstractCRUD
prepare_select_for_query()
:- Trim quotes.
- Add backticks.
- Remove empty fields.
- Don't use
esc_sql()
anymore.
get_placeholders()
:- Return only valid columns.
cast()
:- When the placeholder is not
%d
nor%f
and the column is not serializable, return numeric values as string.
- When the placeholder is not
Basic
get()
:- Disallowed
ARRAY_N
value for the output type, as it conflicts withcast_row()
.
- Disallowed
AbstractTableDefinition
- An instance of
Worker
can be injected into the constructor.
DBUtilities / DBWorker\Worker
- The static class
DBUtilities
is now the instanciable classDBWorker\Worker
that implementsDBWorker\WorkerInterface
.
Seeing howDBUtilities
was used at this point, using a static class was not shorter. The advantage now is that the instance can be typehinted against the interface. Although, it is not typehinted directly inAbstractTableDefinition
today, we need php 7.1 for nullable typehints (this is for a future release), butinstanceof
is used for the time being.
The full instanciation is nownew Table( new MyTableDefinition( new MyWorker() ) )
.
AbstractTableDefinition
falls back tonew DBWorker\Worker()
if no custom worker is specified as argument. - Hide database errors in most methods.
table_exists()
:- Fix returned value by comparing the query value to the unescaped name of the table.
- New method
get_last_error()
, which returns the last$wpdb
error. sanitize_table_name()
:- Allow
0
as a valid table name.
- Allow
quote_string()
:- Do not escape simple quotes anymore, it is done by
esc_sql()
inprepare_values_list()
.
- Do not escape simple quotes anymore, it is done by
can_log()
:- New filter
screenfeed_autowpdb_can_log
.
- New filter
Table
- New method
get_last_error()
, which returns the last DB error. clone_to()
:- Allow
0
as a valid table name.
- Allow
TableUpgrader
- Use
static
instead ofself
, so the class can be extended and tested. init()
:- Move tests from the constructor to the
init()
method. - Don't add the upgrade hook if the hook name is set to
false
.
- Move tests from the constructor to the
table_is_up_to_date()
:- Fix when downgrade is handled, it was returning the opposite of the expected value.