Support » Plugin: BulletProof Security » Intermittent 500 errors due to php.ini handler custom code

  • Resolved Pat K

    (@blackcapdesign)


    This is more of a heads-up than a support question:

    I recently upgraded PHP & mySQL versions and when logging in to the admin dashboard I noticed 2 things:
    1) When moving through the dashboard, pages would randomly fail to load properly; just an unstyled white screen with a vertical list of dashboard links
    2) I received this helpful notification from BPS:

    HUD Check: PHP/php.ini handler htaccess code check PHP/php.ini handler htaccess code was found in your root .htaccess file, but was NOT found in BPS Custom Code.

    …followed by a code snippet to be copied & pasted in to the custom code editor:

    # PHP/php.ini handler htaccess code
    AddHandler application/x-httpd-ea-php73 .php .php7 .phtml

    Excellent (so far)! After I pasted it in & clicked encrypt & save, I carried on working in the admin dashboard. BUT the intermittent page loading problem persisted – only in the dashboard. I checked the source code on one of these broken pages and compared with an unbroken page & the code was the same on both. Then I checked the browser debugger and saw this:

    Failed to load resource: the server responded with a status of 500 (Internal Server Error)

    …so I disabled script concatenation using the config file (added this to wp-config.php):
    define(‘CONCATENATE_SCRIPTS’, false);

    This worked as a short term fix and suggested this is a plugin-related problem. So I removed define(‘CONCATENATE_SCRIPTS’, false); and started disabling plugins. As soon as I disabled BPS the problem went away.

    After MUCH testing, I determined the problem was:
    a) the missing PHP.ini handler code AND
    b) the blank spaces before “AddHandler” in the code snippet provided by the BPS plugin.

    In other words, THIS:
    # PHP/php.ini handler htaccess code
    AddHandler application/x-httpd-ea-php73 .php .php7 .phtml

    SHOULD be THIS:
    # PHP/php.ini handler htaccess code
    AddHandler application/x-httpd-ea-php73 .php .php7 .phtml

    I’m not 100% sure this is completely resolved, but so far, so good (no more broken admin pages).
    pk

Viewing 8 replies - 1 through 8 (of 8 total)
  • Pat K

    (@blackcapdesign)

    Hmmm. The editor stripped out the blank spaces before “AddHandler” in my original post. Just make sure there are no blank spaces before “AddHandler”…and time permitting AITpro might consider removing those blank spaces in the helpful code snippet.

    Plugin Author AITpro

    (@aitpro)

    Are you saying that extra whitespace is being mistakenly added by the BPS Setup Wizard when it creates the php.ini handler htaccess code? I’m going to check that now, but yeah I’d like to know (confirm) if that is what you have found. Whitespace definitely causes 500 errors with htaccess code/files.

    Thanks.

    • This reply was modified 8 months, 2 weeks ago by AITpro.
    • This reply was modified 8 months, 2 weeks ago by AITpro.
    Pat K

    (@blackcapdesign)

    No, not by the wizard. I like to do stuff manually, so I have AutoFix turned OFF. I’m talking about the prompt at the top of the admin screen. If that’s copied and pasted it adds 2 non-breaking spaces (a tab indent) in the code window.

    I think it may be a moot point though because I applied this fix on another site and was still getting the intermittent broken pages afterwards. Of note, I did a ‘wordpress reinstall’ from the WordPress Updates page and this seemed to make matters worse. In the short term I’m disabling script concatenation – until I have more time to troubleshoot.

    I’m wondering if caching may be partly responsible…maybe updating the salts for the authentication keys in config file?

    Thanks for following up! If you have any troubleshooting ideas (other than what I’ve listed above) I’d be happy to try them!

    Plugin Author AITpro

    (@aitpro)

    Got it on the manual copy and paste. I use Notepad++ to do a “staged” copy instead of copying directly from any browser output and definitely copying anything from a Microsoft App like Word or Outlook. By copying something to the (free) Notepad++ App you will see any (hidden) formatting added by your clipboard or when copying from a Microsoft App. And then you can correct any formatting issues before copying the code/text (from Notepad++) into a BPS Custom Code text box.

    Yep, I was going to mention that typically caching causes intermittent errors. If you want me to check your site on the frontend I’d be glad to do that. You can either post a link to your site here or email it to me using my contact page form > https://www.ait-pro.com/contact/

    Also if you want to check for any errors that give you some clues then launch the Google Chrome Browser > hit your Ctrl+Shift+I keyboard keys to launch GC Dev tools > click the Console tab in the GC Dev tools window and check for any errors.

    Pat K

    (@blackcapdesign)

    Excellent! Thanks for the tips!! I’ll do some more testing and when I figure this out, I’ll post back here.

    Plugin Author AITpro

    (@aitpro)

    Resolving old thread.

    Pat K

    (@blackcapdesign)

    Thanks for the reminder. I still haven’t figured this one out. If / when I do, I’ll be sure to report back here.
    pk

    Plugin Author AITpro

    (@aitpro)

    A php/php.ini handler would not cause any of the problems that you are experiencing. Try reinstalling WordPress. Go to the Dashboard menu > Updates menu > click the Re-Install Now button to reinstall WordPress. Deactivating the BPS plugin would only do 1 thing and that would be to decrease your php memory resource usage by around 3MB. So maybe you are maxed out on php memory? You can check that on the BPS System Info page. You should have at least 128M minimum for your php configuration memory limit. 256M is the optimum php configuration memory limit. You PHP Memory Usage should be between 20M-100M depending on how many plugins you have installed.

    • This reply was modified 5 months, 3 weeks ago by AITpro.
    • This reply was modified 5 months, 3 weeks ago by AITpro.
Viewing 8 replies - 1 through 8 (of 8 total)
  • You must be logged in to reply to this topic.