Title: Patch to reduce disk access
Last modified: March 20, 2026

---

# Patch to reduce disk access

 *  Resolved [powerkiki](https://wordpress.org/support/users/powerkiki/)
 * (@powerkiki)
 * [3 weeks, 1 day ago](https://wordpress.org/support/topic/patch-to-reduce-disk-access/)
 * Every time the plugin renders a form, it will re-create the empty `index.php`
   to protect folders from being browsed. Even if the `index.php` already exists.
   This heavily increase disk write for no reason, negatively impacting the server
   performance.
 * Here is a patch that centralize the check whether `index.php` should be created
   inside the concerned method `\Forminator_Field::add_index_file()`. So, that method
   can be called without repeating the fragile, and broken, check before calling
   it.
 *     ```wp-block-code
       diff -ur a/library/abstracts/abstract-class-field.php b/library/abstracts/abstract-class-field.php--- library/abstracts/abstract-class-field.php	2026-01-20 11:31:24.000000000 +0900+++ library/abstracts/abstract-class-field.php	2026-03-20 16:29:23.815566745 +0900@@ -2227,7 +2227,7 @@ 			return; 		} 		// Make sure it was not called before WP init.-		if ( ! file_exists( $upload_root . 'index.php' ) && function_exists( 'insert_with_markers' ) ) {+		if ( function_exists( 'insert_with_markers' ) ) { 			self::add_index_file( $upload_root ); 			self::add_htaccess_file(); 		}@@ -2241,8 +2241,9 @@ 	 * @return void 	 */ 	public static function add_index_file( $dir ) {-		$dir = untrailingslashit( $dir );-		if ( ! is_dir( $dir ) || ! wp_is_writable( $dir ) || is_link( $dir ) ) {+		$dir = untrailingslashit( $dir );+		$index_file_path = $dir . '/index.php';+		if ( is_file( $index_file_path ) || ! is_dir( $dir ) || ! wp_is_writable( $dir ) || is_link( $dir ) ) { 			return; 		} 		$dp = opendir( $dir );@@ -2256,7 +2257,6 @@  		global $wp_filesystem; 		if ( WP_Filesystem() ) {-			$index_file_path = $dir . '/index.php'; 			// creates an empty index.php file. 			$wp_filesystem->put_contents( $index_file_path, '', FS_CHMOD_FILE ); 		}@@ -2289,12 +2289,8 @@ 		}  		self::check_upload_root_index_file();-		if ( ! file_exists( forminator_get_upload_path( $form_id ) . 'index.php' ) ) {-			self::add_index_file( forminator_get_upload_path( $form_id ) );-		}-		if ( ! file_exists( $path . 'index.php' ) ) {-			self::add_index_file( $path );-		}+		self::add_index_file( forminator_get_upload_path( $form_id ) );+		self::add_index_file( $path ); 	}  	/**diff -ur a/forminator/library/class-form-fields.php b/library/class-form-fields.php--- forminator/library/class-form-fields.php	2025-10-20 10:50:06.000000000 +0900+++ library/class-form-fields.php	2026-03-20 16:27:42.102583525 +0900@@ -212,11 +212,7 @@  		Forminator_Field::check_upload_root_index_file(); -		if ( ! file_exists( $upload_root . 'css/index.php' ) ) {-			Forminator_Field::add_index_file( $upload_root . 'css/index.php' );-		}-		if ( ! file_exists( $upload_root . 'signatures/index.php' ) ) {-			Forminator_Field::add_index_file( $upload_root . 'signatures/index.php' );-		}+		Forminator_Field::add_index_file( $upload_root . 'css' );+		Forminator_Field::add_index_file( $upload_root . 'signatures' ); 	} }
       ```
   

Viewing 3 replies - 1 through 3 (of 3 total)

 *  Plugin Support [Patrick – WPMU DEV Support](https://wordpress.org/support/users/wpmudevsupport12/)
 * (@wpmudevsupport12)
 * [3 weeks ago](https://wordpress.org/support/topic/patch-to-reduce-disk-access/#post-18858228)
 * Hi [@powerkiki](https://wordpress.org/support/users/powerkiki/)
 * I hope you are doing well.
 * Thank you for the suggestion, I forwarded it to our developers so they can take
   a closer look at this matter.
 * Best Regards
    Patrick Freitas
 *  Plugin Support [Patrick – WPMU DEV Support](https://wordpress.org/support/users/wpmudevsupport12/)
 * (@wpmudevsupport12)
 * [3 weeks ago](https://wordpress.org/support/topic/patch-to-reduce-disk-access/#post-18858252)
 * Hi [@powerkiki](https://wordpress.org/support/users/powerkiki/)
 * Just an update,
 * We forwarded this to our developers, we can’t give an estimated time to implement
   it as part of core since depends on roadmaps but I hope we can consider it in
   a near future.
 * Best Regards
    Patrick Freitas
 *  Plugin Support [Dmytro – WPMU DEV Support](https://wordpress.org/support/users/wpmudevsupport16/)
 * (@wpmudevsupport16)
 * [5 days, 16 hours ago](https://wordpress.org/support/topic/patch-to-reduce-disk-access/#post-18872473)
 * Hello [@powerkiki](https://wordpress.org/support/users/powerkiki/),
 * I hope you’re doing great today!
 * As the issue has been identified and reported to the developers, I’m marking 
   this thread as resolved for now. Please feel free to reopen it, in case you have
   any further questions.
 * Best Regards,
    Dmytro

Viewing 3 replies - 1 through 3 (of 3 total)

You must be [logged in](https://login.wordpress.org/?redirect_to=https%3A%2F%2Fwordpress.org%2Fsupport%2Ftopic%2Fpatch-to-reduce-disk-access%2F%3Foutput_format%3Dmd&locale=en_US)
to reply to this topic.

 * ![](https://ps.w.org/forminator/assets/icon-256x256.gif?rev=3443182)
 * [Forminator Forms – Contact Form, Payment Form & Custom Form Builder](https://wordpress.org/plugins/forminator/)
 * [Frequently Asked Questions](https://wordpress.org/plugins/forminator/#faq)
 * [Support Threads](https://wordpress.org/support/plugin/forminator/)
 * [Active Topics](https://wordpress.org/support/plugin/forminator/active/)
 * [Unresolved Topics](https://wordpress.org/support/plugin/forminator/unresolved/)
 * [Reviews](https://wordpress.org/support/plugin/forminator/reviews/)

## Tags

 * [performance](https://wordpress.org/support/topic-tag/performance/)

 * 3 replies
 * 3 participants
 * Last reply from: [Dmytro – WPMU DEV Support](https://wordpress.org/support/users/wpmudevsupport16/)
 * Last activity: [5 days, 16 hours ago](https://wordpress.org/support/topic/patch-to-reduce-disk-access/#post-18872473)
 * Status: resolved