| @@ -177,9 +177,9 @@ | ||
| 177 | 177 | $error = esc_html__( 'Invalid response from child site.', 'mainwp' ); |
| 178 | 178 | } |
| 179 | 179 | } |
| 180 | 180 | |
| 181 | - $output_array = array( | |
| 181 | + $output_array = array( | |
| 182 | 182 | 'old_version' => is_array( $information ) && isset( $information['old_version'] ) ? $information['old_version'] : '', |
| 183 | 183 | 'version' => is_array( $information ) && isset( $information['version'] ) ? $information['version'] : '', |
| 184 | 184 | 'success' => $success ? 1 : 0, |
| 185 | 185 | 'error' => $error, |
| @@ -1042,13 +1042,17 @@ | ||
| 1042 | 1042 | } |
| 1043 | 1043 | |
| 1044 | 1044 | $undefined = true; |
| 1045 | 1045 | |
| 1046 | + // Keep this for backward compatibility. | |
| 1046 | 1047 | if ( ! empty( $result['upgrades_started'] ) && is_array( $result['upgrades_started'] ) ) { |
| 1047 | 1048 | foreach ( $result['upgrades_started'] as $k => $v ) { |
| 1048 | - $return_results['result_started'][ rawurlencode( $k ) ] = esc_html( $v ); | |
| 1049 | + if ( empty( $v ) ) { | |
| 1050 | + $return_results['result_error'][ rawurlencode( $k ) ] = esc_html__( 'Premium action request failed. Please try again later.', 'mainwp' ); | |
| 1051 | + } else { | |
| 1052 | + $return_results['result_started'][ rawurlencode( $k ) ] = esc_html( $v ); | |
| 1053 | + } | |
| 1049 | 1054 | } |
| 1050 | - return $return_results; | |
| 1051 | 1055 | } |
| 1052 | 1056 | |
| 1053 | 1057 | if ( isset( $result['upgrades_error'] ) ) { |
| 1054 | 1058 | foreach ( $result['upgrades_error'] as $k => $v ) { |
| @@ -1160,9 +1164,24 @@ | ||
| 1160 | 1164 | } |
| 1161 | 1165 | } |
| 1162 | 1166 | return $return_results; |
| 1163 | 1167 | } elseif ( isset( $result['error'] ) ) { |
| 1164 | - throw new MainWP_Exception( 'WPERROR', esc_html( $result['error'] ) ); | |
| 1168 | + $error_message = esc_html( $result['error'] ); | |
| 1169 | + | |
| 1170 | + if ( ! empty( $result['http_code'] ) ) { | |
| 1171 | + $error_message .= ' HTTP code: ' . esc_html( $result['http_code'] ) . '.'; | |
| 1172 | + } | |
| 1173 | + | |
| 1174 | + if ( ! empty( $result['rep_error'] ) ) { | |
| 1175 | + $error_message .= ' Connection error: ' . esc_html( $result['rep_error'] ) . '.'; | |
| 1176 | + } | |
| 1177 | + | |
| 1178 | + if ( ! empty( $result['rep_error_code'] ) ) { | |
| 1179 | + $error_message .= ' Error code: ' . esc_html( $result['rep_error_code'] ) . '.'; | |
| 1180 | + } | |
| 1181 | + | |
| 1182 | + throw new MainWP_Exception( 'WPERROR', $error_message ); // phpcs:ignore --NOSONAR - escaped. | |
| 1183 | + | |
| 1165 | 1184 | } elseif ( isset( $result['notices'] ) ) { |
| 1166 | 1185 | $noti = $result['notices']; |
| 1167 | 1186 | if ( ! empty( $noti ) && is_string( $noti ) ) { |
| 1168 | 1187 | throw new MainWP_Exception( $noti, '', 'MAINWP_NOTICE' ); //phpcs:ignore WordPress.Security.EscapeOutput.ExceptionNotEscaped |