@@ -160,7 +160,7 @@ public function handleRequestCreateOrEdit(string $db): string
160160 /**
161161 * Backup the privileges
162162 *
163- * @return mixed []
163+ * @return string[] []
164164 */
165165 public function backupPrivileges (): array
166166 {
@@ -176,21 +176,20 @@ public function backupPrivileges(): array
176176
177177 $ privilegesBackupQuery = 'SELECT * FROM ' . Util::backquote ('mysql ' )
178178 . '. ' . Util::backquote ('procs_priv ' )
179- . ' where Routine_name = " ' . $ _POST ['item_original_name ' ]
180- . '" AND Routine_type = " ' . $ _POST ['item_original_type ' ]
181- . '"; ' ;
179+ . ' WHERE Routine_name = ' . $ this ->dbi ->quoteString ($ _POST ['item_original_name ' ])
180+ . ' AND Routine_type = ' . $ this ->dbi ->quoteString ($ _POST ['item_original_type ' ]);
182181
183182 return $ this ->dbi ->fetchResult ($ privilegesBackupQuery , 0 );
184183 }
185184
186185 /**
187186 * Create the routine
188187 *
189- * @param string $routineQuery Query to create routine
190- * @param string $createRoutine Query to restore routine
191- * @param mixed [] $privilegesBackup Privileges backup
188+ * @param string $routineQuery Query to create routine
189+ * @param string $createRoutine Query to restore routine
190+ * @param string[] [] $privilegesBackup Privileges backup
192191 *
193- * @return mixed[]
192+ * @return array{string[], Message|null}
194193 */
195194 public function create (
196195 string $ routineQuery ,
@@ -211,7 +210,15 @@ public function create(
211210 // Try to restore the backup query
212211 $ result = $ this ->dbi ->tryQuery ($ createRoutine );
213212 if (! $ result ) {
214- $ errors = $ this ->checkResult ($ createRoutine , $ errors );
213+ // OMG, this is really bad! We dropped the query,
214+ // failed to create a new one
215+ // and now even the backup query does not execute!
216+ // This should not happen, but we better handle
217+ // this just in case.
218+ $ errors [] = __ ('Sorry, we failed to restore the dropped routine. ' ) . '<br> '
219+ . __ ('The backed up query was: ' )
220+ . '" ' . htmlspecialchars ($ createRoutine ) . '"<br> '
221+ . __ ('MySQL said: ' ) . $ this ->dbi ->getError ();
215222 }
216223
217224 return [$ errors , null ];
@@ -227,13 +234,13 @@ public function create(
227234 $ adjustProcPrivilege = 'INSERT INTO '
228235 . Util::backquote ('mysql ' ) . '. '
229236 . Util::backquote ('procs_priv ' )
230- . ' VALUES(" ' . $ priv [0 ] . '", " '
231- . $ priv [1 ] . '", " ' . $ priv [2 ] . '", " '
232- . $ _POST ['item_name ' ] . '", " '
233- . $ _POST ['item_type ' ] . '", " '
234- . $ priv [5 ] . '", " '
235- . $ priv [6 ] . '", " '
236- . $ priv [7 ] . '" ); ' ;
237+ . ' VALUES( ' . $ this -> dbi -> quoteString ( $ priv [0 ]) . ', '
238+ . $ this -> dbi -> quoteString ( $ priv [1 ]) . ', ' . $ this -> dbi -> quoteString ( $ priv [2 ]) . ', '
239+ . $ this -> dbi -> quoteString ( $ _POST ['item_name ' ]) . ', '
240+ . $ this -> dbi -> quoteString ( $ _POST ['item_type ' ]) . ', '
241+ . $ this -> dbi -> quoteString ( $ priv [5 ]) . ', '
242+ . $ this -> dbi -> quoteString ( $ priv [6 ]) . ', '
243+ . $ this -> dbi -> quoteString ( $ priv [7 ]) . '); ' ;
237244 $ this ->dbi ->query ($ adjustProcPrivilege );
238245 $ resultAdjust = true ;
239246 }
@@ -1010,11 +1017,11 @@ public function handleExecuteRoutine(array $routine): array
10101017 /**
10111018 * Browse row array
10121019 *
1013- * @param mixed [] $row Columns
1020+ * @param (string|null) [] $row Columns
10141021 */
1015- private function browseRow (array $ row ): string | null
1022+ private function browseRow (array $ row ): string
10161023 {
1017- $ output = null ;
1024+ $ output = '' ;
10181025 foreach ($ row as $ value ) {
10191026 if ($ value === null ) {
10201027 $ value = '<i>NULL</i> ' ;
@@ -1195,27 +1202,6 @@ public function getRow(Routine $routine, string $rowClass = ''): array
11951202 ];
11961203 }
11971204
1198- /**
1199- * @param string $createStatement Query
1200- * @param mixed[] $errors Errors
1201- *
1202- * @return mixed[]
1203- */
1204- private function checkResult (string $ createStatement , array $ errors ): array
1205- {
1206- // OMG, this is really bad! We dropped the query,
1207- // failed to create a new one
1208- // and now even the backup query does not execute!
1209- // This should not happen, but we better handle
1210- // this just in case.
1211- $ errors [] = __ ('Sorry, we failed to restore the dropped routine. ' ) . '<br> '
1212- . __ ('The backed up query was: ' )
1213- . '" ' . htmlspecialchars ($ createStatement ) . '"<br> '
1214- . __ ('MySQL said: ' ) . $ this ->dbi ->getError ();
1215-
1216- return $ errors ;
1217- }
1218-
12191205 /**
12201206 * returns details about the PROCEDUREs or FUNCTIONs for a specific database
12211207 * or details about a specific routine
0 commit comments