Skip to content
  • totten's avatar
    GenCode, Cache::cleanKey() - Fix deploop during clean initialization · 77f080cb
    totten authored
    Overview
    --------
    
    Suppose you have a clean codebase with no DAO files, and you try to run `xml/GenCode.php`.
    This currently crashes.
    
    The problem is not symptomatic day-to-day because we commit DAOs, so it's
    very rare to run a full/clean initialization.  However, it does get in the
    way of stress-testing the correctness of GenCode.
    
    Before
    ------
    
    Since 76e697a9, I believe we've had a dependency-loop
    in the clean-gencode scenario, which works as follows:
    
    * We don't have any DAOs, so we run `GenCode`.
    * Running `GenCode` does a partial bootstrap (i.e. `CRM_Core_Config::singleton($loadFromDB===FALSE)`)
    * The partial bootstrap creates some thread-local caches (`Arraycache`)
    * Before creating the cache, it normalizes the name by calling `CRM_Core_BAO_Cache::cleanKey()`
    * `CRM_Core_BAO_Cache` extends `CRM_Core_DAO_Cache`
    * `CRM_Core_BAO_Cache` doesn't exist - that's why we called `GenCode` at the beginning.
    
    After
    -----
    
    This migrates the utility function `cleanKey()` to another class which is always available and
    does not rely on DAOs.
    77f080cb