LearningLocker / learninglocker

Learning Locker - The Open Source Learning Record Store. Started in 2014.
https://learningpool.com/solutions/learning-record-store-learning-locker/learning-locker-community-overview/
GNU General Public License v3.0
548 stars 270 forks source link

Trying to upgrade the learninglocker to laravel 5.1 #835

Closed manjunath-muniraju-4444 closed 7 years ago

manjunath-muniraju-4444 commented 8 years ago

Version 1.13.2

Master at a226636 on 1.13.2

Trying to upgrade the learninglocker to laravel 5.1

packages used are "require": { "php": ">=5.5.9", "laravel/framework": "5.1.", "jenssegers/mongodb": "^3.0", "davejamesmiller/laravel-breadcrumbs": "^3.0", "barryvdh/laravel-cors": "^0.8.0", "learninglocker/statementfactory": "0.0.9", "andywer/js-localization": "dev-laravel-5", "philo/laravel-translate": "2.0.x", "seld/jsonlint": "^1.4", "lucadegasperi/oauth2-server-laravel": "5.1.", "laravelcollective/html": "5.1.*" }

->DashBoard is completed.(with one bug remaining).

-> Now working on API's

when i try to insert statement(), i am getting this error:

BulkWriteException in Update.php line 121: The dollar ($) prefixed field '$in' in 'statement.id.$in' is not valid for storage.

in Update.php line 121 at Server->executeBulkWrite('homestead.statements', object(BulkWrite), object(WriteConcern)) in Update.php line 121 at Update->execute(object(Server)) in UpdateMany.php line 68 at UpdateMany->execute(object(Server)) in Collection.php line 690 at Collection->updateMany(array(), array('$set' => array('lrs_id' => object(ObjectID), 'statement.id' => array('$in' => array('02c8afeb-44c8-4fa3-8ef8-70c7149a688b')))), array('$set' => array('active' => true), 'multiple' => true, 'writeConcern' => object(WriteConcern))) at call_user_func_array(array(object(Collection), 'UpdateMany'), array(array(), array('$set' => array('lrs_id' => object(ObjectID), 'statement.id' => array('$in' => array('02c8afeb-44c8-4fa3-8ef8-70c7149a688b')))), array('$set' => array('active' => true), 'multiple' => true))) in Collection.php line 41 at Collection->__call('UpdateMany', array(array(), array('$set' => array('lrs_id' => object(ObjectID), 'statement.id' => array('$in' => array('02c8afeb-44c8-4fa3-8ef8-70c7149a688b')))), array('$set' => array('active' => true), 'multiple' => true))) in Builder.php line 768 at Builder->performUpdate(array('$set' => array('lrs_id' => object(ObjectID), 'statement.id' => array('$in' => array('02c8afeb-44c8-4fa3-8ef8-70c7149a688b')))), array('$set' => array('active' => true), 'multiple' => true)) in Builder.php line 518 at Builder->update(array('$set' => array('lrs_id' => object(ObjectID), 'statement.id' => array('$in' => array('02c8afeb-44c8-4fa3-8ef8-70c7149a688b')))), array('$set' => array('active' => true)), array('multiple' => true)) in EloquentStorer.php line 145 at EloquentStorer->update(array('statement.id' => array('$in' => array('02c8afeb-44c8-4fa3-8ef8-70c7149a688b'))), array('$set' => array('active' => true)), object(StoreOptions)) in EloquentStorer.php line 100 at EloquentStorer->activateStatements(array('02c8afeb-44c8-4fa3-8ef8-70c7149a688b'), object(StoreOptions)) in EloquentStorer.php line 43 at EloquentStorer->store(array(object(stdClass)), array(), object(StoreOptions)) in EloquentRepository.php line 31 at EloquentRepository->store(array(object(stdClass)), array(), array('authority' => object(stdClass), 'lrs_id' => object(ObjectID), 'scopes' => array('all'), 'client' => object(Client))) in StatementStoreController.php line 138 at StatementStoreController->createStatements(array('lrs_id' => object(ObjectID), 'scopes' => array('all'), 'client' => object(Client))) in StatementStoreController.php line 67 at StatementStoreController->store(array('lrs_id' => object(ObjectID), 'scopes' => array('all'), 'client' => object(Client))) in StatementController.php line 75 at StatementController->store() in BaseController.php line 45 at BaseController->selectMethod() at call_user_func_array(array(object(StatementController), 'selectMethod'), array()) in Controller.php line 256 at Controller->callAction('selectMethod', array()) in ControllerDispatcher.php line 164 at ControllerDispatcher->call(object(StatementController), object(Route), 'selectMethod') in ControllerDispatcher.php line 112 at ControllerDispatcher->Illuminate\Routing{closure}(object(Request)) at call_user_func(object(Closure), object(Request)) in Pipeline.php line 139 at Pipeline->Illuminate\Pipeline{closure}(object(Request)) at call_user_func(object(Closure), object(Request)) in Pipeline.php line 102 at Pipeline->then(object(Closure)) in ControllerDispatcher.php line 114 at ControllerDispatcher->callWithinStack(object(StatementController), object(Route), object(Request), 'selectMethod') in ControllerDispatcher.php line 67 at ControllerDispatcher->dispatch(object(Route), object(Request), 'App\Http\Controllers\xAPI\StatementController', 'selectMethod') in Route.php line 203 at Route->runWithCustomDispatcher(object(Request)) in Route.php line 134 at Route->run(object(Request)) in Router.php line 708 at Router->Illuminate\Routing{closure}(object(Request)) at call_user_func(object(Closure), object(Request)) in Pipeline.php line 139 at Pipeline->Illuminate\Pipeline{closure}(object(Request)) at call_user_func(object(Closure), object(Request)) in Pipeline.php line 102 at Pipeline->then(object(Closure)) in Router.php line 710 at Router->runRouteWithinStack(object(Route), object(Request)) in Router.php line 673 at Router->dispatchToRoute(object(Request)) in Router.php line 635 at Router->dispatch(object(Request)) in Kernel.php line 236 at Kernel->Illuminate\Foundation\Http{closure}(object(Request)) at call_user_func(object(Closure), object(Request)) in Pipeline.php line 139 at Pipeline->Illuminate\Pipeline{closure}(object(Request)) in OAuthExceptionHandlerMiddleware.php line 36 at OAuthExceptionHandlerMiddleware->handle(object(Request), object(Closure)) at call_user_func_array(array(object(OAuthExceptionHandlerMiddleware), 'handle'), array(object(Request), object(Closure))) in Pipeline.php line 124 at Pipeline->Illuminate\Pipeline{closure}(object(Request)) in ShareErrorsFromSession.php line 49 at ShareErrorsFromSession->handle(object(Request), object(Closure)) at call_user_func_array(array(object(ShareErrorsFromSession), 'handle'), array(object(Request), object(Closure))) in Pipeline.php line 124 at Pipeline->Illuminate\Pipeline{closure}(object(Request)) in StartSession.php line 62 at StartSession->handle(object(Request), object(Closure)) at call_user_func_array(array(object(StartSession), 'handle'), array(object(Request), object(Closure))) in Pipeline.php line 124 at Pipeline->Illuminate\Pipeline{closure}(object(Request)) in AddQueuedCookiesToResponse.php line 37 at AddQueuedCookiesToResponse->handle(object(Request), object(Closure)) at call_user_func_array(array(object(AddQueuedCookiesToResponse), 'handle'), array(object(Request), object(Closure))) in Pipeline.php line 124 at Pipeline->Illuminate\Pipeline{closure}(object(Request)) in EncryptCookies.php line 59 at EncryptCookies->handle(object(Request), object(Closure)) at call_user_func_array(array(object(EncryptCookies), 'handle'), array(object(Request), object(Closure))) in Pipeline.php line 124 at Pipeline->Illuminate\Pipeline{closure}(object(Request)) in CheckForMaintenanceMode.php line 44 at CheckForMaintenanceMode->handle(object(Request), object(Closure)) at call_user_func_array(array(object(CheckForMaintenanceMode), 'handle'), array(object(Request), object(Closure))) in Pipeline.php line 124 at Pipeline->Illuminate\Pipeline{closure}(object(Request)) at call_user_func(object(Closure), object(Request)) in Pipeline.php line 102 at Pipeline->then(object(Closure)) in Kernel.php line 122 at Kernel->sendRequestThroughRouter(object(Request)) in Kernel.php line 87 at Kernel->handle(object(Request)) in index.php line 53

Any idea's why i am facing this problem.(New to mongodb)

ht2 commented 8 years ago

Hi @manjunath-muniraju-4444, can I just clarify - are you in the process of trying to upgrade Learning Locker to utilise Laravel 5?

You will need to look at the version of https://github.com/jenssegers/laravel-mongodb library you are using as it has different versions/branches for different versions of Laravel. You will also find that we have forked that library in order to utilise functionality that simply wasn't available in the branch we were using. As such, I think you're going to run into some interesting challenges down the line...

Can I enquire as to why you want to move it to Laravel 5?

ht2 commented 8 years ago

Also, if you have forked the code it would be easier to see and browse the problems. Certainly, given the open source nature of the Learning Locker GPL license, you may want to consider providing access to the source.

manjunath-muniraju-4444 commented 8 years ago

HI @ht2 , Yes i am trying to upgrade to Laravel 5.1..

why you want to move it to Laravel 5?. Reason 1 : Mostly Developers looks for latest Version of Laravel. Reason 2 : Most of the my company Application(currently) are in 5.

First of all, i am ok ok with git. and according to laravel doc(https://laravel.com/docs/5.1/upgrade#upgrade-5.0) The recommended method of upgrading is to create a new Laravel 5.0 install and then to copy your 4.2 site's unique application files into the new application. so i didn't clone it. But once its done i will for sure share it. if u want i can create a new git repo and share with you(for temporarily) or if you have a better approach, let me know.

according to https://github.com/jenssegers/laravel-mongodb

5.1.x(Laravel version) => 2.2.x or 3.0.x(jenssegers/laravel-mongodb supporting version).

"require": { "php": ">=5.5.9", "laravel/framework": "5.1.", "jenssegers/mongodb": "^3.0", "davejamesmiller/laravel-breadcrumbs": "^3.0", "barryvdh/laravel-cors": "^0.8.0", "learninglocker/statementfactory": "0.0.9", "andywer/js-localization": "dev-laravel-5", "philo/laravel-translate": "2.0.x", "seld/jsonlint": "^1.4", "lucadegasperi/oauth2-server-laravel": "5.1.", "laravelcollective/html": "5.1.*" }

ht2 commented 8 years ago

You will find that some of the functionality in the LL code base is geared towards code specific to this branch of the laravel-mongodb library: https://github.com/LearningLocker/laravel-mongodb/tree/issue/count-0.0.2. This may hinder your developement as the different versions of laravel-mongodb will not have these custom additions.

As to your original issue, I'm not sure why there is a problem with what is being sent (the query is absolutely fine for Mongo); the EloquentStorer class and update method (that your problem passes through) utilises the PHP Mongo driver's MongoCollection to call on its update method (http://php.net/manual/en/mongocollection.update.php). My guess is that the new version of the laravel-mongodb library requires the new Mongo driver, and this driver does not have the MongoCollection class, therefore this entire part of the statement update would need to be rewritten to account for the new driver and its methodology.

This would be true of any method that utilised the EloquentReader's getCollection() method: https://github.com/LearningLocker/learninglocker/blob/develop/app/locker/repository/Statement/EloquentReader.php#L41

ht2 commented 8 years ago

Note the new way that bulk updates should be handled in the new driver: http://php.net/manual/en/mongodb-driver-bulkwrite.update.php

manjunath-compassites commented 8 years ago

Hi @ht2 and @ryansmith94

when i render a page(ex: reports). the tables name are not rendered (i.e getting like statements.reporting ). so any idea about it. image

ryasmi commented 8 years ago

Hey @manjunath-muniraju-4444, that issue should disappear after you've ran php composer.phar install.

If that doesn't work, you can try running php artisan js-localization:refresh.

ht2 commented 8 years ago

You can read more about the package here: https://github.com/rmariuzzo/Laravel-JS-Localization As with all the dependencies you will need to see if there are any Laravel 5.x specifics that need dealing with

manjunath-compassites commented 8 years ago

Hi, @ht2 and @ryansmith94

please have a look at the https://github.com/php-compassites/learninglocker

i have converted most of the your code(https://github.com/LearningLocker/learninglocker) to Laravel 5.2. You might find some error, if you do please let me know, will correct it.

manjunath-compassites commented 8 years ago

My System Info: MongoDB shell version: 3.0.12 PHP 7.0.5 Ubuntu 14.04.4 LTS Laravel 5.1 (Homestead)

ryasmi commented 8 years ago

What version of the Mongo PHP extension are you using @manjunath-muniraju-4444?

manjunath-compassites commented 8 years ago

by running php -r 'echo phpversion("mongodb"), "\n";' it returned 1.2.0-dev. so i guess Mongo PHP extension : 1.2.0-dev

or

$php --ri mongodb | grep version

mongodb version => 1.2.0-dev libmongoc version => 1.4.0-dev libbson version => 1.4.0-dev

manjunath-compassites commented 8 years ago

Hi, @ht2 and @ryansmith94 today i was correcting some error/bug. i solved most of it except in migration files error, I was testing in postman Application, which is running good(testing only Statement insertion). but if i try same-thing in Tin Can Lab (http://tincanapi.com/statement-generator/#tab-smar-sending), it showing Status : 0. any idea why i am getting this error. I even tried removing middleware for that API. but still its showing same status(i.e Status : 0) and even tried using dd("here"), at the starting of the function xAPI\StatementController@selectMethod, same response, Status : 0

manjunath-compassites commented 8 years ago

found the problem

please have a look at https://github.com/barryvdh/laravel-cors/issues/87

i think this will solve the issue of https://github.com/LearningLocker/learninglocker/issues/754 also.

ht2 commented 8 years ago

Great find!

manjunath-muniraju-4444 commented 7 years ago

Hi, @ht2 and @ryansmith94
is the delete of the client working properly ? i mean are we getting "Oops. Something went wrong. The client has not been deleted." this message?

ryasmi commented 7 years ago

I can't seem to find anywhere that we're actually using 'cors' in the routes @ht2.

ryasmi commented 7 years ago

Hi @manjunath-muniraju-4444, yeah I am seeing the error message, but the client is actually getting deleted. I'm looking into it, feel free to create a separate issue for that.

manjunath-muniraju-4444 commented 7 years ago

its because $model->delete() returns null on delete(problem with https://github.com/jenssegers/laravel-mongodb i think) and on this line https://github.com/LearningLocker/learninglocker/blob/develop/app/locker/repository/Base/EloquentRepository.php#L28 we are check for bool value. Hence the error message

ryasmi commented 7 years ago

Hi @manjunath-muniraju-4444, I have a fix for the issue and this can be tracked in #840. Thanks for reporting the issue.

ryasmi commented 7 years ago

Hi @manjunath-compassites, can you please create a pull request for your upgrade to Laravel 5? That way it will go through our testing via continuous integration.

ryasmi commented 7 years ago

Hi @manjunath-compassites, this issue is being closed due to inactivity and will be reopened if it later becomes active.