Skip to content
  • Eloy Lafuente's avatar
    MDL-73098 install: Detect stale bootstrap.php files and disable them · 4c0ae3e1
    Eloy Lafuente authored
    It's important to say that this bug apparently (till now) only happens
    when an *incorrect* instalation of a site happens, reusing the dataroot
    from another existing site.
    
    When that happens, the localcache/bootstrap.php file from the old
    site is reused, setting siteidentifier and SYSCONTEXTID when it's not
    time for them to be defined yet.
    
    Their existenece leads to reusing some other structures from the old
    dataroot (that, again, should have been changed or wiped!), ultimately
    leading to all sort of errors about non-existent tables (course,
    context...).
    
    With this change we ensure that:
    
    1) Whenever any change to the database configuration (prefix, user,
       type..) happens, it's detected and immediately the information
       in the localcache/bootstrap.php is discarded and the file removed.
       This should fix problems like MDL-73098 itself.
    
    2) We only set SYSCONTEXTID if the file is not stale. Main reason
       for doing that check within the localcache/bootstrap.php file
       itself is that we cannot "undefine" it @ setup.php. This should
       prevent errros like MDL-72888 to happen.
    
    3) Finally, little detail, we only define SYSCONTEXTID if it has
       not been defined earlier. In the past, it was recommended to
       define it in config.php (exactly to save one DB read) and, sites
       having them will face "already defined" warnings.
    4c0ae3e1