This error occurs when trying to load the "Not in database" report, if the Restrict By IP module is also enabled:

Argument 6 passed to Drupal\auditfiles\ServiceAuditFilesNotInDatabase::__construct() must be an instance of Drupal\Core\Session\AccountProxy, instance of Drupal\restrict_by_ip\Session\AccountProxy given

Issue fork auditfiles-3261115

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

wrd-oaitsd created an issue. See original summary.

victoria-marina’s picture

Assigned: Unassigned » victoria-marina

I'll work on this.

victoria-marina’s picture

Assigned: victoria-marina » Unassigned
Status: Active » Needs review
StatusFileSize
new2.41 KB

Here is a patch, please review it.

I've also fixed the error below that was showing on tests.

Testing /auditfiles/tests
.............EE...                                                18 / 18 (100%)

Time: 02:09.257, Memory: 14.00 MB

There were 2 errors:

1) Drupal\Tests\auditfiles\Functional\AuditFilesUsedNotReferencedTest::testReportPage
Exception: TypeError: Argument 5 passed to Drupal\auditfiles\ServiceAuditFilesUsedNotReferenced::__construct() must be an instance of Drupal\auditfiles\EntityTypeManagerInterface, instance of Drupal\Core\Entity\EntityTypeManager given, called in /app/web/core/lib/Drupal/Component/DependencyInjection/Container.php on line 262
Drupal\auditfiles\ServiceAuditFilesUsedNotReferenced->__construct()() (Line: 59)

2) Drupal\Tests\auditfiles\Functional\AuditFilesUsedNotReferencedTest::testFileEntityCanBeDeleted
Exception: TypeError: Argument 5 passed to Drupal\auditfiles\ServiceAuditFilesUsedNotReferenced::__construct() must be an instance of Drupal\auditfiles\EntityTypeManagerInterface, instance of Drupal\Core\Entity\EntityTypeManager given, called in /app/web/core/lib/Drupal/Component/DependencyInjection/Container.php on line 262
Drupal\auditfiles\ServiceAuditFilesUsedNotReferenced->__construct()() (Line: 59)


ERRORS!
Tests: 18, Assertions: 149, Errors: 2.
wrd-oaitsd’s picture

With the patch, I can now load the report successfully. Thanks for the quick fix!

gaurav.kapoor’s picture

Status: Needs review » Needs work
Issue tags: +Needs reroll

The patch doesn't apply to the latest development release 8.x.3.x as class 'ServiceAuditFilesUsedNotReferenced' already has a use statement added for 'EntityTypeManagerInterface'. So only changes related to changing 'AccountProxy' to 'AccountProxyInterface' in 'ServiceAuditFilesNotInDatabase' should be fine here.

Marking it as needs work, so that patch can be rerolled to work with 8.x-3.x branch. Website using stable releases can use the patch provided in #3 to get rid of this error.

gaurav.kapoor’s picture

Version: 8.x-2.11 » 8.x-2.x-dev
Status: Needs work » Needs review

The patch does apply cleanly only on 8.x-2.x though, so it will require application as well as fixing code conflicts among various releases.

victoria-marina’s picture

StatusFileSize
new1.88 KB

Hi @gaurav.kapoor
Here is a patch for the 8.x-3.x branch.

gaurav.kapoor’s picture

Status: Needs review » Reviewed & tested by the community
dpi’s picture

Version: 8.x-2.x-dev » 8.x-3.x-dev
Issue tags: -Needs reroll

  • dpi committed 09cea9a on 8.x-3.x
    Issue #3261115 by victoria-marina, dpi: Error when "Restrict By IP"...
dpi’s picture

Status: Reviewed & tested by the community » Fixed

Fixed in #3313394: Audit Files should typehint interfaces rather than a specific implementation for 4.x branch.

I've updated and merged the patch here for 3.x.

The 2.x branch is deprecated.

Status: Fixed » Closed (fixed)

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