How to Quickly and Reliably Fix a Bug

Problem:

It may take you much effort to fix a bug. The fix may not be reliable. How can you avoid this situation?

Solution:
  1. Try to reliably reproduce the bug. It is okay if this may not be successful.
  2. Try isolating the bug on the same environment by using specific, smaller data and settings. It is okay if this is still not successful.
  3. Search for an existing solution using the error message, the library or framework name and version, and the operating system name and version. This can save us a lot of effort.
  4. Try to understand all the concepts in the error message.
  5. Debug and log messages to identify the exact location of the source code that causes the issue. In order to to this we need to do the followings.
    • Identifying the flow of the data, i.e. the use case, the entry point and the exit point.
    • Trying to understand the programming language syntax. Do not guess anything.
    • Trying to understand the purpose, inputs and outputs of a library function. Again, do not guess anything.
    • Trying to understand the data structure and a part of the database schema related to the use case.
    • Trying to review some values inside the database if possible.
    • Trying to understand the concepts, algorithms and architecture related to the use case.
    • These steps may be done in parallel and iteratively.
  6. Guess a cause of the problem based on the information retrieved in the third step.
  7. Try to isolate the issue, i.e. try to reproduce the issue using specific code and unit tests, if possible.
  8. Search for or propose a solution for the cause, i.e. propose a fix.
  9. Test the fix.
  10. Repeat from Step 5 to 8 if needed.

How to Fix a Hacked WordPress Website

Problem:

When you visit your WordPress website you are randomly redirected to unwanted websites.

Verification:
  • Log in your website as an Administrator.
  • Go to Appearance >> Theme Editor.
  • Click on the Theme Functions link on the right side.
  • Verify if malicious code was injected into the functions.php file.

Example of malicious code:

<?php @ini_set('display_errors', '0'); 
error_reporting(0); 
global $zeeta;
  • Download the wp-config.php file to your machine via FTP or SSH.
  • Verify if malicious code was injected into the wp-config.php file.

Example of malicious code:

include_once(ABSPATH . WPINC . '/header.php');
      Solution:
      • Stop the website.
      • Download the whole website to your local machine.
      sudo zip -r huybien.zip /var/www/huybien.com/html
      
      • Download the latest version of WordPress.
      • Unzip and the latest version of WordPress to a new folder.
      • Copy the wp-content/uploads folder, the wp-config.php, .htaccess, web.config, and ads.txt file from your original website to the new folder.
      • Review and remove all the suspicious contents in the wp-content/uploads directory of the new folder.
      • Go to the wp-content\themes folder of the new folder.
      • Manually re-download and unzip all the necessary themes.
      • Go to the wp-content\plugins folder of the new folder.
      • Manually re-download and unzip all the necessary plugins. Pay attention to the plugins that were closed due to Guideline Violation.
      • Delete all your website content in your root directory in your hosting server.
      cd /var/www/huybien.com/html
      sudo rm -rf *
      ls -a
      • Zip and upload the new folder to your hosting server.
      • Unzip the new content to your root directory.
      unzip huybien.zip -d /var/www/huybien.com/html
      • Start the website.
      Configuration:
      • Log in your website as an Administrator.
      • Change your Administrator’s password.
      • Remove all the unused plug-ins or themes.
      • Install, activate and configure a CAPTCHA plug-in to protect Login Form, Registration Form, Lost Password Form, Reset Password Form and Comment Form if there is no one.
      • Disable insecure FTP access if there is one.
      • Install and activate the Simple History plugin to review access to your website. After 1 or 2 days, review the access information, and possibly block the malicious IP addresses using the Windows Firewall.
      • Install, activate and configure¬†Cerber Security plug-in to automatically detect and block the malicious IP addresses.

       

       

      How to Fix “The parameter is incorrect” Issue When Disabling the Sync Host OneSyncSvc Service

      Problem:

      The Sync Host OneSyncSvc service was not started correctly and caused error in the Server Manager.

      You wanted to disable this service. However you got the “The parameter is incorrect” error message when disabling it.

      Solution:
      1. Click on the Search icon, type regedit, press Enter.
      2. Locate the key below
      Computer\HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services\OneSyncSvc

      3.  Change the Start value from 2 to 4 (Disabled).

      4. Restart the server.