Problem/Motivation
Trying to install varbase.
Steps to reproduce
Install varbase, using Drupal-VM with postgresql as the database. Enabled most of the extra components (all but SSO & Google).
Get an error:
An AJAX HTTP error occurred.
HTTP Result Code: 200
Debugging information follows.
Path: /core/install.php?rewrite=ok&profile=varbase&langcode=en&id=3&op=do_nojs&op=do
StatusText: OK
ResponseText: Drupal\Core\Entity\EntityStorageException: SQLSTATE[23502]: Not null violation: 7 ERROR: null value in column "lid" violates not-null constraint
DETAIL: Failing row contains (null, user, update, <none>, 1, webmaster, <em class="placeholder">webmaster</em> (uid <em class="placehold..., 0, 192.168.88.1, 1601936279).: INSERT INTO admin_audit_trail (lid, type, operation, description, created, uid, ip, path, ref_char, ref_numeric) VALUES (:db_insert_placeholder_0, :db_insert_placeholder_1, :db_insert_placeholder_2, :db_insert_placeholder_3, :db_insert_placeholder_4, :db_insert_placeholder_5, :db_insert_placeholder_6, :db_insert_placeholder_7, :db_insert_placeholder_8, :db_insert_placeholder_9); Array
(
)
in Drupal\Core\Entity\Sql\SqlContentEntityStorage->save() (line 846 of /web/www/docroot/core/lib/Drupal/Core/Entity/Sql/SqlContentEntityStorage.php).The apache error log includes:
[Mon Oct 05 21:31:09.127475 2020] [proxy_fcgi:error] [pid 46160:tid 140718043535104] [client 192.168.88.1:54880] AH01071: Got error 'PHP message: Drupal\\Core\\Entity\\EntityStorageException: SQLSTATE[23502]: Not null violation: 7 ERROR: null value in column "lid" violates not-null constraint\nDETAIL: Failing row contains (null, user, update, <none>, 1, webmaster, <em class="placeholder">webmaster</em> (uid <em class="placehold..., 0, 192.168.88.1, 1601933427).: INSERT INTO admin_audit_trail (lid, type, operation, description, created, uid, ip, path, ref_char, ref_numeric) VALUES (:db_insert_placeholder_0, :db_insert_placeholder_1, :db_insert_placeholder_2, :db_insert_placeholder_3, :db_insert_placeholder_4, :db_insert_placeholder_5, :db_insert_placeholder_6, :db_insert_placeholder_7, :db_insert_placeholder_8, :db_insert_placeholder_9); Array\n(\n)\n in /web/www/docroot/core/lib/Drupal/Core/Entity/Sql/SqlContentEntityStorage.php on line 846 #0 /web/www/docroot/core/lib/Drupal/Core/Entity/EntityBase.php(395): Drupal\\Core\\Entity\\Sql\\SqlContentEntityStorage->save(Object(Drupal\\user\\Entity\\User))\n#1 /web/www/docroot/modules/contrib/varb...', referer: http://gerpeople.test/core/install.php?rewrite=ok&profile=varbase&langcode=en&id=3&op=start
When I try to visit the module's admin page, I get a bare error page and:
[Mon Oct 05 22:03:33.132977 2020] [proxy_fcgi:error] [pid 46159:tid 140717934429952] [client 192.168.88.1:55818] AH01071: Got error 'PHP message: Uncaught PHP Exception Drupal\\Core\\Database\\DatabaseExceptionWrapper: "SQLSTATE[42P01]: Undefined table: 7 ERROR: relation "admin_audit_trail" does not exist\nLINE 5: admin_audit_trail e) subquery\n ^: SELECT COUNT(*) AS expression\nFROM\n(SELECT 1 AS expression\nFROM\n{admin_audit_trail} e) subquery; Array\n(\n)\n" at /web/www/docroot/core/lib/Drupal/Core/Database/Connection.php line 701', referer: http://gerpeople.test/admin/help/admin_audit_trail
Proposed resolution
Remaining tasks
User interface changes
API changes
Data model changes
| Comment | File | Size | Author |
|---|---|---|---|
| #25 | Issue_3175052.patch | 1.7 KB | rushikesh raval |
| #21 | Screenshot 2023-09-30 at 17-57-23 Admin audit trails Test Website.png | 319.4 KB | rushikesh raval |
| #10 | 3175052-01.patch | 1.83 KB | juanp.rey.z |
Issue fork admin_audit_trail-3175052
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
Comment #2
rivimeyJust to add: retried but not enabling any of the extra components... no change in the bug.
Ubuntu is 20.04; PHP is 7.4; postgresql is v12 ubuntu.
Comment #3
alfakom commentedI had the same error: Debian 9 / PHP 7.3.19-1 / Postgresql 11.9
Comment #4
rajab natshahComment #5
rivimeyIt would help if the module enabled a pgsql and sqlite test in the Automated Tests section.
Comment #6
rajab natshahThank you Ruth for reporting and following.
Good Idea about the Automated Tests
Enabling the Automated Tests config options for DrupalCI
Comment #7
rajab natshahActivated
https://www.drupal.org/node/3152933/qa
Any patch will be very much welcomed. To run the automated tests and have a green build and tests in all options
Comment #8
rivimeyHi,
I have had another look through the source, and suspect the culprit is the following statement from the main .module file:
Invoking a merge requires that the key fields are set in the provided data, as otherwise a merge cannot happen. In this case, 'lid' is the key field but has no value.
I don't see why a merge is needed in this case: even the function docs say 'insert'. So I suggest this code is altered to a simple insert.
Re Tests, I hadn't previously noted that there are in fact no tests specified for this module. Setting that up would be very beneficial, but is outside the scope of this bug-fix.
Comment #9
rivimeyThis issue is of course a duplicate of #3094617: Postgres error not null constraint violation gives me an wsod
which states pretty much exactly the same problem, suggested solution, and suggested patch.
Comment #10
juanp.rey.z commentedLet´s check this patch according to rivimey #9.
Comment #11
rajab natshahComment #12
rajab natshahComment #13
rivimeyJuan, long time but here's a review for that patch.
is_null() is a subset of empty(), so only one of them is required here.
However empty("0") is True, so it might be best to use !isset(), which tests for non-existence and NULLness but not FALSE or 0.
Shouldn't be changing [] into array(), twice
Create a named array just before the 'if' with this content, and then use it.
Comment #16
orkutmuratyilmazAny updates on this issue?
Comment #17
rivimeyarg-paul's branch change looks fine to me (https://git.drupalcode.org/project/admin_audit_trail/-/merge_requests/2....) (RTBC), but needs updating as it can no longer be committed.
Probably updating the base branch will do.
Comment #18
orkutmuratyilmaz@arg-paul, can you update the base branch you've forked?
Comment #21
rushikesh raval commentedComment #22
rajab natshahNoted; to be re-tested for sure.
with PHP 8.1 and PHP 8.2
Comment #23
rajab natshahComment #24
rajab natshahLatest fix by Rushikesh, looks good.
Only the issue fork needs to be updated to latest code from the
1.0.xbranch.Or it could be uploaded as a patch for the 1.0.x branch, not the tag release.
Having one more testing round.
Comment #25
rushikesh raval commented@Rajab Natsha code is tested on PHP8.2 and postgresql.
I am not able to update fork, its giving error.
I think you may be able update fork from your side, I have attached patch herewith.
Comment #26
rajab natshahI like your fix Rushikesh.
Committing your patch and having a follow up release.
Comment #28
rajab natshahComment #29
rajab natshahComment #30
orkutmuratyilmaz@Rajab Natshah, thanks for the fix:)
Comment #31
rajab natshahComment #32
rajab natshah✅ Released admin_audit_trail-1.0.2