PHP Runtime in WordPress

9

questions

How do you debug a white screen on a production WordPress site?

Turn on WP_DEBUG and WP_DEBUG_LOG with WP_DEBUG_DISPLAY off, reproduce the request and read the log. Since WordPress 5.2 a fatal error in a plugin or theme also triggers recovery mode and an email to the admin with the error and the file.

What changed in PHP 8.2 that broke many WordPress plugins?

Dynamic properties became deprecated: assigning a property that the class does not declare now raises a deprecation notice. Old plugins that attach data to objects on the fly flood the log until the properties are declared.

What does OPcache do and when do you need to reset it?

OPcache stores compiled opcodes of PHP files in shared memory, so files are not parsed on every request. When timestamp validation is off or delayed, a changed file keeps running the old code until the cache is reset, so a deploy should reload PHP-FPM or reset OPcache.

What does Requires PHP do?

It is a plugin header (and readme.txt field) with the minimum PHP version. Since WordPress 5.2 the plugin cannot be activated, and its updates are not offered, on a site with a lower PHP version, so new syntax never reaches a host that cannot parse it.

What is PHP-FPM and why do WordPress hosts use it?

PHP-FPM (FastCGI Process Manager) runs a pool of PHP worker processes separately from the web server. nginx or Apache passes .php requests to it over FastCGI. The pool can be sized and restarted independently, and each site can have its own pool, user and php.ini.

What is the difference between memory_limit and WP_MEMORY_LIMIT?

memory_limit is the PHP setting and the hard limit. WP_MEMORY_LIMIT is how much WordPress tries to raise the limit to for front-end requests, and WP_MAX_MEMORY_LIMIT for admin tasks. WordPress can never go above what the server allows.

What is the difference between WP_DEBUG_LOG and WP_DEBUG_DISPLAY?

WP_DEBUG_LOG writes errors to a file (wp-content/debug.log or a custom path). WP_DEBUG_DISPLAY prints them into the page. On any site with visitors you log and never display.

Why can php -v in SSH show a different version from the site?

The CLI and PHP-FPM are separate binaries, often with several PHP versions installed side by side. The terminal uses whatever php is first in PATH; the site uses the FPM pool configured for it. Check the site's version through WordPress itself.

Why use Xdebug instead of var_dump()?

Xdebug pauses execution at a breakpoint and shows every variable and the call stack, without editing code or printing data into the page. var_dump() changes the output, shows one value at a time and tends to end up in commits.