• Hello there,

    This plugin keeps logging a “PHP Warning: filemtime(): stat failed” warning for me and it seems I’m not alone: https://ww.wp.xz.cn/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.ww.wp.xz.cn/woo-related-products-refresh-on-reload/trunk/public/class-woo-related-products-public.php lines 103-105 from:

    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_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

    (@vikrantsant)

    Hey @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.