Skip to content

Releases: Screenfeed/autowpdb

0.3

16 Sep 15:24
016fcda
Compare
Choose a tag to compare
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.

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.

0.2

04 Aug 14:11
07b3f9b
Compare
Choose a tag to compare
0.2 Pre-release
Pre-release

Main changes:

  • DBUtilities:

    • Improved methods a bit, like wrapping table names into quotes in the queries.
    • New methods: delete_table(), reinit_table(), empty_table(), clone_table(), copy_table(), count_table_rows(), and sanitize_table_name(). This is inspired by what BerlinDB does.
  • New class Table: this class basically combines TableDefinitionInterface and DBUtilities, to be easier to work with.

  • CRUD classes:

    • Renamed get_table() into get_table_definition() to prevent confusion between the classes Table and the interface TableDefinitionInterface.
    • AbstractCRUD: the property table_definition is now private. Use get_table_definition() in sub-classes instead.
  • AbstractTableDefinition:

    • get_table_name() now uses DBUtilities::sanitize_table_name().
    • New method jsonSerialize() (from the interface JsonSerializable): returns an array containing the method results. The array keys are table_version, table_short_name, table_name, table_is_global, primary_key, column_placeholders, column_defaults, and table_schema. json_encode() can be used directly on the class instance now.
    • New magic method __toString(): this will simply json_encode() the class.
  • TableUpgrader:

    • Signature change: a Table object must be used as first argument instead of TableDefinitionInterface.
    • New methods table_is_allowed_to_upgrade() and delete_table().
    • The table version is not deleted from the DB anymore if the table upgrade failed.

0.1

04 Aug 13:26
Compare
Choose a tag to compare
0.1 Pre-release
Pre-release

Initial release.