I was hitting this error quite regularly when Claude Code attempted git operations (git add / git checkout / git commit / etc.):
Error: Exit code 128 fatal: Unable to create '/path/to/.git/index.lock': File exists. Another git process seems to be running in this repository, e.g. an editor opened by 'git commit'. Please make sure all processes are terminated then try again. If it still fails, a git process may have crashed in this repository earlier: remove the file manually to continue.
Claude is very determined, so would attempt to work around it by removing the file, waiting, and then trying the process again. And then try other variants until it finally succeeded. This was super slow and annoying. Disk space, which is a common culprit, was not the problem. And I couldn’t find any other obvious causes, so I lived with it for a while.
Eventually, Claude hinted at a background process running git status that could be blocking things. I realized that my Claude statusline script was at fault (a git status call in my statusline refresh was setting a lock and blocking other git operations.)
If you run into the same issue, you can set this env var as part of your statusline script to avoid this: GIT_OPTIONAL_LOCKS = 0 (git docs)
Percentage of top 10 million sites on the web that use WordPress
(up from ~18% last year)
(~29% of all new websites)
Some of the biggest names in media, business, and government
New York Post
TIME.com
Quartz
Re/code
New York Times, Tribune Broadcasting, LIN Media, CBS Local, Conde Nast, ESPN, Grantland, FiveThirtyEight, Cox Media, EW, Cute Overload, TechCrunch, TheNextWeb, a16z, Grist, The Bloggess, Indian Express, USA Today, Stylecaster, BlackBerry, Post Secret, Harvard Business Review, Radar Online, Next Draft, Optus, NASA, and many more.
It’s hip to be WordPress
But do you really know and use WordPress to its potential?
Most Important: Stay Secure
– Keep your WordPress updated
– Use a strong password (or a Password Manager)
– User two-factor authentication
– Make sure your team does the same!
Structured Data
WordPress is a semantic publishing platform.
Custom Post Types
A custom post type is nothing more than a regular post with a different MARKDOWN_HASH01b0357bbb461420eb0aced7e3c2fcb9MARKDOWN_HASH value in the database. The post type of regular posts is post, pages use page, attachments use attachment and so on. You can now create your own to indicate the type of content created. You could create custom post types for books, movies, reviews, products, and so on.
WordPress’ custom taxonomies make it possible to structure large amounts of content in a logical, well-organized way. In WordPress, categories are set up as a hierarchal taxonomy, and tags are set up as a multifaceted taxonomy […] A large news organization could organize its content by world region (Africa, Asia, Europe, Latin America, Middle East, US & Canada), as the BBC does in its “World” section.
Edit Flow gives you custom statuses, a calendar, editorial comments, and more, all to make it much easier for your team to collaborate within WordPress.
Edit Flow: Calendar
A convenient month-by-month look at your content
Edit Flow: Custom Statuses
Define the key stages to your workflow.
Edit Flow: Editorial Comments
Threaded commenting in the admin for private discussion between writers and editors
Edit Flow: Everything Else
Notifications – Receive timely updates on the content you’re following.
User Groups – Keep your users organized by department or function.
Hosted platform for running blogs, sites, etc. using WordPress.
Big multisite network.
What is VIP?
WordPress hosting and services for big companies (CNN, TIME, ESPN, CBS, TechCrunch, Williams, etc.)
A VIP site on WordPress.com is the same as a free site, except with some custom code a bit of magic sauce.
The VIP team works with external developers providing code review, developer support, etc.
Fancy Numbers
54 million sites
62 million users
30 million posts (per month)
13 billion pageviews / 400 uniques (per month)
500 million MySQL tables
2500 servers
3+ DCs
How Many Deploys?
Yesterday: 259
VIP: 165 WP.com: 75 Other: 19
How is code deployed on WordPress.com?
Production servers run trunk
– Commit changes to trunk
– Run deploy script
– Deploy script syncs svn mirrors across DCSs and runs `svn up` on all servers
$ deploy wpcom
Going to update from 93786 to 93787 for /public_html/
Syncing wpcom SVN Mirrors
DFW (1s)...
IAD (2s)...
SAT (2s)...
Deploying wpcom revision 93787
Deploying to static webs
SAT (1s)...
IAD (1s)...
DFW (1s)...
Deploying to dynamic webs
DFW (5s)...
IAD (7s)...
SAT (9s)...
What about VIPs?
Similar to WordPress.com except:
– Code comes from external developers
– Deploy done internally
– We only push the particular folder (code changes are limited to the “theme”)
VIP Numbers
5 Software Engineers; 1 Happiness Engineer; other biz people
7m lines of code (on top of WP.com codebase)
1000s of sites
~100 active developers
Over 140K commits (currently r140321)
70K deploys all time
Avg deploy time (commit => review => deploy): 130 minutes
Challenges
– External developers writing PHP, HTML, and JS so anything is fair game
– Issues on one site can spill over to another (also helps with scaling)
Challenge: Code Review is hard and time-consuming! Blocks business needs!
Deploy Page
– custom built tool to optimize review process
– Used to track pending commits, review changes, and deploy
– Can send feedback on issues, alert rest of team when issues spotted
– Handy revert commands!
– “real-time”
Pre-Deploy Tests
Run when deploy button is pressed.
Loads up the site against a sandbox server in production with live database (crazy!) and latest code.
Static Analysis
Using custom scanning tools + PHP Code Sniffer to catch things like restricted functions, bad coding patterns/practices, etc.
Coming soon: post-commit tests
Using Jenkins to run tests immediately after commit, instead of on-demand using Sandbox server in production.
Other Tools
– Reference Page with handy revert commands
– IRC Channel piping PHP and MySQL errors from 2 servers
– IRC alerts for internal commit and deploy notifications
– Email and webhooks for external commit and deploy notifications
Future: Scaling
– More developers and automation
– Externally initiated deploys and post-deploy reviews
This slideshow could not be started. Try refreshing the page or viewing it in another browser.
Caching; For Fun & Profit
Understanding different caching tools and techniques available to WordPress developers such as the Transient and Object Caching APIs and how/why they can make or break your site.
This is the API WordPress uses and makes available to developers:
/**
* Retrieves the cache contents from the cache by key and group.
*
* @param int|string $key What the contents in the cache are called
* @param string $group Where the cache contents are grouped
*
* @return bool|mixed False on failure to retrieve contents or the cache
* contents on success
*/
function wp_cache_get( $key, $group = '' ) {
Object Caching API
/**
* Saves the data to the cache.
*
* @param int|string $key What to call the contents in the cache
* @param mixed $data The contents to store in the cache
* @param string $group Where to group the cache contents
* @param int $expire When to expire the cache contents
*
* @return bool False on failure, true on success
*/
function wp_cache_set( $key, $data, $group = '', $expire = 0 ) {
Object Caching API
/**
* Adds data to the cache, if the cache key doesn't already exist.
*
* @param int|string $key The cache key to use for retrieval later
* @param mixed $data The data to add to the cache store
* @param string $group The group to add the cache to
* @param int $expire When the cache data should be expired
*
* @return bool False if cache key and group already exist, true on success
*/
function wp_cache_add( $key, $data, $group = '', $expire = 0 ) {
Object Caching API
/**
* Removes the cache contents matching key and group.
*
* @param int|string $key What the contents in the cache are called
* @param string $group Where the cache contents are grouped
* @return bool True on successful removal, false on failure
*/
function wp_cache_delete( $key, $group = '' ) {
Difference between wp_cache_add and wp_cache_set?
If the value already exists, add will bail; set will override.
A few other intricacies as well, although, don’t worry about them unless you’re building really big sites.
The Cache Loop: In Action!
// First, check to see if the value is in the cache
$featured_posts = wp_cache_get( 'my-featured-posts' );
// Did we find it?
if ( false === $featured_posts ) {
// Nope! Let's generate and cache it!
$featured_posts = get_posts( array( 'post__in' => get_option( 'sticky_posts' ) ) );
wp_cache_set( 'my-featured-posts', $featured_posts );
}
// Cool, now we have our value; let's use it!
foreach ( $featured_posts as $post ) {
...
Warning: Careful with the false and error conditions!
You should account for those or be prepared for pain during failures.
This will retain objects in cache across pageloads, so you don’t need to hit the database again.
There are other caching backends as well like APC.
If you don’t have access to object cache…
Transients
If you’re a plugin/theme author, there’s no guarantee of the environment your users are in and whether persistent object caching is available.
WordPress Transients API helps you cache things without needed a caching backend.
Transients
The data:
a) persists across pageloads; and
b) expires after a set period of time (hence the name).
Useful for things like remote data or data that you know has a limited time span.
The Transients API
function get_transient( $transient ) {}
function set_transient( $transient, $value, $expiration ) {}
function delete_transient( $transient ) {}
The Cache Loop: In Action!
// First, check to see if the value is in the cache
$remote_data = get_transient( 'my-remote-data' );
// Did we find it?
if ( false === $remote_data ) {
// Nope! Let's fetch and cache it!
$response = wp_remote_get( 'http://foo.com/file.txt' );
$remote_data = json_decode( wp_remote_retrieve_body( $response ) );
set_transient( 'my-remote-data', $remote_data );
}
// Cool, now we have our value; let's use it!
foreach ( (array) $remote_data as $tweet ) {
...
Warning: Don’t overuse transients
* they’re stored in the options table and can bloat; and
* they require database calls to fetch.
Famous Last Words
“Oh, don’t worry. I’ll just put it in cache/transient…”
I worry. A lot.
Caching helps but…
You need to be smart about and understand what your application is doing.
A slow query will always be slow regardless of how many layers of caching you add around it.
Cache Stampedes Will Break You
Cache stampede: when a load of requests in succession kick of the same expensive process because all of them hit an empty cache on or around the same time.
Too many lumberjacks chopping the same wood
Cache Stampede: Solutions
Locking: Prevent the pileup
Async: Separate the cache generation process
…OR FIX (REMOVE) THE DAMN THING!
The Uncached (“cold cache”) Pageload
Optimize for the worst case scenario: aim for the best by optimizing for the worst (although, within realistic means).
Uncached pageloads should be as slim as possible.
The Uncached (“cold cache”) Pageload
Technique: Kill your object cache and examine load time patterns on a few different types of pages:
homepage
category
single
404
any special or complex templates
Examine the Uncached Pageload
What’s the load time like?
If it times out, that’s a red flag.
If the pageload time is inconsistent, that’s a red flag.
If the pageload time is unusually high, that’s a red flag.
Summary
Caching in WordPress is “easy”: many things built-in; many ways to do it
Understanding the intricacies of who, what, when, where to cache is hard!
There’s a lot more to caching than I’ve covered here!
If used well, caching will help keep your site alive, fast, and $$$!
A lot of the plugins I will talk about are mine or have significant contributions by me. Not because I’m being self-serving asshat but because these are some of the best tools for newsrooms to use.
DISCLAIMER #2
Tailor everything to your community and newsroom’s needs and culture; there is “no one size fits all” approach.
Scientific Fact of the Day!
17.5% of the web uses WordPress
(New York Times, TIME, CNN, CBS Local, National Post, Quartz, Boing Boing, Mashable, etc.)
Unscientific Fact of the Day!
80% of Canadian University newspapers use WordPress to power their sites.
University of Toronto | thevarsity.ca
University of Waterloo | theimprint.ca
University of Western Ontario | westerngazette.ca
York University | excal.on.ca
University of Victoria | martlet.ca
Ryerson University | theeyeopener.com
Carleton University | charlatan.ca
Concordian University | theconcordian.com
University of British Columbia | ubyssey.ca
University of Ottawa | thefulcrum.ca
University of Manitoba | themanitoban.com
It’s hip to be WordPress
But do you really know and use WordPress?
Leveraging Structured Data
WordPress is a semantic publishing platform.
Custom Post Types
A custom post type is nothing more than a regular post with a different MARKDOWN_HASH01b0357bbb461420eb0aced7e3c2fcb9MARKDOWN_HASH value in the database. The post type of regular posts is post, pages use page, attachments use attachment and so on. You can now create your own to indicate the type of content created. You could create custom post types for books, movies, reviews, products and so on.
WordPress’ custom taxonomies make it possible to structure large amounts of content in a logical, well-organized way. In WordPress, categories are set up as a hierarchal taxonomy, and tags are set up as a multifaceted taxonomy […] A large news organization could organize its content by world region (Africa, Asia, Europe, Latin America, Middle East, US & Canada), as the BBC does in its “World” section.
Edit Flow gives you custom statuses, a calendar, editorial comments, and more, all to make it much easier for your team to collaborate within WordPress.
Edit Flow: Calendar
A convenient month-by-month look at your content
Edit Flow: Custom Statuses
Define the key stages to your workflow.
Edit Flow: Editorial Comments
Threaded commenting in the admin for private discussion between writers and editors
Edit Flow: Everything Else
Notifications – Receive timely updates on the content you’re following.
User Groups – Keep your users organized by department or function.