diff --git a/core/includes/install.core.inc b/core/includes/install.core.inc index 7b66911..f8de4f1 100644 --- a/core/includes/install.core.inc +++ b/core/includes/install.core.inc @@ -2116,6 +2116,25 @@ function install_check_requirements($install_state) { } } } + + // Installations on Windows can run into limitations with MAX_PATH if the + // Drupal root directory is too deep in the filesystem. Generally this shows + // up in cached Twig templates. Because of their variable length, for example + // template suggestions can arbitrarily lengthen a filename, there is no set + // limit beyond which Drupal will not function correctly on Windows. Thus we + // only warn if a Drupal is being installed more than 100 characters deep in + // the filesystem. + if (strpos(strtolower(php_uname('s')), 'win') === 0) { + $depth = strlen(realpath(DRUPAL_ROOT)); + if ($depth > 100) { + $requirements['max_path_on_windows'] = [ + 'title' => t('Windows installation'), + 'description' => t('The path length to the Drupal root directory (@depth characters) is greater than 100 characters. This may cause problems when running on a Windows server. It is recommended to install Drupal on Windows in a shorter path.', ['@depth' => $depth]), + 'severity' => REQUIREMENT_WARNING, + ]; + } + } + return $requirements; }