|
|
|
Environment:
|
Solaris 10, Oracle 10.2.0.2, version 1.9.2+ build 20080716
|
|
| Database: |
Oracle
|
| Participants: |
Dan Poltawski and Gerd Goetschalckx
|
| Security Level: |
None
|
| Resolved date: |
09/Oct/08
|
| Affected Branches: |
MOODLE_19_STABLE, MOODLE_20_STABLE
|
| Fixed Branches: |
MOODLE_20_STABLE
|
The documentation of the function 'role_assign' says that the function returns the new id of the assignment, but actually the function returns 'true' if successfull, false otherwise. I would suggest to change the implementation to match the documentation. When unsuccessfull, the function should still return false. This should not break existing code, as the id is > 0, and therefore will evaluate to true. I can provide a patch. This is a problem for us, as we need the id to integrate with our other backend systems.
The issue is not visible. In order to experience it, write code that calls the function 'role_assign' with valid arguments, then print out the return value. But it is probably a lot easier just reading the code.
The actual result is true, the expected result is $ra->id
|
|
Description
|
The documentation of the function 'role_assign' says that the function returns the new id of the assignment, but actually the function returns 'true' if successfull, false otherwise. I would suggest to change the implementation to match the documentation. When unsuccessfull, the function should still return false. This should not break existing code, as the id is > 0, and therefore will evaluate to true. I can provide a patch. This is a problem for us, as we need the id to integrate with our other backend systems.
The issue is not visible. In order to experience it, write code that calls the function 'role_assign' with valid arguments, then print out the return value. But it is probably a lot easier just reading the code.
The actual result is true, the expected result is $ra->id |
Show » |
|
diff --git a/lib/accesslib.php b/lib/accesslib.php
index 84a731d..847897e 100755
— a/lib/accesslib.php
+++ b/lib/accesslib.php
@@ -2803,7 +2803,7 @@ function role_assign($roleid, $userid, $groupid, $contexti
events_trigger('role_assigned', $ra);
+ return $ra->id;
}