APCu class loading does not automatically distinguish between sites in a multisite that has per-site code

Created on 6 July 2018, almost 6 years ago
Updated 30 January 2023, over 1 year ago

Hi,

We faced issue with code caching on multisite. In our structure we have few sites and in each of them we have modules folder.

Case 1:
On-site A we have EventSubscriber with 2 events(E1 and E2).
On-site B we have EventSubscriber with 1 events(E1).
After a while, we get site B down because drupal trying to call callback of E1 event but this method does not exist.

Case 2:
On-site A we have SomeForm with a redirect to page P1.
On-site B we have SomeForm with a redirect to page P2.
After a while on submit form on site B we get redirected to page P1.

After some investigation, i found the approximate cause of the error. Drupal use APC for caching, but site_path variable does not uses on building of apc prefix building.

web/core/lib/Drupal/Core/DrupalKernel.php:1041

protected function initializeSettings(Request $request) {
    $site_path = static::findSitePath($request);
    $this->setSitePath($site_path);
    $class_loader_class = get_class($this->classLoader);
    Settings::initialize($this->root, $site_path, $this->classLoader);

    // Initialize our list of trusted HTTP Host headers to protect against
    // header attacks.
    $host_patterns = Settings::get('trusted_host_patterns', []);
    if (PHP_SAPI !== 'cli' && !empty($host_patterns)) {
      if (static::setupTrustedHosts($request, $host_patterns) === FALSE) {
        throw new BadRequestHttpException('The provided host name is not valid for this server.');
      }
    }

    // If the class loader is still the same, possibly
    // upgrade to an optimized class loader.
    if ($class_loader_class == get_class($this->classLoader)
        && Settings::get('class_loader_auto_detect', TRUE)) {
      $prefix = Settings::getApcuPrefix('class_loader', $this->root);

In the last line you can see that $site_path does not send to prefix builder.

πŸ› Bug report
Status

Needs work

Version

9.5

Component
BaseΒ  β†’

Last updated about 3 hours ago

Created by

πŸ‡ΊπŸ‡¦Ukraine shalimanov

Live updates comments and jobs are added and updated live.
  • Needs documentation

    A documentation change is requested elsewhere. For Drupal core (and possibly other projects), once the change has been committed, this status should be recorded in a change record node.

Sign in to follow issues

Comments & Activities

Not all content is available!

It's likely this issue predates Contrib.social: some issue and comment data are missing.

  • The Needs Review Queue Bot β†’ tested this issue. It either no longer applies to Drupal core, or fails the Drupal core commit checks. Therefore, this issue status is now "Needs work".

    Apart from a re-roll or rebase, this issue may need more work to address feedback in the issue or MR comments. To progress an issue, incorporate this feedback as part of the process of updating the issue. This helps other contributors to know what is outstanding.

    Consult the Drupal Contributor Guide β†’ to find step-by-step guides for working with issues.

Production build 0.69.0 2024