Cannot redeclare bpsPro_AP_Check()

Home Forums BulletProof Security Pro Cannot redeclare bpsPro_AP_Check()

Viewing 13 posts - 1 through 13 (of 13 total)
  • Author
    Posts
  • #41568
    Andy
    Participant

    Hello,

    The PHP Error log continuously gives the error shown below. What is the cause and what action do we need to take to resolve this?

    Andy

    [05-Mar-2022 17:21:48 UTC] PHP Fatal error: Cannot redeclare bpsPro_AP_Check() (previously declared in /home/mycbcc5/public_html/wp-content/plugins/bulletproof-security/includes/functions.php:43) in /home/mycbcc5/public_html/wp-content/plugins/bulletproof-security/includes/functions.php on line 53
    #41569
    AITpro Admin
    Keymaster

    This php error is always caused by another plugin that you have installed.  You can disregard the php error since it is not correct/valid.  The good news is that I have changed this function in BPS Pro 16.4 in a way that other plugins can no longer cause this problem.  BPS Pro 16.4 will be released sometime tomorrow.

    #41570
    Andy
    Participant

    Hello again,

    I received the automated reply above, asking me “To confirm or eliminate that BPS or BPS Pro is blocking something in another Plugin or Theme click the appropriate troubleshooting link below”. When I click the link, there are not specific instructions on how to confirm or eliminate what BPS Pro is blocking. Can you provide more specific instructions on what actions I need to take?

    Andy

    #41571
    AITpro Admin
    Keymaster

    You don’t need to do anything for this problem. The problem has been fixed in BPS Pro 16.4, which will be released tomorrow.

    #41578
    AITpro Admin
    Keymaster

    BPS Pro 16.4 was released 1.5 hours ago.  Please upgrade to BPS Pro 16.4 and let me know if the php error is no longer occurring.

    #44894
    UPR
    Participant

    It seems this error resurfaced in version 17.4?

    [03-Apr-2025 01:32:24 UTC] PHP Fatal error: Cannot redeclare bpsPro_AP_Check() (previously declared in /home/…/domains/…/public_html/wp-content/plugins/bulletproof-security/includes/functions.php:44) in /home/…/domains/…/public_html/wp-content/plugins/bulletproof-security/includes/functions.php on line 44

    Any suggestions or ignore?
    Many thanks!
    Sash

    #44895
    AITpro Admin
    Keymaster

    Try clearing plugin cache and browser cache. If that does not work then this error could be caused by another plugin or server-side cache. Do you have the WP Edit plugin installed?  See this forum topic for help information:  https://forum.ait-pro.com/forums/topic/php-fatal-error-cannot-redeclare-bpspro_ap_check/page/4/#post-25456 Another possibility could be this issue > https://wordpress.org/support/topic/wordpress-4-7-fatal-error-cannot-redeclare-get_paged_template/

    #44896
    UPR
    Participant

    No WP-Edit and opCache not active as far as I can see. Using WP-Rocket though.

    #45117
    UPR
    Participant

    Hi team,
    still encountering the same error message:

    PHP Fatal error: Cannot redeclare bpsPro_AP_Check() (previously declared in /home/XXXXX/domains/unplugrentals.com/public_html/wp-content/plugins/bulletproof-security/includes/functions.php:44) in /home/XXXXX/domains/unplugrentals.com/public_html/wp-content/plugins/bulletproof-security/includes/functions.php on line 52

    Site details:

    Domain: unplugrentals.com

    File involved: /wp-content/plugins/bulletproof-security/includes/functions.php

    The issue occurs during normal admin access (not during plugin activation or updates).

    What we’ve found:

    The function bpsPro_AP_Check($D8) appears to be declared twice in the same functions.php file — once at line 44 and again at line 52.

    This causes a PHP fatal error because PHP doesn’t allow function redeclaration.

    We’re using the latest version of WordPress, and the plugin is otherwise functioning normally.

    Temporary workaround considered:
    We thought about wrapping the function in a function_exists() check:

    if ( ! function_exists( 'bpsPro_AP_Check' ) ) {
    function bpsPro_AP_Check($D8) {
    ...
    }
    }
    
    

    However, since this appears to be part of BPS Pro’s anti-piracy mechanism, we’re reluctant to modify it directly.
    Could you please advise whether this is a known issue in the current version, or if there’s a recommended fix or update we should apply? I know it doesn’t cause any issues, however, it annoys the heck out of me seeing the php error message popping up constantly.😉
    Thanks in advance for your help!
    Best regards,

    Sash

    #45118
    UPR
    Participant

    Checking with the server hosting if there is some server sided caching installed, can’t see opCache straight up.

    #45119
    AITpro Admin
    Keymaster

    A “cannot redeclare” php error basically means something is being loaded twice/headers already loaded. If you have Cloudflare installed or your web host uses Cloudflare and you are using WP Rocket then see this WP Rocket help topic > https://docs.wp-rocket.me/article/18-using-wp-rocket-with-cloudflare. Another thing to check would be your wp-config.php file for any issues. ie some additional code in the wp-config.php file that could cause headers to be sent more than once.

    Also Cloudflare used to cache the wp-admin area by default the last time I checked. So if you are using Cloudflare there is an option to exclude the wp-admin area from being cached.

    #45123
    UPR
    Participant

    Confirming no OPcache was running initially. However, we’ve enabled this with the recommended parameters for testing – no luck. Error still there. We don’t use Cloudflare with WP-Rocket.

    Nothing special in the wp-config.php either. This is the code below BPSPro ini_set settings:

    /** Absolute path to the WordPress directory. */
    if ( !defined('ABSPATH') )
    define('ABSPATH', dirname(__FILE__) . '/');
    
    /** Set memory limits BEFORE WordPress loads */
    if ( ! defined( 'WP_MEMORY_LIMIT' ) ) {
    define( 'WP_MEMORY_LIMIT', '256M' );
    }
    
    if ( ! defined( 'WP_MAX_MEMORY_LIMIT' ) ) {
    define( 'WP_MAX_MEMORY_LIMIT', '512M' );
    }
    
    define('FS_METHOD', 'direct');
    
    /** Sets up WordPress vars and included files. */
    require_once(ABSPATH . 'wp-settings.php');

     

    Server-hosting is suggesting to delete and re-install BPS? How do I do this without loosing any settings and custom code?

     

    #45125
    AITpro Admin
    Keymaster

    Try deactivating all of your other plugins and see if the php error is still occurring or not. The php error is coming from how php files are being processed and does not have anything to do with your WordPress database. So uninstalling BPS Pro would not change anything.  You can try manually reinstalling BPS Pro using the BPS Pro Upload Zip installer, which will replace all BPS Pro files.

    Upgrading an existing BulletProof Security Pro Installation (Using the BPS Pro Built-in Upload Zip Installer)
    Download the bulletproof-security.zip file from the AITpro.com Secure Download Area.  Under the BPS Pro Setup Main menu, click the Upload Zip Install submenu link.  Click the Choose File button, navigate to where you downloaded the bulletproof-security.zip file on your computer (Note:  the zip file MUST be named bulletproof-security.zip) and click the Install Zip Now button.

Viewing 13 posts - 1 through 13 (of 13 total)
  • You must be logged in to reply to this topic.