gocodebox / lifterlms

LifterLMS, a WordPress LMS Solution: Easily create, sell, and protect engaging online courses.
https://lifterlms.com
GNU General Public License v3.0
178 stars 134 forks source link

Warning when htaccess file doesn't exist #2735

Open brianhogg opened 1 month ago

brianhogg commented 1 month ago

Reproduction Steps

  1. Delete the wp-content/uploads/lifterlms/.htaccess file
  2. Clear the lifterlms_check_media_protection_files transient
  3. Login as admin

Expected Behavior

No warning, file is created.

Actual Behavior

PHP warning that we're trying to get contents of wp-content/uploads/lifterlms/.htaccess which doesn't exist.

Error Messages / Logs

file_get_contents(.../wp-content/uploads/lifterlms/.htaccess): Failed to open stream: No such file or directory

    wp-admin/includes/class-wp-filesystem-direct.php:39
    file_get_contents()
    wp-admin/includes/class-wp-filesystem-direct.php:39
    WP_Filesystem_Direct->get_contents()
    wp-content/plugins/lifterlms/includes/class-llms-media-protector.php:652
    LLMS_Media_Protector->save_mod_rewrite_rules()
    wp-includes/class-wp-hook.php:324
    do_action('admin_init')
    wp-admin/admin.php:175

This issue has be recreated: