mirror of
https://github.com/home-assistant/core.git
synced 2025-12-25 05:26:47 +00:00
Prevent leak of current_entry context variable (#128145)
This commit is contained in:
@@ -529,10 +529,21 @@ class ConfigEntry(Generic[_DataT]):
|
||||
integration: loader.Integration | None = None,
|
||||
) -> None:
|
||||
"""Set up an entry."""
|
||||
current_entry.set(self)
|
||||
if self.source == SOURCE_IGNORE or self.disabled_by:
|
||||
return
|
||||
|
||||
current_entry.set(self)
|
||||
try:
|
||||
await self.__async_setup_with_context(hass, integration)
|
||||
finally:
|
||||
current_entry.set(None)
|
||||
|
||||
async def __async_setup_with_context(
|
||||
self,
|
||||
hass: HomeAssistant,
|
||||
integration: loader.Integration | None,
|
||||
) -> None:
|
||||
"""Set up an entry, with current_entry set."""
|
||||
if integration is None and not (integration := self._integration_for_domain):
|
||||
integration = await loader.async_get_integration(hass, self.domain)
|
||||
self._integration_for_domain = integration
|
||||
|
||||
Reference in New Issue
Block a user