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

USH-228 - Upgrade project dependencies #4527

Merged
merged 32 commits into from Mar 29, 2023
Merged

Conversation

webong
Copy link
Collaborator

@webong webong commented Mar 1, 2023

This pull request makes the following changes:

Update Notes

5.5 to 5.6

Laravel doc

  • Added config/hashing.php
  • Added config/logging.php
  • Several vendor versions were updated in composer.json file:
"fideloper/proxy": "~4.0",
"laravel/passport": "^6.0"
"laravel/laravel": "5.6.*"
"robmorgan/phinx": "~0.10.0"
"phpspec/phpspec": "~5.0"
  • Note for dev: COMPOSER_MEMORY_LIMIT=-1 composer install --verbose -vvv we might have to run composer without memory limit

5.6 to 5.7

Laravel doc

  • Dependencies changes:
"laravel/framework": "5.7.*"
"laravel/passport": "^7.0"
  • public/svg directory must exist.
  • storage/framework/cache/data must exist.
  • Define public $mockConsoleOutput = false as a property in test class calling artisan i.e Datasource console.

5.7 to 5.8

Laravel doc

  • Dependencies changes:
"laravel/framework": "5.8.*"
  • Replaced array_pluck by Arr::pluck
  • Replaced array_flatten by Arr::flatten
  • Replaced str_random by Str::random
  • Replaced str_slug by Str::slug
  • Changed Cache class methods usage to consider seconds instead of minutes
  • The setUp and tearDown methods now require a void return type:
    • Updated the setUp method so that its return type is void in the ushahidi/platform/tests/unit directory.
    • Updated the tearDown method so that its return type is void in the ushahidi/platform/tests/unit directory.
    • Removed redundant tearDown method from test classes
  • Read-Only env Helper, so putenv doesn't work anymore
  • Updated app/PlatformVerifier/Env.php to use new syntax of Dotenv library: Dotenv::create().

5.8 to 6.0

Laravel doc

  • Dependencies changes:
    "laravel/framework": "^6.0"
    "sentry/sentry-laravel": "*"
    "laravel/passport": "^9.3.2"
    "doctrine/dbal": "^2.0"
  • Replaces sentry config by running php artisan sentry:publish
  • Change Event::fire to Event::dispatch
  • Added camel_case function that wraps around Str::camel for backwards compatibility with laravel-ckan-api package as 6.0 doesn't have the camel_case helper function anymore.
  • The default Redis client has changed from predis to phpredis. In order to keep using predis, ensure the redis.
  • Replaced translator->trans() method in KohanaValidationEngine, ValidatorTrait and ContactRepository by translator->get()method asIlluminate\Contracts\Translation\Translator` changed.
  • Replaced Input::get by Request::input in Post.php and Survey.php as the Illuminate\Support\Facades\Input facade has been removed.
  • Updated create method in platform/app/Passport/ClientRepository.php to be compatible with new Passport version. It now matches platform/vendor/laravel/passport/src/ClientRepository.php
  • Updated createPasswordGrantClient method in platform/app/Passport/ClientRepository.php to be compatible with new Passport version. It now matches platform/vendor/laravel/passport/src/ClientRepository.php
  • Replaced League\OAuth2\Server\Exception\OAuthServerException by Laravel\Passport\Exceptions\OAuthServerException in:
  • Changed secret field in oauth_clients table as per Passport documentation on public clients: migrations/20201110132445_update_oauth_clients_table_secret.php
  • Added provider field in oauth_clients table as per Passport documentation on multiple guards: migrations/20201110135500_update_oauth_clients_table_providers.php
  • "doctrine/dbal": "^2.0" dependency was added because it was needed to make changes in oauth tables
  • Modified TokenGuard to use PsrHttpFactory instead of DiactorosFactory (deprecated). More info here
  • League Oauth Password Grant throws invalid_grant instead invalid crentials when user authentication fails, which has http status code 400 instead of 401. So, we need to update the Scenario: Requesting access token with incorrect password fails in tests/features/oauth2.feature to check for 400 status code instead of 401.

6.0 to 7.0

Laravel doc

  • Dependencies changes:
"laravel/framework": "^7.0"
"fruitcake/laravel-cors": "^2.0"
"phpunit/phpunit": "^8.5"
"nyholm/psr7": "^1.5"
"asm89/stack-cors": "~2.0"
"robmorgan/phinx": "~0.11.2"
"phpspec/phpspec": "~7.0"
"captainhook/captainhook": "^5.0"
  • The big deal here is that laravel now relies on symfony 5, so we had to check in all the dependencies how it was affected.
  • Updated report and render methods in app/Exceptions/Handler.php so that they take Throwable instead of Exception as parameters
  • Added "symfony/psr-http-message-bridge": "^2.0" as dependency
  • Added nyholm/psr7 as dependency
  • Replaced "barryvdh/laravel-cors" by "fruitcake/laravel-cors"
    • Replaced Barryvdh\Cors\HandleCors::class by Fruitcake\Cors\HandleCors::class in app/Http/Kernel.php
  • The optional $delta parameter of assertEquals() is deprecated and will be removed in PHPUnit 9. Refactor your test to use assertEqualsWithDelta() instead.
    • assertAttributeEquals() is deprecated and will be removed in PHPUnit 9.
    • readAttribute() is deprecated and will be removed in PHPUnit 9.
    • getObjectAttribute() is deprecated and will be removed in PHPUnit 9.
  • assertInternalType() is deprecated and will be removed in PHPUnit 9. More info
  • dms/phpunit-arraysubset-asserts supports usage of assertArraySubset(), that is deprecated and will be removed in PHPUnit 9. More info here
  • Update Resources to use Illuminate\Http\Resources\Json\JsonResource instead of Illuminate\Http\Resources\Json\Resource
  • Update Collections to use Illuminate\Http\Resources\Json\ResourceCollection instead of Illuminate\Http\Resources\Json\Resource
  • Replaced "sebastianfeldmann/captainhook" by "captainhook/captainhook"
    • Updated tests/CaptainHook/PHPCS.php and captainhook.json to be compatible with new captainhook version
    • Make sure hooks are installed by running bin/captainhook install
  • Updated (Dotenv::create(...))->load(); by
$dotenv = Dotenv::createImmutable(__DIR__ . '/../');
$dotenv->load();

in the files: app/PlatformVerifier/Env.php

  • Removed "phpunit/dbunit": "~4.0.0" depedency there is no compatible version with "phpunit/phpunit": "^8.5". More on dbunit deprecation can be found here and here.
    • Behat Tests heavily depends on seed data
    • dbunit is used to seed data in behat tests, but unfortunately there is no compatible version with phpunit 8.5
    • We extracted the utility classes from dbunit that can be used to seed data in behat tests
    • The future plan is to replace these seeders with laravel factories

Benefits

7.0 to 8.0

  • Dependencies changes:
"laravel/framework": "^8.0"
"laravel/passport": "^10.0",
"laravel/tinker": "^2.5",
"guzzlehttp/guzzle": "^6.5|^7.0.1",
"php-http/curl-client": "^2.2",
"ushahidi/laravel-ckan-api": "dev-master",
"vonage/client": "^2.3",
"fakerphp/faker": "^1.9.1",
"phpunit/phpunit": "^9.0",
"nunomaduro/collision": "^5.10",
"facade/ignition": "~2.5",
  • Guzzle Conflict with v7
    • intercom-php relies on Guzzle v6, so we can use a different HTTP client, for example cURL: See more
    • Replace nexmo/client-core with vonage/client-core
      • Update the namespace and reference of these packages in Nexmo datasource plugin
      • Fix failing unit tests
      • Fix failing feature tests
      • [Update] Laravel 8 doesn't really require Guzzle 7, so it's fine to keep using Guzzle 6 also. See more here.
  • Remove ramsey/uuid already in laravel 8
  • Replaced germanazo/laravel-ckan-api with ushahidi/laravel-ckan-api
    • The ushahidi/laravel-ckan-api package is a fork of germanazo/laravel-ckan-api with some fixes and improvements
  • Refactored your test code to use assertMatchesRegularExpression() instead of assertRegExp() as it is deprecated and will be removed in PHPUnit 10.
  • Refactor your code to use assertDoesNotMatchRegularExpression() instead of assertNotRegExp() as it is deprecated and will be removed in PHPUnit 10.
  • Run ./bin/phpunit --migrate-configuration to migrate your configuration to the new format.
  • Seeders and factories are now namespaced. To accommodate for these changes,
    • Added the Database\Seeders namespace to the seeder classes.
    • Renamed the previous database/seeds directory to database/seeders

Ping @ushahidi/platform

@webong webong force-pushed the chore/upgrade-dependencies branch 5 times, most recently from 668c171 to 2f819c8 Compare March 1, 2023 15:37
@webong webong force-pushed the chore/upgrade-dependencies branch from 2f819c8 to 20098c4 Compare March 1, 2023 16:19
@webong webong force-pushed the chore/upgrade-dependencies branch from 30638b3 to 4abf6c2 Compare March 1, 2023 17:30
@webong webong force-pushed the chore/upgrade-dependencies branch from e0cbf6f to f01f564 Compare March 1, 2023 17:42
@webong webong force-pushed the chore/upgrade-dependencies branch from 2220f1e to 3bade71 Compare March 1, 2023 23:16
@webong webong force-pushed the chore/upgrade-dependencies branch from 8a781c8 to 806c2ec Compare March 2, 2023 01:28
@webong webong force-pushed the chore/upgrade-dependencies branch from aeec161 to 7bf79b2 Compare March 2, 2023 16:11
@webong webong force-pushed the chore/upgrade-dependencies branch from 7bf79b2 to d38c368 Compare March 2, 2023 16:20
@webong webong force-pushed the chore/upgrade-dependencies branch from a765c2c to 3add9d8 Compare March 10, 2023 12:43
@webong webong requested review from Mh-Asmi and tuxpiper and removed request for Mh-Asmi March 10, 2023 12:57
Dockerfile Show resolved Hide resolved
composer.json Outdated Show resolved Hide resolved
.github/workflows/test-and-ship.yml Show resolved Hide resolved
composer.json Show resolved Hide resolved
config/logging.php Show resolved Hide resolved
@tuxpiper
Copy link
Member

@webong

“Looking foward to using this [7.x] Add extendable relations for models laravel/framework#33025 in the future

What is one scenario where are you looking forward to using these extendable relations?

@tuxpiper tuxpiper changed the title Upgrade project dependencies USH-228 - Upgrade project dependencies Mar 13, 2023
@webong
Copy link
Collaborator Author

webong commented Mar 13, 2023

@webong

“Looking foward to using this [7.x] Add extendable relations for models laravel/framework#33025 in the future

What is one scenario where are you looking forward to using these extendable relations?

@tuxpiper

Extendable relations allow us to dynamically add entity associations in Eloquent, a typical scenario in our system would be for targeted forms (surveys). The association of a contact to a post and form will most likely be an isolated feature from the core system, so it's something we'll see being dynamically created based on the query.

Copy link
Member

@tuxpiper tuxpiper left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Marking the requested changes explicitly

.github/workflows/test-and-ship.yml Show resolved Hide resolved
composer.json Outdated Show resolved Hide resolved
@tuxpiper
Copy link
Member

@webong has kindly addressed all my comments. @Mh-Asmi please go ahead with your review and merge the PR whenever you think it's good.

Copy link
Contributor

@Mh-Asmi Mh-Asmi left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

it's good for me

@tuxpiper
Copy link
Member

@webong @Mh-Asmi Can we merge this on Monday? We have conflicts now that block the merge

@Mh-Asmi
Copy link
Contributor

Mh-Asmi commented Mar 26, 2023

@webong @Mh-Asmi Can we merge this on Monday? We have conflicts now that block the merge

@tuxpiper I solved the conflicts

@Mh-Asmi
Copy link
Contributor

Mh-Asmi commented Mar 27, 2023

@webong can you look at the error in test 7.4 , any idea ?

@webong
Copy link
Collaborator Author

webong commented Mar 27, 2023

@Mh-Asmi trying to replicate this on my local to see what went wrong

@webong webong merged commit ac8fe4c into project-mzima Mar 29, 2023
6 checks passed
@webong webong deleted the chore/upgrade-dependencies branch March 29, 2023 17:54
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants