Title: HTTP ERROR 500 &#8211; troubleshooting functions.php
Last modified: April 4, 2024

---

# HTTP ERROR 500 – troubleshooting functions.php

 *  Resolved [Jameth12](https://wordpress.org/support/users/jameth12/)
 * (@jameth12)
 * [2 years, 1 month ago](https://wordpress.org/support/topic/http-error-500-troubleshooting-functions-php/)
 * Hi there
 * Thank you for creating what looks to be an incredibly useful plugin, that will
   be helping many folks with CSP-related headaches!
 * When I enable tag capture, our website crashes with a ‘HTTP ERROR 500’ message.
   From a lot of trial and error I established that removing this ‘show_content_snippet’
   function from functions.php stops the crash happening, but it is pretty crucial
   to our site working properly. Do you have any ideas why this would be interfering
   with your plugin? Many thanks!
 * */ function show_content_snippet( $post, $amount = 100 ) {
   $post = (array)$post;
   if( $post[‘post_excerpt’] !== ” ) {echo apply_filters( ‘the_excerpt’, $post[‘
   post_excerpt’] );}elseif( preg_match( ‘##is’, $post[‘post_content’] ) ) {$moreSplit
   = explode( ”, apply_filters( ‘the_content’, $post[‘post_content’] ) );echo $moreSplit[
   0];}else{echo ” . substr( strip_tags( $post[‘post_content’] ), 0, $amount ) .‘…’;}}
    -  This topic was modified 2 years, 1 month ago by [Jameth12](https://wordpress.org/support/users/jameth12/).
 * The page I need help with: _[[log in](https://login.wordpress.org/?redirect_to=https%3A%2F%2Fwordpress.org%2Fsupport%2Ftopic%2Fhttp-error-500-troubleshooting-functions-php%2F%3Foutput_format%3Dmd&locale=en_US)
   to see the link]_

Viewing 8 replies - 1 through 8 (of 8 total)

 *  Plugin Author [Giuseppe](https://wordpress.org/support/users/mociofiletto/)
 * (@mociofiletto)
 * [2 years, 1 month ago](https://wordpress.org/support/topic/http-error-500-troubleshooting-functions-php/#post-17552950)
 * How this function is hooked/called in wp?
 *  Thread Starter [Jameth12](https://wordpress.org/support/users/jameth12/)
 * (@jameth12)
 * [2 years, 1 month ago](https://wordpress.org/support/topic/http-error-500-troubleshooting-functions-php/#post-17553871)
 * It appears in about 8 php templates, like search.php, index.php, archive.php 
   and the home page template to show a short text excerpt
 * e.g. [https://www.tsl.com/?s=MC67](https://www.tsl.com/?s=MC67)
 *     ```wp-block-code
       <div class="entry-content">
       	<?php show_content_snippet( $post, 200 ); ?>
       </div>
       ```
   
 *  Plugin Author [Giuseppe](https://wordpress.org/support/users/mociofiletto/)
 * (@mociofiletto)
 * [2 years, 1 month ago](https://wordpress.org/support/topic/http-error-500-troubleshooting-functions-php/#post-17563618)
 * Hi @Jameth, i have tested your function in a couple o standard themes, and it
   doesn’t create any error if capture is enabled or not.
 * Can you try to extend the amount of memory allowed in your php.ini? Do you have
   any server report of the crash?
 * Maybe it’s just a typo, but I think there is an error in your code:
 * i guess that
 * `$moreSplit = explode( '', apply_filters( 'the_content', $post['post_content']));`
 * should be:
 * `$moreSplit = explode( ' ', apply_filters( 'the_content', $post['post_content']));`
 * For me your code generates an error:
 * Uncaught ValueError: explode(): Argument #1 ($separator) cannot be empty
 * But this is completely unrelated to No unsafe-inline
 *  Thread Starter [Jameth12](https://wordpress.org/support/users/jameth12/)
 * (@jameth12)
 * [2 years, 1 month ago](https://wordpress.org/support/topic/http-error-500-troubleshooting-functions-php/#post-17695885)
 * Apologies for the late reply, and thank you for your help! I did try extending
   memory limit but still experienced the same crash. I also checked the error log
   file but couldn’t see anything being reported at the time of the crash. I’ll 
   do some further tests to make sure I haven’t missed something.
 * Thank you for pointing out the unrelated error, thats very kind of you. We will
   look further into that.
 *  Plugin Author [Giuseppe](https://wordpress.org/support/users/mociofiletto/)
 * (@mociofiletto)
 * [2 years, 1 month ago](https://wordpress.org/support/topic/http-error-500-troubleshooting-functions-php/#post-17705500)
 * Hi [@jameth12](https://wordpress.org/support/users/jameth12/), please test the
   development version of the plugin and tell me if the issue is still present.
 * The new version should spare some memory when protection is enabled; however 
   the new code has to be considered experimental until the new version will be 
   released.
 *  Thread Starter [Jameth12](https://wordpress.org/support/users/jameth12/)
 * (@jameth12)
 * [2 years, 1 month ago](https://wordpress.org/support/topic/http-error-500-troubleshooting-functions-php/#post-17706885)
 * Thank you, but same crash with the developer version unfortunately. Learning 
   as I go, the error logs within CP File Manager weren’t the right ones to be looking
   at, I needed to be looking at the latest error messages at a higher level in 
   cPanel tools. It shows a handful of logs all with identical content, here’s one:
 *     ```wp-block-code
       [Tue Apr 23 02:02:12.070337 2024] [lsapi:error] [pid 4086348:tid 23349990254336] [remote 94.192.115.19:63537] [host www.tsl.com] Backend fatal error: PHP Fatal error:  Uncaught League\\Uri\\Exceptions\\SyntaxError: The port unpkg.com is invalid in /home/cosnvb59uf13/public_html/web.tsl-hid.com/wp-content/plugins/no-unsafe-inline/vendor/league/uri/src/UriString.php:382\nStack trace:\n#0 /home/cosnvb59uf13/public_html/web.tsl-hid.com/wp-content/plugins/no-unsafe-inline/vendor/league/uri/src/UriString.php(359): League\\Uri\\UriString::filterPort('unpkg.com')\n#1 /home/cosnvb59uf13/public_html/web.tsl-hid.com/wp-content/plugins/no-unsafe-inline/vendor/league/uri/src/UriString.php(323): League\\Uri\\UriString::parseAuthority('www.tsl.comhttp...')\n#2 /home/cosnvb59uf13/public_html/web.tsl-hid.com/wp-content/plugins/no-unsafe-inline/vendor/league/uri/src/Uri.php(468): League\\Uri\\UriString::parse('https://www.tsl...')\n#3 /home/cosnvb59uf13/public_html/web.tsl-hid.com/wp-content/plugins/no-unsafe-inline/src/Nunil_Capture.php(894): League\\Uri\\Uri::createFromString('https://www.tsl...')\n#4 /home/cosnvb59uf13/public_html/web.tsl-hid.com/wp-content/plugins/no-unsafe-inline/src/Nunil_Capture.php in /home/cosnvb59uf13/public_html/web.tsl-hid.com/wp-content/plugins/no-unsafe-inline/vendor/league/uri/src/UriString.php on line 382\n
       ```
   
 *  Plugin Author [Giuseppe](https://wordpress.org/support/users/mociofiletto/)
 * (@mociofiletto)
 * [2 years, 1 month ago](https://wordpress.org/support/topic/http-error-500-troubleshooting-functions-php/#post-17708973)
 * Nice shot!
 * What happens here is that your page contains an invalid url in the src property
   of a <script> tag, maybe badly created by the snippet you showed.
 * the interested line (in the example url you posted) is 782:
 * `<script type="text/javascript" src="[https://www.tsl.comhttps:unpkg.com/isotope-layout@3/dist/isotope.pkgd.js](https://wordpress.org/support/topic/http-error-500-troubleshooting-functions-php/?output_format=md)"
   id="isotope-js"></script>`
 * I will fix the code, because the plugins should not crash when it finds an invalid
   url but simply it should not process it, however I think you should fix your 
   page.
 * The bug wil be fixed in next release.
 *  Thread Starter [Jameth12](https://wordpress.org/support/users/jameth12/)
 * (@jameth12)
 * [2 years, 1 month ago](https://wordpress.org/support/topic/http-error-500-troubleshooting-functions-php/#post-17709841)
 * The tag capture is working now! That invalid URL was being generated by an incorrectly
   enqueued script within functions.php.
 * Thank you so much for your help and for pinpointing the issue!

Viewing 8 replies - 1 through 8 (of 8 total)

The topic ‘HTTP ERROR 500 – troubleshooting functions.php’ is closed to new replies.

 * ![](https://ps.w.org/no-unsafe-inline/assets/icon-256x256.png?rev=2699768)
 * [No unsafe-inline](https://wordpress.org/plugins/no-unsafe-inline/)
 * [Frequently Asked Questions](https://wordpress.org/plugins/no-unsafe-inline/#faq)
 * [Support Threads](https://wordpress.org/support/plugin/no-unsafe-inline/)
 * [Active Topics](https://wordpress.org/support/plugin/no-unsafe-inline/active/)
 * [Unresolved Topics](https://wordpress.org/support/plugin/no-unsafe-inline/unresolved/)
 * [Reviews](https://wordpress.org/support/plugin/no-unsafe-inline/reviews/)

 * 8 replies
 * 2 participants
 * Last reply from: [Jameth12](https://wordpress.org/support/users/jameth12/)
 * Last activity: [2 years, 1 month ago](https://wordpress.org/support/topic/http-error-500-troubleshooting-functions-php/#post-17709841)
 * Status: resolved