Uncategorized

  • CSS Grid arrived, and the layout hacks can go

    Chrome 57 and Firefox 52 shipped it a fortnight apart in March. Replacing a grid system of nested rows, negative margins and a clearfix with fourteen lines.

  • Redis 4.0 UNLINK frees in the background

    Redis is single-threaded, so DEL on a structure with a million members blocks every other client for as long as freeing it takes — which is milliseconds for…

  • wp_json_encode over json_encode, for the charset

    json_encode() returns false on invalid UTF-8 and gives no indication why, which on a site with content pasted from Word is a JSON response that is silently empty.…

  • wp_add_inline_script instead of wp_localize_script

    wp_localize_script() exists to pass translated strings to JavaScript and has been used for everything else because it was the only way to get data across. 4.5 added the…

  • Generated columns can be indexed and cannot be written

    A value derived from other columns is usually maintained by application code or a trigger, and both drift. A generated column is computed by the server and cannot…

  • wp-cli –require to load a file before the command

    A one-off maintenance script usually gets written as a file and run with wp eval-file, which works until it needs to define a class or register a command…

  • A correlation id through every service

    Centralised logs from four services are four streams in one place until something ties a single request together across them. That something has to be generated at the…

  • wp_cache_get with the found flag

    A cached value of false and a cache miss both return false, so a lookup that legitimately caches “no result” re-queries on every request and the cache appears…

  • Secrets in environment variables are visible to the process list

    Environment variables are the standard place to put configuration and they are readable by anything that can see the process — including, on many systems, other users. The…

  • Batching a WP-CLI loop so it does not exhaust memory

    A command iterating every post accumulates objects in the query cache and the object cache, so a loop that works over 10,000 rows fails over 200,000 — and…