diff --git a/content/database-orm/eloquent-orm.mdx b/content/database-orm/eloquent-orm.mdx index bd99744..b8b65c3 100644 --- a/content/database-orm/eloquent-orm.mdx +++ b/content/database-orm/eloquent-orm.mdx @@ -53,6 +53,12 @@ Remember that the Namespace inside the WordPress plugins architecture should be WP Bones connects Eloquent to the database WordPress itself uses. On most sites that is MySQL, configured by `DB_HOST`, `DB_NAME`, `DB_USER` and `DB_PASSWORD` in `wp-config.php`. +Since WP Bones 2.0.12 that connection talks to MySQL the way WordPress does. It uses the charset and collation WordPress settled on (`$wpdb->charset` and `$wpdb->collate`, `utf8mb4` on any recent install, even when `DB_CHARSET` still says `utf8`), so emoji and other 4-byte characters are written and read back intact. It also reads `DB_HOST` like WordPress: a port (`localhost:3307`) and a socket (`localhost:/tmp/mysql.sock`) both work, and an IPv6 host is put in brackets when PHP uses `mysqlnd`, as WordPress does. + + +Up to 2.0.11 the connection was always `utf8`: on MySQL 8 writing an emoji through Eloquent failed with error 3988, and an emoji written by WordPress came back as `?`. A `DB_HOST` with a socket didn't connect. + + Since WP Bones 2.0.11, when WordPress runs on SQLite (WordPress Playground, WordPress Studio, or any site with the [SQLite Database Integration](https://wordpress.org/plugins/sqlite-database-integration/) plugin), Eloquent connects to the same SQLite file instead, the one the `FQDB` constant points at. The WordPress tables keep their names there, so your models work unchanged, and what they write is what `$wpdb` reads. diff --git a/package.json b/package.json index 4214d9b..10e86e9 100644 --- a/package.json +++ b/package.json @@ -77,5 +77,5 @@ "test": "yarn next typegen && yarn format:test && yarn lint && yarn typecheck && yarn jest", "typecheck": "tsc --noEmit" }, - "version": "2.0.11" + "version": "2.0.12" } diff --git a/public/newsletter/wpbones-2.0.12-eloquent-mysql.png b/public/newsletter/wpbones-2.0.12-eloquent-mysql.png new file mode 100644 index 0000000..dce6613 Binary files /dev/null and b/public/newsletter/wpbones-2.0.12-eloquent-mysql.png differ diff --git a/public/wpkirk-api-boilerplate.zip b/public/wpkirk-api-boilerplate.zip index 277530d..1f7bc40 100644 Binary files a/public/wpkirk-api-boilerplate.zip and b/public/wpkirk-api-boilerplate.zip differ diff --git a/public/wpkirk-blade-boilerplate.zip b/public/wpkirk-blade-boilerplate.zip index 5a3afd1..7f9df48 100644 Binary files a/public/wpkirk-blade-boilerplate.zip and b/public/wpkirk-blade-boilerplate.zip differ diff --git a/public/wpkirk-boilerplate.zip b/public/wpkirk-boilerplate.zip index 2d48c26..59fb9e0 100644 Binary files a/public/wpkirk-boilerplate.zip and b/public/wpkirk-boilerplate.zip differ diff --git a/public/wpkirk-cpt-boilerplate.zip b/public/wpkirk-cpt-boilerplate.zip index ac2329c..2f9b195 100644 Binary files a/public/wpkirk-cpt-boilerplate.zip and b/public/wpkirk-cpt-boilerplate.zip differ diff --git a/public/wpkirk-cron-boilerplate.zip b/public/wpkirk-cron-boilerplate.zip index 5277e14..2422ced 100644 Binary files a/public/wpkirk-cron-boilerplate.zip and b/public/wpkirk-cron-boilerplate.zip differ diff --git a/public/wpkirk-database-boilerplate.zip b/public/wpkirk-database-boilerplate.zip index 38ea241..be2e535 100644 Binary files a/public/wpkirk-database-boilerplate.zip and b/public/wpkirk-database-boilerplate.zip differ diff --git a/public/wpkirk-hooks-boilerplate.zip b/public/wpkirk-hooks-boilerplate.zip index 2580d47..1354b63 100644 Binary files a/public/wpkirk-hooks-boilerplate.zip and b/public/wpkirk-hooks-boilerplate.zip differ diff --git a/public/wpkirk-internationalization-boilerplate.zip b/public/wpkirk-internationalization-boilerplate.zip index ef99713..2c7d791 100644 Binary files a/public/wpkirk-internationalization-boilerplate.zip and b/public/wpkirk-internationalization-boilerplate.zip differ diff --git a/public/wpkirk-mantine-boilerplate.zip b/public/wpkirk-mantine-boilerplate.zip index 94df200..cddd9a2 100644 Binary files a/public/wpkirk-mantine-boilerplate.zip and b/public/wpkirk-mantine-boilerplate.zip differ diff --git a/public/wpkirk-options-boilerplate.zip b/public/wpkirk-options-boilerplate.zip index 9b2caef..c03bfcc 100644 Binary files a/public/wpkirk-options-boilerplate.zip and b/public/wpkirk-options-boilerplate.zip differ diff --git a/public/wpkirk-packages-boilerplate.zip b/public/wpkirk-packages-boilerplate.zip index 2fbff11..3bb4076 100644 Binary files a/public/wpkirk-packages-boilerplate.zip and b/public/wpkirk-packages-boilerplate.zip differ diff --git a/public/wpkirk-reactjs-boilerplate.zip b/public/wpkirk-reactjs-boilerplate.zip index 7065d94..ff25de1 100644 Binary files a/public/wpkirk-reactjs-boilerplate.zip and b/public/wpkirk-reactjs-boilerplate.zip differ diff --git a/public/wpkirk-routes-boilerplate.zip b/public/wpkirk-routes-boilerplate.zip index bfb82fc..35afc39 100644 Binary files a/public/wpkirk-routes-boilerplate.zip and b/public/wpkirk-routes-boilerplate.zip differ diff --git a/public/wpkirk-typescript-boilerplate.zip b/public/wpkirk-typescript-boilerplate.zip index e8e3cfb..a65f4b6 100644 Binary files a/public/wpkirk-typescript-boilerplate.zip and b/public/wpkirk-typescript-boilerplate.zip differ