getCacheSlotResultsForRequestedPage(); if (!isset($requestedPageSlotResults[$slotId])) { $requestedPageSlotResults[$slotId] = []; } /** * Metadata and other rendering may occurs * recursively in one request * * We record only the first one because the second call one will use the first * one */ if (!isset($requestedPageSlotResults[$slotId][$cacheParser->mode])) { $date = null; if (file_exists($cacheParser->cache)) { $date = Iso8601Date::createFromTimestamp(filemtime($cacheParser->cache))->getDateTime(); } $requestedPageSlotResults[$slotId][$cacheParser->mode] = [ self::RESULT_STATUS => $result, self::DATE_MODIFIED => $date ]; } } public function getXhtmlCacheSlotResultsForRequestedPage(): array { $cacheSlotResultsForRequestedPage = $this->getCacheSlotResultsForRequestedPage(); if ($cacheSlotResultsForRequestedPage === null) { return []; } $xhtmlRenderResult = []; foreach ($cacheSlotResultsForRequestedPage as $slotId => $modes) { foreach ($modes as $mode => $values) { if ($mode === "xhtml") { $xhtmlRenderResult[$slotId] = $values[self::RESULT_STATUS]; } } } return $xhtmlRenderResult; } private function &getCacheSlotResultsForRequestedPage(): ?array { $requestedPage = $this->getRequestedPage(); $requestedPageSlotResults = &$this->cacheResults[$requestedPage]; if (!isset($requestedPageSlotResults)) { $requestedPageSlotResults = []; } return $requestedPageSlotResults; } public function isCacheLogPresentForSlot($slotId, $mode): bool { $cacheSlotResultsForRequestedPage = $this->getCacheSlotResultsForRequestedPage(); return isset($cacheSlotResultsForRequestedPage[$slotId][$mode]); } /** * @return array - a array that will be transformed as json HTML data block * to be included in a HTML page */ public function getCacheSlotResultsAsHtmlDataBlockArray(): array { $htmlDataBlock = []; $cacheSlotResultsForRequestedPage = $this->getCacheSlotResultsForRequestedPage(); if ($cacheSlotResultsForRequestedPage === null) { LogUtility::msg("No page slot results were found"); return []; } foreach ($cacheSlotResultsForRequestedPage as $pageId => $resultByFormat) { foreach ($resultByFormat as $format => $result) { $modifiedDate = $result[self::DATE_MODIFIED]; if ($modifiedDate !== null) { $modifiedDate = Iso8601Date::createFromDateTime($modifiedDate)->toString(); } $htmlDataBlock[$pageId][$format] = [ self::RESULT_STATUS => $result[self::RESULT_STATUS], "mtime" => $modifiedDate ]; } } return $htmlDataBlock; } private function getRequestedPage() { global $_REQUEST; $requestedPage = $_REQUEST[DokuwikiId::DOKUWIKI_ID_ATTRIBUTE]; if ($requestedPage !== null) { return $requestedPage; } /** * We are not on a HTTP request * but may be on a {@link Page::renderMetadataAndFlush() metadata rendering request} */ global $ID; if ($ID !== null) { return $ID; } if(PluginUtility::isTest()) { /** * {@link p_get_metadata()} check the cache and is used * also in several place such as {@link feed.php} * where we don't have any influence */ LogUtility::msg("The requested page should be known to register a page cache result"); } return "unknown"; } public function isEmpty(): bool { return sizeof($this->cacheResults) === 0; } }