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

php 8 compatibility #41

Closed
m1kesk opened this issue Mar 14, 2022 · 8 comments
Closed

php 8 compatibility #41

m1kesk opened this issue Mar 14, 2022 · 8 comments

Comments

@m1kesk
Copy link

m1kesk commented Mar 14, 2022

I am using php version 8.1.3 with example from documents on mysql

// Create the Connection URI
// See more: https://github.com/byjg/anydataset#connection-based-on-uri
$uriString = 'mysql://' . $dbUser . ':' . $dbPass . '@' . $dbHost . ':' . $dbPort . '/' . $dbName;
$connectionUri = new \ByJG\Util\Uri($uriString);

// Create the Migration instance
$migration = new \ByJG\DbMigration\Migration($connectionUri, './resources', false);

// Register the Database or Databases can handle that URI:
$migration->registerDatabase('mysql', \ByJG\DbMigration\Database\MySqlDatabase::class);
$migration->registerDatabase('maria', \ByJG\DbMigration\Database\MySqlDatabase::class);

$migration->reset();

I got these warnings:

PHP Deprecated: parse_str(): Passing null to parameter #1 ($string) of type string is deprecated in /var/www/html/vendor/byjg/uri/src/Uri.php on line 118
Deprecated: http_build_query(): Passing null to parameter #2 ($numeric_prefix) of type string is deprecated in /var/www/html/vendor/byjg/uri/src/Uri.php on line 125

I tested this on 7.4 & 7.3 with no warnings

@byjg
Copy link
Owner

byjg commented Mar 14, 2022

I created a PR for the project URI, where the error is thrown.

Could you validate it?

Thanks.

@m1kesk
Copy link
Author

m1kesk commented Mar 15, 2022

Those warnings are fixed, however this new one appears
PHP Deprecated: file_exists(): Passing null to parameter #1 ($filename) of type string is deprecated in /var/www/html/vendor/byjg/migration/src/Migration.php on line 187

issue appears when migrating up or reset (with up)

@byjg
Copy link
Owner

byjg commented Mar 15, 2022

All right. I merged the URI project, so you can restore your composer JSON and the next update will get the correct one.

I'll take a look at this error.

@byjg
Copy link
Owner

byjg commented Mar 15, 2022

I wasn't able to reproduce this error :(

Could you paste the code you are using including the parameters of the database? You can fake the DB the password.

Thanks

@m1kesk
Copy link
Author

m1kesk commented Mar 15, 2022

<?php

require __DIR__ . '/vendor/autoload.php';

$dbHost = '127.0.0.1';
$dbName = 'project';
$dbPort = 3306;
$dbUser = 'user';
$dbPass = 'pass';

$uriString = 'mysql://' . $dbUser . ':' . $dbPass . '@' . $dbHost . ':' . $dbPort . '/' . $dbName;
$connectionUri = new \ByJG\Util\Uri($uriString);

$migration = new \ByJG\DbMigration\Migration($connectionUri, './resources', false);
$migration->registerDatabase('mysql', \ByJG\DbMigration\Database\MySqlDatabase::class);
$migration->registerDatabase('maria', \ByJG\DbMigration\Database\MySqlDatabase::class);

$migration->reset();

migration files

./resources/migrations/down/00000.sql
./resources/migrations/up/00001.sql

00000.sql

-- Migrate to Version 0
-- @description: delete user table
DROP TABLE `user`;

00001.sql

-- Migrate to Version 1
-- @description: create user table
CREATE TABLE `user` (
    `id` INT(10) UNSIGNED NOT NULL AUTO_INCREMENT,
    `name` VARCHAR(255) NULL DEFAULT NULL COLLATE 'utf8_unicode_ci',
    PRIMARY KEY (`id`)
) COLLATE = 'utf8_unicode_ci' ENGINE = InnoDB;

byjg added a commit that referenced this issue Mar 15, 2022
@byjg
Copy link
Owner

byjg commented Mar 15, 2022

Found the issue and fixed it in branch 4.2.1.

You can change your composer to use 4.2.1.x-dev

Let me know if it fixes, so I can create a new release with this.

@m1kesk
Copy link
Author

m1kesk commented Mar 15, 2022

seems to be fixed

@byjg
Copy link
Owner

byjg commented Mar 15, 2022

OK. PR merged.

Release 4.2.2 created.

I am closing this issue.

@byjg byjg closed this as completed Mar 15, 2022
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

No branches or pull requests

2 participants