Title: Fatal error: Uncaught TypeError: count():
Last modified: October 3, 2023

---

# Fatal error: Uncaught TypeError: count():

 *  Resolved [timbearcub](https://wordpress.org/support/users/timbearcub/)
 * (@timbearcub)
 * [2 years, 7 months ago](https://wordpress.org/support/topic/fatal-error-uncaught-typeerror-count-3/)
 * I am using the gallery dynamically with tags from Medla Library Categories plugin
   with a shortcode, e.g.
 * [gallery category="image-forsale" order="DESC" orderby="post_date"]
 * It was working fine, but I’ve noticed some of the galleries now give this error,
   usually the larger galleries?
 * **Fatal error**: Uncaught TypeError: count(): Argument #1 ($value) must be of
   type Countable|array, bool given in /wp-includes/formatting.php:3501 Stack trace:#
   0 /wp-includes/class-wp-hook.php(310): convert_smilies() #1 /wp-includes/plugin.
   php(205): WP_Hook->apply_filters() #2 /wp-includes/blocks/post-content.php(54):
   apply_filters() #3 /wp-includes/class-wp-block.php(258): render_block_core_post_content()#
   4 /wp-includes/class-wp-block.php(244): WP_Block->render() #5 /wp-includes/blocks.
   php(1133): WP_Block->render() #6 /wp-includes/blocks.php(1171): render_block()#
   7 /wp-includes/block-template.php(231): do_blocks() #8 /wp-includes/template-
   canvas.php(12): get_the_block_template_html() #9 /wp-includes/template-loader.
   php(106): include(‘…’) #10 /wp-blog-header.php(19): require_once(‘…’) #11 /index.
   php(17): require(‘…’) #12 {main} thrown in **/wp-includes/formatting.php** on
   line **3501**
 * (edited out my /var/www etc server paths for security)
   If I disable all plugins,
   page shows fine, no gallery though. If I just disable Meow Gallery, it shows,
   but annoyingly not in columns, but shows the gallery shortcode is working. Disable
   all but those two plugins, still errors. Changing the theme to a non block theme
   like Twenty Twenty Two standard still errors. So I think this is caused by Meow
   Gallery? Using PHP 8.0 on nginx, everything else seems fine.
    -  This topic was modified 2 years, 7 months ago by [timbearcub](https://wordpress.org/support/users/timbearcub/).
    -  This topic was modified 2 years, 7 months ago by [timbearcub](https://wordpress.org/support/users/timbearcub/).
 * The page I need help with: _[[log in](https://login.wordpress.org/?redirect_to=https%3A%2F%2Fwordpress.org%2Fsupport%2Ftopic%2Ffatal-error-uncaught-typeerror-count-3%2F%3Foutput_format%3Dmd&locale=en_US)
   to see the link]_

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

 *  Thread Starter [timbearcub](https://wordpress.org/support/users/timbearcub/)
 * (@timbearcub)
 * [2 years, 7 months ago](https://wordpress.org/support/topic/fatal-error-uncaught-typeerror-count-3/#post-17097963)
 * P.S. if it seems to be working now, it isn’t, as temporarily I’ve had to completely
   remove Meow Gallery and replace all the shortcodes with the Media Library Assistant
   gallery, not as good but I can’t have the pages broken like that.
   It’s a temporary
   measure, and I’d like to get Meow Gallery to work, but I don’t know if a response
   is going to take days or weeks, so I need something to at least be working in
   the meantime.Also what’s with the standard WP Gallery Shortcode? It’s broken,
   it doesn’t have columns anymore!
    -  This reply was modified 2 years, 7 months ago by [timbearcub](https://wordpress.org/support/users/timbearcub/).
 *  Thread Starter [timbearcub](https://wordpress.org/support/users/timbearcub/)
 * (@timbearcub)
 * [2 years, 7 months ago](https://wordpress.org/support/topic/fatal-error-uncaught-typeerror-count-3/#post-17100359)
 * I fixed it – kinda.
 * The error still remains, but it seems that the problem for Gallery AND Lightbox
   is if you have a gallery for more than 500 images – I know one that broke was
   687 and another was 514, so guessing somewhere around that – then if Meow Gallery
   is enabled it kicks out that error.and you don’t see the page, just get a ‘critical
   error’ if PHP errors are disabled – and you can’t edit that page either! 
   And
   Meow Lightbox stops working on that gallery even if Meow Gallery is disabled,
   links open directly in the browser on a >500 image gallery, smaller galleries
   work fine
 * I kind of fixed it with Media Library Assistant; using pagination means both 
   started working again, and then using mla_alt_shortcode=gallery as per a post
   here [https://wordpress.org/support/topic/using-mla-with-meow-gallery/](https://wordpress.org/support/topic/using-mla-with-meow-gallery/)
   meant then Meow Gallery could see it, not freak out at the large gallery, and
   then use the tiling and Lighbox started working again for those two large galleries.
   Phew – I was dreading trying to use another plugin cos it’s mean having to retag
   over 2,600 images.
   Not totally happy about using MLA cos it does weird things
   to my Media Library view, and I don’t like running two plugins for my gallery,
   but it’s better than nothing.
 * Error still remains though – MG and ML doesn’t like galleries bigger than 500
   or so images, seemingly.
    -  This reply was modified 2 years, 7 months ago by [timbearcub](https://wordpress.org/support/users/timbearcub/).
    -  This reply was modified 2 years, 7 months ago by [timbearcub](https://wordpress.org/support/users/timbearcub/).
    -  This reply was modified 2 years, 7 months ago by [timbearcub](https://wordpress.org/support/users/timbearcub/).
    -  This reply was modified 2 years, 7 months ago by [timbearcub](https://wordpress.org/support/users/timbearcub/).
    -  This reply was modified 2 years, 7 months ago by [timbearcub](https://wordpress.org/support/users/timbearcub/).
    -  This reply was modified 2 years, 7 months ago by [timbearcub](https://wordpress.org/support/users/timbearcub/).
 *  Plugin Support [Val Meow](https://wordpress.org/support/users/valwa/)
 * (@valwa)
 * [2 years, 7 months ago](https://wordpress.org/support/topic/fatal-error-uncaught-typeerror-count-3/#post-17108431)
 * Hey [@timbearcub](https://wordpress.org/support/users/timbearcub/) !
 * I was able to replicate your issue with a gallery of 550 images. It seems the
   issue is arising from how the block is generated. Thank you for reporting this
   issue; we will definitely look into it. By the way, if you use the Infinite Scroll
   feature, it should solve the problem, although it should work in both cases to
   begin with. 😊
 *  Thread Starter [timbearcub](https://wordpress.org/support/users/timbearcub/)
 * (@timbearcub)
 * [2 years, 7 months ago](https://wordpress.org/support/topic/fatal-error-uncaught-typeerror-count-3/#post-17108773)
 * Glad to be of help! Love the gallery and lightbox, so was glad I found a partial
   solution to this, I hope a fix is forthcoming soon. I do actually like my paginated
   galleries, would be great if MG had that function too so I didn’t need to rely
   on MLA, but it works.
 * Thanks.
 *  Plugin Support [Val Meow](https://wordpress.org/support/users/valwa/)
 * (@valwa)
 * [2 years, 7 months ago](https://wordpress.org/support/topic/fatal-error-uncaught-typeerror-count-3/#post-17109141)
 * Hey [@timbearcub](https://wordpress.org/support/users/timbearcub/) !
 * I’ve been investigating this issue, and here is what I’ve found. WordPress verifies
   the HTML of loaded pages to _convert content with text smilies to images_. To
   achieve this, WordPress uses an “ungreedy” regular expression. The use of the“
   ungreedy” parameter causes the backtrack limit to be exhausted quickly, especially
   when dealing with long strings. This becomes apparent, for example, when processing
   a gallery with over 500 meta data entries simultaneously. If you manually remove
   this “ungreedy” parameter, the process works as intended.
 * Since modifying WordPress files is not recommended as updates will erase changes,
   you can address this issue by adjusting the backtrack limit in your PHP settings.
   To do this, add the following line to your php.ini file: `pcre.backtrack_limit
   =1000000000`. It’s essential to exercise caution when increasing the backtrack
   limit, and for this particular use case, it might be more suitable to use features
   such as infinite loading or pagination, as you’re already doing.
 * Hope this helps ! 😊

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

The topic ‘Fatal error: Uncaught TypeError: count():’ is closed to new replies.

 * ![](https://ps.w.org/meow-gallery/assets/icon-256x256.png?rev=2791571)
 * [Meow Gallery](https://wordpress.org/plugins/meow-gallery/)
 * [Support Threads](https://wordpress.org/support/plugin/meow-gallery/)
 * [Active Topics](https://wordpress.org/support/plugin/meow-gallery/active/)
 * [Unresolved Topics](https://wordpress.org/support/plugin/meow-gallery/unresolved/)
 * [Reviews](https://wordpress.org/support/plugin/meow-gallery/reviews/)

## Tags

 * [count](https://wordpress.org/support/topic-tag/count/)
 * [gallery issue](https://wordpress.org/support/topic-tag/gallery-issue/)
 * [media](https://wordpress.org/support/topic-tag/media/)
 * [uncaught TypeError](https://wordpress.org/support/topic-tag/uncaught-typeerror/)

 * 5 replies
 * 2 participants
 * Last reply from: [Val Meow](https://wordpress.org/support/users/valwa/)
 * Last activity: [2 years, 7 months ago](https://wordpress.org/support/topic/fatal-error-uncaught-typeerror-count-3/#post-17109141)
 * Status: resolved