@@ -258,23 +258,28 @@ public static function getServerSSL(): string
258258 /**
259259 * Returns default function for a particular column.
260260 *
261- * @param mixed[] $field Data about the column for which
262- * to generate the dropdown
263- * @param bool $insertMode Whether the operation is 'insert'
264- *
265261 * @return string An HTML snippet of a dropdown list with function
266262 * names appropriate for the requested column.
267- *
268- * @global mixed $data data of currently edited row
269- * (used to detect whether to choose defaults)
270- * @global array $cfg PMA configuration
271263 */
272- public static function getDefaultFunctionForField (array $ field , bool $ insertMode ): string
273- {
264+ public static function getDefaultFunctionForField (
265+ string $ trueType ,
266+ bool $ firstTimestamp ,
267+ string |null $ defaultValue ,
268+ string $ extra ,
269+ bool $ isNull ,
270+ string $ key ,
271+ string $ type ,
272+ bool $ insertMode ,
273+ ): string {
274+ // For uuid field, no default function
275+ if ($ trueType === 'uuid ' ) {
276+ return '' ;
277+ }
278+
274279 $ defaultFunction = '' ;
275280
276281 // Can we get field class based values?
277- $ currentClass = $ GLOBALS ['dbi ' ]->types ->getTypeClass ($ field [ ' True_Type ' ] );
282+ $ currentClass = $ GLOBALS ['dbi ' ]->types ->getTypeClass ($ trueType );
278283 if (! empty ($ currentClass ) && isset ($ GLOBALS ['cfg ' ]['DefaultFunctions ' ]['FUNC_ ' . $ currentClass ])) {
279284 $ defaultFunction = $ GLOBALS ['cfg ' ]['DefaultFunctions ' ]['FUNC_ ' . $ currentClass ];
280285 // Change the configured default function to include the ST_ prefix with MySQL 5.6 and later.
@@ -295,27 +300,22 @@ public static function getDefaultFunctionForField(array $field, bool $insertMode
295300 // and the column does not have the
296301 // ON UPDATE DEFAULT TIMESTAMP attribute.
297302 if (
298- ($ field [ ' True_Type ' ] === 'timestamp ' )
299- && $ field [ ' first_timestamp ' ]
300- && empty ( $ field [ ' Default ' ] )
301- && $ field [ ' Extra ' ] !== 'on update CURRENT_TIMESTAMP '
302- && $ field [ ' Null ' ] === ' NO '
303+ ($ trueType === 'timestamp ' )
304+ && $ firstTimestamp
305+ && ( $ defaultValue === null || $ defaultValue === '' )
306+ && $ extra !== 'on update CURRENT_TIMESTAMP '
307+ && ! $ isNull
303308 ) {
304309 $ defaultFunction = $ GLOBALS ['cfg ' ]['DefaultFunctions ' ]['first_timestamp ' ];
305310 }
306311
307- // For uuid field, no default function
308- if ($ field ['True_Type ' ] === 'uuid ' ) {
309- return '' ;
310- }
311-
312312 // For primary keys of type char(36) or varchar(36) UUID if the default
313313 // function
314314 // Only applies to insert mode, as it would silently trash data on updates.
315315 if (
316316 $ insertMode
317- && $ field [ ' Key ' ] === 'PRI '
318- && ($ field [ ' Type ' ] === 'char(36) ' || $ field [ ' Type ' ] === 'varchar(36) ' )
317+ && $ key === 'PRI '
318+ && ($ type === 'char(36) ' || $ type === 'varchar(36) ' )
319319 ) {
320320 return $ GLOBALS ['cfg ' ]['DefaultFunctions ' ]['FUNC_UUID ' ];
321321 }
@@ -326,16 +326,12 @@ public static function getDefaultFunctionForField(array $field, bool $insertMode
326326 /**
327327 * Creates a dropdown box with MySQL functions for a particular column.
328328 *
329- * @param mixed[] $field Data about the column for which to generate the dropdown
330- * @param bool $insertMode Whether the operation is 'insert'
331329 * @param mixed[] $foreignData Foreign data
332330 *
333331 * @return string An HTML snippet of a dropdown list with function names appropriate for the requested column.
334332 */
335- public static function getFunctionsForField (array $ field , bool $ insertMode , array $ foreignData ): string
333+ public static function getFunctionsForField (string $ defaultFunction , array $ foreignData ): string
336334 {
337- $ defaultFunction = self ::getDefaultFunctionForField ($ field , $ insertMode );
338-
339335 // Create the output
340336 $ retval = '<option></option> ' . "\n" ;
341337 // loop on the dropdown array and print all available options for that
0 commit comments