Get rid of create_function in favor of anonymous functions Cleanup install code
jdarwood007

jdarwood007 commited on 2016-12-26 09:04:21
Showing 2 changed files, with 35 additions and 35 deletions.


Signed-off-by: jdarwood007 <unmonitored+github@sleepycode.com>
... ...
@@ -109,8 +109,9 @@ function sd_initialize_install()
109 109
 	if (SMF == 'SSI')
110 110
 		db_extend('packages');
111 111
 
112
-	// We have a lot to do. Make sure as best we can that we have the time to do so.
113
-	@set_time_limit(600);
112
+	// We have a lot to do. Make sure as best we can that we have the time to do so. But only if the function wasn't disabled.
113
+	if (function_exists('set_time_limit'))
114
+		set_time_limit(600);
114 115
 }
115 116
 
116 117
 /*
... ...
@@ -604,14 +605,14 @@ function sd_get_install_tables()
604 605
 			db_field('field_loc', 'tinyint'),
605 606
 			db_field('icon', 'varchar', 20),
606 607
 			db_field('field_type', 'tinyint'),
607
-			db_field('field_length', 'smallint', 5, 255),
608
+			db_field('field_length', 'smallint', 5, true),
608 609
 			db_field('field_options', 'text'),
609 610
 			db_field('bbc', 'tinyint'),
610 611
 			db_field('default_value', 'varchar', 255),
611
-			db_field('can_see', 'varchar', 3, '0,0'),
612
-			db_field('can_edit', 'varchar', 3, '0,0'),
612
+			db_field('can_see', 'varchar', 3),
613
+			db_field('can_edit', 'varchar', 3),
613 614
 			db_field('display_empty', 'tinyint'),
614
-			db_field('placement', 'tinyint', 0, 1),
615
+			db_field('placement', 'tinyint', 0, true),
615 616
 		),
616 617
 		'indexes' => array(
617 618
 			array(
... ...
@@ -151,27 +151,26 @@ function shd_admin_browse_attachments($list_title = '')
151 151
 					'value' => $txt['attachment_name'],
152 152
 				),
153 153
 				'data' => array(
154
-					'function' => create_function('$rowData', '
154
+					'function' => function($rowData)
155
+					{
155 156
 						global $modSettings, $context, $scripturl;
156 157
 
157
-						$link = \'<a href="\';
158
-
159
-						$link .= sprintf(\'%1$s?action=dlattach;ticket=%2$d.0;id=%3$d\', $scripturl, $rowData[\'id_ticket\'], $rowData[\'id_attach\']);
160
-
161
-						$link .= \'"\';
158
+						$link = '<a href="';
159
+						$link .= sprintf('%1$s?action=dlattach;ticket=%2$d.0;id=%3$d', $scripturl, $rowData['id_ticket'], $rowData['id_attach']);
160
+						$link .= '"';
162 161
 
163 162
 						// Show a popup on click if it\'s a picture and we know its dimensions.
164
-						if (!empty($rowData[\'width\']) && !empty($rowData[\'height\']))
165
-							$link .= sprintf(\' onclick="return reqWin(this.href + \\\';image\\\', %1$d, %2$d, true);"\', $rowData[\'width\'] + 20, $rowData[\'height\'] + 20);
163
+						if (!empty($rowData['width']) && !empty($rowData['height']))
164
+							$link .= sprintf(' onclick="return reqWin(this.href + \';image\', %1$d, %2$d, true);"', $rowData['width'] + 20, $rowData['height'] + 20);
166 165
 
167
-						$link .= sprintf(\'>%1$s</a>\', preg_replace(\'~&amp;#(\\\\d{1,7}|x[0-9a-fA-F]{1,6});~\', \'&#\\\\1;\', htmlspecialchars($rowData[\'filename\'])));
166
+						$link .= sprintf('>%1$s</a>', preg_replace('~&amp;#(\d{1,7}|x[0-9a-fA-F]{1,6});~', '&#\1;', htmlspecialchars($rowData['filename'])));
168 167
 
169 168
 						// Show the dimensions.
170
-						if (!empty($rowData[\'width\']) && !empty($rowData[\'height\']))
171
-							$link .= sprintf(\' <span class="smalltext">%1$dx%2$d</span>\', $rowData[\'width\'], $rowData[\'height\']);
169
+						if (!empty($rowData['width']) && !empty($rowData['height']))
170
+							$link .= sprintf(' <span class="smalltext">%1$dx%2$d</span>', $rowData['width'], $rowData['height']);
172 171
 
173 172
 						return $link;
174
-					'),
173
+					},
175 174
 				),
176 175
 				'sort' => array(
177 176
 					'default' => 'a.filename',
... ...
@@ -183,11 +182,12 @@ function shd_admin_browse_attachments($list_title = '')
183 182
 					'value' => $txt['attachment_file_size'],
184 183
 				),
185 184
 				'data' => array(
186
-					'function' => create_function('$rowData','
185
+					'function' => function($rowData)
186
+					{
187 187
 						global $txt;
188 188
 
189
-						return sprintf(\'%1$s%2$s\', round($rowData[\'size\'] / 1024, 2), $txt[\'kilobyte\']);
190
-					'),
189
+						return sprintf('%1$s%2$s', round($rowData['size'] / 1024, 2), $txt['kilobyte']);
190
+					},
191 191
 					'class' => 'windowbg',
192 192
 				),
193 193
 				'sort' => array(
... ...
@@ -200,11 +200,10 @@ function shd_admin_browse_attachments($list_title = '')
200 200
 					'value' => $txt['posted_by'],
201 201
 				),
202 202
 				'data' => array(
203
-					'function' => create_function('$rowData', '
204
-						global $scripturl;
205
-
206
-						return htmlspecialchars($rowData[\'poster_name\']);
207
-					'),
203
+					'function' => function($rowData)
204
+					{
205
+						return htmlspecialchars($rowData['poster_name']);
206
+					},
208 207
 				),
209 208
 				'sort' => array(
210 209
 					'default' => 'mem.real_name',
... ...
@@ -216,11 +215,12 @@ function shd_admin_browse_attachments($list_title = '')
216 215
 					'value' => $txt['date'],
217 216
 				),
218 217
 				'data' => array(
219
-					'function' => create_function('$rowData', '
220
-						global $txt, $context, $scripturl;
218
+					'function' => function($rowData)
219
+					{
220
+						global $txt;
221 221
 
222
-						return empty($rowData[\'poster_time\']) ? $txt[\'never\'] : timeformat($rowData[\'poster_time\']);
223
-						'),
222
+						return empty($rowData['poster_time']) ? $txt['never'] : timeformat($rowData['poster_time']);
223
+					},
224 224
 					'class' => 'windowbg',
225 225
 				),
226 226
 				'sort' => array(
... ...
@@ -233,11 +233,10 @@ function shd_admin_browse_attachments($list_title = '')
233 233
 					'value' => $txt['downloads'],
234 234
 				),
235 235
 				'data' => array(
236
-					'function' => create_function('$rowData','
237
-						global $txt;
238
-
239
-						return comma_format($rowData[\'downloads\']);
240
-					'),
236
+					'function' => function($rowData)
237
+					{
238
+						return comma_format($rowData['downloads']);
239
+					},
241 240
 					'class' => 'windowbg',
242 241
 				),
243 242
 				'sort' => array(
244 243