php

  • Docker for Mac replaced the virtual machine

    The shared-folder problem that nearly killed this last year is gone. What changes in the compose file, what the new file sharing costs, and where Linux and Mac…

  • Uniform variable syntax changed what $$a means

    PHP 7 made variable-variable expressions evaluate consistently left to right. That is an improvement and it silently changed the meaning of expressions that had been working for a…

  • The container binds interfaces, not only concrete classes

    The container resolves concrete classes automatically, which is convenient enough that most code type-hints the concrete class and the abstraction never happens. Contextual binding is the part worth…

  • wc_get_orders is the query you should be using

    Orders are posts, so WP_Query works and every example on the internet uses it — with a post_type of shop_order, a meta query for the customer, and a…

  • Null coalescing chains, and where null still gets through

    ?? chains left to right and returns the first operand that is not null, which reads like a safe navigation operator and is not one. It only guards…

  • Group use declarations shorten the import block

    A file importing six classes from the same namespace repeats the namespace six times, which is noise that grows with the depth of the tree. It is purely…

  • The N+1 queries you did not write

    1,400 queries on a page showing 40 rows. Eager loading, the difference between with() and load(), and the accessor that no eager load can fix.

  • wp_die is the wrong way to fail an AJAX request

    wp_die() in an AJAX handler sends an HTML error page with a 200 status, so the JavaScript sees a successful response containing markup and fails while parsing it.…

  • Query scopes are where the repeated where() clauses go

    The same three conditions appear in nine controllers, and when the definition of “active” changes there are nine places to edit and one that gets missed. The naming…

  • chunkById is the safe one when the loop mutates rows

    chunk() paginates with OFFSET, so if the loop body changes whether a row still matches the query, the offset for the next page has shifted and rows get…