How to Quickly and Reliably Fix a Bug

Problem:

You need to fix a bug. However it takes you a lot of effort to fix. The fix may also not be reliable. How can you avoid this situation?

Solution:
  1. Try to understand the scenario or use case. Ensure that you and the tester are talking about the same thing and agree about the missing or incorrect elements by comparing the final user interface with the original approved use case or user story or specification.
  2. Try to reliably reproduce the bug. It is okay if this attempt may not be successful.
  3. Try isolating the bug in the same or similar environment by using specific, smaller data and fewer settings. It is okay if this attempt may not be done due to your inherent complex software.
  4. Search for an existing solution using error message generated by the system. Include any library or framework name and version, and operating system name and version in search key words. If there is already an existing solution then this attempt can save us a lot of effort.
  5. Try to understand all the concepts in error message.
  6. Debug and log messages to identify the exact location in 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 in the code related to the issue.
    • Trying to understand programming language syntax in the code. Do not guess anything.
    • Trying to understand purpose, inputs and outputs of library functions related to the use case. Again, do not guess anything.
    • Trying to understand data structure and a part of the database schema related to the use case.
    • Trying to review some concrete values inside the database if possible.
    • Trying to understand concepts, algorithms and architecture related to the use case. Again, do not guess anything.
    • These steps may be done in parallel and iteratively.
  7. Guess a cause of the problem based on the information that you can get in the sixth step.
  8. Try to isolate the issue, i.e. try to reproduce the issue using specific code and unit tests, if possible.
  9. Search for or propose a solution for the cause, i.e. propose a fix.
  10. Implement and test the fix.
  11. Repeat from step 5 to step 10 if necessary.

 

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 File 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.
    cd /var/hosting/huybien.com
    ls
    sudo zip -r huybien.zip /var/hosting/huybien.com/html
Configuration:
  • Log in your website as an Administrator.
  • Change your Administrator’s password.
  • Change file owner and group to www-data:
    sudo chown -R www-data:www-data /var/hosting/huybien.com/html
  • IMPORTANT STEP – Set minimum permissions for folders and files:
    cd /var/hosting/huybien.com/html
    sudo find . -type d -exec chmod 755 {} \; # directory permissions rwxr-xr-x
    sudo find . -type f -exec chmod 644 {} \; # file permissions rw-r--r--
  • 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.
  • Back up database.
    cd /home/ubuntu
    ls
    mysqldump -u root -p -h localhost huybiencomwp > huybiencomwp.sql
  • Back up files.
    cd /home/ubuntu
    ls
    sudo zip -r /home/ubuntu/huybien.zip /var/hosting/huybien.com/html
  • Download database and files backup.
  • Remove the backups.
    sudo rm -rf /home/ubuntu/huybiencomwp.sql
    sudo rm -rf /home/ubuntu/huybien.zip
    ls

 

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.