views:

199

answers:

2

I have some nodes that I have manually written to the database. (Don't ask why; it's easier than other options.) They show up fine on the Content List at http://www.domain.com/admin/content/node/overview. However, when I go to that node's page (http://www.domain.com/node/2582/view, where 2582 is the nid of the node in question), I get a page not found error. What could be causing this?

Here is such a node in the database (exported from PHPMyAdmin as XML)

<node>
<!-- node table -->
    <nid>2587</nid>
    <vid>2588</vid>
    <type>bout</type>
    <language>en</language>
    <title>the title 8</title>
    <uid>0</uid>
    <status>1</status>
    <created>0</created>
    <changed>0</changed>
    <comment>0</comment>
    <promote>0</promote>
    <moderate>0</moderate>
    <sticky>0</sticky>
    <tnid>0</tnid>
    <translate>0</translate>
<!-- content_type_bout table -->
    <vid>2588</vid>
    <nid>2587</nid>
    <field_fencer_uid>8</field_fencer_uid>
    <field_touches_scored_value>5</field_touches_scored_value>
    <field_touches_received_value>2</field_touches_received_value>
    <field_meet_nid>2583</field_meet_nid>
    <field_round_value>3</field_round_value>
    <field_legacy_bout_value>0</field_legacy_bout_value>
<!-- term_node table -->
    <nid>2587</nid>
    <vid>2588</vid>
    <tid>29</tid>
</node>
A: 

Look ok to me. I go to that page and it says access denied, but not page not found. I don't know if you need /view on the end of the URL or not.

Brian T Hannan
viewing the nodes is prohibited for Anon users. But when I go to it, with permission to view, it says page not found.
Rosarch
+2  A: 

In your example, the nid is 2587, while the vid (version id from the revisions table) is 2588. Now this could well be OK, if you use revisions and node 2587 itself or some older node has been updated once already - otherwise it might be a problem, as without any revisions ever created, both should be the same.

So you should check the entries in your revisions table - every node should have at least one corresponding entry (node_nid == revision_nid) there, with the vid equal or higher than the nid.

If you insert new nodes manually, you need to create a corresponding revision as well, with the vid set to the next available value (will happen automatically, as it is a serial).

(NOTE: Edited slightly, as the the initial answer contained an erroneous assumption about the nid<>vid relation)

Henrik Opel
Ok, but what if another node already has a vid of the nid I want to use? Does this mean I have to keep incrementing nid until it is greater than all existing nids, and all existing vids?
Rosarch
Oups - No, it doesn't mean that. I was in error, as I thought the revisions table had a combined primary key of nid and vid, but it is only the vid! So a new node (or new revision of an existing node) just gets the next free vid. Will edit answer accordingly.
Henrik Opel
Ok, edited. So now it just boils down to 'make sure you have created proper revisions for your nodes', which you seem to have, so that is probably not the culprit. Sorry for the confusion :/
Henrik Opel
+1. the lack of revision. it solved my problem. thanks.
takpar