• Resolved margje

    (@margje)


    After i’ve activate wordfence this error is showing up in all headers.

    How to make wordfence work?

    Warning: mysql_connect() [function.mysql-connect]: Access denied for user ‘user’@’localhost’ (using password: NO) in /home/website/domains/website.com/public_html/wp-content/plugins/wordfence/lib/wfDB.php on line 31

    Warning: mysql_select_db() expects parameter 2 to be resource, boolean given in /home/website/domains/website.com/public_html/wp-content/plugins/wordfence/lib/wfDB.php on line 32

    Warning: mysql_query() expects parameter 2 to be resource, boolean given in /home/website/domains/website.com/public_html/wp-content/plugins/wordfence/lib/wfDB.php on line 66

    Warning: mysql_connect() [function.mysql-connect]: Access denied for user ‘user’@’localhost’ (using password: NO) in /home/website/domains/website.com/public_html/wp-content/plugins/wordfence/lib/wfDB.php on line 31

    Warning: mysql_select_db() expects parameter 2 to be resource, boolean given in /home/website/domains/website.com/public_html/wp-content/plugins/wordfence/lib/wfDB.php on line 32

    Warning: mysql_query() expects parameter 2 to be resource, boolean given in /home/website/domains/website.com/public_html/wp-content/plugins/wordfence/lib/wfDB.php on line 66

    Warning: mysql_query() expects parameter 2 to be resource, boolean given in /home/website/domains/website.com/public_html/wp-content/plugins/wordfence/lib/wfDB.php on line 66

    Warning: Cannot modify header information – headers already sent by (output started at /home/website/domains/website.com/public_html/wp-content/plugins/wordfence/lib/wfDB.php:31) in /home/website/domains/website.com/public_html/wp-content/plugins/wordfence/lib/wordfenceClass.php on line 1046

    https://www.ads-software.com/extend/plugins/wordfence/

Viewing 9 replies - 1 through 9 (of 9 total)
  • Plugin Author Wordfence Security

    (@mmaunder)

    Hi Margie,

    This is an error I have not seen before. Can you tell me which WordPress host you’re using? And what version of WordPress?

    If can email me privately if you prefer at [email protected]

    Thanks,

    Mark.

    I get the following error when activating the plugin immediately after downloading it using auto install:


    Wordfence DB error in C:\Inetpub\wwwroot\IQShare\wp-content\plugins\wordfence\lib\wfConfig.php line 382: Table ‘iqshare.wp_wfconfig’ doesn’t exist

    If I try activating it again, I get the following:


    Plugin could not be activated because it triggered a fatal error.

    Error fetching free API key from Wordfence: We could not fetch data from the API when calling ‘get_anon_api_key’: Array

    Plugin Author Wordfence Security

    (@mmaunder)

    Hi,

    It looks like you’re running Windows. We don’t fully support PHP on windows yet but have recently set up our test lab and are in the process of working through all windows issues.

    I’ve added your bug report to our issue tracker.

    Kind regards,

    Mark.

    Plugin Author Wordfence Security

    (@mmaunder)

    I’m resolving this issue since there’s no further user feedback.

    I also ran into this issue and I am wondering if it is the same cause. This is on an OSX test environment and deployed to a Linux server, however it should not matter as the error is with the code in the plugin specifically, not the OS platform.

    In wfDB.php there are the following lines
    if(! $wpdb->dbhost ){ $this->errorMsg = “The WordPress variable from wpdb dbhost is not defined.”; }
    if(! $wpdb->dbuser ){ $this->errorMsg = “The WordPress variable from wpdb dbuser is not defined.”; }
    if(! $wpdb->dbpassword ){ $this->errorMsg = “The WordPress variable from wpdb dbpassword is not defined.”; }
    if(! $wpdb->dbname ){ $this->errorMsg = “The WordPress variable from wpdb dbname is not defined.”; }

    However if any one of those variables inside $wpdb contain an empty string your conditional fails. Though not recommended, it is entirely possible to have an empty string for the password, as is the case on this test machine. You should update the code to use isset as follows:

    if(! isset($wpdb->dbhost) )
    if(! isset($wpdb->dbuser) )
    if(! isset($wpdb->dbpassword)
    if(! isset($wpdb->dbname) )

    Additionally, if you are going to cause the method to end without setting up the database object you should ensure that it is setup later in your code before attempting to use it or the errors in the original post will happen, not good.

    Finally, why are you creating your own database object and connection when there is a perfectly good database object already built into WordPress? This not only breaks WP convention, it also restricts the environments your plugin can run in. It is possible to use WP with different databases as WP provides the functionality to do that and I have seen it in the wild and done it myself. You should always use the WP API if there is a function available to do what you need, and there is ??
    https://codex.www.ads-software.com/Class_Reference/wpdb#Run_Any_Query_on_the_Database

    Plugin Author Wordfence Security

    (@mmaunder)

    Thanks for the bug report, I’ll get that fixed.

    I use wfDB because wpdb has a lot of unnecessary overhead and I want tight control over database performance.

    Thanks for the quick response. I am not sure I understand the reasoning of using wfDB. Adding another database layer and connection will cause a lot more overhead than the one that is already built in and ready to do.

    Plugin Author Wordfence Security

    (@mmaunder)

    wfDB does not add another layer. It replaces wpdb with a more efficient database layer for our particular needs.

    It does not add more overhead. In fact it reduces memory overhead substantially.

    wpdb is less efficient for large queries. For example, please see line 1083 and 1086 of wp-includes/wp-db.php where a copy of the entire query is stored, twice, and those copies persist beyond the scope of the query() method in the func_call and last_query properties.

    By creating our own DB class I can also use things like unbuffered queries which wpdb does not support and which dramatically reduce memory usage and number of queries on the DB for a given result set.

    Hi,

    I just ran into a similar issue of the header (as first posted on the topic). There were these headers and some reported Error Establishing database connection. I had to delete the entire plugin via FTP to get the site back to normal.

    https://www.androidkothon.com

Viewing 9 replies - 1 through 9 (of 9 total)
  • The topic ‘wordfence install error’ is closed to new replies.