Counter module Column 'nid' cannot be null

Error:

  1. PDOException: SQLSTATE[23000]: Integrity constraint violation: 1048 Column 'nid' cannot be null: INSERT INTO {counter} (ip,created,url, uid, nid, type, browser_name, browser_version, platform) VALUES (:ip, :created, :url, :uid, :nid, :type, :browser_name, :browser_version, :platform); Array ( [:ip] => my_ip [:created] => 1427207343 [:url] => /node/132424 [:uid] => 1 [:nid] => [:type] => [:browser_name] => Mozilla Firefox [:browser_version] => 35.0 [:platform] => Linux ) in counter_block_view() (line 183 of /sites/all/modules/counter/counter.module).

solution:

  1. diff --git a/web/sites/all/modules/counter/counter.module b/web/sites/all/modules/counter/counter.module
  2. index 64091ff..a983a8b 100644
  3. --- a/web/sites/all/modules/counter/counter.module
  4. +++ b/web/sites/all/modules/counter/counter.module
  5. @@ -152,7 +152,7 @@ function counter_block_view($delta = '') {
  6. $node = menu_get_object();
  7. $nid = 0;
  8. $type = '';
  9. - if (arg(0) == 'node' && is_numeric(arg(1))) {
  10. + if (arg(0) == 'node' && is_numeric(arg(1)) && is_object($node)) {
  11. $nid = $node->nid;
  12. $type = $node->type;
  13. }


Article Information
Article ID Categories Tags Levels Status
#33
Free
Solved