Problem/Motivation
PHP fatal error:
NOTICE: PHP message: PHP Fatal error: Uncaught Error: Call to a member function prepare() on null in /var/www/html/web/core/lib/Drupal/Core/Database/StatementWrapper.php:49
Stack trace:
#0 /var/www/html/web/core/lib/Drupal/Core/Database/Connection.php(562): Drupal\Core\Database\StatementWrapper->__construct()
#1 /var/www/html/web/core/lib/Drupal/Core/Database/Connection.php(861): Drupal\Core\Database\Connection->prepareStatement()
#2 /var/www/html/web/core/lib/Drupal/Core/Database/Driver/mysql/Insert.php(32): Drupal\Core\Database\Connection->query()
#3 /var/www/html/web/core/lib/Drupal/Core/Lock/DatabaseLockBackend.php(77): Drupal\Core\Database\Driver\mysql\Insert->execute()
#4 /var/www/html/web/core/lib/Drupal/Core/ProxyClass/Lock/DatabaseLockBackend.php(75): Drupal\Core\Lock\DatabaseLockBackend->acquire()
#5 /var/www/html/web/core/lib/Drupal/Core/TempStore/PrivateTempStore.php(136): Drupal\Core\ProxyClass\Lock\DatabaseLockBackend->acquire()
#6 /var/www/html/web/modules/contrib/google_tag_events/src/GoogleTagEvents.php(183): Drupal\Core\TempStore\PrivateTempStore->set()
#7 /var/www/html/web/modules/contrib/google_tag_events/src/GoogleTagEvents.php(175): Drupal\google_tag_events\GoogleTagEvents->saveEvents()
#8 [internal function]: Drupal\google_tag_events\GoogleTagEvents->__destruct()
#9 {main}
thrown in /var/www/html/web/core/lib/Drupal/Core/Database/StatementWrapper.php on line 49
Steps to reproduce
1. Install dev version;
2. Enable google_tag container, open any page;
3. Check php errors.log (possibly it willn't reported on watchdog).
Proposed resolution
Remove $this->saveEvents call on __destruct function, since temporary storage deleted from memory at this moment.
Another changes
setEvent function, $save_to_tempstore variable now by default is TRUE, so in most cases, the events will saved to temp storage.
Comments
Comment #3
validoll commentedFixed. Thanks!