BoldGrid / boldgrid-backup

The Total Upkeep plugin.
GNU General Public License v2.0
11 stars 9 forks source link

Restorations fail when using Socket instead of Localhost for DB #572

Closed jessecowens closed 10 months ago

jessecowens commented 11 months ago

Describe the bug Platform InMotion servers use localhost:/var/lib/mysql/mysql.sock for the DB_HOST value, as the team identified the socket to be more performant than TCP/IP localhost. However, when using this host value, restorations fail due to a "No route to host" error.

To Reproduce Steps to reproduce the behavior:

  1. Set the DB_HOST value in wp-config.php to the mysql socket path (reach out to Jesse on Platform i team if you need assistance replicating)
  2. Restore a backup file
  3. Note the following error in the restoration log:
    [message] => Uncaught PDOException: SQLSTATE[HY000] [2002] No route to host in /home/wordpress/doc_root/wp-content/plugins/boldgrid-backup/admin/class-boldgrid-backup-admin-db-import.php:154
    Stack trace:
    #0 /home/wordpress/doc_root/wp-content/plugins/boldgrid-backup/admin/class-boldgrid-backup-admin-db-import.php(154): PDO->__construct('mysql:host=loca...', 'wordpress', 'arTSbUdobApzWWw')
    #1 /home/wordpress/doc_root/wp-content/plugins/boldgrid-backup/admin/class-boldgrid-backup-admin-db-import.php(102): Boldgrid_Backup_Admin_Db_Import->import_lines(Array)
    #2 /home/wordpress/doc_root/wp-content/plugins/boldgrid-backup/admin/class-boldgrid-backup-admin-core.php(1317): Boldgrid_Backup_Admin_Db_Import->import('/home/wordpress...')
    #3 /home/wordpress/doc_root/wp-content/plugins/boldgrid-backup/admin/class-boldgrid-backup-admin-core.php(2565): Boldgrid_Backup_Admin_Core->restore_database('/home/wordpress...', 'wp_', NULL)
    #4 /home/wordpress/doc_root/wp-content/plugins/boldgrid-backup/includes/class-boldgrid-backup-restorer.php(200): Boldgrid_Backup_Admin_Core->restore_archive_file()
    #5 /home/wordpress/doc_root/wp-content/plugins/boldgrid-backup/admin/class-boldgrid-backup-admin-core.php(3069): Boldgrid_Backup_Restorer->run()
    #6 /home/wordpress/doc_root/wp-includes/class-wp-hook.php(324): Boldgrid_Backup_Admin_Core->wp_ajax_restore('')
    #7 /home/wordpress/doc_root/wp-includes/class-wp-hook.php(348): WP_Hook->apply_filters('', Array)
    #8 /home/wordpress/doc_root/wp-includes/plugin.php(517): WP_Hook->do_action(Array)
    #9 /home/wordpress/doc_root/wp-admin/admin-ajax.php(188): do_action('wp_ajax_boldgri...')
    #10 {main}
    thrown
    [file] => /home/wordpress/doc_root/wp-content/plugins/boldgrid-backup/admin/class-boldgrid-backup-admin-db-import.php
    [line] => 154

Expected behavior The database should be able to restore regardless of whether the localhost or socket is used for DB connections. Additionally, no failure message is presented to the user when the restoration fails, see #568