DEV Community

Cover image for How to Get Information to Fix Bug in WordPress
GretaThemes
GretaThemes

Posted on • Edited on • Originally published at gretathemes.com

How to Get Information to Fix Bug in WordPress

How to Get Information to Fix Bug in WordPress

Managing a WordPress site so that it can deliver the best value for company business is not a simple duty. There is a wide range of skills and knowledge required to operate WordPress sites effectively. A capacity for investigating and fixing bugs for WordPress sites is the most important to make your website run smoothly.

The process of identifying the root causes of a WordPress site may vary from site to site. It is because of the diversity in site architecture & its corresponding components. The below post provides several essential points for fixing WordPress bugs from a bird-eyes view. Therefore, troubleshooting WordPress issues should not only belong to science but also belong to art.

Understanding the Essential Architecture of a WordPress Site

Looking at DevSecOps scope, the WordPress bugs may originate from:

  • Front-ends.
  • Web platform --- WordPress.
  • Web Servers (LAMP stack).
  • Operating System
  • Hardware infrastructure / VPS (Amazon, VMware ESXI...).
  • Network & Security.

Front-ends

Clearing cache & flushing DNS are common action plans for end-users when encountering web loading issues.

Using developer tools from clients' web browsers to identify the problematic HTML elements, then double-check from server sites. This is often to the next level --- troubleshooting at the web platform level.

Web browsers' developer's tools

Web Platform --- WordPress

Notice important files and directories from WordPress home. (The default value of $WP_HOME is /var/www/html/<wordpress_root_dir>).

File pathDescriptions$WP_HOME/wp-config.php- A configuration file for a site.$WP_HOME/wp-content- Contains contents of WordPress sites.$WP_HOME/wp-content/uploads

  • A directory that contains upload files of WordPress.

  • This upload directory is CONFIGURABLE.

Backup Your Current States

For complicated bugs, false-attempts in troubleshooting plans seem unavoidable. Backing up the whole system or important components is necessary to deal with unexpected outcomes while fixing bugs at WordPress sites. The backup versions can be a WordPress theme, web sources with its accompanying database. It would be ideal if developers can implement a backup of the whole host.

It would be great if system admins prepared several stable versions in advance to reduce downtime of production sites.

Clear WordPress Cache

Clearing cached data makes WordPress sites work with the latest available resource. Operators can use plugins to remove cached items for simplicity.

Troubleshooting at Pages/Posts Level

First of all, attempt several pages/posts to verify whether all pages/posts encounter similar bugs. Sometimes re-creating the page/post with similar contents resolves an issue.

Troubleshoot Plugins Level

1. Disable all plugins.\
2. Re-activate plugins one at a time.\
3. Test your site after each reactivation. Has the problem returned? If so, you have now found the suspect plugin. If not, continue to the next plugins.\
4. Disable the problematic plugins, update to the latest version, find alternate plugins if it is possible.\
5. Test other plugins to ensure you don't have multiple plugin problems.

Troubleshooting at WordPress Core

1. Download a clean version of WordPress from wordpress.org.\
2. Connect to your site via SSH, FTP, or using appropriate terminals tools.\
3. Rename wp-admin and wp-includes to ensure uploading clean copies of these directories.\
4. Back up wp-config.php just in case. These files hold your database connection details (amongst other things).\
5. Upload your clean version of WordPress.\
6. Test. If the issue disappears, the root cause is at the WordPress core. If the issue persists, time to proceed with further action plans.\
7. Re-activate your theme and test it.\
8. Re-activate your plugins and test them.

Web Server (LAMP Stack)

Web servers are software that are responsible for receiving HTTP requests, proceeding HTTP requests, and providing HTTP responses to clients. Every WordPress site runs on top of specific web servers. LAMP stack (Linux --- Apache --- MySql/MariaDB --- PHP) is a common web server for WordPress sites.

Linux

As usual, Linux is a common Operating system implemented as a platform to run Web Server. This is to maximize resource usage, system controls, and performance.

Apache

Important directories (default values when deploying Apache on CentOS. The default values can diversify depends on different platforms).

  • Important configuration files: /etc/httpd/conf/httpd.conf\
  • List of Apache configuration files:

  • [root@centos-wp-01 logs]# ls -1 /etc/httpd/conf.d/

  • autoindex.conf

  • php.conf

  • phpMyAdmin.conf

  • README

  • userdir.conf

  • welcome.conf

MySQL/MariaDB

Managing WordPress sites does not require much Database admin experience. Several common SQL commands related to CRUD operations, user management, schema management, and backup/restore are useful for WordPress site management.\
A WordPress site operator can manipulate Database directly on MySQL console, or phpMyAdmin (a web-based DBMS).

PHP

PHP plays an important role in the WordPress site. It connects to the database directly, renders the dynamic web page, and response to clients' requests. Close monitoring of WordPress sites is crucial to operating a healthy, secure, and well-performing website.

One important technique of controlling PHP operation is enabling logs. WordPress operators can enable logs by modifying the .htaccess file or the php.ini files. When a bug occurs, developers can backup, enable debug logs, and reproduce the issue. System behaviors will be recorded in the log files. This information is useful for operators to identify the root causes and come up with resolutions.

To determine the absolute path of the log file, operators can check the parameter $_SERVER['DOCUMENT_ROOT'].

Operating System

Monitoring the system performance with important parameters such as RAM, disk spaces, CPU usages, network traffics. The detailed utilities depend on the platform hosting WordPress sites.

Using the top command to monitor Linux resources

For ease-of-use, Windows/Windows Server can be used to deploy WordPress sites. For performance optimization, the Linux platform should be a preferred option.

Hardware Infrastructure/VPS

WordPress operators should be familiar with the essential techniques of operating WordPress hosts (either physical hosts or virtual hosts).

VMware workstation as a virtualization platform to host WordPress site

One common technique to operate a WordPress site effectively is having some backups of full host/snapshots. This is to restore the WordPress site in urgent circumstances immediately.

Network and Security

Ensure the traffic for HTTP/HTTPS protocols are under normal operation. By default, they should be on port 80/443 (HTTP/HTTPS). Another important port that should be concerned is 3306 for MySQL/Maria DB.

Using network tools to investigate port opening status of remote hosts

Be noticed that those above port numbers are common values for outgoing traffic. The internal traffics of HTTP requests & Database traffic may run on different ports. These ports may be NAT to comply with internal security rules.

Ask for Community Support

Because WordPress has the largest community all over the world, you can easily ask for help by providing your issues with accompanied operational logs/screenshots. There are a bunch of WordPress developers available to report bugs.

StackOverflow is a useful resource to gather referential clues for fix WordPress bugs

Another option is hiring freelancers to handle your WordPress bugs.

Restore the Whole System to Previous Stable Versions

In many circumstances, it is recommended to consider investigating a bug and minimize the downtime of a WordPress site. For several complicated bugs, it may take several hours to several days to resolve. Therefore, it is mandatory to have alternate actions to keep production sites under casual operation.

Preparing a full backup of a WordPress's host

Preparing a high-availability host to handle HTTP requests from visitors is a preferred option. Another common choice is to restore the previous stable version from backup images. The backup images can be the snapshots of virtual hosts, or just the websites & its corresponding database.

Conclusions

The ultimate goal of fixing WordPress bugs is to deliver the best performance of websites. Therefore, it is about delivering the best value for companies' business. Knowing how to fix WordPress bugs is an important skill to have an in-depth understanding of website operations. Operators not only maintain business operations seamlessly but also have more chances to advance their careers in the web development market.

We hope that after reading this post, you'll have a deeper insight into bug-fixing and can get information to fix bugs yourself more easily.

--- --- ---

The publication at GretaThemes.

Top comments (0)