Merge pull request #4445 from toddlahman/master

improved ob_end_clean for download handler
This commit is contained in:
Mike Jolley 2014-01-07 07:40:56 -08:00
commit f36d67fa69
3 changed files with 35 additions and 14 deletions

View File

@ -217,7 +217,13 @@ class WC_Download_Handler {
@ob_end_clean(); // Clear the output buffer
if ( ob_get_level() ) {
@ob_end_clean(); // Zip corruption fix
$levels = ob_get_level();
for ( $i = 0; $i < $levels; $i++ ) {
@ob_end_clean(); // Zip corruption fix
}
}
if ( $is_IE && is_ssl() ) {

View File

@ -679,22 +679,27 @@ class WC_Form_Handler {
$validation_error = new WP_Error();
$validation_error = apply_filters( 'woocommerce_process_login_errors', $validation_error, $_POST['username'], $_POST['password'] );
if ( $validation_error->get_error_code() )
if ( $validation_error->get_error_code() ) {
throw new Exception( '<strong>' . __( 'Error', 'woocommerce' ) . ':</strong> ' . $validation_error->get_error_message() );
}
if ( empty( $_POST['username'] ) )
if ( empty( $_POST['username'] ) ) {
throw new Exception( '<strong>' . __( 'Error', 'woocommerce' ) . ':</strong> ' . __( 'Username is required.', 'woocommerce' ) );
}
if ( empty( $_POST['password'] ) )
if ( empty( $_POST['password'] ) ) {
throw new Exception( '<strong>' . __( 'Error', 'woocommerce' ) . ':</strong> ' . __( 'Password is required.', 'woocommerce' ) );
}
if ( is_email( $_POST['username'] ) ) {
$user = get_user_by( 'email', $_POST['username'] );
if ( isset( $user->user_login ) )
if ( isset( $user->user_login ) ) {
$creds['user_login'] = $user->user_login;
else
} else {
throw new Exception( '<strong>' . __( 'Error', 'woocommerce' ) . ':</strong> ' . __( 'A user could not be found with this email address.', 'woocommerce' ) );
}
} else {
$creds['user_login'] = $_POST['username'];
}
@ -722,6 +727,7 @@ class WC_Form_Handler {
wp_redirect( apply_filters( 'woocommerce_login_redirect', $redirect, $user ) );
exit;
}
} catch (Exception $e) {
wc_add_notice( apply_filters('login_errors', $e->getMessage() ), 'error' );
@ -796,13 +802,22 @@ class WC_Form_Handler {
public function process_registration() {
if ( ! empty( $_POST['register'] ) ) {
WC()->verify_nonce( 'register' );
wp_verify_nonce( $_POST['register'], 'woocommerce-register' );
$validation_error = new WP_Error();
$validation_error = apply_filters( 'woocommerce_process_registration_errors', $validation_error, $_POST['username'], $_POST['password'], $_POST['email'] );
try {
$validation_error = new WP_Error();
$validation_error = apply_filters( 'woocommerce_process_registration_errors', $validation_error, $_POST['username'], $_POST['password'], $_POST['email'] );
if ( $validation_error->get_error_code() ) {
throw new Exception( '<strong>' . __( 'Error', 'woocommerce' ) . ':</strong> ' . $validation_error->get_error_message() );
}
} catch ( Exception $e ) {
wc_add_notice( $e->getMessage(), 'error' );
return;
if ( $validation_error->get_error_code() ) {
throw new Exception( '<strong>' . __( 'Error', 'woocommerce' ) . ':</strong> ' . $validation_error->get_error_message() );
}
$username = ! empty( $_POST['username'] ) ? wc_clean( $_POST['username'] ) : '';

View File

@ -48,7 +48,7 @@ function wc_create_new_customer( $email, $username = '', $password = '' ) {
if ( email_exists( $email ) )
return new WP_Error( "registration-error", __( "An account is already registered with your email address. Please login.", "woocommerce" ) );
wp_verify_nonce( $_POST['_wpnonce'], 'woocommerce-register' );
wp_verify_nonce( $_POST['register'], 'woocommerce-register' );
// Handle username creation
if ( get_option( 'woocommerce_registration_generate_username' ) == 'no' || ! empty( $username ) ) {
@ -259,7 +259,7 @@ function wc_customer_bought_product( $customer_email, $user_id, $product_id ) {
}
/**
* Checks if a user has a certain capability
* Checks if a user has a certain capability
*
* @access public
* @param array $allcaps
@ -328,4 +328,4 @@ function wc_customer_has_capability( $allcaps, $caps, $args ) {
}
return $allcaps;
}
add_filter( 'user_has_cap', 'wc_customer_has_capability', 10, 3);
add_filter( 'user_has_cap', 'wc_customer_has_capability', 10, 3);