Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Error thrown during gzip Import #106

Open
sidedwards opened this issue Dec 9, 2019 · 1 comment
Open

Error thrown during gzip Import #106

sidedwards opened this issue Dec 9, 2019 · 1 comment

Comments

@sidedwards
Copy link

Trying to import a gzip sql file and it gets stuck on "Parsing SQL file, please wait". Here is the error thrown in the logs.

Stack trace:
#0 /app/wp-content/plugins/wp-migrate-db-pro/class/Pro/Import.php(543): DeliciousBrains\WPMDB\Pro\Import->file_is_gzipped('/tmp/5dee95da03...')
#1 /app/wp-content/plugins/wp-migrate-db-pro/class/Pro/Import.php(123): DeliciousBrains\WPMDB\Pro\Import->str_is_gzipped('# WordPress MyS...')
#2 /app/wp-includes/class-wp-hook.php(288): DeliciousBrains\WPMDB\Pro\Import->ajax_get_import_info('')
#3 /app/wp-includes/class-wp-hook.php(312): WP_Hook->apply_filters('', Array)
#4 /app/wp-includes/plugin.php(478): WP_Hook->do_action(Array)
#5 /app/wp-admin/admin-ajax.php(175): do_action('wp_ajax_wpmdb_g...')
#6 {main}
  thrown in /app/wp-content/plugins/wp-migrate-db-pro/class/Pro/Import.php on line 566
/**
 * Checks if the provided file is gzipped
 *
 * @param string $file
 *
 * @return bool
 */
public function file_is_gzipped( $file ) {
    $is_gzipped = false;

    if ( ! $this->filesystem->is_file( $file ) ) {
        return $is_gzipped;
    }

    $content_type = mime_content_type( $file ); // Looks like it's getting stuck here..

    if ( in_array( $content_type, array( 'application/x-gzip', 'application/gzip' ) ) ) {
        $is_gzipped = true;
    }

    return $is_gzipped;
}
@jpumfrey
Copy link

jpumfrey commented Mar 10, 2021

This helps to resolve the issue:

public function file_is_gzipped( $file ) {
    $is_gzipped = false;
    if ( ! $this->filesystem->is_file( $file ) ) {
        return $is_gzipped;
    }

    $mime = wp_check_filetype( $file );
    if ( false === $mime['type'] && function_exists( 'mime_content_type' ) ) {
        $mime['type'] = mime_content_type( $file );
    }

    if ( in_array( $mime['type'], array( 'application/x-gzip', 'application/gzip' ) ) ) {
        $is_gzipped = true;
    }

    return $is_gzipped;
}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants