Answer the question
In order to leave comments, you need to log in
Why is the cache not updated correctly in the cached area when calling the CIBlockSection::GetList method?
Good evening everyone.
What I have:
In the parameters, the cache lifetime is 30 seconds.
template.php
<pre>
<? var_dump($arResult) ?>
</pre>
if ($this->StartResultCache()) {
if (!CModule::IncludeModule("iblock")) {
$this->AbortResultCache();
ShowError("IBLOCK_MODULE_NOT_INSTALLED");
return false;
}
$arSort= array("SORT" => "ASC", "DATE_ACTIVE_FROM" => "DESC", "ID" => "DESC");
$arFilter = array("IBLOCK_ID" => $arParams["IBLOCK_ID"], "ACTIVE" => "Y", "ACTIVE_DATE" => "Y");
$arSelect = array("ID", "IBLOCK_ID", "IBLOCK_SECTION_ID", "NAME", "DATE_ACTIVE_FROM", "DEPTH_LEVEL", "UF_MAIN_SECTION");
$rsElement = CIBlockSection::GetList(false, $arFilter, false, $arSelect, false);
while ($obElement = $rsElement->GetNext()) {
$arResult["ITEMS"][] = $obElement;
}
$this->SetResultCacheKeys(array());
$this->IncludeComponentTemplate();
}
if ($this->StartResultCache()) {
if (!CModule::IncludeModule("iblock")) {
$this->AbortResultCache();
ShowError("IBLOCK_MODULE_NOT_INSTALLED");
return false;
}
$arSort= array("SORT" => "ASC", "DATE_ACTIVE_FROM" => "DESC", "ID" => "DESC");
$arFilter = array("IBLOCK_ID" => $arParams["IBLOCK_ID"], "ACTIVE" => "Y", "ACTIVE_DATE" => "Y");
$arSelect = array("ID", "IBLOCK_ID", "NAME", "DATE_ACTIVE_FROM", "PREVIEW_TEXT", "PREVIEW_PICTURE");
$rsElement = CIBlockElement::GetList($arSort, $arFilter, false, $arNavParams, $arSelect);
while($obElement = $rsElement->GetNextElement()) {
$arElement = $obElement->GetFields();
$arResult["ITEMS"][] = $arElement;
}
$this->SetResultCacheKeys(array());
$this->IncludeComponentTemplate();
}
Answer the question
In order to leave comments, you need to log in
As a result, the problem was not in CIBlockSection::GetList, but in CIBlockElement::GetList. For some reason, CIBlockElement::GetList was ignoring the access rules that are set in the infoblock settings. More details in the comments to the question (see above)
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question