Skip to content

0.3

Pre-release
Pre-release
Compare
Choose a tag to compare
@Screenfeed Screenfeed released this 16 Sep 15:24
016fcda

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.

Basic

  • get():
    • Disallowed ARRAY_N value for the output type, as it conflicts with cast_row().

AbstractTableDefinition

  • An instance of Worker can be injected into the constructor.

DBUtilities / DBWorker\Worker

  • The static class DBUtilities is now the instanciable class DBWorker\Worker that implements DBWorker\WorkerInterface.
    Seeing how DBUtilities 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 in AbstractTableDefinition today, we need php 7.1 for nullable typehints (this is for a future release), but instanceof is used for the time being.
    The full instanciation is now new Table( new MyTableDefinition( new MyWorker() ) ).
    AbstractTableDefinition falls back to new 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.
  • quote_string():
    • Do not escape simple quotes anymore, it is done by esc_sql() in prepare_values_list().
  • can_log():
    • New filter screenfeed_autowpdb_can_log.

Table

  • New method get_last_error(), which returns the last DB error.
  • clone_to():
    • Allow 0 as a valid table name.

TableUpgrader

  • Use static instead of self, 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.
  • table_is_up_to_date():
    • Fix when downgrade is handled, it was returning the opposite of the expected value.