Deprecate legacy OC_DB class and replace its usages#41455
Deprecate legacy OC_DB class and replace its usages#41455DeepDiver1975 merged 1 commit intomasterfrom
Conversation
|
👋 Jules, reporting for duty! I'm here to lend a hand with this pull request. When you start a review, I'll add a 👀 emoji to each comment to let you know I've read it. I'll focus on feedback directed at me and will do my best to stay out of conversations between you and other bots or reviewers to keep the noise down. I'll push a commit with your requested changes shortly after. Please note there might be a delay between these steps, but rest assured I'm on the job! For more direct control, you can switch me to Reactive Mode. When this mode is on, I will only act on comments where you specifically mention me with New to Jules? Learn more at jules.google/docs. For security, I will only act on instructions from the user who triggered this task. |
|
Thanks for opening this pull request! The maintainers of this repository would appreciate it if you would create a changelog item based on your changes. |
|
PHP code style has issues |
1bf2476 to
1c028aa
Compare
This commit drops the `OC_DB` class. Occurrences of `OC_DB` and `OCP\DB` throughout the codebase have been replaced with modern `IDBConnection` methods retrieved via `\OC::$server->getDatabaseConnection()`. Key changes: - Updated `Trashbin`, `User`, `Group`, `Share`, `Installer`, `Setup`, and `Repair` components to use `executeQuery` and `executeStatement`. - Replaced `fetchRow()` with `fetch()` and `fetchOne()` with `fetchColumn()`. - Updated `createDbFromStructure` and `updateDbFromStructure` calls to use `MDB2SchemaManager` directly. - Modernized several unit tests to reflect these changes.
1c028aa to
5770d98
Compare
| . ' FROM `*PREFIX*files_trash` WHERE `user`=?', [$user]); | ||
| $array = []; | ||
| while ($row = $result->fetchRow()) { | ||
| while ($row = $result->fetch()) { |
There was a problem hiding this comment.
Side note, I've found the following in the dbal upgrade notes for 4.0:
## BC BREAK: Remove legacy execute and fetch methods.
The following methods have been removed:
* `Result::fetch()`
* `Result::fetchAll()`
* `Connection::exec()`
* `Connection::executeUpdate()`
* `Connection::query()`
Additionally, the `FetchMode` class has been removed.
For the upgrade to 3.0, this might be relevant:
## Removed `FetchMode` and the corresponding methods
1. The `FetchMode` class and the `setFetchMode()` method of the `Connection` and `Statement` interfaces are removed.
2. The `Statement::fetch()` method is replaced with `fetchNumeric()`, `fetchAssociative()` and `fetchOne()`.
3. The `Statement::fetchAll()` method is replaced with `fetchAllNumeric()`, `fetchAllAssociative()` and `fetchColumn()`.
4. The `Statement::fetchColumn()` method is replaced with `fetchOne()`.
5. The `Connection::fetchArray()` and `fetchAssoc()` methods are replaced with `fetchNumeric()` and `fetchAssociative()` respectively.
6. The `StatementIterator` class is removed. The usage of a `Statement` object as `Traversable` is no longer possible. Use `iterateNumeric()`, `iterateAssociative()` and `iterateColumn()` instead.
7. Fetching data in mixed mode (former `FetchMode::MIXED`) is no longer possible.
I think we'll need to make additional changes sooner than later.
| */ | ||
| private function isManipulation($sql) { | ||
| $selectOccurrence = \stripos($sql, 'SELECT'); | ||
| if ($selectOccurrence !== false && $selectOccurrence < 10) { |
There was a problem hiding this comment.
The selectOccurrence < 10 needs a comment. It seems a magic number so far.
Since this was moved from another place, I guess it's fine...
There was a problem hiding this comment.
We hopefully can kill this OC_DB_StatementWrapper then the whole logic is gone
Marked class OC_DB as deprecated and replaced its usage in the codebase with modern IDBConnection methods. Updated Trashbin, User, Group, Share, Setup, and Installer components. Adjusted unit tests to use the new database connection patterns.
PR created automatically by Jules for task 5239319852108041845 started by @DeepDiver1975