diff --git a/libraries/db_routines.inc.php b/libraries/db_routines.inc.php
index 2aa00f8770..ea105136c3 100644
--- a/libraries/db_routines.inc.php
+++ b/libraries/db_routines.inc.php
@@ -633,12 +633,16 @@ $routine_errors = array();
/**
* Handle all user requests other than the default of listing routines
*/
-if (! empty($_GET['exportroutine']) && ! empty($_GET['routine_name']) && ! empty($_GET['routinetype'])) {
+if (! empty($_GET['exportroutine']) && ! empty($_GET['routine_name'])) {
/**
* Display the export for a routine.
*/
$routine_name = htmlspecialchars(PMA_backquote($_GET['routine_name']));
- if ($create_proc = PMA_DBI_get_definition($db, $_GET['routinetype'], $_GET['routine_name'])) {
+ $routine_type = PMA_DBI_fetch_value("SELECT ROUTINE_TYPE "
+ . "FROM INFORMATION_SCHEMA.ROUTINES "
+ . "WHERE ROUTINE_SCHEMA='" . PMA_sqlAddslashes($db) . "' "
+ . "AND SPECIFIC_NAME='" . PMA_sqlAddslashes($_GET['routine_name']) . "';");
+ if (! empty($routine_type) && $create_proc = PMA_DBI_get_definition($db, $routine_type, $_GET['routine_name'])) {
$create_proc = '';
if (! empty($_REQUEST['ajax_request'])) {
$extra_data = array('title' => sprintf(__('Export of routine %s'), $routine_name));
@@ -842,7 +846,6 @@ if (! $routines) {
$exprlink = '' . $titles['Export'] . '';
}
if (PMA_currentUserHasPrivilege('ALTER ROUTINE', $db)) {