Title: PHP Warning: filemtime(): stat failed
Last modified: November 28, 2025

---

# PHP Warning: filemtime(): stat failed

 *  [gerche](https://wordpress.org/support/users/gerche/)
 * (@gerche)
 * [6 months, 2 weeks ago](https://wordpress.org/support/topic/php-warning-filemtime-stat-failed-3/)
 * Hello there,
 * This plugin keeps logging a “PHP Warning: filemtime(): stat failed” warning for
   me and it seems I’m not alone: [https://wordpress.org/support/topic/warning-filemtime-stat-failed-for-4/](https://wordpress.org/support/topic/warning-filemtime-stat-failed-for-4/)(
   I can’t post in this Topic).
 * I’ve done some debugging and found that `filemtime()` expects a filesystem path,
   but `plugin_dir_url()` returns a URL. This triggers the PHP warnings. Using `
   plugin_dir_path()` fixes it. To fix it I updated [https://plugins.svn.wordpress.org/woo-related-products-refresh-on-reload/trunk/public/class-woo-related-products-public.php](https://plugins.svn.wordpress.org/woo-related-products-refresh-on-reload/trunk/public/class-woo-related-products-public.php)
   lines 103-105 from:
 *     ```wp-block-code
       wp_register_script( 'owl-carousel', plugin_dir_url( FILE ) . 'owl-carousel/owl.carousel.min.js', '', gmdate( 'ymd-Gis', filemtime( plugin_dir_url( FILE ) . 'owl-carousel/owl.carousel.min.js' ) ), true );wp_enqueue_script( 'owl-carousel' );wp_enqueue_style( 'owl-carousel-stylesheet', plugin_dir_url( FILE ) . 'owl-carousel/owl.carousel.css', '', gmdate( 'ymd-Gis', filemtime( plugin_dir_url( FILE ) . 'owl-carousel/owl.carousel.css' ) ) );
       ```
   
 * To
 *     ```wp-block-code
       wp_register_script( 'owl-carousel', plugin_dir_url( __FILE__ ) . 'owl-carousel/owl.carousel.min.js', '', gmdate( 'ymd-Gis', filemtime( plugin_dir_path( __FILE__ ) . 'owl-carousel/owl.carousel.min.js' ) ), true );wp_enqueue_script( 'owl-carousel' );wp_enqueue_style( 'owl-carousel-stylesheet', plugin_dir_url( __FILE__ ) . 'owl-carousel/owl.carousel.css', '', gmdate( 'ymd-Gis', filemtime( plugin_dir_path( __FILE__ ) . 'owl-carousel/owl.carousel.css' ) ) );
       ```
   
 * Could you please fix the plugin?

Viewing 1 replies (of 1 total)

 *  Plugin Author [Vikrant Sant](https://wordpress.org/support/users/vikrantsant/)
 * (@vikrantsant)
 * [6 months, 1 week ago](https://wordpress.org/support/topic/php-warning-filemtime-stat-failed-3/#post-18740102)
 * Hey [@gerche](https://wordpress.org/support/users/gerche/) 
   Thank you for flagging
   this and for taking the time to investigate the root cause. Really appreciate
   the detailed breakdown.
 * You’re absolutely right about `filemtime()` requiring a filesystem path and the
   issue being triggered by `plugin_dir_url()`. We’ll be updating the plugin to 
   use `plugin_dir_path()` as suggested.
 * We’ll get a fix pushed out soon.
 * Thanks again for bringing this to our attention! 
   Let me know if you notice anything
   else.

Viewing 1 replies (of 1 total)

The topic ‘PHP Warning: filemtime(): stat failed’ is closed to new replies.

 * ![](https://ps.w.org/woo-related-products-refresh-on-reload/assets/icon-256x256.
   png?rev=1531812)
 * [Related Products for WooCommerce](https://wordpress.org/plugins/woo-related-products-refresh-on-reload/)
 * [Support Threads](https://wordpress.org/support/plugin/woo-related-products-refresh-on-reload/)
 * [Active Topics](https://wordpress.org/support/plugin/woo-related-products-refresh-on-reload/active/)
 * [Unresolved Topics](https://wordpress.org/support/plugin/woo-related-products-refresh-on-reload/unresolved/)
 * [Reviews](https://wordpress.org/support/plugin/woo-related-products-refresh-on-reload/reviews/)

 * 1 reply
 * 2 participants
 * Last reply from: [Vikrant Sant](https://wordpress.org/support/users/vikrantsant/)
 * Last activity: [6 months, 1 week ago](https://wordpress.org/support/topic/php-warning-filemtime-stat-failed-3/#post-18740102)
 * Status: not resolved