| @@ -42,13 +42,20 @@ | ||
| 42 | 42 | $output = array(); |
| 43 | 43 | $check_exts = array(); |
| 44 | 44 | foreach ( $extensions as $ext ) { |
| 45 | 45 | if ( isset( $ext['activated_key'] ) && 'Activated' === $ext['activated_key'] ) { |
| 46 | + // MWP-1546: $ext['api_key'] no longer exists in the aggregated | |
| 47 | + // mainwp_extensions option (the plaintext was removed from | |
| 48 | + // there). Fetch the per-slug activation info, which decrypts | |
| 49 | + // the api_key on read and returns plaintext only for this | |
| 50 | + // request scope. | |
| 46 | 51 | $args = array(); |
| 52 | + $api_slug = isset( $ext['slug'] ) ? dirname( $ext['slug'] ) : ''; | |
| 53 | + $activation = MainWP_Api_Manager::instance()->get_activation_info( $api_slug ); | |
| 47 | 54 | $args['plugin_name'] = $ext['api']; |
| 48 | 55 | $args['version'] = $ext['version']; |
| 49 | 56 | $args['product_id'] = $ext['product_id']; |
| 50 | - $args['api_key'] = $ext['api_key']; | |
| 57 | + $args['api_key'] = is_array( $activation ) && isset( $activation['api_key'] ) ? $activation['api_key'] : ''; | |
| 51 | 58 | $args['instance'] = $ext['instance_id']; |
| 52 | 59 | $args['software_version'] = $ext['software_version']; |
| 53 | 60 | $check_exts[ $args['plugin_name'] ] = $args; |
| 54 | 61 | } |
| @@ -77,9 +84,9 @@ | ||
| 77 | 84 | } |
| 78 | 85 | $rslt = new \stdClass(); |
| 79 | 86 | $rslt->slug = $slug; |
| 80 | 87 | $rslt->new_version = $response['new_version']; |
| 81 | - $rslt->package = $response['package']; | |
| 88 | + $rslt->package = array_key_exists( 'package', $response ) ? $response['package'] : null; | |
| 82 | 89 | $rslt->key_status = ''; |
| 83 | 90 | $rslt->apiManager = 1; |
| 84 | 91 | |
| 85 | 92 | if ( isset( $response['errors'] ) ) { |
| @@ -111,13 +118,18 @@ | ||
| 111 | 118 | $extensions = MainWP_Extensions_Handler::get_extensions(); |
| 112 | 119 | $rslt = null; |
| 113 | 120 | foreach ( $extensions as $ext ) { |
| 114 | 121 | if ( isset( $ext['api'] ) && ( $pSlug === $ext['api'] ) && isset( $ext['apiManager'] ) && ! empty( $ext['apiManager'] ) ) { |
| 122 | + // MWP-1546: same migration as check_exts_upgrade above -- | |
| 123 | + // pull the api_key from per-slug get_activation_info() instead | |
| 124 | + // of the (now-stripped) aggregated mainwp_extensions option. | |
| 125 | + $api_slug = isset( $ext['slug'] ) ? dirname( $ext['slug'] ) : ''; | |
| 126 | + $activation = MainWP_Api_Manager::instance()->get_activation_info( $api_slug ); | |
| 115 | 127 | $args = array(); |
| 116 | 128 | $args['plugin_name'] = $ext['api']; |
| 117 | 129 | $args['version'] = $ext['version']; |
| 118 | 130 | $args['product_id'] = $ext['product_id']; |
| 119 | - $args['api_key'] = $ext['api_key']; | |
| 131 | + $args['api_key'] = is_array( $activation ) && isset( $activation['api_key'] ) ? $activation['api_key'] : ''; | |
| 120 | 132 | $args['instance'] = $ext['instance_id']; |
| 121 | 133 | $args['software_version'] = $ext['software_version']; |
| 122 | 134 | $response = MainWP_Api_Manager_Plugin_Update::instance()->update_check( $args ); |
| 123 | 135 | |
| @@ -152,13 +164,16 @@ | ||
| 152 | 164 | $extensions = MainWP_Extensions_Handler::get_extensions(); |
| 153 | 165 | $rslt = null; |
| 154 | 166 | foreach ( $extensions as $ext ) { |
| 155 | 167 | if ( isset( $ext['api'] ) && $pSlug === $ext['api'] && isset( $ext['apiManager'] ) && ! empty( $ext['apiManager'] ) ) { |
| 168 | + // MWP-1546: same migration as the two functions above. | |
| 169 | + $api_slug = isset( $ext['slug'] ) ? dirname( $ext['slug'] ) : ''; | |
| 170 | + $activation = MainWP_Api_Manager::instance()->get_activation_info( $api_slug ); | |
| 156 | 171 | $args = array(); |
| 157 | 172 | $args['plugin_name'] = $ext['api']; |
| 158 | 173 | $args['version'] = $ext['version']; |
| 159 | 174 | $args['product_id'] = $ext['product_id']; |
| 160 | - $args['api_key'] = $ext['api_key']; | |
| 175 | + $args['api_key'] = is_array( $activation ) && isset( $activation['api_key'] ) ? $activation['api_key'] : ''; | |
| 161 | 176 | $args['instance'] = $ext['instance_id']; |
| 162 | 177 | $args['software_version'] = $ext['software_version']; |
| 163 | 178 | $rslt = MainWP_Api_Manager::instance()->request_extension_information( $args ); |
| 164 | 179 | break; |