Title: Galler Sort Bug
Last modified: August 21, 2016

---

# Galler Sort Bug

 *  [Gonçalo Peres](https://wordpress.org/support/users/gonperesgmailcom/)
 * (@gonperesgmailcom)
 * [12 years, 2 months ago](https://wordpress.org/support/topic/galler-sort-bug/)
 * Greetings.
 * The Sort Gallery page (/wp-admin/admin.php?page=nggallery-manage-gallery&mode
   =edit&gid=24&paged=1) throws a:
 * > “PHP Fatal error: Allowed memory size of 268435456 bytes exhausted (tried to
   > allocate 1926485 bytes) in /xxx/wp-includes/wp-db.php on line 880”
 * …and the page breaks at the (X)nth image. PHP dies and the page doesn’t finish
   to load, so everything fails to work (no JS available).
 * This happens when i have a big gallery (250 images or more). I can fix it by 
   editing the code on /wp-content/plugins\nextgen-gallery/products/photocrati_nextgen/
   modules/ngglegacy/admin/manage-sort.php
 * Notice the commented “echo” call, replaced by a different echo, just for the 
   image_slug field. This solves the PHP Fatal error / memory problem.
 *     ```
       <div class='jqui-sortable'>
       	<?php
       	if($picturelist) {
       		foreach($picturelist as $picture) {
       			?>
       			<div class="imageBox" id="pid-<?php echo $picture->pid ?>">
       				<div class="imageBox_theImage" style="background-image:url('<?php echo nextgen_esc_url( $picture->thumbURL ); ?>')"></div>
       				<div class="imageBox_label"><span><?php echo $picture->image_slug; //echo esc_html( stripslashes($picture->alttext) ); ?></span></div>
       			</div>
       			<?php
       		}
       	}
       	?>
       </div>
       ```
   
 * This bug has been annoying me for quite some versions ago. And would be great
   if you could fix it, because every time i upgrade Nextgen Gallery, the sort page
   become useless.
 * Can anyone else reproduce this problem?
 * I’m using WordPress Multisite 3.8.1 and the latest Nextgen Gallery (2.0.59), 
   but, like I said, this bug as been present since I can remember.
 * Thank you in advance for caring.
 * [https://wordpress.org/plugins/nextgen-gallery/](https://wordpress.org/plugins/nextgen-gallery/)

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

 *  Plugin Contributor [photocrati](https://wordpress.org/support/users/photocrati/)
 * (@photocrati)
 * [12 years, 2 months ago](https://wordpress.org/support/topic/galler-sort-bug/#post-4738059)
 * [@gon](https://wordpress.org/support/users/gon/)çalo Peres – That’s a huge amount
   of memory you are consuming, have you looked at anything else on the site that
   may also be using a lot of its resources. We understand NextGEN Gallery can use
   a lot of resources under certain conditions but a PHP Memory Limit of 256 (as
   indicated by your error message) is generally well more than enough.
 * If you case is particularly unique, perhaps you could get it raised to 512 and
   see if you can push through things at that level.
 * Thanks!
 * – Cais.
 *  Thread Starter [Gonçalo Peres](https://wordpress.org/support/users/gonperesgmailcom/)
 * (@gonperesgmailcom)
 * [12 years, 2 months ago](https://wordpress.org/support/topic/galler-sort-bug/#post-4738081)
 * Ok, so i’ve done some more testing and the memory problem appears to be related
   to Polylang plugin.
 * Like I said before, I overcome the fatal error by changing the loop on “/wp-content/
   plugins/nextgen-gallery/products/photocrati_nextgen/modules/ngglegacy/admin/manage-
   sort.php”
 * The problem goes away, if I do not use “$picture->alttext” inside the “$picturelist”
   while loop.
 * So i look a little bit further up and tracked how the “$picturelist” was generated(
   $picturelist = $nggdb->get_gallery())
 * So I tracked it down to “/wp-content/plugins/nextgen-gallery/products/photocrati_nextgen/
   modules/nextgen_data/class.image_wrapper.php”
 * The “$nggdb->get_gallery()” call places some extra burden on “alltext”.
 * Line 124:
 *     ```
       case 'alttext':
         $this->_cache['alttext'] = (empty($this->_cache['alttext'])) ?  ' ' : html_entity_decode(stripslashes(nggGallery::i18n($this->_cache['alttext'], 'pic_' . $this->__get('id') . '_alttext')));
         return $this->_cache['alttext'];
       ```
   
 * This “i18n()” call is the problem.
    If i just return the original “alttext”, 
   without making the “i18n” call, everything works fine.
 *     ```
       case 'alttext':
         <strong>//</strong>$this->_cache['alttext'] = (empty($this->_cache['alttext'])) ?  ' ' : html_entity_decode(stripslashes(nggGallery::i18n($this->_cache['alttext'], 'pic_' . $this->__get('id') . '_alttext')));
         return $this->_cache['alttext'];
       ```
   
 * So, looking at “/wp-content/plugins/nextgen-gallery/products/photocrati_nextgen/
   modules/ngglegacy/lib/core.php” I can see that it’s checking for an “icl_translate()”
   function, which exists on Polylang plugin and is registering translations for
   every pictures “alttext”.
 * I still have some more digging to do to on the Polylang plugin side. It would
   be nice to have a plugin setting to avoid these translations to occur on NextGEN
   Gallery side.
 *  Plugin Contributor [photocrati](https://wordpress.org/support/users/photocrati/)
 * (@photocrati)
 * [12 years, 2 months ago](https://wordpress.org/support/topic/galler-sort-bug/#post-4738087)
 * [@gon](https://wordpress.org/support/users/gon/)çalo Peres – The `icl_*` functions
   were basically added for WPML compatibility, is this “Polylang” plugin referencing
   a different plugin or the same one?
 * – Cais.

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

The topic ‘Galler Sort Bug’ is closed to new replies.

 * ![](https://ps.w.org/nextgen-gallery/assets/icon-256x256.png?rev=2083961)
 * [Photo Gallery, Sliders, Proofing and Themes - NextGEN Gallery](https://wordpress.org/plugins/nextgen-gallery/)
 * [Frequently Asked Questions](https://wordpress.org/plugins/nextgen-gallery/#faq)
 * [Support Threads](https://wordpress.org/support/plugin/nextgen-gallery/)
 * [Active Topics](https://wordpress.org/support/plugin/nextgen-gallery/active/)
 * [Unresolved Topics](https://wordpress.org/support/plugin/nextgen-gallery/unresolved/)
 * [Reviews](https://wordpress.org/support/plugin/nextgen-gallery/reviews/)

 * 3 replies
 * 2 participants
 * Last reply from: [photocrati](https://wordpress.org/support/users/photocrati/)
 * Last activity: [12 years, 2 months ago](https://wordpress.org/support/topic/galler-sort-bug/#post-4738087)
 * Status: not resolved