Child pages
  • [deployment] Trait usage results in fatal error during deploy [5.2.1]
Skip to end of metadata
Go to start of metadata

Traits were added in PHP 5.4 and allows to make great decisions, when it comes to improving application architecture.

From In-Portal perspective traits look like regular classes, that can be:

  • added
  • registered within a factory
  • use in other traits/classes (file containing used trait will be automatically loaded)

Although I've noticed a side effect, which leads to "Trait '.....' not found" fatal error, when rebuilding unit config cache (that happens also on the deploy) in case if a newly added trait is used in the sub-class of UsersEventHandler class. Also it wasn't clear how that class is invoked in deployment process. This is what happened:

  1. the "adm:OnStartup" event was fired as part of "kApplication::Init" method call
  2. one of the hooks to that event was "u:OnAutoLoginUser" event
  3. that resulted in "UsersEventHandler" class (or it's sub-class, when available) being included
  4. that triggered new trait lookup

All that was happening before new unit config cache (that contained that trait location on disk) was saved to db/memcache.

Solution

  1. introduce "full_init" flag in URL (enabled by default, but not visible in any url)
  2. when present call the "adm:OnStartup" event
  3. pass "full_init=0" flag value when:
    1. doing deploy (from CLI and WEB)
    2. doing any other action from "Tools > System Tools" section

Related Tasks

INP-1413 - Getting issue details... STATUS