From b6164a4cb7db9cd61caceaea2c36a377ffe7f94d Mon Sep 17 00:00:00 2001
From: Dries Buytaert <dries@buytaert.net>
Date: Wed, 14 Oct 2009 01:01:54 +0000
Subject: [PATCH] - Patch #586436 by Amitaibu: execute node_type_save() after
 variable_set().

---
 modules/node/content_types.inc | 10 ++++++----
 1 file changed, 6 insertions(+), 4 deletions(-)

diff --git a/modules/node/content_types.inc b/modules/node/content_types.inc
index 4634d62e5380..a0e0d0607e6e 100644
--- a/modules/node/content_types.inc
+++ b/modules/node/content_types.inc
@@ -37,7 +37,7 @@ function node_overview_types() {
   if (empty($rows)) {
     $rows[] = array(array('data' => t('No content types available. <a href="@link">Add content type</a>.', array('@link' => url('admin/structure/types/add'))), 'colspan' => '5', 'class' => array('message')));
   }
-  
+
   $build['node_table'] = array(
     '#theme' => 'table',
     '#header' => $header,
@@ -199,7 +199,7 @@ function node_type_form($form, &$form_state, $type = NULL) {
     '#description' => t('Enable the <em>submitted by Username on date</em> text.'),
   );
   $form['display']['teaser_length'] = array(
-    '#type' => 'select', 
+    '#type' => 'select',
     '#title' => t('Length of trimmed posts'),
     '#default_value' => variable_get('teaser_length_' . $type->type, 600),
     '#options' => drupal_map_assoc(array(0, 200, 400, 600, 800, 1000, 1200, 1400, 1600, 1800, 2000), '_node_characters'),
@@ -323,8 +323,6 @@ function node_type_form_submit($form, &$form_state) {
     return;
   }
 
-  $status = node_type_save($type);
-
   $variables = $form_state['values'];
 
   // Remove everything that's been saved already - whatever's left is assumed
@@ -352,6 +350,10 @@ function node_type_form_submit($form, &$form_state) {
     }
   }
 
+  // Saving the content type after saving the variables allows modules to act
+  // on those variables via hook_node_type_insert().
+  $status = node_type_save($type);
+
   node_types_rebuild();
   menu_rebuild();
   $t_args = array('%name' => $type->name);
-- 
GitLab