Skip to content

Instantly share code, notes, and snippets.

WordPress Database Migration to UTF8 (Altis)

Moving a WordPress database to "all UTF8" can be problematic. Without taking note of the specific scenario, you might find yourself struggling with messed up encoding (on not-ascii chars). If you find yourself manually replacing messed up chars in a database, stop! You should never need to do this. Only in the worst cases of "split brain encoding" might you need to do something like that.

When moving a WordPress database to a new charset, it's not uncommon for there to be a mixture of latin and utf8 in different settings. This is because WordPress' default encoding used to be latin1 a long time ago. To confuse things furthere, there can also be a mismatch between WordPress' understanding of the encoding for the database, and MySQL's.

DB_CHARSET

You must find the value of DB_CHARSET in WordPress. This is typically in the wp-config.php, however it might not be. WordPress has a default value, which can vary depending if you are using a DB drop-in pl

#!/bin/bash
SINCE_BRANCH=$1
TO_BRANCH=${2:-master}
if [[ -z $SINCE_BRANCH ]]; then
echo "usage: changelog <since-branch> [<to-branch>]"
exit 1
fi
CURRENT_DIR=$(PWD)
ISSUE_REGEX="#([0-9]+)"
<?php
class FSStreamWrapper {
function stream_open( $file, $mode ) {
$this->handle = fopen( str_replace( 'fs://', '', $file ), $mode );
return true;
}
function stream_read( $count ) {
return fread( $this->handle, $count );
}
@joehoyle
joehoyle / bench.php
Created September 10, 2017 10:12
PHP Benchmark
<?php
/*
##########################################################################
# PHP Benchmark Performance Script #
# � 2010 Code24 BV #
# #
# Author : Alessandro Torrisi #
# Company : Code24 BV, The Netherlands #
# Date : July 31, 2010 #
# version : 1.0 #
Tachyon
Faster than light image resizing service that runs on AWS. It's super simple to set up, highly available and very performant.
A Human Made project. Maintained by @joehoyle.
<?php
global $wp_filter;
if ( ! $wp_filter ) {
$wp_filter = array(
'parse_request' => array(),
'rest_post_dispatch' => array(),
);
}
Process 3781 received signal 11: segmentation violation
process id 3781 fatal signal (SIGSEGV, SIGFPE, SIGILL, SIGBUS, ...) - stack dump follows (code=0x7fc8cc762000 bss=0x7fc8cca0e02c):
/usr/lib/php/20151012/newrelic.so(+0x4b63e)[0x7fc8cc7ad63e]
/usr/lib/php/20151012/newrelic.so(+0x2bffa)[0x7fc8cc78dffa]
/lib/x86_64-linux-gnu/libpthread.so.0(+0x10330)[0x7fc8d6af5330]
/usr/lib/php/20151012/newrelic.so(+0x43a19)[0x7fc8cc7a5a19]
/usr/lib/php/20151012/newrelic.so(+0x46b9e)[0x7fc8cc7a8b9e]
/usr/lib/php/20151012/newrelic.so(+0x46b59)[0x7fc8cc7a8b59]
/usr/lib/php/20151012/newrelic.so(+0x1b3b3)[0x7fc8cc77d3b3]
/usr/lib/php/20151012/newrelic.so(+0x1bd82)[0x7fc8cc77dd82]
<?php
/**
* Plugin Name: DB Query Backtrace
* Description: Add backtraces to MySQL Queries to enable backtracing from mysql slowlogs / process lists.
* Author: Joe Hoyle
* Version: 1.0
*/
namespace DB_Query_Backtrace;
<?php
/*
* Plugin Name: Post Likes
* Description: WP REST API Post Likes
* Author: Joe Hoyle
* Version: 1.0
* Author URI: http://joehoyle.co.uk
*/
<?php
/**
* @rest-api-base-namespace: /wp/v2
* @rest-api-base-path: /posts
*/
class REST_API_Endpoint_Test extends WP_REST_Unit_Test_Case {
function test_create_item() {