Title: PHP Warning in 5.3.1
Last modified: August 31, 2016

---

# PHP Warning in 5.3.1

 *  Resolved [Dave Chimny](https://wordpress.org/support/users/netzblogr/)
 * (@netzblogr)
 * [10 years, 2 months ago](https://wordpress.org/support/topic/php-warning-in-531/)
 * After updating to the latest version, I get a warning on every page in the backend
   and frontend:
 * `Warning: file_put_contents(/var/www/******/wp-content/uploads/ithemes-security/
   logs/index.php): failed to open stream: No such file or directory in /var/www/******/
   wp-content/plugins/better-wp-security/core/class-itsec-logger.php on line 34`
 * Even after creating an _index.php_ in the mentioned folder, the warning persists.
 * [https://wordpress.org/plugins/better-wp-security/](https://wordpress.org/plugins/better-wp-security/)

Viewing 15 replies - 1 through 15 (of 21 total)

1 [2](https://wordpress.org/support/topic/php-warning-in-531/page/2/?output_format=md)
[→](https://wordpress.org/support/topic/php-warning-in-531/page/2/?output_format=md)

 *  [WebEndev](https://wordpress.org/support/users/munman/)
 * (@munman)
 * [10 years, 2 months ago](https://wordpress.org/support/topic/php-warning-in-531/#post-7122765)
 * Yep, same here
 *  [Gerroald](https://wordpress.org/support/users/gerroald/)
 * (@gerroald)
 * [10 years, 2 months ago](https://wordpress.org/support/topic/php-warning-in-531/#post-7122771)
 * Hi,
 * Thanks for reporting this.
 * @WebEndev – Can you please share the complete error as well?
 * The developer is looking into this. If you’d like to temporarily suppress the
   error, and feel comfortable editing the file you can place an ” @ ” in class-
   itsec-logger.php on line 34 in front of the file_put_contents.
 * [http://screencast.com/t/BdHdnGLT](http://screencast.com/t/BdHdnGLT)
 * I’ll report back here as soon as I know more.
 * Thanks,
 * Gerroald
 *  [dwinden](https://wordpress.org/support/users/dwinden/)
 * (@dwinden)
 * [10 years, 2 months ago](https://wordpress.org/support/topic/php-warning-in-531/#post-7122836)
 * [@falk](https://wordpress.org/support/users/falk/) Wussow & @WebEndev
 * Is there also not a **.htaccess** file in the logs (and backups) folder(s) ?
 * Note all (3) commands for the **.htaccess** file creation are already preceeded
   by a @.
    So if a **.htaccess** file does not exist in these folders its creation
   is also failing but you are not getting any warning because the fopen\fwrite\
   fclose commands are all already preceeded by a @.
 * dwinden
 *  [WebEndev](https://wordpress.org/support/users/munman/)
 * (@munman)
 * [10 years, 2 months ago](https://wordpress.org/support/topic/php-warning-in-531/#post-7122871)
 * [@gerroald](https://wordpress.org/support/users/gerroald/)
 * Here is the message:
 * `<b>Warning</b>: Cannot modify header information - headers already sent by (
   output started at /home/******/public_html/wp-content/plugins/better-wp-security/
   core/class-itsec-logger.php:34) in <b>/home/*******/public_html/wp-includes/pluggable.
   php</b> on line <b>1228</b><br />`
 * I am also getting Sucuri security warning messages as a result of the above. 
   I had to disable Ithemes Security on the site to remove the Sucuri issues.
 * Thanks.
 *  [WebEndev](https://wordpress.org/support/users/munman/)
 * (@munman)
 * [10 years, 2 months ago](https://wordpress.org/support/topic/php-warning-in-531/#post-7122874)
 * [@dwinden](https://wordpress.org/support/users/dwinden/)
 * Yes, there is an .htaccess file in both /logs and /backups. The contents of both
   are ‘Deny from all’.
 * Thanks.
 *  [dwinden](https://wordpress.org/support/users/dwinden/)
 * (@dwinden)
 * [10 years, 2 months ago](https://wordpress.org/support/topic/php-warning-in-531/#post-7122879)
 * [@falk](https://wordpress.org/support/users/falk/) Wussow & @WebEndev & [@gerroald](https://wordpress.org/support/users/gerroald/)
 * The reason why this warning is happening is because the [@mkdir](https://wordpress.org/support/users/mkdir/)()
   command positioned 2 lines earlier is also failing…
    Unfortunately because of
   the @ we have never been notified of this.
 * The [@mkdir](https://wordpress.org/support/users/mkdir/)() command is failing
   because it tries to create a …/ithemes-security/logs subfolder while the parent
   ithemes-security folder does not yet exist.
 * Change your code to look like this and the issue will be fixed:
 *     ```
       //Make sure the ithemes-security directory and logs subdirectory are created
       if ( ! is_dir( $itsec_globals['ithemes_log_dir'] ) ) {
       	@mkdir( $itsec_globals['ithemes_dir'] );  // <- Add this new line
       	@mkdir( $itsec_globals['ithemes_log_dir'] );
       	// Make sure we have an index file to block directory listing
       	file_put_contents( path_join( $itsec_globals['ithemes_log_dir'], 'index.php' ), "<?php\n// Silence is golden." );
       }
       ```
   
 * dwinden
 *  Thread Starter [Dave Chimny](https://wordpress.org/support/users/netzblogr/)
 * (@netzblogr)
 * [10 years, 2 months ago](https://wordpress.org/support/topic/php-warning-in-531/#post-7122881)
 * [@dwinden](https://wordpress.org/support/users/dwinden/) Works. Even after deleting
   the folders, they are recreated seconds later. 🙂
 *  [WebEndev](https://wordpress.org/support/users/munman/)
 * (@munman)
 * [10 years, 2 months ago](https://wordpress.org/support/topic/php-warning-in-531/#post-7122882)
 * [@dwinden](https://wordpress.org/support/users/dwinden/)
 * Thanks much for this. I will try it.
 * I also assume that iThemes will release a patch 🙂
 *  [dwinden](https://wordpress.org/support/users/dwinden/)
 * (@dwinden)
 * [10 years, 2 months ago](https://wordpress.org/support/topic/php-warning-in-531/#post-7122888)
 * @WebEndev
 * I made a quick and dirty fix to illustrate what is wrong and to demonstrate how
   to fix it. However this code needs some more work.
 * The original piece of code never worked. The fix makes it work but also revealed
   a new bug …
    For instance with my fix applied there is no .htaccess file created
   in the logs folder…
 * I’m sure in the near future iThemes will release an update that will include 
   a more comprehensive fix.
 * One other thing to consider is the content of the .htaccess file.
    ‘Deny from
   all’ is Apache 2.2.x syntax only. Would make sense to add Apache 2.4.x syntax
   as well. ‘Require all denied’
 * Another thing is why is the ITSEC_Logger class so worried about the logs subfolder?
   It should only worry about it when the Log Type setting is set to **File Only**
   or **Both** …
    Most people use the default, **Database Only** … So who cares 
   whether the logs subfolder exists or not ?
 * dwinden
 *  [Gerroald](https://wordpress.org/support/users/gerroald/)
 * (@gerroald)
 * [10 years, 2 months ago](https://wordpress.org/support/topic/php-warning-in-531/#post-7122893)
 * Hi,
 * My apologies for the trouble here. A fix is in the works, and should be out later
   today.
 * The code no longer generates a .htaccess file as the index.php is more reliable,
   and does not run into syntax issues.
 * I’ll update you here as soon as I know more.
 * Thanks,
 * Gerroald
 *  [dwinden](https://wordpress.org/support/users/dwinden/)
 * (@dwinden)
 * [10 years, 2 months ago](https://wordpress.org/support/topic/php-warning-in-531/#post-7122898)
 * [@gerroald](https://wordpress.org/support/users/gerroald/)
 * No problem. I do feel I need to make one correction.
 * iTSec 5.3.1 (without my fix) does create .htaccess files in all three (ithemes-
   security, backups and logs) folders.
 * I guess the 3 fopen/fwrite/fclose groups of commands that create the .htaccess
   file(s) should be removed from the activate_execute() function in the class-itsec-
   setup.php file…
 * dwinden
 *  [heinelg](https://wordpress.org/support/users/heinelg/)
 * (@heinelg)
 * [10 years, 2 months ago](https://wordpress.org/support/topic/php-warning-in-531/#post-7122930)
 * Just installed 5.3.1 and got same error but I also cannot access the Media Library–
   don’t know if this is related or not. Is it possible to download and install 
   the previous version (maybe as 5.3.2) until a fix is available?
 *  [heinelg](https://wordpress.org/support/users/heinelg/)
 * (@heinelg)
 * [10 years, 2 months ago](https://wordpress.org/support/topic/php-warning-in-531/#post-7122931)
 * Update: Deactivating iTSec allows me to access the media library.
 *  [Gerroald](https://wordpress.org/support/users/gerroald/)
 * (@gerroald)
 * [10 years, 2 months ago](https://wordpress.org/support/topic/php-warning-in-531/#post-7122932)
 * Hey All,
 * Can you please update to version 5.3.2 and let me know if it resolves this for
   you?
 * [@dwinden](https://wordpress.org/support/users/dwinden/) – Apologies. The .htaccess
   is being created. But the index.php is also being created and is more reliable.
 * Thanks!
 * Gerroald
 *  [seaturtledave](https://wordpress.org/support/users/seaturtledave/)
 * (@seaturtledave)
 * [10 years, 2 months ago](https://wordpress.org/support/topic/php-warning-in-531/#post-7122934)
 * I would if I could But I am locked out of the WordPress login.

Viewing 15 replies - 1 through 15 (of 21 total)

1 [2](https://wordpress.org/support/topic/php-warning-in-531/page/2/?output_format=md)
[→](https://wordpress.org/support/topic/php-warning-in-531/page/2/?output_format=md)

The topic ‘PHP Warning in 5.3.1’ is closed to new replies.

 * ![](https://ps.w.org/better-wp-security/assets/icon.svg?rev=3529351)
 * [Kadence Security – Password, Two Factor Authentication, and Brute Force Protection](https://wordpress.org/plugins/better-wp-security/)
 * [Frequently Asked Questions](https://wordpress.org/plugins/better-wp-security/#faq)
 * [Support Threads](https://wordpress.org/support/plugin/better-wp-security/)
 * [Active Topics](https://wordpress.org/support/plugin/better-wp-security/active/)
 * [Unresolved Topics](https://wordpress.org/support/plugin/better-wp-security/unresolved/)
 * [Reviews](https://wordpress.org/support/plugin/better-wp-security/reviews/)

## Tags

 * [file missing](https://wordpress.org/support/topic-tag/file-missing/)
 * [Logs](https://wordpress.org/support/topic-tag/logs/)
 * [warning](https://wordpress.org/support/topic-tag/warning/)

 * 21 replies
 * 6 participants
 * Last reply from: [heinelg](https://wordpress.org/support/users/heinelg/)
 * Last activity: [10 years, 2 months ago](https://wordpress.org/support/topic/php-warning-in-531/page/2/#post-7122947)
 * Status: resolved