Changeset 14623 for sites/trunk/wordpress.org/public_html/wp-content/plugins/plugin-directory/jobs/class-zip-cleanup.php
- Timestamp:
- 01/06/2026 01:01:00 AM (4 months ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
sites/trunk/wordpress.org/public_html/wp-content/plugins/plugin-directory/jobs/class-zip-cleanup.php
r13647 r14623 29 29 30 30 $attachments = get_posts( [ 31 'fields' => 'id=>parent', 31 32 'post_type' => 'attachment', 32 33 'post_mime_type' => 'application/zip', … … 38 39 'before' => self::KEEP_DAYS . ' days ago', 39 40 ] 40 ] 41 ], 42 43 // Don't prime caches, helps with some memory when we're not really using any of it. 44 'update_post_meta_cache' => false, 45 'update_post_term_cache' => false, 41 46 ] ); 42 47 43 foreach ( $attachments as $attachment ) {44 $plugin = get_post( $ attachment->post_parent);48 foreach ( $attachments as $attachment_id => $plugin_id ) { 49 $plugin = get_post( $plugin_id ); 45 50 46 51 // If not a plugin upload, or something drastically is wrong.. 47 if ( ! $ attachment->post_parent|| ! $plugin || 'plugin' !== $plugin->post_type ) {52 if ( ! $plugin_id || ! $plugin || 'plugin' !== $plugin->post_type ) { 48 53 continue; 49 54 } … … 63 68 $plugin_last_touched_date = 0; 64 69 foreach ( [ 'plugin_closed_date', '_approved', '_publish', '_rejected' ] as $meta_field ) { 65 $meta_value = get_post_meta( $plugin ->ID, $meta_field, true );70 $meta_value = get_post_meta( $plugin_id, $meta_field, true ); 66 71 if ( ! $meta_value ) { 67 72 continue; … … 85 90 86 91 // Cleanup ZIP-related metadata. 87 delete_post_meta( $plugin ->ID, '_submitted_zip_size' );88 delete_post_meta( $plugin ->ID, '_submitted_zip_loc' );92 delete_post_meta( $plugin_id, '_submitted_zip_size' ); 93 delete_post_meta( $plugin_id, '_submitted_zip_loc' ); 89 94 90 95 // Delete the file hash from the post. 91 $file_on_disk = get_attached_file( $attachment );96 $file_on_disk = get_attached_file( $attachment_id ); 92 97 if ( $file_on_disk && file_exists( $file_on_disk ) ) { 93 98 $file_hash = sha1_file( $file_on_disk ); … … 97 102 } 98 103 99 wp_delete_attachment( $attachment ->ID, true );104 wp_delete_attachment( $attachment_id, true ); 100 105 } 101 106 }
Note: See TracChangeset
for help on using the changeset viewer.