Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

TypeError when running SaphireTest::logInWithPermission #11240

Closed
2 tasks done
Ofthemasses opened this issue May 16, 2024 · 2 comments
Closed
2 tasks done

TypeError when running SaphireTest::logInWithPermission #11240

Ofthemasses opened this issue May 16, 2024 · 2 comments

Comments

@Ofthemasses
Copy link
Contributor

Ofthemasses commented May 16, 2024

Module version(s) affected

5.2.7

Description

I am in the process of testing one of my controllers using the FunctionalTest class. One of my tests makes use of the ::logInWithPermission method. Running this alone causes: TypeError "Return value must be of type bool, null returned.

I tested allowing the null to return, returning true and returning false in the function that produces this error. All of these ends up producing SilverStripe\Core\Injector\InjectorNotFoundException: Class SilverStripe\Versioned\RecursiveStagesInterface does not exist

I have silverstripe/versioned installed via composer so I am not sure why this next error is occuring.

How to reproduce

Test:

public function testCheckUserPerms()
{
    $this->logInWithPermission();
}

Possible Solution

I am providing a PR with this, I believe the config should return false on default in this scenario. The InjectionNotFoundException I am not sure about though.

Additional Context

This is a custom silverstripe install without the cms as we are not using Pages

1) Ordino\Lib\Tests\OControllerTests::testCheckUserPerms
TypeError: SilverStripe\ORM\Connect\DBQueryBuilder::shouldBuildTraceComment(): Return value must be of type bool, null returned
Expand to see stack trace
/srv/http/ordino-skeleton/vendor/silverstripe/framework/src/ORM/Connect/DBQueryBuilder.php:88
/srv/http/ordino-skeleton/vendor/silverstripe/framework/src/ORM/Connect/DBQueryBuilder.php:76
/srv/http/ordino-skeleton/vendor/silverstripe/framework/src/ORM/DB.php:141
/srv/http/ordino-skeleton/vendor/silverstripe/framework/src/ORM/Queries/SQLExpression.php:92
/srv/http/ordino-skeleton/vendor/silverstripe/framework/src/ORM/Queries/SQLExpression.php:112
/srv/http/ordino-skeleton/vendor/silverstripe/framework/src/ORM/DataList.php:1031
/srv/http/ordino-skeleton/vendor/silverstripe/framework/src/ORM/DataList.php:967
/srv/http/ordino-skeleton/vendor/silverstripe/framework/src/ORM/DataList.php:947
/srv/http/ordino-skeleton/vendor/silverstripe/framework/src/ORM/DataList.php:1669
/srv/http/ordino-skeleton/vendor/silverstripe/framework/src/Dev/SapphireTest.php:976
/srv/http/ordino-skeleton/vendor/silverstripe/framework/src/Dev/SapphireTest.php:1018
/srv/http/ordino-skeleton/ordino-lib/tests/controllers/OControllerTests.php:71
1) Ordino\Lib\Tests\OControllerTests::testCheckUserPerms
SilverStripe\Core\Injector\InjectorNotFoundException: Class SilverStripe\Versioned\RecursiveStagesInterface does not exist
Expand to see stack trace
/srv/http/ordino-skeleton/vendor/silverstripe/framework/src/Core/Injector/InjectionCreator.php:29
/srv/http/ordino-skeleton/vendor/silverstripe/framework/src/Core/Injector/Injector.php:631
/srv/http/ordino-skeleton/vendor/silverstripe/framework/src/Core/Injector/Injector.php:1027
/srv/http/ordino-skeleton/vendor/silverstripe/framework/src/Core/Injector/Injector.php:979
/srv/http/ordino-skeleton/vendor/silverstripe/versioned/src/RecursiveStagesService.php:28
/srv/http/ordino-skeleton/vendor/silverstripe/versioned/src/RecursivePublishable.php:462
/srv/http/ordino-skeleton/vendor/silverstripe/framework/src/Core/Extension.php:142
/srv/http/ordino-skeleton/vendor/silverstripe/framework/src/Core/Extensible.php:438
/srv/http/ordino-skeleton/vendor/silverstripe/framework/src/ORM/DataObject.php:1251
/srv/http/ordino-skeleton/vendor/silverstripe/framework/src/ORM/DataObject.php:1595
/srv/http/ordino-skeleton/vendor/silverstripe/framework/src/Dev/SapphireTest.php:987
/srv/http/ordino-skeleton/vendor/silverstripe/framework/src/Dev/SapphireTest.php:1018
/srv/http/ordino-skeleton/ordino-lib/tests/controllers/OControllerTests.php:71

Fresh install with similar composer:

SilverStripe\Core\Injector\InjectorNotFoundException: Class SilverStripe\ErrorPage\ErrorPageControllerExtension does not exist in /srv/http/fresh/vendor/silverstripe/framework/src/Core/Injector/InjectionCreator.php:29
Expand to see stack trace
#0 /srv/http/fresh/vendor/silverstripe/framework/src/Core/Injector/Injector.php(631): SilverStripe\Core\Injector\InjectionCreator->create()
#1 /srv/http/fresh/vendor/silverstripe/framework/src/Core/Injector/Injector.php(1027): SilverStripe\Core\Injector\Injector->instantiate()
#2 /srv/http/fresh/vendor/silverstripe/framework/src/Core/Injector/Injector.php(979): SilverStripe\Core\Injector\Injector->getNamedService()
#3 /srv/http/fresh/vendor/silverstripe/framework/src/Core/Extensible.php(536): SilverStripe\Core\Injector\Injector->get()
#4 /srv/http/fresh/vendor/silverstripe/framework/src/Core/Extensible.php(436): SilverStripe\View\ViewableData->getExtensionInstances()
#5 /srv/http/fresh/vendor/silverstripe/framework/src/Control/Controller.php(117): SilverStripe\View\ViewableData->extend()
#6 /srv/http/fresh/vendor/silverstripe/framework/src/Dev/SapphireTest.php(896): SilverStripe\Control\Controller->doInit()
#7 [internal function]: SilverStripe\Dev\SapphireTest::SilverStripe\Dev\{closure}()
#8 /srv/http/fresh/vendor/silverstripe/framework/src/Control/HTTPApplication.php(137): call_user_func()
#9 /srv/http/fresh/vendor/silverstripe/framework/src/Control/Middleware/HTTPMiddlewareAware.php(65): SilverStripe\Control\HTTPApplication->SilverStripe\Control\{closure}()
#10 /srv/http/fresh/vendor/silverstripe/framework/src/Control/HTTPApplication.php(130): SilverStripe\Control\HTTPApplication->callMiddleware()
#11 /srv/http/fresh/vendor/silverstripe/framework/src/Dev/SapphireTest.php(884): SilverStripe\Control\HTTPApplication->execute()
#12 /srv/http/fresh/vendor/silverstripe/framework/src/Dev/SapphireTest.php(391): SilverStripe\Dev\SapphireTest::start()
#13 /srv/http/fresh/vendor/phpunit/phpunit/src/Framework/TestSuite.php(629): SilverStripe\Dev\SapphireTest::setUpBeforeClass()
#14 /srv/http/fresh/vendor/phpunit/phpunit/src/TextUI/TestRunner.php(651): PHPUnit\Framework\TestSuite->run()
#15 /srv/http/fresh/vendor/phpunit/phpunit/src/TextUI/Command.php(146): PHPUnit\TextUI\TestRunner->run()
#16 /srv/http/fresh/vendor/phpunit/phpunit/src/TextUI/Command.php(99): PHPUnit\TextUI\Command->run()
#17 /srv/http/fresh/vendor/phpunit/phpunit/phpunit(107): PHPUnit\TextUI\Command::main()
#18 /srv/http/fresh/vendor/bin/phpunit(122): include('...')
#19 {main}
Expand to see composer.json
{
    "name": "ordino-nz/ordino-skeleton",
    "description": "The Ordino Web Skeleton",
    "require": {
        "php": "^8.1",
        "silverstripe/recipe-core": "~5.2.0@stable",
        "silverstripe/admin": "^2.0",
        "silverstripe/mimevalidator": "~3.1.0@stable",
        "silverstripe/config": "~2.1.0@stable",
        "symfony/process": "^6.3",
        "ext-yaml": "*"
    },
    "require-dev": {
        "phpunit/phpunit": "^9.5",
        "mikey179/vfsstream": "^1.6.11",
        "squizlabs/php_codesniffer": "^3.7",
        "gskema/phpcs-type-sniff": "^82.2"
    },
    "config": {
        "process-timeout": 600,
        "allow-plugins": {
            "composer/installers": true,
            "silverstripe/recipe-plugin": true,
            "silverstripe/vendor-plugin": true
        }
    },
    "prefer-stable": true,
    "minimum-stability": "dev",
    "extra": {
        "project-files-installed": [
            ".htaccess",
            "app/.htaccess",
            "app/_config/mimevalidator.yml",
            "app/_config/mysite.yml"
        ]
    }
}

composer (fresh):

{
    "name": "silverstripe/installer",
    "type": "silverstripe-recipe",
    "description": "The SilverStripe Framework Installer",
    "require": {
        "php": "^8.1",
        "silverstripe/recipe-core": "~5.2.0@stable",
        "silverstripe/admin": "^2.0",
        "silverstripe/mimevalidator": "~3.1.0@stable",
        "silverstripe/config": "~2.1.0@stable",
        "symfony/process": "^6.3",
        "ext-yaml": "*"
    },
    "require-dev": {
        "phpunit/phpunit": "^9.5",
        "mikey179/vfsstream": "^1.6.11",
        "squizlabs/php_codesniffer": "^3.7",
        "gskema/phpcs-type-sniff": "^82.2"
    },
    "extra": {
        "project-files-installed": [
            ".htaccess",
            "app/.htaccess",
            "app/_config/mimevalidator.yml",
            "app/_config/mysite.yml",
            "app/src/Page.php",
            "app/src/PageController.php"
        ],
        "public-files-installed": [
            ".htaccess",
            "index.php",
            "web.config"
        ]
    },
    "config": {
        "process-timeout": 600,
        "allow-plugins": {
            "composer/installers": true,
            "silverstripe/recipe-plugin": true,
            "silverstripe/vendor-plugin": true
        }
    },
    "prefer-stable": true,
    "minimum-stability": "dev"
}

Validations

  • Check that there isn't already an issue that reports the same bug
  • Double check that your reproduction steps work in a fresh installation of silverstripe/installer (with any code examples you've provided)

PRs

@mandrew
Copy link
Contributor

mandrew commented Sep 25, 2024

Got this error weirdly when doing an update from v5.0. Although it was a caching issue, it gave me a fright. If this issue is still outstanding, can it be merged please 🙂 /cc @GuySartorelli

@GuySartorelli
Copy link
Member

PR merged.
It will be included in the April 2025 minor release.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants