node_install() creates node_access record that violates constraint

Created on 27 July 2012, almost 13 years ago
Updated 19 March 2025, about 2 months ago

When Drupal is installed, node_install() creates a record in the node_access table with nid = 0. Zero is not a valid value for nid and violates the foreign key constraint declared in node_schema(). The default should be stored some other way or a default node with nid = 0 should be added to the node table.

🐛 Bug report
Status

Needs work

Version

11.0 🔥

Component

node system

Created by

🇨🇦Canada Liam Morland Ontario, CA 🇨🇦

Live updates comments and jobs are added and updated live.
Sign in to follow issues

Merge Requests

Comments & Activities

Not all content is available!

It's likely this issue predates Contrib.social: some issue and comment data are missing.

  • First commit to issue fork.
  • Merge request !11542Issue #1703222: Remove nid 0 population → (Open) created by acbramley
  • 🇦🇺Australia acbramley

    This definitely should be solved but as per #10 this seems baked into the node grants system?

  • Pipeline finished with Failed
    about 2 months ago
    Total: 177s
    #452722
  • Pipeline finished with Failed
    about 2 months ago
    Total: 1060s
    #452727
  • 🇦🇺Australia acbramley

    Looking into this further, I'm not really sure how we would even start to unpick this. It's much more baked in than just node_install

    1. NodeGrantDatabaseStorage::writeDefault does the same thing. This is called from NodeAccessControlHandler::writeDeafultGrant which is called by node_access_rebuild when there are no hook_node_grants implementations
    2. In NodeGrantDatabaseStorage::access we specifically add an OR condition on nid = 0 when the node is published

Production build 0.71.5 2024