Bitrix Site Manager

CBitrixComponent::AbortResultCache

void
AbortResultCache();

This helper method is used by components for internal caching.

It is used if the data fetching procedure figured it out that it is not necessary to cache data.

For example, if there is no news with the required ID, caching should be stopped and a warning message is to be displayed. If caching is not interrupted, malicious persons can increase cache size up to a maximum possible value, thereby calling the page with arbitrary ID's.

Example


// Check and initialize input parameters
if ($arParams["ID"] <= 0)
	$arParams["ID"] = 10;

// If there is no valid cache (data is to be queried and 
// a valid cache is to be created) if ($this->StartResultCache()) { // Query data and fill in $arResult $arResult = array( "ID" => rand(1, 100) ); for ($i = 0; $i < 5; $i++) $arResult["FIELDS"][] = rand(1, 100); // If any condition is true,
       // do not cache data if ($arParams["ID"] < 10) $this->AbortResultCache(); // Include the display template $this->IncludeComponentTemplate(); } // Set the page heading using the delay function $APPLICATION->SetTitle($arResult["ID"]);

See Also

  • CBitrixComponent::StartResultCache
  • CBitrixComponent::ClearResultCache