@@ -255,6 +255,9 @@ function onBeforeUpdate() {
255255 }
256256 }
257257 unset($ old_record );
258+
259+ if (strlen ($ dbname_prefix . $ this ->dataRecord ['database_name ' ]) > 64 ) $ app ->tform ->errorMessage .= str_replace ('{db} ' ,$ dbname_prefix . $ this ->dataRecord ['database_name ' ],$ app ->tform ->wordbook ["database_name_error_len " ]).'<br /> ' ;
260+ if (strlen ($ dbuser_prefix . $ this ->dataRecord ['database_user ' ]) > 16 ) $ app ->tform ->errorMessage .= str_replace ('{user} ' ,$ dbuser_prefix . $ this ->dataRecord ['database_user ' ],$ app ->tform ->wordbook ["database_user_error_len " ]).'<br /> ' ;
258261
259262 if ($ app ->tform ->errorMessage == '' ){
260263 /* restrict the names if there is no error */
@@ -278,11 +281,17 @@ function onBeforeInsert() {
278281 $ global_config = $ app ->getconf ->get_global_config ('sites ' );
279282 $ dbname_prefix = replacePrefix ($ global_config ['dbname_prefix ' ], $ this ->dataRecord );
280283 $ dbuser_prefix = replacePrefix ($ global_config ['dbuser_prefix ' ], $ this ->dataRecord );
284+
285+ if (strlen ($ dbname_prefix . $ this ->dataRecord ['database_name ' ]) > 64 ) $ app ->tform ->errorMessage .= str_replace ('{db} ' ,$ dbname_prefix . $ this ->dataRecord ['database_name ' ],$ app ->tform ->wordbook ["database_name_error_len " ]).'<br /> ' ;
286+ if (strlen ($ dbuser_prefix . $ this ->dataRecord ['database_user ' ]) > 16 ) $ app ->tform ->errorMessage .= str_replace ('{user} ' ,$ dbuser_prefix . $ this ->dataRecord ['database_user ' ],$ app ->tform ->wordbook ["database_user_error_len " ]).'<br /> ' ;
287+
281288
282289 /* restrict the names */
283290 /* crop user and db names if they are too long -> mysql: user: 16 chars / db: 64 chars */
284- $ this ->dataRecord ['database_name ' ] = substr ($ dbname_prefix . $ this ->dataRecord ['database_name ' ], 0 , 64 );
285- $ this ->dataRecord ['database_user ' ] = substr ($ dbuser_prefix . $ this ->dataRecord ['database_user ' ], 0 , 16 );
291+ if ($ app ->tform ->errorMessage == '' ){
292+ $ this ->dataRecord ['database_name ' ] = substr ($ dbname_prefix . $ this ->dataRecord ['database_name ' ], 0 , 64 );
293+ $ this ->dataRecord ['database_user ' ] = substr ($ dbuser_prefix . $ this ->dataRecord ['database_user ' ], 0 , 16 );
294+ }
286295
287296 parent ::onBeforeInsert ();
288297 }
0 commit comments