Author: Andy Fragen

wp-config file

WordPress Debugging

It is inevitable. At some point when running a WordPress site you will have a conflict, an error, or worst case – a PHP Fatal leading to a WSOD (White Screen of Death).

My goal is to provide the means with which you should be able to view and hopefully understand, to some degree, the errors so that the most appropriate person can provide a solution.

Why is it Inevitable?

By virtue of the shear number of different WordPress plugins, themes, and PHP versions, there are bound to be interactions that cause issues. Hopefully these issues don’t bring down your site. But some will.

Types of Errors

There are a few basic types of errors common to WordPress sites. Primarily all are PHP errors. There are 3 primary types of PHP errors: PHP Fatal, PHP Warning, and PHP Notice.

Under most circumstances you might not even be aware of either the PHP Warning or PHP Notice errors as they commonly only display in your PHP error log. A PHP Fatal error is the most common cause of the WSOD, but again you won’t see the actual error outside of an error log.

By default WordPress doesn’t display these errors to the user. You can adjust certain settings within wp-config.php to bring these errors to display and/or log them to a WordPress specific debug.log.

For many, modifying the wp-config.php file is a daunting task that in and of itself, can bring your site down. I’ve tried to simplify this with the creation of my WP Debugging plugin.

My plugin will add settings to wp-config.php. More specifically setting WP_DEBUG to true and setting WP_DEBUG_LOG to true. There are a number of additional settings that can also set to assist in debugging.

xDebug Isn’t the Only Way

Tom McFarlin has written extensively about coding and debugging.

In this member’s only post, Tom explains many of the individual settings that can assist in debugging a WordPress site using only native WordPress functions.

Automate All the Things

WP Debugging is a plugin I wrote to automatically add many of WordPress’ built-in settings on plugin activation and remove them on plugin deactivation.

Additionally, the plugin automatically installs and activates 2 additional plugins, Query Monitor by John Billion and Debug Quick Look by Andrew Norcross. These plugins are required, though that can be modified by the user, only because I made that decision.

Query Monitor is an established development plugin that provides a wealth of information for debugging. Debug Quick Look is a wonderful plugin whose sole function is to display the debug.log that WordPress writes debugging errors to when WP_DEBUG_LOG is set to true.

There are also two optional plugin dependencies that request to be installed, Debug Bar and GitHub Updater. The purpose of installing GitHub Updater is to keep the WP Debugging plugin updated.

Looking in the Logs

Viewing the debug.log will allow you to gain insight into the cause of the error. Often these errors will provide a stack trace pointing to exactly the file, function, or line of the error. They will definitely aid the developer.

Debugging is a art. One that you will only gain proficiency in through practice. It is my goal to help bring this information closer to you as simply as possible via the WP Debugging plugin.

You can read more about the specifics of what the WP Debugging plugin does on GitHub and, as always, PRs are happily considered on the develop branch.

Filed under: code, WordPressTagged with: , ,
raspberry pi

Installing Gitea on a Raspberry Pi

While adding an integration for Gitea to GitHub Updater I stumbled upon the fact that many were installing Gitea on a Raspberry Pi. Now the Raspberry Pi has developed a cult-like following and the Internet is full of innumerable use cases.

Gitea is a very performant self-hosted git server written in Go. While working on GitHub Updater’s Gitea integration, I was looking for a way to continue to be able to test in the long term. The Gitea access I had during the development was gone and so I was looking for a solution. A Google search showed that many had successfully installed Gitea on a Raspberry Pi.

As of this writing the Raspberry Pi 3B+ is the latest model. It is quite capable for a credit card sized computer. The 3B+ comes complete with WiFi, HDMI, Ethernet, 4 USB ports, and a micro SD card reader all built in.

There are many posts and YouTube videos providing instruction on setting up a Raspberry Pi just to get the point where you can start.

tl;dr, it’s really simple.

However, that’s where the simple stopped. I found a couple of web pages that gave instructions on how to install Gitea and Go on the Raspberry Pi, but most were lacking in some way.

To that end I offer my own fork, Installing Gitea on a Raspberry Pi 3.

This version adds instructions that I have followed several times from the beginning to end and come out with a working Gitea server. Within the instructions are instructions on updating both Go and Gitea once the installation is complete.

I offer no warranties and make no claims other than it worked for me.

Filed under: codeTagged with:

GitHub Updater and Gitea

Gitea is the new kid on the block for creating a self-hosted git server. Gitea is written in Go and is highly performant with very low overhead. In fact, Gitea is so efficient you can run it on a Raspberry Pi. There’s another post coming about that. 😉

As with most integrations of new git servers into GitHub Updater it all starts with an issue and a user willing to help. In this case, the user was Marco Berchart.

Over the years, I’ve continued to refactor GitHub Updater to become more OOP based and adding Gitea support definitely shows that this was the way to go. Adding support for Gitea was far and away the simplest integration yet. Much of this has to do with API closely following the GitHub API.

Marco was kind enough to start by creating  a PR and we were able to work on a branch until it was complete and able to be merged. There is a demo site at https://try.gitea.io where a test account can be created. There is no guarantee any sort of persistence and don’t expect your data, or possibly even your user, to be around long term. Marco was able to provide an account on his Gitea instance for me to test. I couldn’t have finished the integration with this access.

Since then I have figured out how to install Gitea on a Raspberry Pi. I’ve actually done the process several times and even updated both Go and Gitea. It makes testing much easier for me and it makes setting up your own local git server for less than $100 simple.

Filed under: code, computer, WordPressTagged with: ,

GitHub Updater – the Path to 8

In July it will have been 5 years since the first commit to GitHub Updater. In its 5 year span it has grown significantly in its evolution from a single file plugin to the complex integrated object oriented plugin that exists today.

Version 8 will see a bump in the requirement to at least PHP 5.6. Yes, it does work in PHP 7.2 but as PHP 5.6 is the lowest version of PHP still supported, I thought this was a nice minimum requirement. When PHP 5.6 becomes EOL’d I will transition up to PHP 7. I can only hope that at some point WordPress follows suit. I have learned that what this also means is that the bootstrap file needs to be compliant with a lower PHP version or the file will white screen the user’s site.

Version 8 has also seen a more modular architecture to the core of the plugin. What this means is that I’ve added a number of hooks to now allow me to keep most of the specific code siloed into its own classes. This has especially been beneficial to the Settings and Install functions.

In the Settings, this can result in a slight cosmetic difference as the APIs are hit and the server specific subtabs display. I’ve added a number of icons, tooltips, and notices to let the user know what’s happening and that no it’s not broken.

In case I haven’t mentioned it before, GitHub Updater also works with WP-CLI and can be used with a webhook for a continuous integration type of updating.

There’s already been a bump to version 8.1.1. The new feature is automatic renaming of the GitHub Updater plugin upon activation. If the plugin is renamed the activation fails as the activated plugin no longer exists. It has been renamed. 😉

As always, the best source of current information about GitHub Updater is the wiki.

Here’s the changelog.

Filed under: code, WordPress

GitHub Updater and Background Updates

GitHub Updater is a WordPress plugin that seeks to emulate the wp-admin dashboard updating experience for plugins and themes hosted on other git hosts. Among the most popular git hosts to use for social coding, or simply provide an external version control system, are GitHub, Bitbucket, GitLab, and Gitea. In order to provide an identical in-app experience GitHub Updater needs to make 5-6 API calls to the get all the data required. There are ways, and hooks, to bypass some of these API calls and therefore speed up the process, but this can result in a lesser experience.

A solution presented itself in WP-Cron. By using WP-Cron I have been able to drastically reduce the time required to bring the site back to a usable condition while GitHub Updater does its API checks in the background.

Naturally there is a hook to bypass this system as troubleshooting when WP-Cron is active can be difficult.

Using a background process does mean that there may be times when the user might try to access an update or branch switching and it may not yet be available. I’ve tried to make as many indicators as I can to let the user know that nothing is broken and that they are simply waiting on WP-Cron to finish.

The overall result is a much faster response time and much less potential wait while the GitHub Updater cache is updating or being refreshed.

As always there is more information in the wiki.

Filed under: WordPress