Problem/Motivation

When trying to generate a dump, I get the error
[error] Error: Call to undefined method Drupal\mysql\Driver\Database\mysql\Connection::transactionManager() in Drupal\gdpr_dump\Service\GdprSqlDump->cleanup() (line 348 of /var/www/html/web/modules/contrib/gdpr/modules/gdpr_dump/src/Service/GdprSqlDump.php) #0 /var/www/html/web/modules/contrib/gdpr/modules/gdpr_dump/src/Service/GdprSqlDump.php(317): Drupal\gdpr_dump\Service\GdprSqlDump->cleanup()

Steps to reproduce

Drupal 9.5.11, php 8.1.18

run

drush gdpr-sql-dump --result-file=sites/default/files/dumps/240729-userdata_anonymisation.sql

Proposed resolution

gdpr/modules/gdpr_dump/src/Service/GdprSqlDump.php l 216 and 348

Use

    if (method_exists($this->database, 'transactionManager')) {
      $this->database->transactionManager()->unpile($transaction->name());
    }
    else {
      // @phpstan-ignore-next-line to handle backward compatibility.
      $this->database->popTransaction($transaction->name());
    }

instead of

    if ($this->database->transactionManager()) {
      $this->database->transactionManager()->unpile($transaction->name());
    }
    else {
      // @phpstan-ignore-next-line to handle backward compatibility.
      $this->database->popTransaction($transaction->name());
    }

Remaining tasks

User interface changes

API changes

Data model changes

Issue fork gdpr-3464381

Command icon Show commands

Start within a Git clone of the project using the version control instructions.

Or, if you do not have SSH keys set up on git.drupalcode.org:

Comments

abelass created an issue. See original summary.

atul_ghate made their first commit to this issue’s fork.

abelass changed the visibility of the branch 3.0-x/fix/check_if_method_exists to hidden.

abelass changed the visibility of the branch 3.0-x/fix/check_if_method_exists to active.

abelass changed the visibility of the branch 3464381-call-to-undefined to hidden.

abelass’s picture

StatusFileSize
new1.26 KB

Here is the patch

abelass’s picture

Issue tags: +Drupal 9

ankitv18 made their first commit to this issue’s fork.

ankitv18’s picture

Status: Active » Needs review
Issue tags: -Drupal 9

Please review and validate the MR!46

Rajeshreeputra made their first commit to this issue’s fork.

rajeshreeputra’s picture

Status: Needs review » Fixed

tommyk’s picture

Status: Fixed » Needs work

I reverted to the fix commit from 3.1.0 and it's not fixed.

Error: Call to undefined method Drupal\Core\Database\Transaction::id() in Drupal\gdpr_dump\Service\GdprSqlDump->cleanup() (line 349 of /var/www/html/web/modules/contrib/gdpr/modules/gdpr_dump/src/Service/GdprSqlDump.php).

rajeshreeputra’s picture

@TommyK, thanks for your input, will check with 3.0.1 and 3.0.x branch, again!

rajeshreeputra’s picture

Version: 3.1.0 » 3.0.x-dev
ankitv18’s picture

Status: Needs work » Needs review

I've logged a issue in drupal core to retrieve the transaction id: https://www.drupal.org/project/drupal/issues/3466569#comment-15717284

ankitv18’s picture

As per suggestion on https://www.drupal.org/project/drupal/issues/3466569
I've raised a new MR

ankitv18 changed the visibility of the branch 3.0-x/fix/check_if_method_exists to hidden.

ankitv18’s picture

With new MR!49
Before unsetting transaction
without unsetting txn

After unsetting transaction
with unset txn

rajeshreeputra’s picture

Merged.

rajeshreeputra’s picture

Status: Needs review » Fixed

Status: Fixed » Closed (fixed)

Automatically closed - issue fixed for 2 weeks with no activity.