Skip to content

Fix bugs where config.when_first_matching_example_defined hooks would fire multiple times

gitlab-qa-bot requested to merge fix-when_first_matching_example_defined into master

Created by: yujinakayama

The config.when_first_matching_example_defined hooks are registered on @derived_metadata_blocks, which is an instance of FilterableItemRepository::QueryOptimized, and unregistered on the first invocation, so that they won't run multiple times.

However, they are actually unregistered only from the internal memoized cache for a particular metadata in FilterableItemRepository::QueryOptimized. As a result, the hooks would be invoked multiple times in the following cases:

To fix these bugs, we need to properly unregister the hook from the original hook collection (@items_and_filters in FilterableItemRepository::QueryOptimized) rather than the memoized cache.

Merge request reports