Browse code

update fix - more fields in the same table

Jimako authored on 2024/04/13 03:29:20
Showing 1 changed files
... ...
@@ -94,27 +94,53 @@ if ($oldVersion[0] == 3 && ($oldVersion[1] < 5 || $oldVersion[2] < 6))  //3.5.5
94 94
 		{
95 95
 
96 96
 			// List of DB tables (key) and field (value) which need changing to accommodate datetime field
97
+			// List of DB tables (key) and field (value) which need changing date from datetime/timestamp to int
97 98
 			$date_upgrade = array(
98
-				'fanfiction_authors' => 'date',
99
-				'fanfiction_comments'  => 'time',
100
-				'fanfiction_reviews' => 'date',
101
-				'fanfiction_stories'  => 'date',
102
-				'fanfiction_stories' => 'updated',
103
-				'fanfiction_news' => 'time',
104
-				'fanfiction_poll' => 'poll_start',
105
-				'fanfiction_poll' => 'poll_end',
99
+				array('table' => 'fanfiction_authors', 'field' => 'date'),
100
+				array(
101
+					'table' =>
102
+					'fanfiction_comments', 'field'  => 'time'
103
+				),
104
+				array(
105
+					'table' =>
106
+					'fanfiction_reviews', 'field' => 'date'
107
+				),
108
+				array(
109
+					'table' =>
110
+					'fanfiction_stories', 'field'  => 'date'
111
+				),
112
+				array(
113
+					'table' =>
114
+					'fanfiction_stories', 'field' => 'updated'
115
+				),
116
+				array(
117
+					'table' =>
118
+					'fanfiction_news', 'field' => 'time'
119
+				),
120
+				array(
121
+					'table' =>
122
+					'fanfiction_poll', 'field' => 'poll_start'
123
+				),
124
+				array(
125
+					'table' =>
126
+					'fanfiction_poll', 'field' => 'poll_end'
127
+				),
106 128
 			);
107 129
 
108 130
 			// Tables where IP address field needs updating to accommodate IPV6
109 131
 			// Set to varchar(45) - just in case something uses the IPV4 subnet (see http://en.wikipedia.org/wiki/IPV6#Notation)
110
-			foreach ($date_upgrade as $t => $f)
132
+			foreach ($date_upgrade as $tmp)
111 133
 			{
134
+
135
+				$t = $tmp['table'];
136
+				$f = $tmp['field'];
112 137
 				if (isTable($t))
113 138
 				{
114 139
 
115 140
 					// Check for table - might add some core plugin tables in here
116 141
 					if ($field_info =  dbassoc(dbquery("SHOW COLUMNS FROM " . TABLEPREFIX . $t . " LIKE '{$f}'")))
117 142
 					{ 
143
+
118 144
 						if (strtolower($field_info['Type']) == 'datetime')
119 145
 						{
120 146
 
... ...
@@ -244,27 +270,46 @@ function do_version_check_355() {
244 270
 	$check_355 = false;
245 271
 
246 272
 	// List of DB tables (key) and field (value) which need changing date from datetime/timestamp to int
247
-	$date_upgrade = array(
248
-		'fanfiction_authors' => 'date',
249
-		'fanfiction_comments'  => 'time',
250
-		'fanfiction_reviews' => 'date',
251
-		'fanfiction_stories'  => 'date',
252
-		'fanfiction_stories' => 'updated',
253
-		'fanfiction_news' => 'time',
254
-		'fanfiction_poll' => 'poll_start',
255
-		'fanfiction_poll' => 'poll_end',
273
+	$date_upgrade = array(	
274
+		array('table'=>'fanfiction_authors', 'field' => 'date'),
275
+		array(
276
+			'table' =>
277
+			'fanfiction_comments', 'field'  => 'time'),
278
+			array(
279
+			'table' =>
280
+			'fanfiction_reviews', 'field' => 'date'),
281
+				array(
282
+			'table' =>
283
+			'fanfiction_stories', 'field'  => 'date'),
284
+					array(
285
+			'table' =>
286
+			'fanfiction_stories', 'field' => 'updated'),
287
+						array(
288
+			'table' =>
289
+			'fanfiction_news', 'field' => 'time'),
290
+							array(
291
+			'table' =>
292
+			'fanfiction_poll', 'field' => 'poll_start'),
293
+								array(
294
+			'table' =>
295
+			'fanfiction_poll', 'field' => 'poll_end'),
256 296
 	);
257 297
 
258
-	foreach ($date_upgrade as $t => $f)
298
+	foreach ($date_upgrade as $tmp)
259 299
 	{
260 300
 
301
+		$t = $tmp['table'];
302
+		$f = $tmp['field'];
261 303
 		if (isTable($t))
262 304
 		{
263 305
 
264 306
 			// Check for table - might add some core plugin tables in here
265 307
 			if ($field_info =  dbassoc(dbquery("SHOW COLUMNS FROM " . TABLEPREFIX . $t . " LIKE '{$f}'")))
266 308
 			{
267
-
309
+				// echo "<pre>";
310
+				// print_r($t);
311
+				// print_r($field_info);
312
+				// echo "</pre>";
268 313
 				if (strtolower($field_info['Type']) != 'int' 
269 314
 				&& strtolower($field_info['Type']) != 'int(10)'
270 315
 				&& strtolower($field_info['Type']) != 'int(11)'