When deleting a previously emptied content type from the content types admin page (admin/content/types), I have twice recieved a fatal error and and a timeout message. When I reload the content type is no longer listed, but a table still exists for it in the database ().
I am running on Drupal 6.9
using Content Construction Kit (CCK) 6.x-2.1
MySQL database 5.0.67
PHP 5.2.6
| Comment | File | Size | Author |
|---|---|---|---|
| #2 | content.crud-376196.patch | 2.8 KB | nextdude |
Comments
Comment #1
timb commentedThe content type being deleted does share fields (text) in common with another CCK created content type. I had no problem deleting a content type that had only it's own fields. I just replicated by doing the following:
It hangs for awhile then I get this error: Fatal error: Maximum execution time of 30 seconds exceeded in ......../includes/database.mysqli.inc on line 108
As I said above, the content type will no longer be listed in drupal, but a table will still exist for it in the database (i.e. content_type_mycontent).
Comment #2
nextdude commentedI just ran into this myself. It is caused by the fact that when you delete a content type that has fields associated with it, the content module in turn deletes all those fields. The method responsible for deleting the fields from the {content_node_field_instance} table (content_field_instance_delete() in includes/content.crud.inc) does a whole bunch of schema altering, menu rebuilding and cache clearing stuff after deleting each field which causes a substantial delay (like 6 or 7 seconds on my box).
If only one field is getting deleted, like might be the case when you remove a particular field from a content type through the admin/content/types interface, this is fine. But if you're deleting the whole content type, performing these rebuilding/cache clearing actions on each and every field is clearly a waste. In particular, the content_field_instance_delete() method is calling content_clear_type_cache(TRUE) which forces drupal to rebuild the entire database schema for all tables, not just cck related tables. For a content type with more than a few fields, you can easily hit the default 30 second php execution limit.
I would probably argue that these admin functions should be entirely removed from the delete method and placed elsewhere. But, I wrote a more conservative patch for now. Attached is a patch to the 6.x-2.1 content module's content.crud.inc file to extend the content_field_instance_delete() method to add a third parameter that indicates whether you should perform all the rebuild/clearing actions or not. This $rebuild argument defaults to TRUE, preserving the current behavior. In those cases in content.crud.inc where several fields are being deleted at once and content_clear_type_cache(TRUE) is already being called afterwards (like when deleting a content type or all the content fields for a particular module), I've set the $rebuild arg to false. This removes the excessive delays for me.
I've only tested locally and not extensively, so YMMV.
Comment #3
timb commentedThanks Nextdude. After reading your great analysis of the issue I was facing, I was able to successfully delete the content type by first removing all fields that the content type used and then deleting the content type itself. This was w/o your patch. Thanks again.
Comment #4
lmaharas commentedI was just about to reinstall CCK since a few content-types I created didn't have the "delete" option available. But decided to go into the database to remove the unnecessary content-types instead. Here's what I did...
Log in to PHPMyAdmin where you are hosting your drupal Database.
1) from the table "uc_product_classes" delete the particular content types with the following SQL query...
SELECT * FROM `uc_product_classes` WHERE `name`="my-content-type"
Where 'my-content-type' is the name of the content type you are deleting. Then hit the red X to delete that row.
2) from the table "node_type" delete the particular content types with the following SQL query...
SELECT * FROM `node_type` WHERE `name` = "my-content-type"
Where 'my-content-type' is the name of the content type you are deleting. Then hit the red X to delete that row.
3) from the table "menu_links" delete the particular content types with the following SQL query...
SELECT * FROM `menu_links` WHERE `link_title` = "my-content-type"
Where 'my-content-type' is the name of the content type you are deleting. Then hit the red X to delete that row.
*Before doing this be sure to delete any nodes or content related to the content-type you want to delete to avoid errors. Additionally, be sure to 'flush all caches' to reload the correct content-types.
**Also be sure to put the correct query in based on your database names (some might have a "drupal_" before the table name).
Hope this helps someone.
//L
Comment #5
edleitch commentedhi all ,
i have created a content type and set the thumbnail to be required , and when i started to enter data i figured out that required is not good for me , so i went and remove the tick from required and suddenly an error appeared :
user warning: Got a packet bigger than 'max_allowed_packet' bytes query: UPDATE cache_views SET data
any help please
thanks