Closed CalamarMihai closed 4 years ago
I'll leave here composer.json from laravel in case it helps you better understand what's going wrong.
{ "name": "laravel/laravel", "type": "project", "description": "The Laravel Framework.", "keywords": [ "framework", "laravel" ], "license": "MIT", "require": { "php": "^7.2", "barryvdh/laravel-cors": "^0.11.4", "fideloper/proxy": "^4.0", "laravel/framework": "^6.0", "laravel/tinker": "^1.0", "myclabs/php-enum": "1.2.0", "tymon/jwt-auth": "^1.0.0" }, "require-dev": { "facade/ignition": "^1.4", "fzaninotto/faker": "^1.4", "mockery/mockery": "^1.0", "nunomaduro/collision": "^3.0", "phpunit/phpunit": "^8.0" }, "config": { "optimize-autoloader": true, "preferred-install": "dist", "sort-packages": true }, "extra": { "laravel": { "dont-discover": [] } }, "autoload": { "psr-4": { "App\": "app/" }, "classmap": [ "database/seeds", "database/factories" ] }, "autoload-dev": { "psr-4": { "Tests\": "tests/" } }, "minimum-stability": "dev", "prefer-stable": true, "scripts": { "post-autoload-dump": [ "Illuminate\Foundation\ComposerScripts::postAutoloadDump", "@php artisan package:discover --ansi" ], "post-root-package-install": [ "@php -r \"file_exists('.env') || copy('.env.example', '.env');\"" ], "post-create-project-cmd": [ "@php artisan key:generate --ansi" ] } }
Ok it appears we are switching on the enum object but comparing it against against the enum constants. Bit of an oversight on our part. The easy fix to get you up and running would be to get the value of $typeCode and provide that to the switch statment.
The better fix would be to invoke the enum method instead of the constant. Which will probably be the change I will make tomorrow ( unless @CyberiaResurrection is still up and happy to take a look) I should be avaliable to look at and fix it in about 12 hours. Alternatively if you wanted to send a pull request I could review it first thing in the morning
@CyberiaResurrection in addition to the bug fix. Perhaps We should consider making all enum constants protected to prevent this oversight in the future
@CalamarMihai , can you try again and see if pain persists?
@CalamarMihai , @c-harris , I took the supplied composer.json on PHP 7.3, ran composer install
, then on top of that ran composer require algo-web/podata-laravel
.
Both installs ran clean after the fixes to POData itself.
@CyberiaResurrection, I tried on a clean instance of laravel, and after including the providers in the app.php I get the above error.
Thanks for your help and promptness.
@CalamarMihai , which providers are you adding to your app config, when and why?
Can youre-try a clean install, to pick up the changes I made in POData that should fix your issue.
If it's the POData-Laravel providers, I'm not seeing how they would be available to be pulled into the autoloader until after successfully running composer require algo-web/podata-laravel
.
As to the why, are the POData-Laravel providers not being auto-discovered by Laravel 6?
On the testbed I reported success with above, manually adding the providers as per the instructions does not replicate the failure you reported - php artisan list
returns the list of available Artisan commands.
Likewise, setting up a database on the testbed, and adding the MetadataTrait to the User model, also lets php artisan list
run cleanly.
@CyberiaResurrection, i try on a new clean instance of laravel and now it has passed this issue, but i have another 2 new issues.
$controllerMethod = '\AlgoWeb\PODataLaravel\Controllers\ODataController@index'; Route::get('odata2.svc/$metadata', ['uses' => $controllerMethod]); Route::any('odata2.svc/{section}', ['uses' => $controllerMethod])->where(['section' => '.*']); Route::any('odata2.svc', ['uses' => $controllerMethod]); Now it's working
Symfony\Component\Debug\Exception\FatalThrowableError Argument 2 passed to POData\Providers\Metadata\ResourceAssociationSet::keyNameFromTypeAndProperty() must be an instance of POData\Providers\Metadata\ResourceProperty, null given, called in /var/www/testing/vendor/algo-web/podata/src/POData/UriProcessor/QueryProcessor/ExpandProjectionParser/ExpandProjectionParser.php on line 193
Thank you very much and I really appreciate the effort.
@CalamarMihai , thank you for helping us figure this one out.
Could you report your additional issue(s) as fresh issues please, so you and I can keep them straight?
Hi, I have the following problem when I try to install the package ErrorException : Object of class POData\Providers\Metadata\Type\EdmPrimitiveType could not be converted to int.
Can you please tell me what you think I should look at? Thank you for your support
at /var/www/api/vendor/algo-web/podata/src/POData/Providers/Metadata/ResourceType.php:793 789| @return ResourcePrimitiveType 790| / 791| public static function getPrimitiveResourceType($typeCode) 792| {
Exception trace:
1 Illuminate\Foundation\Bootstrap\HandleExceptions::handleError("Object of class POData\Providers\Metadata\Type\EdmPrimitiveType could not be converted to int", "/var/www/api/vendor/algo-web/podata/src/POData/Providers/Metadata/ResourceType.php", [Object(POData\Providers\Metadata\Type\EdmPrimitiveType)]) /var/www/api/vendor/algo-web/podata/src/POData/Providers/Metadata/ResourceType.php:793
2 POData\Providers\Metadata\ResourceType::getPrimitiveResourceType(Object(POData\Providers\Metadata\Type\EdmPrimitiveType)) /var/www/api/vendor/algo-web/podata/src/POData/Providers/Metadata/SimpleMetadataProvider.php:476