Problem/Motivation

Tried to install the module using drush and got an error message:

[error] Error: Class 'User' not found in user_revision_module_preinstall() (line 16 of /app/web/modules/contrib/user_revision/user_revision.install) #0 [internal function]: user_revision_module_preinstall('user_revision')...

Steps to reproduce

1. Install the module using composer: composer require drupal/user_revision:1.x-dev@dev
2. Enable the module using drush: drush en user_revision

Proposed resolution

The line 7 of user_revision.install file should be changed like this:

- use Drupal\user\Entity\User as UserEntity;
+ use Drupal\user\Entity\User;

Comments

zoiosilva created an issue. See original summary.

zoiosilva’s picture

StatusFileSize
new372 bytes
zoiosilva’s picture

Actually there are more errors in the installation process that the #2 patch is not addressing.

aritrika.d’s picture

With above patch the module gets enabled successfully.

Attaching screanshots.

aritrika.d’s picture

Status: Active » Needs review
geek-merlin’s picture

Status: Needs review » Fixed

Thanks a lot for spotting and fixing this. Committed and soon pushed.

  • geek-merlin committed 70ae241 on 8.x-1.x
    Issue #3192391 by zoiosilva, aritrika.d: Class 'User' not found in...
geek-merlin’s picture

liquidcms’s picture

lots of issues trying to get this installed... and now i think 1/2 installed and can't get it uninstalled. :(

D8 not the easiest thing to clean up but will keep hacking away to get this removed.

liquidcms’s picture

ok, burned up a few hours on this.. anyone have any hints?

I am pretty sure the module is not properly installed. When i login the site whitescreens with this:

Drupal\Core\Database\DatabaseExceptionWrapper: SQLSTATE[42000]: Syntax error or access violation: 1064 You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'WHERE uid='1'' at line 1: SELECT COUNT(DISTINCT vid) FROM {} WHERE uid=:uid; Array ( [:uid] => 1 ) in user_revision_count() (line 305 of E:\www\ottcomp\web\modules\contrib\user_revision\user_revision.module).

When i use drush to uninstall i get this: This module can not be uninstalled.

And when looking at the module's .install file the uninstall hook simply throws exception saying can't be uninstalled. Not sure how that works.

so if i comment out that line i get:

SQLSTATE[42S22]: Column not found: 1054 Unknown column 'vid' in 'where clause': SELECT 1 AS expression
FROM
{users_field_data} t
WHERE vid IS NOT NULL
LIMIT 1 OFFSET 0; Array
(
)

and of course D8 makes it pretty hard to clean out a corrupted install.

zoiosilva’s picture

Status: Fixed » Needs work
liquidcms’s picture

I tried removing the 2 deprecated (odd they are listed as being deprecated for 9.0 but i am running 8.8.8) calls to onEntityTypeDelete() and replaced with the newer version:

$listener = \Drupal::service('entity_type.listener');
$listener->onEntityTypeDelete($user_storage->getEntityType());

and now get this error on install:

[error] An error occurred while notifying the creation of the vid field storage definition: "!message" in Drupal\Core\Entity\Sql\SqlContentEntityStorage->wrapSchemaException() (line 1615 of E:\www\drupal8\web\core\lib\Drupal\Core\Entity\Sql\SqlContentEntityStorage.php).

hoanns’s picture

LOL I already fixed this all here 3months ago, but it was closed as outdated (I guess its not important that you can acutally install the module): https://www.drupal.org/project/user_revision/issues/3057189

Well now because of the new changes we can't apply the patch anymore, fixing this partly (only commit the User fix) like it was done here does not even fix the install, so its useless to commit that. My problem is that my fix gets closed as outdated without a solution available. It would be more intelligent to first use the fix until #3197068 is solved, so that an installation is even possible at all.

We get the same error on install as liquidcms but it works afterwards

hoanns’s picture

StatusFileSize
new1.68 KB

said patch for the newest version