Last modified: 2014-07-01 06:40:46 UTC

Wikimedia Bugzilla is closed!

Wikimedia migrated from Bugzilla to Phabricator. Bug reports are handled in Wikimedia Phabricator.
This static website is read-only and for historical purposes. It is not possible to log in and except for displaying bug reports and their history, links might be broken. See T68624, the corresponding Phabricator task for complete and up-to-date bug report information.
Bug 66624 - User's IP is shown as '<IP> is a student in Intellectual Freedom - LIS 493 (course talk).' on all IP editors' contributions
User's IP is shown as '<IP> is a student in Intellectual Freedom - LIS 493 (c...
Status: RESOLVED FIXED
Product: MediaWiki extensions
Classification: Unclassified
EducationProgram (Other open bugs)
master
All All
: Highest major (vote)
: ---
Assigned To: Nobody - You can work on this!
:
Depends on:
Blocks:
  Show dependency treegraph
 
Reported: 2014-06-14 19:49 UTC by Danielle Leishman
Modified: 2014-07-01 06:40 UTC (History)
11 users (show)

See Also:
Web browser: ---
Mobile Platform: ---
Assignee Huggle Beta Tester: ---


Attachments
Screenshot (25.07 KB, image/png)
2014-06-14 19:49 UTC, Danielle Leishman
Details

Description Danielle Leishman 2014-06-14 19:49:24 UTC
On the English Encylopedia, if you were to view ANY IP editors' contributions, you will see the text '69.130.114.203 is a student in Intellectual Freedom - LIS 493 (course talk).' on all of them, no matter who they are. Here are some examples:
* https://en.wikipedia.org/wiki/Special:Contributions/108.30.135.96
* https://en.wikipedia.org/wiki/Special:Contributions/82.22.102.235
* https://en.wikipedia.org/wiki/Special:Contributions/74.97.76.166
* https://en.wikipedia.org/wiki/Special:Contributions/85.166.161.50
* https://en.wikipedia.org/wiki/Special:Contributions/74.212.159.2

I'm not sure if this is due to a javascript issue, but it is a problem nonetheless. 

Thank you.
Comment 1 Danielle Leishman 2014-06-14 19:49:53 UTC
Created attachment 15654 [details]
Screenshot

Screenshot of the bug
Comment 2 Huon 2014-06-14 19:54:19 UTC
It's not necessarily 69.130.114.203; it's the IP address of the person encountering the bug.
Comment 3 Kunal Mehta (Legoktm) 2014-06-14 19:55:50 UTC
Trying to remove the user from the course fails with no error message.
Comment 4 Alex Monk 2014-06-14 20:09:25 UTC
MariaDB [enwiki_p]> select * from ep_students where student_user_id = 0;
+------------+-----------------+----------------------+----------------------+---------------------+---------------------+---------------------+-----------------------+
| student_id | student_user_id | student_first_enroll | student_first_course | student_last_enroll | student_last_course | student_last_active | student_active_enroll |
+------------+-----------------+----------------------+----------------------+---------------------+---------------------+---------------------+-----------------------+
|       6507 |               0 | 20140614191200       |                  359 | 20140614191200      |                 359 | 20140614191200      |                     1 |
+------------+-----------------+----------------------+----------------------+---------------------+---------------------+---------------------+-----------------------+
1 row in set (0.00 sec)

MariaDB [enwiki_p]> select * from ep_users_per_course where upc_user_id=0;
+-------------+---------------+----------+----------------+
| upc_user_id | upc_course_id | upc_role | upc_time       |
+-------------+---------------+----------+----------------+
|           0 |           359 |        0 | 20140614191200 |
+-------------+---------------+----------+----------------+
1 row in set (0.00 sec)
Comment 5 Alex Monk 2014-06-14 20:15:04 UTC
<legoktm> oh crap. random people's IPs are being cached in varnish.
<Krenair> That's... not good.
<Krenair> It reveals to anyone that an IP has visited this exact page.
Comment 6 Kunal Mehta (Legoktm) 2014-06-14 20:15:16 UTC
I ran delete from ep_users_per_course where upc_user_id=0 limit 1 on enwiki, which got rid of it from appearing on Special:Contributions. Still showing up on the EP course page.
Comment 7 Kunal Mehta (Legoktm) 2014-06-14 20:29:19 UTC
Removing the user from ep_students removed them from everywhere I can see. Might still show up for people due to cache issues, I can't really do much about that.

Fixes probably need to be made in the EP extension to prevent this from happening again.
Comment 8 Danielle Leishman 2014-06-14 20:30:53 UTC
Note, going to be going somewhere where I don't have Internet, so won't be able to update this. I'm just the reporter; if it's fixed, go ahead and mark as fixed and don't wait for my input. I don't know much about it at all, nor how to fix it. Cheers.
Comment 9 Alex Monk 2014-06-14 20:33:06 UTC
We don't generally wait for the reporter to mark this as fixed. This bug will be left open at least until the EP extension is fixed itself (to prevent anons enrolling). I imagine we might want to purge the varnish cache for any affected anon contrib pages.
Comment 10 Gerrit Notification Bot 2014-06-14 20:36:58 UTC
Change 139644 had a related patch set uploaded by Legoktm:
Update SpecialContributionsBeforeMainOutput hook handler

https://gerrit.wikimedia.org/r/139644
Comment 11 Gerrit Notification Bot 2014-06-14 21:02:07 UTC
Change 139646 had a related patch set uploaded by Withoutaname:
Restrict enrollment to the "users" group

https://gerrit.wikimedia.org/r/139646
Comment 12 Gerrit Notification Bot 2014-06-14 21:37:09 UTC
Change 139646 merged by jenkins-bot:
Restrict enrollment to the "users" group

https://gerrit.wikimedia.org/r/139646
Comment 13 Sage Ross 2014-06-14 22:29:01 UTC
Kunal's patch (not yet merged) should prevent this specific problem from happening again.

The underlying issue of user 0 sneaking into the database is still a mystery to me. The permissions patch makes it more explicit that anons should not be able to enroll, but there was already a check for users being logged in before enrollment.

Maybe there's some way to sneak an anon through special:enroll, or maybe there's another unusually way of enrolling an anon (such as the "add students" feature available to logged in users.)
Comment 14 Gerrit Notification Bot 2014-06-15 05:26:29 UTC
Change 139644 merged by jenkins-bot:
Update SpecialContributionsBeforeMainOutput hook handler

https://gerrit.wikimedia.org/r/139644
Comment 15 Andrew Green 2014-06-16 03:14:17 UTC
Thanks again everyone for helping with this! There is one more place in the DB that needs to be fixed: a blob in the course_students column in one row of the ep_courses table.

(from Labs replica)

MariaDB [enwiki_p]> select * from ep_courses where course_id=359 \G
*************************** 1. row ***************************
              course_id: 359
          course_org_id: 6
           course_title: Simmons College/Intellectual Freedom - LIS 493 (Summer 2014)
            course_name: Intellectual Freedom - LIS 493
<snip/>
        course_students: a:4:{i:0;s:0:"";i:1;i:6404;i:2;i:21613420;i:3;i:21613446;}
<snip/>

This is a serialized array of the user IDs of students in the course.

$ php -r "var_dump( unserialize( 'a:4:{i:0;s:0:\"\";i:1;i:6404;i:2;i:21613420;i:3;i:21613446;}' ) );"
array(4) {
  [0]=>
  string(0) ""
  [1]=>
  int(6404)
  [2]=>
  int(21613420)
  [3]=>
  int(21613446)
}

I think that string could be replaced with "a:3:{i:0;i:6404;i:1;i:21613420;i:2;i:21613446;}", which is the serialized version of the correct array of students in the course.

After that's done, the number of students shown on the course page [1] and the related institution page will be corrected the next time students are added to or removed from the course.

I tried this locally and it seemed to work. :)

P.S. A fix is in the works for the EducationProgram extension issue that caused this.

[1] At the bottom of https://en.wikipedia.org/wiki/Education_Program:Simmons_College/Intellectual_Freedom_-_LIS_493_%28Summer_2014%29
Comment 16 Andrew Green 2014-06-16 03:38:42 UTC
P.S. The contents of course_students in that row of ep_courses should be re-checked right before any changes are made, in case students have been added or removed recently. (I don't have the rights to fix the row myself.)
Comment 17 Kunal Mehta (Legoktm) 2014-06-16 03:50:21 UTC
I'd rather not fiddle with the database directly if possible, is there something that can regenerate that in PHP with eval.php?

Like: 

> $course = new Course( $id );
> $course->updateStudents();

That's probably not the API, but just something that doesn't require directly dumping serialized PHP into a database row.
Comment 18 Andrew Green 2014-06-16 04:19:58 UTC
Sure. I can do a little maintenance script...
Comment 19 Gerrit Notification Bot 2014-06-18 18:29:00 UTC
Change 140137 had a related patch set uploaded by Alex Monk:
Prevent ApiAddStudents enrolling invalid users

https://gerrit.wikimedia.org/r/140137
Comment 20 Gerrit Notification Bot 2014-06-18 19:35:54 UTC
Change 140137 merged by jenkins-bot:
Prevent ApiAddStudents enrolling invalid users

https://gerrit.wikimedia.org/r/140137
Comment 21 Kunal Mehta (Legoktm) 2014-06-30 03:16:52 UTC
Andrew, is this fixed now?
Comment 22 Andrew Green 2014-06-30 17:32:55 UTC
Almost! The change that prevents it happening is merged on the cluster. The maintenance script (which will actually check all courses for this issue and fix any that have it) is coming in a little while, apologies for the delay!! :)

(No additional problems have been detected so far... ;) )
Comment 23 Gerrit Notification Bot 2014-07-01 05:48:35 UTC
Change 143246 had a related patch set uploaded by AndyRussG:
Maintenance script to unenroll invalid users

https://gerrit.wikimedia.org/r/143246
Comment 24 Andrew Green 2014-07-01 06:17:56 UTC
The maintenance script has two modes:
- To repair a course specified by ID.
- To check for and repair instances of the same problem anywhere on a wiki.

Most of the DB issues were fixed by hand on enwiki. The remaining issue can be fixed with the --courseId=359 option.

To check for the problem on other wikis with the EducationProgram extension, run the script with no arguments.
Comment 25 Gerrit Notification Bot 2014-07-01 06:33:00 UTC
Change 143246 merged by jenkins-bot:
Maintenance script to unenroll invalid users

https://gerrit.wikimedia.org/r/143246
Comment 26 Andrew Green 2014-07-01 06:40:46 UTC
Script was run successfully on production (thanks, Legoktm!) Enwiki course fixed, no problems detected elsewhere.

Note You need to log in before you can comment on or make changes to this bug.


Navigation
Links