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

Use Deprecation::triggerIfCalledFromOutside in listTableDetails #6086

Merged
merged 1 commit into from
Jul 7, 2023

Conversation

Aweptimum
Copy link
Contributor

Q A
Type bug/feature/improvement
Fixed issues #6085

Summary

Except for the Sqlite platform (which already used triggerIfCalledFromOutside), replaced the use of Deprecation::trigger with Deprecation::triggerIfCalledFromOutside in the SchemaManagers

@Aweptimum
Copy link
Contributor Author

Had to force-push because my editor didn't save the change in MySqlSchemaManager

@greg0ire
Copy link
Member

greg0ire commented Jul 5, 2023

The commit message should explain the reason behind this change.

@Aweptimum
Copy link
Contributor Author

For the force-push?

@greg0ire
Copy link
Member

greg0ire commented Jul 5, 2023

The second commit should be fixed up into the first one, but that's a detail. The first commit should explain why you are doing this (because these methods are still called internally, right?).

Though listTableDetails is deprecated, it is still called internally. To avoid getting deprecation messages when called by other doctrine function, we can replace the use of Deprecation::trigger with Deprecation::triggerIfCalledFromOutside in the SchemaManagers. With the exception of SqliteSchemaManager, which already did this
@Aweptimum
Copy link
Contributor Author

Got it, I've amended the commit with a more detailed explanation.

@greg0ire greg0ire requested a review from morozov July 6, 2023 07:11
@greg0ire greg0ire added this to the 3.6.5 milestone Jul 7, 2023
@greg0ire greg0ire added the Bug label Jul 7, 2023
@greg0ire greg0ire merged commit 1c462ee into doctrine:3.6.x Jul 7, 2023
74 checks passed
@greg0ire
Copy link
Member

greg0ire commented Jul 7, 2023

Thanks @Aweptimum !

@VincentLanglet
Copy link
Contributor

HI @Aweptimum, I just found the PR and I'm not sure it will solve all the deprecations:

Currently I get

User Deprecated: Doctrine\DBAL\Schema\MySQLSchemaManager::listTableDetails is deprecated. Use introspectTable() instead. (MySQLSchemaManager.php:76 called by AbstractSchemaManager.php:614, https://github.com/doctrine/dbal/pull/5595, package doctrine/dbal)

and

User Deprecated: Passing $database to AbstractSchemaManager::listTableColumns() is deprecated. (AbstractSchemaManager.php:245 called by MySQLSchemaManager.php:91, https://github.com/doctrine/dbal/issues/5284, package doctrine/dbal)

This PR will solve the first one, but there will still be the second one.

The issue is that introspectTable(string $name) is calling listTableDetails($name) which is calling listTableColumns($name) but this trigger a deprecation when $name is not null.

Do you or @greg0ire know how to solve the deprecation ?

@Aweptimum
Copy link
Contributor Author

Aweptimum commented Jul 20, 2023

It seems each concrete schema managers' listTableDetails calls the protected AbstractSchemaManager->doListTableDetails, which does pass the deprecated $database parameter to AbstractSchemaManager->listTableColumns, but the further complication is that each sub-type overrides listTableColumns to use the protected AbstractSchemaManager->doListTableColumns($table, $database). Which has the same deprecation trigger as the public listTableColumns.

I understand the deprecations being in the public methods, but not in the protected methods. The solution might be to move the deprecation trigger out of doListTableColumns and up to each instance of listTableColumns in the schema managers. This would be consistent with the AbstractSchemaManager as that is where its deprecation trigger is.

But I'm very ignorant of the intentions here, there's really only this issue to go off of: #5284
It seems to me that morozov might have took issue with the inconsistencies of the public api, maybe not so much the internal one. However, if the change really was meant to target the internal API as well, then another solution would be needed.

I would wait for gregoire's input, but it is probably worth a new issue

@greg0ire
Copy link
Member

greg0ire commented Jul 20, 2023

Yes, a separate issue please, with as many github permalinks as possible please. I don't want to have to click around 36 files to understand this.

this trigger a deprecation when $name is not null.

🤔 no it does not:

public function listTableColumns($table, $database = null)
{
if ($database === null) {
$database = $this->getDatabase(__METHOD__);
} else {
Deprecation::trigger(
'doctrine/dbal',
'https://github.com/doctrine/dbal/issues/5284',
'Passing $database to AbstractSchemaManager::listTableColumns() is deprecated.',
);
}

Only when $database is not null.

@VincentLanglet
Copy link
Contributor

this trigger a deprecation when $name is not null.

🤔 no it does not:

public function listTableColumns($table, $database = null)
{
if ($database === null) {
$database = $this->getDatabase(__METHOD__);
} else {
Deprecation::trigger(
'doctrine/dbal',
'https://github.com/doctrine/dbal/issues/5284',
'Passing $database to AbstractSchemaManager::listTableColumns() is deprecated.',
);
}

Only when $database is not null.

My bad, I was confuse ; still I think I found a deprecation to solve #6104 ^^

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants