Merge pull request #14070 from woocommerce/fix/13946-2

Dont throw exceptions when reading in saved bad downloads
This commit is contained in:
Claudio Sanches 2017-04-06 18:01:52 -03:00 committed by GitHub
commit 7d37d858b4
1 changed files with 6 additions and 2 deletions

View File

@ -1155,13 +1155,17 @@ class WC_Product extends WC_Abstract_Legacy_Product {
// Validate the file extension
if ( ! $download_object->is_allowed_filetype() ) {
$errors[] = sprintf( __( 'The downloadable file %1$s cannot be used as it does not have an allowed file type. Allowed types include: %2$s', 'woocommerce' ), '<code>' . basename( $download_object->get_file() ) . '</code>', '<code>' . implode( ', ', array_keys( $download_object->get_allowed_mime_types() ) ) . '</code>' );
if ( $this->get_object_read() ) {
$errors[] = sprintf( __( 'The downloadable file %1$s cannot be used as it does not have an allowed file type. Allowed types include: %2$s', 'woocommerce' ), '<code>' . basename( $download_object->get_file() ) . '</code>', '<code>' . implode( ', ', array_keys( $download_object->get_allowed_mime_types() ) ) . '</code>' );
}
continue;
}
// Validate the file exists.
if ( ! $download_object->file_exists() ) {
$errors[] = sprintf( __( 'The downloadable file %s cannot be used as it does not exist on the server.', 'woocommerce' ), '<code>' . $download_object->get_file() . '</code>' );
if ( $this->get_object_read() ) {
$errors[] = sprintf( __( 'The downloadable file %s cannot be used as it does not exist on the server.', 'woocommerce' ), '<code>' . $download_object->get_file() . '</code>' );
}
continue;
}