Title: Endless while loop
Last modified: January 11, 2021

---

# Endless while loop

 *  Resolved [Philipp Thom](https://wordpress.org/support/users/philipp-thom/)
 * (@philipp-thom)
 * [5 years, 5 months ago](https://wordpress.org/support/topic/endless-while-loop/)
 * Dear Developer,
 * I found a bug that came with your recent version of this plugin.
 * In the file facebook-for-woocommerce/includes/Products.php on line 584
 * There error belongs to this while loop, which runs endless if the parent is empty!
 *     ```
       while ( $parent_category->parent !== 0 ) {
          $parent_category = get_term( $parent_category->parent, 'product_cat' );
          $level ++;
        }
       ```
   
 * Wrap it in a check if parent is set to avoid endless looping and server out of
   memory!!
    Change it to:
 *     ```
       if(isset($parent_category->parent)) {
          while ( $parent_category->parent !== 0 ) {
          $parent_category = get_term( $parent_category->parent, 'product_cat' );
          $level ++;
        }
       }
       ```
   
    -  This topic was modified 5 years, 5 months ago by [Philipp Thom](https://wordpress.org/support/users/philipp-thom/).

Viewing 1 replies (of 1 total)

 *  [Damianne P (a11n)](https://wordpress.org/support/users/drwpcom/)
 * (@drwpcom)
 * [5 years, 4 months ago](https://wordpress.org/support/topic/endless-while-loop/#post-14023377)
 * Hi [@philipp-thom](https://wordpress.org/support/users/philipp-thom/). Thanks
   for reporting this issue. For bug reports, please post to [https://github.com/facebookincubator/facebook-for-woocommerce](https://github.com/facebookincubator/facebook-for-woocommerce).
   There, you will be able to communicate with the developers of the plugin directly,
   rather than our support team.

Viewing 1 replies (of 1 total)

The topic ‘Endless while loop’ is closed to new replies.

 * ![](https://ps.w.org/facebook-for-woocommerce/assets/icon.svg?rev=3469606)
 * [Meta for WooCommerce](https://wordpress.org/plugins/facebook-for-woocommerce/)
 * [Support Threads](https://wordpress.org/support/plugin/facebook-for-woocommerce/)
 * [Active Topics](https://wordpress.org/support/plugin/facebook-for-woocommerce/active/)
 * [Unresolved Topics](https://wordpress.org/support/plugin/facebook-for-woocommerce/unresolved/)
 * [Reviews](https://wordpress.org/support/plugin/facebook-for-woocommerce/reviews/)

## Tags

 * [improvement](https://wordpress.org/support/topic-tag/improvement/)

 * 1 reply
 * 2 participants
 * Last reply from: [Damianne P (a11n)](https://wordpress.org/support/users/drwpcom/)
 * Last activity: [5 years, 4 months ago](https://wordpress.org/support/topic/endless-while-loop/#post-14023377)
 * Status: resolved