PluginProbe
MainWP Dashboard: Self-hosted WordPress Management for Agencies / 6.2.2
MainWP Dashboard: Self-hosted WordPress Management for Agencies v6.2.2
6.2.2 6.2.1 6.2 6.1.8 6.1.7 6.1.6 6.1.5 6.1.4 6.1.3 6.1.2 6.1.1 6.1 6.0.12 6.0.11 4.6.0.1 5.0 5.0.1 5.0.2 5.0.3 5.0.3.1 5.0.3.2 5.1 5.1.1 5.2 5.2.1 All 155 releases
← All changes | pages/page-mainwp-updates-handler.php +34 -2 6.1.1 → 6.2.2 View file →
@@ -154,10 +154,11 @@
154 154 * Log upgrade activities.
155 155 *
156 156 * @param object $website Child site object.
157 157 * @param array $information Upgrade information.
158 + * @param bool $is_auto_update Whether the update is automatic.
158 159 */
159 - public static function activity_log_upgrade( $website, $information ) {
160 + public static function activity_log_upgrade( $website, $information, $is_auto_update = false ) { // phpcs:ignore -- NOSONAR - complex.
160 161 // Implementation for logging upgrade activities.
161 162 $error = '';
162 163 $success = false;
163 164
@@ -182,8 +183,13 @@
182 183 'version' => is_array( $information ) && isset( $information['version'] ) ? $information['version'] : '',
183 184 'success' => $success ? 1 : 0,
184 185 'error' => $error,
185 186 );
187 +
188 + if ( $is_auto_update ) {
189 + MainWP_Updates_Report_Manager::save_update_info( $website, $output_array, 'core' );
190 + }
191 +
186 192 $actions_handler = mainwp_get_actions_handler_instance();
187 193 if ( is_object( $actions_handler ) ) {
188 194 $actions_handler->do_action_mainwp_install_actions( $website, 'updated', $output_array, 'core' );
189 195 }
@@ -1036,8 +1042,19 @@
1036 1042 }
1037 1043
1038 1044 $undefined = true;
1039 1045
1046 + // Keep this for backward compatibility.
1047 + if ( ! empty( $result['upgrades_started'] ) && is_array( $result['upgrades_started'] ) ) {
1048 + foreach ( $result['upgrades_started'] as $k => $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 + }
1054 + }
1055 + }
1056 +
1040 1057 if ( isset( $result['upgrades_error'] ) ) {
1041 1058 foreach ( $result['upgrades_error'] as $k => $v ) {
1042 1059 $return_results['result_error'][ rawurlencode( $k ) ] = esc_html( $v );
1043 1060 }
@@ -1147,9 +1164,24 @@
1147 1164 }
1148 1165 }
1149 1166 return $return_results;
1150 1167 } elseif ( isset( $result['error'] ) ) {
1151 - 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 +
1152 1184 } elseif ( isset( $result['notices'] ) ) {
1153 1185 $noti = $result['notices'];
1154 1186 if ( ! empty( $noti ) && is_string( $noti ) ) {
1155 1187 throw new MainWP_Exception( $noti, '', 'MAINWP_NOTICE' ); //phpcs:ignore WordPress.Security.EscapeOutput.ExceptionNotEscaped