How come: "Must specify course id, short name or idnumber" or "A required parameter (d) was missing" or "No operation specified".

How come: "Must specify course id, short name or idnumber" or "A required parameter (d) was missing" or "No operation specified".

by Remco Liefting -
Number of replies: 18

Who can solve this problem?

If an user wants to enter a course, moodle ask for his login. When the known user enter his name and password he gets a new page with this announcement: "Must specify course id, short name or idnumber".

Also, If a user gets an e-mail when somebody post to a forum and he uses the link in the e-mail to go directly to the site, moodle ask for his login. When the known user enter his name and password he gets a new page with one of the following announcements: "Must specify course id, short name or idnumber" or "A required parameter (d) was missing" or "No operation specified".

So i think there is something wrong with the login module? Or is it something else? I can't find the answers on the forums. Please help.

Average of ratings: -
In reply to Remco Liefting

Re: How come: "Must specify course id, short name or idnumber" or "A required parameter (d) was missing" or "No operation specified".

by Jan Dierckx -
Does this happen with every user or only with specific users?
Do you have users using odd characters in their username?
In reply to Jan Dierckx

Re: How come: "Must specify course id, short name or idnumber" or "A required parameter (d) was missing" or "No operation specified".

by Remco Liefting -

Hi Jan,

It seems it does this with every user and all the users use their normal names. It is also not my cookie settings. I thought that was the problem. I also checked if the server can handle sessions. And it does. It is also not my firewall. We have checked that all. So it must be in the software. Any suggestions? I'am using 1.5.

Remco

In reply to Remco Liefting

Re: How come: "Must specify course id, short name or idnumber" or "A required parameter (d) was missing" or "No operation specified".

by Jan Dierckx -

Can you provide some more details (like Paul already asked in one of the other threads you started)

  • PHP, mysql version, which authentication are you using? etc...

  • You seem to be quite sure that it must be a problem in the software. Did you make any custom changes to it?

  • When did the problem arise for the first time? You mention people posting to the forums. Is this still possible?

  • All of the errors refer to missing parameters in the url of the pages that are called. How does the link that is sent through email look like? Does it include a course id or a parameter d?

  • Can you see sessions being written to the moodledata directory? Or are you using a database to store sessions?

  • Your profile doesn't mention a site. Is it a public site so other people can take a look?

In reply to Jan Dierckx

Re: How come: "Must specify course id, short name or idnumber" or "A required parameter (d) was missing" or "No operation specified".

by Remco Liefting -

Hi Jan,

Thanks for helping me out. Here you will find the answers on your questions. Please help me out.

Answer 1: Versions Moodle: 1.5.4.

Naam Informatie Rapport Status
database mysql versie 4.1.7 OK
php versie 4.3.9 OK
php_extension mbstring OK

Answer 2: Changes

No custom changes at all

Answer 3: When

Since the beginning. People can do everything (including posting).

Answer 4: Missing parameters

All links include the parameters. Example: http://www.mans.nl/lms/mod/forum/discuss.php?d=7#23

Answer 5: store sessions

First it was in the moddledata directory and I changed it to database. But this doesn't make any difference.

Answer 6: Site

If you go to www.mans.nl/lms i have made a course called test. You have to make an account and the coursekey is test. Please try so you will see.

In reply to Remco Liefting

Re: How come: "Must specify course id, short name or idnumber" or "A required parameter (d) was missing" or "No operation specified".

by Iñaki Arenaza -
Picture of Core developers Picture of Documentation writers Picture of Particularly helpful Moodlers Picture of Peer reviewers Picture of Plugin developers
It seems Moodle is not able to record the URL (including full
parameters) it came from when you are sent to the login page. It
remembers the URL, but not the parameters (the '?d=7#23' in your
example above). So after login, you are redirected to the right page,
but with missing parameters that are mandatory. That's why you get the
error.

Now the question is, why isn't Moodle able to record the parameters in
your installation? The $FULLME global variable should contain the full
URL+parameter data. That variable is set in lib/setup.php and used
(among other places) in require_login(), where you are sent after
trying to access something that requires you are logged in.

$FULLME is setup using a function called qualified_me() in weblib.php,
which in turns calls a function called me() in that same file to get
the 'URI' part of the URL.

So I guess we need to 'debug' qualified_me() and me() to see why they
are not recording the parameters in the URI.

You can add the following lines (the ones in blue) in function
qualified_me() to see what you get in $FULLME when you are sent to the
login page:
    if (isset($_SERVER['HTTPS'])) {
$protocol = ($_SERVER['HTTPS'] == 'on') ? 'https://' : 'http://';
} else if (isset($_SERVER['SERVER_PORT'])) { # Apache2 does not export $_SERVER['HTTPS']
$protocol = ($_SERVER['SERVER_PORT'] == '443') ? 'https://' : 'http://';
} else {
$protocol = 'http://';
}

$url_prefix = $protocol.$hostname;
$uri = me();
echo "<!-- url_prefix = $url_prefix , uri = $uri -->\n";
return $url_prefix . me();

And the following lines in function me():
function me() {

if (!empty($_SERVER['REQUEST_URI'])) {
echo "<!-- path 1 -->\n";
return $_SERVER['REQUEST_URI'];

} else if (!empty($_SERVER['PHP_SELF'])) {
if (!empty($_SERVER['QUERY_STRING'])) {
echo "<!-- path 2 -->\n";
return $_SERVER['PHP_SELF'] .'?'. $_SERVER['QUERY_STRING'];
}
echo "<!-- path 3 -->\n";
return $_SERVER['PHP_SELF'];

} else if (!empty($_SERVER['SCRIPT_NAME'])) {
if (!empty($_SERVER['QUERY_STRING'])) {
echo "<!-- path 4 -->\n";
return $_SERVER['SCRIPT_NAME'] .'?'. $_SERVER['QUERY_STRING'];
}
echo "<!-- path 5 -->\n";
return $_SERVER['SCRIPT_NAME'];

} else if (!empty($_SERVER['URL'])) { // May help IIS (not well tested)
if (!empty($_SERVER['QUERY_STRING'])) {
echo "<!-- path 6 -->\n";
return $_SERVER['URL'] .'?'. $_SERVER['QUERY_STRING'];
}
echo "<!-- path 7 -->\n";
return $_SERVER['URL'];

} else {
notify('Warning: Could not find any of these web server variables: $REQUEST_URI, $PHP_SELF, $SCRIPT_NAME or $URL');
return false;
}
}

You'll get the values as HTMLs comment, so they won't be displayed in the browser, but you can see them if you look at the page source.

Saludos. Iñaki.
Average of ratings: Useful (1)
In reply to Iñaki Arenaza

Re: How come: "Must specify course id, short name or idnumber" or "A required parameter (d) was missing" or "No operation specified".

by Remco Liefting -

Dear Iñaki,

Wow, this is debugging for experts. I think

I've tried it but I didn't see anything in de page source. I did see now a new page (for 1 second) with this: Cannot modify header information - headers already sent by (output started at d:\....\weblip.php:175). This is a new one.

I also see in the modifying page of the forum this: Warning: Invalid argument supplied for foreach() in d:\www\mans.nl\www\lms\lib\weblib.php on line 3691. This was there rigght from the beginning. But I dont't know if this has anything to do with it.

Any other suggestions????

Remco

In reply to Remco Liefting

Re: How come: "Must specify course id, short name or idnumber" or "A required parameter (d) was missing" or "No operation specified".

by Iñaki Arenaza -
Picture of Core developers Picture of Documentation writers Picture of Particularly helpful Moodlers Picture of Peer reviewers Picture of Plugin developers
Do you have access to your web server logs?

Saludos. Iñaki.
In reply to Iñaki Arenaza

Re: How come: "Must specify course id, short name or idnumber" or "A required parameter (d) was missing" or "No operation specified".

by Remco Liefting -

Hi Iñaki,

Not directly. It is hosted on a shared server so they can't send me (for security reasons) the log file direct. But, they say, If we test the site write down the time and date and they can filter out the specific information we need.

Does this help?

Remco

In reply to Remco Liefting

Re: How come: "Must specify course id, short name or idnumber" or "A required parameter (d) was missing" or "No operation specified".

by Iñaki Arenaza -
Picture of Core developers Picture of Documentation writers Picture of Particularly helpful Moodlers Picture of Peer reviewers Picture of Plugin developers

Ok, then you need to replace those 'echo' with 'error_log', so all the output is sent to your web server logs and we can have a look at it.

Replace all the:

echo "some string here";

with:

error_log ("some string here");

Then do the test and ask your provider for the logs.

Saludos. Iñaki.

Average of ratings: Useful (1)
In reply to Iñaki Arenaza

Re: How come: "Must specify course id, short name or idnumber" or "A required parameter (d) was missing" or "No operation specified".

by Remco Liefting -

Dear Iñaki,

I tried again with that echo thing, and this is what i've got from the source:

<!-- path 1 -->
<!-- url_prefix = http://www.mans.nl , uri = /lms/login/index.php -->
<!-- path 1 -->

What does this mean? And what is the next step in this exciting debugging process?

Remco

In reply to Remco Liefting

Re: How come: "Must specify course id, short name or idnumber" or "A required parameter (d) was missing" or "No operation specified".

by Remco Liefting -

And... if i put a url in the adress to a forum (with iD) I get:

<!-- path 1 -->
<!-- url_prefix = http://www.mans.nl , uri = /lms/mod/forum/discuss.php -->
<!-- path 1 -->

Remco

In reply to Iñaki Arenaza

Re: How come: "Must specify course id, short name or idnumber" or "A required parameter (d) was missing" or "No operation specified".

by Dan Roozemond -
Dear Iñaki,

Remco pointed me to this thread, and I did the debugging as you suggested.

The problem seems to be that the first control path in me() doesn't check $_SERVER['QUERY_STRING']. Maybe this problem never showed up because the majority of your users is using Apache, and we are using IIS?

Nevertheless, I changed me() to the following and now it's working fine as far as I can tell.

 function me() {

    if (!empty($_SERVER['REQUEST_URI'])) {
        $out = $_SERVER['REQUEST_URI'];
    } else if (!empty($_SERVER['PHP_SELF'])) {
        $out = $_SERVER['PHP_SELF'];
    } else if (!empty($_SERVER['SCRIPT_NAME'])) {
        $out = $_SERVER['SCRIPT_NAME'];
    } else if (!empty($_SERVER['URL'])) {
        $out = $_SERVER['URL'];
    } else {
        notify('Warning: Could not find any of these web server variables: $REQUEST_URI, $PHP_SELF, $SCRIPT_NAME or $URL');
        return false;
    }

    if (!empty($_SERVER['QUERY_STRING'])) {
        $out .= '?'.$_SERVER['QUERY_STRING'];
    }
   
    return $out;
}

Best regards,
Dan
In reply to Dan Roozemond

Re: How come: "Must specify course id, short name or idnumber" or "A required parameter (d) was missing" or "No operation specified".

by Dan Roozemond -
Now that I think of it (and checked with Apache) my solution would break the behaviour in Apache, resulting in a me() with QUERY_STRING occuring twice.

Indeed, I think we can safely blame IIS for not appending the query string to REQUEST_URI.

Below is a workaround which should work on Apache as well ("should", since I haven't tested it, so no guarantees here ;) )

 function me() {
   
    $tocheck = array('REQUEST_URI', 'PHP_SELF', 'SCRIPT_NAME', 'URL');
   
    $out = '';
    foreach ($tocheck as $var) {
        if (!empty($_SERVER[$var])) {
            $out = $_SERVER[$var];
            break;
        }  
    }
   
    if ($out == '') {
        $msg = 'Warning: Could not find any of these web server variables: ';
        foreach ($tocheck as $var) $msg .= $var. ' ';
        notify($msg);
        return false;
       
    }

    if (!empty($_SERVER['QUERY_STRING'])) {
        if (strpos($out, '?') === false)
            $out .= '?'.$_SERVER['QUERY_STRING'];
    }
    return $out;
}


Best regards,
Dan
Average of ratings: Useful (1)
In reply to Dan Roozemond

Re: How come: "Must specify course id, short name or idnumber" or "A required parameter (d) was missing" or "No operation specified".

by Remco Liefting -

Dear Iñaki and Dan,

It works and it looks like the problem is solved. I hope that the solution provided will help the Moodle community to run it on ISS. Thank you all for your time and effort.

Remco

In reply to Remco Liefting

Re: How come: "Must specify course id, short name or idnumber" or "A required parameter (d) was missing" or "No operation specified".

by Jan Dierckx -
Phew!

I would never have found out about these iis / apache differences.
Thanks Iñaki and Dan.
In reply to Dan Roozemond

Re: How come: "Must specify course id, short name or idnumber" or "A required parameter (d) was missing" or "No operation specified".

by Tyler Bithell -
Forgive my ignorance very much new to Moodle with not much php experience, but are you referring to function me() in moodle/lib/weblib.php? Also, are you suggesting adding this to function me(), or replacing function me() with your code?

I'm using Moodle verions 1.9.5 with IIS 7, and receive the same error message, " Must specify course id, short name or idnumber" whenever I attempt to login no matter what type of user to include guest users.

Thanks!
In reply to Dan Roozemond

Re: How come: "Must specify course id, short name or idnumber" or "A required parameter (d) was missing" or "No operation specified".

by Abdul Hakkim -
Dear Dan,
im using the code u mentioned but its not working in Firefox 3+ and its not redirecting in IE 6+ , can u plz help

Regards
Abdul
In reply to Dan Roozemond

Re: How come: "Must specify course id, short name or idnumber" or "A required parameter (d) was missing" or "No operation specified".

by Chris Jay -

Thanks Dan, this worked a treat for me.