No announcement yet.

delete invalid nodes

  • Filter
  • Time
  • Show
Clear All
new posts

  • [CMS] delete invalid nodes


    I have some nodes that I want deleted from the node table because the contentid is no longer a valid id, since the source is deleted from it's source table.

    When I click on a category which contains one of these nodes, I get empty templates in my CMS and I can't delete them via the admincp or inline.

    Is there a way to safely delete nodes from the tables by using the CMS? I can easily identify the nodes that are invalid.

    Thanks in advance"

  • #2
    You should never change info in the database directly. Did you try the 'Verify and Repair Node Table' option in the Admin CP.
    Steve Machol, former vBulletin Customer Support Manager (and NOT retired!)
    Change CKEditor Colors to Match Style (for 4.1.4 and above)

    Steve Machol Photography

    Mankind is the only creature smart enough to know its own history, and dumb enough to ignore it.


    • #3
      Assuming you are comfortable in SQL, and with all the appropriate warnings and cautions (especially having a backup):

      Yes. Remembering that nodeid is the primary key for the cms_node table which is the primary one.

      If they are articles, you pull the contentid from TABLE_PREFIXcms_node and delete the record with that contentid from TABLE_PREFIXcms_article.

      If they are sections, delete from TABLE_PREFIXcms_nodecategory and TABLE_PREFIXcms_permissions with that nodeid. Delete from TABLE_PREFIXcms_sectionorder with that sectionid.

      Then delete records from TABLE_PREFIXcms_nodeconfig, TABLE_PREFIXcms_nodeinfo, TABLE_PREFIXcms_rate, TABLE_PREFIXcms_sectionorder, and TABLE_PREFIXcms_node with that nodeid.

      Then do a "verify and repair node table".

      But the question I would have is why? Unless you've done something major, the amount of space saved is small and there would be no particular benefit. And there's always risk when you're at the SQL prompt.
      Last edited by Edwin Brown; Fri 10 Dec '10, 12:12pm.
      Please- I'm not tech support. Don't send your problem reports to me unless I've asked you to.


      • #4
        @Steve Machol: Yes of course!

        Well, somehow they don't come up in the section, neither in de admincp under content, nor under content of the section. They DO however come up under categories or the CMS calendar. Another thing is that when they DO come up, all I see is some template info that is fixed and nothing from the content itself ... anyway, the SQL queries seem to have worked, but does this impact the nodeleft / noderight stuff? Don't know what that is used for ... I did run the verify and repair again ...

        Problem is that I am using custom content, so I am not using the cms_article table. When I delete from the website CMS, it deletes some information but apparently NOT in the nodecategory table nor the node table. Is there a delete function I should override for my custom content?

        So all I need to do in the future is FIRST delete the article / Custom Content and THEN delete the content / thread ... it works ok, but apparently not in deletion.

        The problem is that I might have this regularly, which means I need to program a plugin that when a thread is deleted that has extra content along, this content is deleted (should work already). This content has an ID which is in the contentid field of a node and then I should delete the node.

        Is there a function that deletes a node without all the trouble around it?
        Last edited by ZexTasy; Fri 10 Dec '10, 6:46pm.


        • #5
          If you're using a custom content type then you should create a custom data manager by extending /packages/vbcms/dm/node.php. Then create your own getTypeConditionalSQL, prepareFields, postSave and preDelete methods. Call it from your content class. Look at /packages/vbcms/dm/article.php and /packages/vbcms/content/article.php saveData() to see how we do it.
          Please- I'm not tech support. Don't send your problem reports to me unless I've asked you to.


          • #6
            Yes, I have done the most of that, except for the preDelete method ... thanks!


            • #7
              Cool! I know not a lot of people have created their own content types. Hope it's working for you.
              Please- I'm not tech support. Don't send your problem reports to me unless I've asked you to.


              widgetinstance 262 (Related Topics) skipped due to lack of content & hide_module_if_empty option.