laminas-api-tools / api-tools-admin

Laminas API Tools Admin module
https://api-tools.getlaminas.org/documentation
BSD 3-Clause "New" or "Revised" License
13 stars 21 forks source link

Class 'Laminas\ApiTools\Admin\Controller\InputFilter\RpcService\PostInputFilter' not found #71

Closed diego-sorribas closed 2 years ago

diego-sorribas commented 3 years ago

BC Break Report

Q A
Version 1.10.0

Summary

After upgrading to 1.10.0 from 1.9.0 I want to create a RPC service from the UI and launch me that error. I think there is some error in the aliases config. When I inspect with PhpStorm the new vendor/laminas-api-tools/api-tools-admin/config/module.config.php it cant resolve the PostInputFilter location.

Previous behavior

Create RPC services without error.

Current behavior

Can't create RPC services from api tools admin ui.

How to reproduce

weierophinney commented 3 years ago

Do you get any error messages? If so, can you please share them?

I did a manual verification of the aliases we have, and none appear to have changed; the only change was how we are resolving the legacy (ZF) aliases to the shipped classes (we are importing ZF class names in most cases). Error messages will help me better isolate the issue.

Thanks!

diego-sorribas commented 3 years ago

I created a new laminas-api-tools from scratch and this is the result I attach to you my composer.lock if you need it

composer.lock.zip

Screen Shot 2021-06-30 at 13 18 41

spectravp commented 3 years ago

I have the identical issue.

froschdesign commented 3 years ago

@weierophinney The problem is in api-tools-content-validation:

use Laminas\InputFilter\InputFilterAbstractServiceFactory;
use Laminas\ServiceManager\Factory\InvokableFactory;
use ZF\ContentValidation\InputFilter\InputFilterPlugin;

https://github.com/laminas-api-tools/api-tools-content-validation/blob/6994b2d01fa676f9996b8c20daa2f9771dd83b10/config/module.config.php#L7

cvigorsICBF commented 3 years ago

Can I just add to this and say I am seeing a similar issue which results in the following php log: PHP Fatal error: Uncaught Error: Class 'Laminas\ApiTools\Admin\Controller\InputFilter\RestService\PatchInputFilter' not found in ..... /vendor/laminas/laminas-servicemanager/src/Factory/InvokableFactory.php:33

Steps to reproduce: Update laminas-api-tools/api-tools-admin to 1.10.1 Select any service, change the 'page size' and Save. You will get the above error

tempsnip

fmangat commented 3 years ago

is there any solution to fix this problem?

froschdesign commented 3 years ago

@fmangat You can create a pull request to fix the namespace in the configuration file of laminas-api-tools/api-tools-content-validation.

https://github.com/laminas-api-tools/api-tools-content-validation/blob/6994b2d01fa676f9996b8c20daa2f9771dd83b10/config/module.config.php#L7

Thanks in advance! 👍

fmangat commented 3 years ago

@froschdesign am not sure .looks like ModuleInputFilter is not accessible its coming under undeined classes in psalm-baseline.xml

diego-sorribas commented 3 years ago

@froschdesign But the namespace is okay its the legacy ZF namespace or Im wrong? https://github.com/zfcampus/zf-content-validation/blob/master/src/InputFilter/InputFilterPlugin.php

fmangat commented 3 years ago

yep as per rewrites rulesits correcr...... it s very odd that the basic installation is not working

fmangat commented 3 years ago

its not something related to configs?

froschdesign commented 3 years ago

@diego-sorribas

@froschdesign But the namespace is okay its the legacy ZF namespace or Im wrong? https://github.com/zfcampus/zf-content-validation/blob/master/src/InputFilter/InputFilterPlugin.php

You are right and the Laminas\ApiTools\ContentValidation\ContentValidationListener::class try to fetch the service with the legacy ZF namespace. The module configuration of api-tools-content-validation looks good:


Please try to delete the cache for the config.

diego-sorribas commented 3 years ago

@froschdesign I dont know why but when we update to 1.10.0 the listener cant find the filter, look at my image the line: 1768 its what I added, the full namespace and works but above is the package declaration and at the left of the file is the path to the file thats its okay, so strange

Screen Shot 2021-07-05 at 10 06 13

froschdesign commented 3 years ago

@diego-sorribas Various problems are listed in this issue report:

Please only one problem at a time, otherwise we will not reach any goal. Thanks!

diego-sorribas commented 3 years ago

@froschdesign It seems to be all related to the module.config.php.

froschdesign commented 3 years ago

@diego-sorribas Sorry, I don't have an IDE available because I'm on the road. So I can only look here on GitHub.

Can you check the classnames and namespaces? The classes are there and under namespace Laminas but something is wrong here:

https://github.com/laminas-api-tools/api-tools-admin/tree/1.11.x/src/InputFilter/RestService

fmangat commented 3 years ago

"laminas-api-tools/api-tools-admin": "1.9.0",

i have downgraded api-tools-admin version to 1.9.0 which worked for now

ezkimo commented 3 years ago

This is a namespace issue in the module.config.php file. The namespace Laminas\ApiTools\Admin is somewhere overwritten with ZF\Apigility\Admin\Controller. This issue leads in several other issues so that services can 't be resolved by the service manager, because the class ZF\Apigility\Admin\Controller\InputFilter\WhatSoEver does not exist. All input filter entries are affected. I have not yet been able to find the cause of this. But this small hotfix solves the problem.

Just replace the input filter configuration with the following snipped. This one worked fine for me.

'input_filters'                => [
        'aliases'   => [
            InputFilter\Authentication\BasicAuth::class  => \Laminas\ApiTools\Admin\InputFilter\Authentication\BasicInputFilter::class,
            InputFilter\Authentication\DigestAuth::class => \Laminas\ApiTools\Admin\InputFilter\Authentication\DigestInputFilter::class,
            InputFilter\Authentication\OAuth2::class     => \Laminas\ApiTools\Admin\InputFilter\Authentication\OAuth2InputFilter::class,
            InputFilter\Authorization::class             => \Laminas\ApiTools\Admin\InputFilter\AuthorizationInputFilter::class,
            InputFilter\ContentNegotiation::class        => \Laminas\ApiTools\Admin\InputFilter\ContentNegotiationInputFilter::class,
            InputFilter\CreateContentNegotiation::class  => \Laminas\ApiTools\Admin\InputFilter\CreateContentNegotiationInputFilter::class,
            InputFilter\DbAdapter::class                 => \Laminas\ApiTools\Admin\InputFilter\DbAdapterInputFilter::class,
            InputFilter\Documentation::class             => \Laminas\ApiTools\Admin\InputFilter\DocumentationInputFilter::class,
            InputFilter\Module::class                    => \Laminas\ApiTools\Admin\InputFilter\ModuleInputFilter::class,
            InputFilter\RestService\PATCH::class         => \Laminas\ApiTools\Admin\InputFilter\RestService\PatchInputFilter::class,
            InputFilter\RestService\POST::class          => \Laminas\ApiTools\Admin\InputFilter\RestService\PostInputFilter::class,
            InputFilter\RpcService\PATCH::class          => \Laminas\ApiTools\Admin\InputFilter\RpcService\PatchInputFilter::class,
            InputFilter\RpcService\POST::class           => \Laminas\ApiTools\Admin\InputFilter\RpcService\PostInputFilter::class,
            InputFilter\Version::class                   => \Laminas\ApiTools\Admin\InputFilter\VersionInputFilter::class,

            // Legacy Zend Framework aliases
            BasicAuth::class                                        => \Laminas\ApiTools\Admin\InputFilter\Authentication\BasicAuth::class,
            DigestAuth::class                                       => \Laminas\ApiTools\Admin\InputFilter\Authentication\DigestAuth::class,
            OAuth2::class                                           => \Laminas\ApiTools\Admin\InputFilter\Authentication\OAuth2::class,
            \ZF\Apigility\Admin\InputFilter\Authorization::class    => \Laminas\ApiTools\Admin\InputFilter\Authorization::class,
            ContentNegotiation::class                               => \Laminas\ApiTools\Admin\InputFilter\ContentNegotiation::class,
            CreateContentNegotiation::class                         => \Laminas\ApiTools\Admin\InputFilter\CreateContentNegotiation::class,
            DbAdapter::class                                        => \Laminas\ApiTools\Admin\InputFilter\DbAdapter::class,
            \ZF\Apigility\Admin\InputFilter\Documentation::class    => \Laminas\ApiTools\Admin\InputFilter\Documentation::class,
            Module::class                                           => \Laminas\ApiTools\Admin\InputFilter\Module::class,
            PATCH::class                                            => \Laminas\ApiTools\Admin\InputFilter\RestService\PATCH::class,
            POST::class                                             => \Laminas\ApiTools\Admin\InputFilter\RestService\POST::class,
            \ZF\Apigility\Admin\InputFilter\RpcService\PATCH::class => \Laminas\ApiTools\Admin\InputFilter\RpcService\PATCH::class,
            \ZF\Apigility\Admin\InputFilter\RpcService\POST::class  => \Laminas\ApiTools\Admin\InputFilter\RpcService\POST::class,
            Version::class                                          => \Laminas\ApiTools\Admin\InputFilter\Version::class,
            BasicInputFilter::class                                 => \Laminas\ApiTools\Admin\InputFilter\Authentication\BasicInputFilter::class,
            DigestInputFilter::class                                => \Laminas\ApiTools\Admin\InputFilter\Authentication\DigestInputFilter::class,
            OAuth2InputFilter::class                                => \Laminas\ApiTools\Admin\InputFilter\Authentication\OAuth2InputFilter::class,
            AuthorizationInputFilter::class                         => \Laminas\ApiTools\Admin\InputFilter\AuthorizationInputFilter::class,
            ContentNegotiationInputFilter::class                    => \Laminas\ApiTools\Admin\InputFilter\ContentNegotiationInputFilter::class,
            CreateContentNegotiationInputFilter::class              => \Laminas\ApiTools\Admin\InputFilter\CreateContentNegotiationInputFilter::class,
            DbAdapterInputFilter::class                             => \Laminas\ApiTools\Admin\InputFilter\DbAdapterInputFilter::class,
            DocumentationInputFilter::class                         => \Laminas\ApiTools\Admin\InputFilter\DocumentationInputFilter::class,
            ModuleInputFilter::class                                => \Laminas\ApiTools\Admin\InputFilter\ModuleInputFilter::class,
            PatchInputFilter::class                                 => \Laminas\ApiTools\Admin\InputFilter\RestService\PatchInputFilter::class,
            PostInputFilter::class                                  => \Laminas\ApiTools\Admin\InputFilter\RestService\PostInputFilter::class,
            \ZF\Apigility\Admin\InputFilter\RpcService\PatchInputFilter::class => \Laminas\ApiTools\Admin\InputFilter\RpcService\PatchInputFilter::class,
            \ZF\Apigility\Admin\InputFilter\RpcService\PostInputFilter::class  => \Laminas\ApiTools\Admin\InputFilter\RpcService\PostInputFilter::class,
            VersionInputFilter::class                                          => \Laminas\ApiTools\Admin\InputFilter\VersionInputFilter::class,
            \ZF\Apigility\Admin\InputFilter\InputFilter::class                 => \Laminas\ApiTools\Admin\InputFilter\InputFilter::class,
        ],
        'factories' => [
            \Laminas\ApiTools\Admin\InputFilter\Authentication\BasicInputFilter::class     => InvokableFactory::class,
            \Laminas\ApiTools\Admin\InputFilter\Authentication\DigestInputFilter::class    => InvokableFactory::class,
            \Laminas\ApiTools\Admin\InputFilter\Authentication\OAuth2InputFilter::class    => InvokableFactory::class,
            \Laminas\ApiTools\Admin\InputFilter\AuthorizationInputFilter::class            => InvokableFactory::class,
            \Laminas\ApiTools\Admin\InputFilter\ContentNegotiationInputFilter::class       => InvokableFactory::class,
            \Laminas\ApiTools\Admin\InputFilter\CreateContentNegotiationInputFilter::class => InvokableFactory::class,
            \Laminas\ApiTools\Admin\InputFilter\DbAdapterInputFilter::class                => InvokableFactory::class,
            \Laminas\ApiTools\Admin\InputFilter\DocumentationInputFilter::class            => InvokableFactory::class,
            \Laminas\ApiTools\Admin\InputFilter\ModuleInputFilter::class                   => InvokableFactory::class,
            \Laminas\ApiTools\Admin\InputFilter\RestService\PatchInputFilter::class        => InvokableFactory::class,
            \Laminas\ApiTools\Admin\InputFilter\RestService\PostInputFilter::class         => InvokableFactory::class,
            \Laminas\ApiTools\Admin\InputFilter\RpcService\PatchInputFilter::class         => InvokableFactory::class,
            \Laminas\ApiTools\Admin\InputFilter\RpcService\PostInputFilter::class          => InvokableFactory::class,
            \Laminas\ApiTools\Admin\InputFilter\VersionInputFilter::class                  => InvokableFactory::class,
            \Laminas\ApiTools\Admin\InputFilter\InputFilter::class                         => InputFilter\Factory\InputFilterInputFilterFactory::class,
        ],
    ],

This can not be the solution of this problem. We all should look why the Laminas\ApiTools\Admin namespace is overwritten with the ZF\Apigility\Admin\Controller namespace.

goharsahi commented 3 years ago

This issue still stands unresolved. I've downgraded to 1.9.0 and it works fine. Why does it work for few and not for others or everyone has downgraded to 1.9.0 to make it work?

How long is it going to take to fix it? any idea?

weierophinney commented 2 years ago

Fixed with #79