Skip to content

fix broken cache warmup after setup#974

Merged
odain-cbd merged 2 commits into
support/3.3-beta1from
fix-commit
Jul 17, 2026
Merged

fix broken cache warmup after setup#974
odain-cbd merged 2 commits into
support/3.3-beta1from
fix-commit

Conversation

@odain-cbd

Copy link
Copy Markdown
Contributor

Fix below issue after setup:

2026-07-16 14:20:36 | Error   |       | Uncaught ReflectionException: Class "TagSetFieldDataFor_FAQ__domains" does not exist in /var/www/html/iTop/core/metamodel.class.php:3891
Stack trace:
#0 /var/www/html/iTop/core/metamodel.class.php(3891): ReflectionClass->__construct()
#1 /var/www/html/iTop/core/dbobjectsearch.class.php(1875): MetaModel::IsAbstract()
#2 /var/www/html/iTop/core/expressioncache.class.inc.php(120): DBObjectSearch::GetPolymorphicExpression()
#3 /var/www/html/iTop/core/expressioncache.class.inc.php(91): ExpressionCache::GetSerializedExpression()
#4 /var/www/html/iTop/core/metamodel.class.php(5790): ExpressionCache::Warmup()
#5 /var/www/html/iTop/application/startup.inc.php(76): MetaModel::Startup()
#6 /var/www/html/iTop/pages/UI.php(235): require_once('...')
#7 {main}
  thrown | IssueLog |||
array (
  'type' => 1,
  'file' => '/var/www/html/iTop/core/metamodel.class.php',
  'line' => 3891,
)

@odain-cbd odain-cbd self-assigned this Jul 16, 2026
Copilot AI review requested due to automatic review settings July 16, 2026 12:51
@odain-cbd odain-cbd added internal Work made by Combodo Setup Related to the setup process (install / upgrade) labels Jul 16, 2026
@odain-cbd
odain-cbd requested review from Lenaick and eespie July 16, 2026 12:52

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Invalidates the expression cache after setup to prevent warmup failures caused by stale generated classes.

Changes:

  • Clears the expression-cache directory during environment commit.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

@greptile-apps

greptile-apps Bot commented Jul 16, 2026

Copy link
Copy Markdown
Contributor

Greptile Summary

This PR adds a single line to RunTimeEnvironment::Commit() to clear the expressioncache/ subdirectory after the data-cache commit and before the env-directory commit. The intent is to prevent a stale expressioncache from surviving into post-setup page loads and causing a ReflectionException during ExpressionCache::Warmup().

  • What changed: One SetupUtils::tidydir(...) call inserted inside the if ($this->sFinalEnv != $this->sBuildEnv) block, after CommitDir for the data cache and before CommitDir for the env directory.
  • Interactive wizard: Works correctly — the commit step runs in a fresh HTTP request where MetaModel defaults to 'production', so GetCachePath() resolves to the right directory.
  • Unattended/CLI setup: UpdateDBSchema calls InitDataModel earlier in the same process, binding MetaModel::$m_sEnvironment to 'production-build'. By the time line 919 executes, GetCachePath() returns the build-env path which was already moved away, making the tidydir a no-op.

Confidence Score: 3/5

Safe to merge for interactive wizard setups, but the fix does not take effect in unattended/CLI installations due to the environment resolution issue.

The one-line change solves the reported bug for the interactive setup wizard (the common case), but has a hidden gap: when all setup steps run in a single process (unattended installs), MetaModel is already bound to the build environment by the time Commit() runs, so GetCachePath() resolves to the build-env cache directory — which no longer exists at that point — making the tidydir a no-op and leaving the stale expressioncache in place.

setup/runtimeenv.class.inc.php line 919 — the environment argument passed to utils::GetCachePath() needs to be made explicit.

Important Files Changed

Filename Overview
setup/runtimeenv.class.inc.php Adds a tidydir call to clear the expressioncache directory during Commit(), but uses utils::GetCachePath() without an explicit environment argument — in unattended/CLI setups this resolves to the build env cache path rather than the production one, making the fix a no-op.

Reviews (1): Last reviewed commit: "fix broken cache warmup after setup" | Re-trigger Greptile

Comment thread setup/runtimeenv.class.inc.php Outdated
false
);

SetupUtils::tidydir(utils::GetCachePath().'expressioncache/');

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P1 Wrong cache path in unattended/CLI setup

utils::GetCachePath() resolves the environment by calling MetaModel::GetEnvironment(), which returns whatever environment was last passed to MetaModel::Startup(). In the interactive wizard, the commit step runs in a fresh HTTP request where no Startup() has been called yet, so MetaModel::$m_sEnvironment falls back to the compile-time default 'production' — making this call work correctly.

In an unattended (CLI/all-in-one-request) setup, UpdateDBSchema() calls InitDataModel() earlier in the same process, which calls MetaModel::Startup(..., $this->sBuildEnv), setting MetaModel::$m_sEnvironment = 'production-build'. When Commit() reaches line 919, GetCachePath() returns data/cache-production-build/expressioncache/ — but that directory was already moved away by CommitDir at line 913. The tidydir is a no-op, the stale expressioncache in cache-production/ is never cleared, and the bug persists for unattended installs. Use utils::GetCachePath($this->sFinalEnv) to always target the correct directory.

Suggested change
SetupUtils::tidydir(utils::GetCachePath().'expressioncache/');
SetupUtils::tidydir(utils::GetCachePath($this->sFinalEnv).'expressioncache/');

@odain-cbd
odain-cbd merged commit a5aa8c2 into support/3.3-beta1 Jul 17, 2026
@odain-cbd
odain-cbd deleted the fix-commit branch July 17, 2026 08:40
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

internal Work made by Combodo Setup Related to the setup process (install / upgrade)

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants