N°8772 - cache fix

This commit is contained in:
Eric Espie
2025-12-16 11:14:39 +01:00
parent 75afd3ba46
commit b653236e86
2 changed files with 2 additions and 5 deletions

View File

@@ -49,13 +49,13 @@ class FormBlockService
public function GetFormBlockById(string $sId, string $sType): FormBlock
{
$sFilteredId = preg_replace('/[^0-9a-zA-Z_]/', '', $sId);
if (strlen($sFilteredId) === 0) {
if (strlen($sFilteredId) === 0 || $sFilteredId !== $sId) {
throw new FormBlockException('Malformed name for block: '.json_encode($sId));
}
if (!$this->oCacheService->HasEntry(self::CACHE_POOL, $sFilteredId) || utils::IsDevelopmentEnvironment()) {
// Cache not found, compile the form
$sPHPContent = FormsCompiler::GetInstance()->CompileForm($sFilteredId, $sType);
$this->oCacheService->StorePhpContent(FormBlockService::CACHE_POOL, $sId, "<?php\n\n$sPHPContent");
$this->oCacheService->StorePhpContent(FormBlockService::CACHE_POOL, $sFilteredId, "<?php\n\n$sPHPContent");
}
$this->oCacheService->Fetch(self::CACHE_POOL, $sFilteredId);
$sFormBlockClass = 'FormFor__'.$sFilteredId;

View File

@@ -5,10 +5,8 @@
* @license http://opensource.org/licenses/AGPL-3.0
*/
use Combodo\iTop\Forms\Block\Base\ChoiceFromInputsBlock;
use Combodo\iTop\Forms\Compiler\FormsCompiler;
use Combodo\iTop\Test\UnitTest\ItopDataTestCase;
use Symfony\Component\Validator\Constraints\NotNull;
class FormsCompilerTest extends ItopDataTestCase
{
@@ -17,7 +15,6 @@ class FormsCompilerTest extends ItopDataTestCase
*
* @param string $sXMLContent
* @param string $sExpectedPHP
* @param string $sMessage
*
* @return void
* @throws \Combodo\iTop\Forms\Compiler\FormsCompilerException