Skip to content

Deprecate legacy OC_DB class and replace its usages#41455

Merged
DeepDiver1975 merged 1 commit intomasterfrom
deprecate-oc-db-and-replace-usage-5239319852108041845
Feb 20, 2026
Merged

Deprecate legacy OC_DB class and replace its usages#41455
DeepDiver1975 merged 1 commit intomasterfrom
deprecate-oc-db-and-replace-usage-5239319852108041845

Conversation

@DeepDiver1975
Copy link
Member

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

@google-labs-jules
Copy link

👋 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 @jules. You can find this option in the Pull Request section of your global Jules UI settings. You can always switch back!

New to Jules? Learn more at jules.google/docs.


For security, I will only act on instructions from the user who triggered this task.

@update-docs
Copy link

update-docs bot commented Feb 18, 2026

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.

@CLAassistant
Copy link

CLAassistant commented Feb 18, 2026

CLA assistant check
All committers have signed the CLA.

@DeepDiver1975
Copy link
Member Author

PHP code style has issues

1) lib/private/Share/Share.php (class_definition, method_argument_space, braces_position)
      ---------- begin diff ----------
--- /home/runner/work/core/core/lib/private/Share/Share.php
+++ /home/runner/work/core/core/lib/private/Share/Share.php
@@ -205,7 +205,7 @@
 				`*PREFIX*share`
 				WHERE
 				`item_source` = ? AND `share_type` IN (?, ?) AND `item_type` IN (\'file\', \'folder\')',
-				[$source, self::SHARE_TYPE_USER, self::$shareTypeGroupUserUnique]
+					[$source, self::SHARE_TYPE_USER, self::$shareTypeGroupUserUnique]
 				);
 			}
 
@@ -1221,7 +1221,8 @@
 
 		if (!$itemUnshared && isset($groupShare) && !isset($uniqueGroupShare)) {
 			$connection = \OC::$server->getDatabaseConnection();
-			$connection->executeStatement('INSERT INTO `*PREFIX*share`'
+			$connection->executeStatement(
+				'INSERT INTO `*PREFIX*share`'
 				.' (`item_type`, `item_source`, `item_target`, `parent`, `share_type`,'
 				.' `share_with`, `uid_owner`, `permissions`, `stime`, `file_source`, `file_target`)'
 				.' VALUES (?,?,?,?,?,?,?,?,?,?,?)',
@@ -1228,7 +1229,8 @@
 				[$groupShare['item_type'], $groupShare['item_source'], $groupShare['item_target'],
 				$groupShare['id'], self::$shareTypeGroupUserUnique,
 				\OC_User::getUser(), $groupShare['uid_owner'], 0, $groupShare['stime'], $groupShare['file_source'],
-				$groupShare['file_target']]);
+				$groupShare['file_target']]
+			);
 			$shareTmp = [
 				'id' => $groupShare['id'],
 				'shareWith' => $groupShare['share_with'],


Detected deprecations in use (they will stop working in next major release):
- Rule "visibility_required" is deprecated. Use "modifier_keywords" instead.
      ----------- end diff -----------

@DeepDiver1975 DeepDiver1975 force-pushed the deprecate-oc-db-and-replace-usage-5239319852108041845 branch 3 times, most recently from 1bf2476 to 1c028aa Compare February 20, 2026 09:27
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.
@DeepDiver1975 DeepDiver1975 force-pushed the deprecate-oc-db-and-replace-usage-5239319852108041845 branch from 1c028aa to 5770d98 Compare February 20, 2026 09:34
Copy link
Member

@jvillafanez jvillafanez left a comment

Choose a reason for hiding this comment

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

Assuming tests pass

. ' FROM `*PREFIX*files_trash` WHERE `user`=?', [$user]);
$array = [];
while ($row = $result->fetchRow()) {
while ($row = $result->fetch()) {
Copy link
Member

Choose a reason for hiding this comment

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

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.

Copy link
Member Author

Choose a reason for hiding this comment

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

see #41450

*/
private function isManipulation($sql) {
$selectOccurrence = \stripos($sql, 'SELECT');
if ($selectOccurrence !== false && $selectOccurrence < 10) {
Copy link
Member

Choose a reason for hiding this comment

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

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...

Copy link
Member Author

Choose a reason for hiding this comment

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

We hopefully can kill this OC_DB_StatementWrapper then the whole logic is gone

@DeepDiver1975 DeepDiver1975 merged commit 0b0db02 into master Feb 20, 2026
7 checks passed
@DeepDiver1975 DeepDiver1975 deleted the deprecate-oc-db-and-replace-usage-5239319852108041845 branch February 20, 2026 10:35
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.

3 participants

Comments