PluginProbe
Forumax – AI Powered Advanced Community Forum Plugin / 2.5.1
Forumax – AI Powered Advanced Community Forum Plugin v2.5.1
2.5.1 2.5.0 2.4.4 2.4.3 2.4.2 2.4.1 2.4.0 trunk 1.0.8 1.1.0 1.2.1 1.2.2 1.2.3 1.2.4 1.2.5 1.2.6 1.2.7 1.2.8 1.2.9 1.3.0 1.3.1 1.3.2 1.3.3 1.4.0 1.4.1 All 31 releases
← All changes | includes/features/bbpc_attachments/code/front.php +19 -15 2.4.4 → 2.5.1 View file →
@@ -118,21 +118,26 @@
118 118
119 119 public function process_attachments( $reply_id, $topic_id, $forum_id, $anonymous_data = null, $reply_author = null ) {
120 120 $uploads = [];
121 121 $revision = false;
122 + $errors = new gdbbp_Error();
122 123
123 124 if ( ! empty( $_FILES ) && ! empty( $_FILES['bbpc_attachment'] ) ) {
124 125 require_once ABSPATH . 'wp-admin/includes/file.php';
125 126
126 - $errors = new gdbbp_Error();
127 127 $overrides = [
128 128 'test_form' => false,
129 - 'upload_error_handler' => 'bbpc_bbattachment_handle_upload_error',
129 + 'upload_error_handler' => 'forumax_bbattachment_handle_upload_error',
130 130 ];
131 131
132 - foreach ( $_FILES['bbpc_attachment']['error'] as $key => $error ) {
132 + foreach ( (array) $_FILES['bbpc_attachment']['error'] as $key => $error ) {
133 133 $file_name = $_FILES['bbpc_attachment']['name'][ $key ];
134 134
135 + // Empty file inputs are not errors.
136 + if ( UPLOAD_ERR_NO_FILE === (int) $error ) {
137 + continue;
138 + }
139 +
135 140 if ( $error == UPLOAD_ERR_OK ) {
136 141 $file = [
137 142 'name' => $file_name,
138 143 'type' => $_FILES['bbpc_attachment']['type'][ $key ],
@@ -154,31 +159,30 @@
154 159 } else {
155 160 $errors->add( 'bbpc_upload', 'File exceeds allowed file size.', $file_name );
156 161 }
157 162 } else {
158 - switch ( $error ) {
159 - default:
160 - case 'UPLOAD_ERR_NO_FILE':
161 - $errors->add( 'php_upload', 'File not uploaded.', $file_name );
162 - break;
163 - case 'UPLOAD_ERR_INI_SIZE':
163 + switch ( (int) $error ) {
164 + case UPLOAD_ERR_INI_SIZE:
164 165 $errors->add( 'php_upload', 'Upload file size exceeds PHP maximum file size allowed.', $file_name );
165 166 break;
166 - case 'UPLOAD_ERR_FORM_SIZE':
167 + case UPLOAD_ERR_FORM_SIZE:
167 168 $errors->add( 'php_upload', 'Upload file size exceeds FORM specified file size.', $file_name );
168 169 break;
169 - case 'UPLOAD_ERR_PARTIAL':
170 + case UPLOAD_ERR_PARTIAL:
170 171 $errors->add( 'php_upload', 'Upload file only partially uploaded.', $file_name );
171 172 break;
172 - case 'UPLOAD_ERR_CANT_WRITE':
173 + case UPLOAD_ERR_CANT_WRITE:
173 174 $errors->add( 'php_upload', 'Can\'t write file to the disk.', $file_name );
174 175 break;
175 - case 'UPLOAD_ERR_NO_TMP_DIR':
176 + case UPLOAD_ERR_NO_TMP_DIR:
176 177 $errors->add( 'php_upload', 'Temporary folder for upload is missing.', $file_name );
177 178 break;
178 - case 'UPLOAD_ERR_EXTENSION':
179 + case UPLOAD_ERR_EXTENSION:
179 180 $errors->add( 'php_upload', 'Server extension restriction stopped upload.', $file_name );
180 181 break;
182 + default:
183 + $errors->add( 'php_upload', 'File not uploaded.', $file_name );
184 + break;
181 185 }
182 186 }
183 187 }
184 188 }
@@ -254,9 +258,9 @@
254 258
255 259 $attachments = forumax_get_post_attachments( $id );
256 260
257 261 $post = get_post( $id );
258 - $author_id = $post->post_author;
262 + $author_id = $post ? $post->post_author : 0;
259 263
260 264 if ( ! empty( $attachments ) ) {
261 265 $content .= '<div class="bbp-attachments">';
262 266 $content .= '<h6>' . __( 'Attachments', 'forumax' ) . ':</h6>';