Skip to content
View in the app

A better way to browse. Learn more.

thirty bees forum

A full-screen app on your home screen with push notifications, badges and more.

To install this app on iOS and iPadOS
  1. Tap the Share icon in Safari
  2. Scroll the menu and tap Add to Home Screen.
  3. Tap Add in the top-right corner.
To install this app on Android
  1. Tap the 3-dot menu (⋮) in the top-right corner of the browser.
  2. Tap Add to Home screen or Install app.
  3. Confirm by tapping Install.

PageCache bug (and solution)

Featured Replies

Categories are not removed from the cache (Redis etc) when invalidated, because the cache keys are deleted before they are collected. See fix below.

/**
 * Invalidate an entity from the cache
 *
 * @param string   $entityType
 * @param int|null $idEntity
 *
 * @since 1.0.0
 */
public static function invalidateEntity($entityType, $idEntity = null)
{
    $keysToInvalidate = [];

    if ($entityType === 'product') {
        // Refresh the homepage
        $keysToInvalidate = array_merge(
            $keysToInvalidate,
            static::getKeysToInvalidate('index')
        );

        Db::getInstance()->delete(
            'page_cache',
            '`entity_type` = \'index\''
        );
        if ($idEntity) {
            // Invalidate product's categories only
            $product = new Product((int) $idEntity);
            if ($product) {
                $categories = $product->getCategories();
                foreach ($categories as $idCategory) {

                    //Edit by Kasper: Moved to the top in the loop to collect the keys before they are deleted.
                    $keysToInvalidate = array_merge(
                        $keysToInvalidate,
                        static::getKeysToInvalidate('category', $idCategory)
                    );

                   //Edit by Kasper: Moved to the bottom of the loop so we can delete the keys after they are collected.
                    Db::getInstance()->delete(
                        'page_cache',
                        '`entity_type` = \'category\' AND `id_entity` = '.(int) $idCategory
                    );

                }
            }
        } else {
            // Invalidate all parent categories
            Db::getInstance()->delete(
                'page_cache',
                '`entity_type` = \'category\''
            );
            $keysToInvalidate = array_merge(
                $keysToInvalidate,
                static::getKeysToInvalidate('category')
            );
        }
    }

    $keysToInvalidate = array_merge(
        $keysToInvalidate,
        static::getKeysToInvalidate($entityType, $idEntity)
    );
    Db::getInstance()->delete(
        'page_cache',
        '`entity_type` = \''.pSQL($entityType).'\''.($idEntity ? ' AND `id_entity` = '.(int) $idEntity : '')
    );

    $cache = Cache::getInstance();
    foreach ($keysToInvalidate as $item) {
        $cache->delete($item);
    }
}

Create an account or sign in to comment

Account

Navigation

Search

Search

Configure browser push notifications

Chrome (Android)
  1. Tap the lock icon next to the address bar.
  2. Tap Permissions → Notifications.
  3. Adjust your preference.
Chrome (Desktop)
  1. Click the padlock icon in the address bar.
  2. Select Site settings.
  3. Find Notifications and adjust your preference.