Issue with update code and HTTPS redirect
-
There appears to be an issue with the code that updates from bwps_enable_ssl to itsec_enable_ssl meta_key.
I noticed this because pages which were previously forced to SSL stopped being redirected. The code I believe is at fault is in ssl_redirect method of the ITSEC_SSL class.
$bwps_ssl = get_post_meta( $post->ID, 'bwps_enable_ssl', true ); if ( $bwps_ssl == true ) { delete_post_meta( $post->ID, 'bwps_enable_ssl' ); update_post_meta( $post->ID, 'itsec_enable_ssl', true ); } elseif ( $bwps_ssl == false ) { delete_post_meta( $post->ID, 'bwps_enable_ssl' ); update_post_meta( $post->ID, 'itsec_enable_ssl', false ); }
I think the issue is caused because get_post_meta returns an empty string when the ‘bwps_enable_ssl’ meta_key does not exist. When compared with ==, an empty string evaluates to false, and thus itsec_enable_ssl is set to empty in the database. Adding an explicit test for an empty string ( ” != $bwps_ssl ) would fix this.
I also think, the upgrade code may be “bad” because the first time a legacy HTTPS page is viewed it is does not redirect to HTTPS. Moving the code from line 54 to 68 would fix this issue.
- The topic ‘Issue with update code and HTTPS redirect’ is closed to new replies.