Score:1

Call to undefined function Drupal\Core\drupal_valid_test_ua()

cn flag

I'm having this trouble while trying to upgrade drupal 8.9 to 9.4. I've followed the steps explained on drupal.org, and I'm using composer to do this. I've already upgraded other D9 sites, but never a D8.

This is the error when trying to access frontpage:

Fatal error: Uncaught Error: Call to undefined function Drupal\Core\drupal_valid_test_ua() in /code/docroot/core/lib/Drupal/Core/DrupalKernel.php:1020 Stack trace: #0 /code/docroot/core/lib/Drupal/Core/DrupalKernel.php(696): Drupal\Core\DrupalKernel::bootEnvironment() #1 /code/docroot/index.php(19): Drupal\Core\DrupalKernel->handle(Object(Symfony\Component\HttpFoundation\Request)) #2 {main} thrown in /code/docroot/core/lib/Drupal/Core/DrupalKernel.php on line 1020

This is the error when trying to access /update.php

Fatal error: Uncaught Error: Call to undefined function drupal_valid_test_ua() in /code/docroot/update.php:19 Stack trace: #0 {main} thrown in /code/docroot/update.php on line 19

I've searched in for this error in the web, but found no solution. This is my composer.json config:

{
    "name": "nestle/your-project",
    "description": "Project template for Drupal 8 sites built with Lightnest.",
    "type": "project",
    "minimum-stability": "dev",
    "prefer-stable": true,
    "repositories": {
        "drupal": {
            "type": "composer",
            "url": "https://packages.drupal.org/8"
        },
        "asset-packagist": {
            "type": "composer",
            "url": "https://asset-packagist.org"
        },
        "brilsergei": {
            "type": "package",
            "package": {
                "name": "brilsergei/county",
                "version": "master",
                "type": "drupal-library",
                "dist": {
                    "url": "https://github.com/brilsergei/county/archive/master.zip",
                    "type": "zip"
                },
                "require": {
                    "composer/installers": "^1.2.0"
                }
            }
        },
        "kbwood": {
            "type": "package",
            "package": {
                "name": "kbwood/countdown",
                "version": "master",
                "type": "drupal-library",
                "dist": {
                    "url": "https://github.com/kbwood/countdown/archive/master.zip",
                    "type": "zip"
                },
                "require": {
                    "composer/installers": "^1.2.0"
                }
            }
        },
        "lightnest": {
            "type": "composer",
            "url": "https://webcms:[email protected]/"
        }
    },
    "require": {
        "php": ">=7.4",
        "acquia/blt": "^12.0.0",
        "acquia/drupal-spec-tool": "*",
        "bower-asset/blazy": "^1.8.0",
        "bower-asset/chosen": "^1.8.0",
        "bower-asset/jquery.easing": "^1.3.0",
        "brilsergei/county": "master",
        "composer/installers": "^1.2",
        "drupal/admin_toolbar": "^3.2",
        "drupal/autologout": "^1.4",
        "drupal/captcha": "^1.5",
        "drupal/config_split": "^1.0.0",
        "drupal/core-composer-scaffold": "^9.1",
        "drupal/core-recommended": "^9",
        "drupal/csp": "^1.15",
        "drupal/devel": "^4.0",
        "drupal/embed": "^1.6",
        "drupal/entity_embed": "^1.3",
        "drupal/flag": "^4.0@beta",
        "drupal/notificationswidget": "^1.6",
        "drupal/qa_accounts": "^1.0.0-alpha1",
        "drupal/recaptcha": "^3.0",
        "drupal/recaptcha_v3": "^1.7",
        "drupal/redirect": "^1.8",
        "drupal/twig_tweak": "^2.9",
        "drupal/twig_vardumper": "^3.0",
        "drupal/webform": "^6.1",
        "drupal/webp": "^1.0@beta",
        "drush/drush": "^10.0",
        "kbwood/countdown": "master",
        "lightnest/lightnest": "^4.0.0",
        "symfony/service-contracts": "^2.5",
        "wikimedia/composer-merge-plugin": "^2.0"
    },
    "require-dev": {
        "mglaman/drupal-check": "^1.4"
    },
    "config": {
        "platform": {
            "php": "8"
        },
        "sort-packages": true,
        "optimize-autoloader": true,
        "apcu-autoloader": true,
        "allow-plugins": {
            "composer/installers": true,
            "oomphinc/composer-installers-extender": false,
            "cweagans/composer-patches": false,
            "acquia/blt": true,
            "drupal/core-composer-scaffold": true,
            "wikimedia/composer-merge-plugin": false
        }
    },
    "extra": {
        "merge-plugin": {
            "include": [
                "composer-extensions/*.composer.json"
            ],
            "recurse": true,
            "replace": false,
            "ignore-duplicates": false,
            "merge-dev": true,
            "merge-extra": false,
            "merge-extra-deep": false,
            "merge-scripts": false
        },
        "composer-exit-on-patch-failure": true,
        "drupal-scaffold": {
            "allowed-packages": [
                "pantheon-systems/drupal-integrations"
            ],
            "locations": {
                "web-root": "docroot"
            },
            "file-mapping": {
                "[project-root]/pantheon.upstream.yml": false,
                "[web-root]/sites/default/settings.pantheon.php": false
            },
            "initial": {
                "sites/default/default.services.yml": "sites/default/services.yml",
                "sites/default/default.settings.php": "sites/default/settings.php"
            }
        },
        "enable-patching": true,
        "installer-paths": {
            "docroot/core": [
                "type:drupal-core"
            ],
            "docroot/modules/contrib/{$name}": [
                "type:drupal-module"
            ],
            "docroot/modules/custom/{$name}": [
                "type:drupal-custom-module"
            ],
            "docroot/profiles/contrib/{$name}": [
                "type:drupal-profile"
            ],
            "docroot/profiles/custom/{$name}": [
                "type:drupal-custom-profile"
            ],
            "docroot/themes/contrib/{$name}": [
                "type:drupal-theme"
            ],
            "docroot/themes/custom/{$name}": [
                "type:drupal-custom-theme"
            ],
            "docroot/libraries/{$name}": [
                "type:drupal-library",
                "type:bower-asset",
                "type:npm-asset"
            ],
            "drush/Commands/{$name}": [
                "type:drupal-drush"
            ]
        },
        "installer-types": [
            "bower-asset",
            "npm-asset"
        ],
        "patchLevel": {
            "drupal/core": "-p2"
        },
        "patches": []
    }
}

Does someone know how to solve this problem? I've tried already removing vendor and composer.lock, and installing again. Tried checking problems with packages. Tried running drush, but it causes another error. Tried running composer update -W, etc.

This is the drush error:

[warning] Undefined array key 1 Application.php:199
Error: Interface "Symfony\Contracts\Service\ResetInterface" not found in C:\xampp\htdocs\...\docroot\core\lib\Drupal\Component\DependencyInjection\Container.php on line 47 #0 C:\xampp\htdocs\...\docroot\vendor\composer\ClassLoader.php(480): include()
#1 C:\xampp\htdocs\...\docroot\vendor\composer\ClassLoader.php(346): Composer\Autoload\includeFile('C:\\xampp\\htdocs...')
#2 C:\xampp\htdocs\...\docroot\core\lib\Drupal\Component\DependencyInjection\PhpArrayContainer.php(25): Composer\Autoload\ClassLoader->loadClass('Drupal\\Componen...')
#3 C:\xampp\htdocs\...\docroot\vendor\composer\ClassLoader.php(480): include('C:\\xampp\\htdocs...')
#4 C:\xampp\htdocs\...\docroot\vendor\composer\ClassLoader.php(346): Composer\Autoload\includeFile('C:\\xampp\\htdocs...')
#5 C:\xampp\htdocs\...\docroot\core\lib\Drupal\Core\DrupalKernel.php(469): Composer\Autoload\ClassLoader->loadClass('Drupal\\Componen...')
#6 C:\xampp\htdocs\...\docroot\vendor\drush\drush\src\Boot\DrupalBoot8.php(241): Drupal\Core\DrupalKernel->boot()
#7 C:\xampp\htdocs\...\docroot\vendor\drush\drush\src\Boot\BootstrapManager.php(293): Drush\Boot\DrupalBoot8->bootstrapDrupalFull(Object(Drush\Boot\BootstrapManager), NULL)
#8 C:\xampp\htdocs\...\docroot\vendor\drush\drush\src\Boot\BootstrapManager.php(493): Drush\Boot\BootstrapManager->doBootstrap(5, 6, NULL)
#9 C:\xampp\htdocs\...\docroot\vendor\drush\drush\src\Boot\BootstrapManager.php(427): Drush\Boot\BootstrapManager->bootstrapMax(6)
#10 C:\xampp\htdocs\...\docroot\vendor\drush\drush\src\Boot\BootstrapManager.php(396): Drush\Boot\BootstrapManager->bootstrapToPhaseIndex(-2, Object(Consolidation\AnnotatedCommand\AnnotationData))
#11 C:\xampp\htdocs\...\docroot\vendor\drush\drush\src\Boot\BootstrapHook.php(28): Drush\Boot\BootstrapManager->bootstrapToPhase('max', Object(Consolidation\AnnotatedCommand\AnnotationData))
#12 C:\xampp\htdocs\...\docroot\vendor\consolidation\annotated-command\src\Hooks\Dispatchers\InitializeHookDispatcher.php(34): Drush\Boot\BootstrapHook->initialize(Object(Drush\Symfony\DrushArgvInput), Object(Consolidation\AnnotatedCommand\AnnotationData))
#13 C:\xampp\htdocs\...\docroot\vendor\consolidation\annotated-command\src\Hooks\Dispatchers\InitializeHookDispatcher.php(27): Consolidation\AnnotatedCommand\Hooks\Dispatchers\InitializeHookDispatcher->callInitializeHook(Object(Drush\Boot\BootstrapHook), Object(Drush\Symfony\DrushArgvInput), Object(Consolidation\AnnotatedCommand\AnnotationData))
#14 C:\xampp\htdocs\...\docroot\vendor\consolidation\annotated-command\src\CommandProcessor.php(145): Consolidation\AnnotatedCommand\Hooks\Dispatchers\InitializeHookDispatcher->initialize(Object(Drush\Symfony\DrushArgvInput), Object(Consolidation\AnnotatedCommand\AnnotationData))
#15 C:\xampp\htdocs\...\docroot\vendor\consolidation\annotated-command\src\AnnotatedCommand.php(289): Consolidation\AnnotatedCommand\CommandProcessor->initializeHook(Object(Drush\Symfony\DrushArgvInput), Array, Object(Consolidation\AnnotatedCommand\AnnotationData))
#16 C:\xampp\htdocs\...\docroot\vendor\symfony\console\Command\Command.php(221): Consolidation\AnnotatedCommand\AnnotatedCommand->initialize(Object(Drush\Symfony\DrushArgvInput), Object(Symfony\Component\Console\Output\ConsoleOutput))
#17 C:\xampp\htdocs\...\docroot\vendor\symfony\console\Application.php(1005): Symfony\Component\Console\Command\Command->run(Object(Drush\Symfony\DrushArgvInput), Object(Symfony\Component\Console\Output\ConsoleOutput))
#18 C:\xampp\htdocs\...\docroot\vendor\symfony\console\Application.php(255): Symfony\Component\Console\Application->doRunCommand(Object(Consolidation\AnnotatedCommand\AnnotatedCommand), Object(Drush\Symfony\DrushArgvInput), Object(Symfony\Component\Console\Output\ConsoleOutput))
#19 C:\xampp\htdocs\...\docroot\vendor\symfony\console\Application.php(148): Symfony\Component\Console\Application->doRun(Object(Drush\Symfony\DrushArgvInput), Object(Symfony\Component\Console\Output\ConsoleOutput))
#20 C:\xampp\htdocs\...\docroot\vendor\drush\drush\src\Runtime\Runtime.php(118): Symfony\Component\Console\Application->run(Object(Drush\Symfony\DrushArgvInput), Object(Symfony\Component\Console\Output\ConsoleOutput))
#21 C:\xampp\htdocs\...\docroot\vendor\drush\drush\src\Runtime\Runtime.php(48): Drush\Runtime\Runtime->doRun(Array, Object(Symfony\Component\Console\Output\ConsoleOutput))
#22 C:\xampp\htdocs\...\docroot\vendor\drush\drush\drush.php(72): Drush\Runtime\Runtime->run(Array)
#23 C:\xampp\htdocs\...\docroot\vendor\drush\drush\drush(4): require('C:\\xampp\\htdocs...')
#24 {main}
 [warning] Drush command terminated abnormally.
Error: Interface "Symfony\Contracts\Service\ResetInterface" not found in include() (line 47 of C:\xampp\htdocs\...\docroot\core\lib\Drupal\Component\DependencyInjection\Container.php).
cn flag
This is pretty common (I had the same happen to me less than 2 hours ago by coincidence), but very difficult to search for because the exact missing function/class depends on your setup. A combination of `composer dump-autoload` and restarting apache or php-fpm usually solves it
Jean da Silva avatar
cn flag
I've tried running `composer dump-autoload` and restarting apache, but no luck :(
id flag
Does the function exist?
apaderno avatar
us flag
The first shown error is caused by PHP that doesn't find [`drupal_valid_test_ua()`](https://api.drupal.org/api/drupal/core%21includes%21bootstrap.inc/function/drupal_valid_test_ua/9.4.x) and tries to look at the function in the current namespace. Since `drupal_valid_test_ua()` is defined in the [core/includes/bootstrap.inc](https://api.drupal.org/api/drupal/core%21includes%21bootstrap.inc/9.4.x) file, it could also be the function is called before that file is loaded, that file is corrupted, or it doesn't exist.
I sit in a Tesla and translated this thread with Ai:

mangohost

Post an answer

Most people don’t grasp that asking a lot of questions unlocks learning and improves interpersonal bonding. In Alison’s studies, for example, though people could accurately recall how many questions had been asked in their conversations, they didn’t intuit the link between questions and liking. Across four studies, in which participants were engaged in conversations themselves or read transcripts of others’ conversations, people tended not to realize that question asking would influence—or had influenced—the level of amity between the conversationalists.