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 +38 -3 6.0.12 → 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,9 +183,17 @@
182 183 'version' => is_array( $information ) && isset( $information['version'] ) ? $information['version'] : '',
183 184 'success' => $success ? 1 : 0,
184 185 'error' => $error,
185 186 );
186 - mainwp_get_actions_handler_instance()->do_action_mainwp_install_actions( $website, 'updated', $output_array, 'core' );
187 +
188 + if ( $is_auto_update ) {
189 + MainWP_Updates_Report_Manager::save_update_info( $website, $output_array, 'core' );
190 + }
191 +
192 + $actions_handler = mainwp_get_actions_handler_instance();
193 + if ( is_object( $actions_handler ) ) {
194 + $actions_handler->do_action_mainwp_install_actions( $website, 'updated', $output_array, 'core' );
195 + }
187 196 }
188 197
189 198 /**
190 199 * Add a plugin or theme to the ignor list.
@@ -1033,8 +1042,19 @@
1033 1042 }
1034 1043
1035 1044 $undefined = true;
1036 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 +
1037 1057 if ( isset( $result['upgrades_error'] ) ) {
1038 1058 foreach ( $result['upgrades_error'] as $k => $v ) {
1039 1059 $return_results['result_error'][ rawurlencode( $k ) ] = esc_html( $v );
1040 1060 }
@@ -1144,9 +1164,24 @@
1144 1164 }
1145 1165 }
1146 1166 return $return_results;
1147 1167 } elseif ( isset( $result['error'] ) ) {
1148 - 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 +
1149 1184 } elseif ( isset( $result['notices'] ) ) {
1150 1185 $noti = $result['notices'];
1151 1186 if ( ! empty( $noti ) && is_string( $noti ) ) {
1152 1187 throw new MainWP_Exception( $noti, '', 'MAINWP_NOTICE' ); //phpcs:ignore WordPress.Security.EscapeOutput.ExceptionNotEscaped