|
[
Permalink
| « Hide
]
Przemyslaw Stencel added a comment - 23/Sep/08 03:53 PM
Of course I meant "... or 2 (admin user)"
Assigning to Tim Hunt... thanks!
Tim, I see you've scheduled this issue to be fixed in 1.9.4. How are you planning to implement this? Will CREATEDBY and MODIFIEDBY be set to unknown or to admin? Or are you planning a different fix?
Best, I am only planning to fix what happens for future restores.
I don't think there is anything I can do about bad data already in the database. Well, if createdby or modifiedby point to a non-existent user, then I will reset it to NULL, but where they point to an actual user, there is no way for Moodle to know if that is the correct information of the result of a bad restore in the past. As admin, you could get a list of question_category ids that came from bad backups, and then manually do a database query to fix them. Something like: UPDATE mdl_question SET createdby = NULL, modifiedby = NULL WHERE category IN (123, 234, 345, ...); using a tool like phpMyAdmin. However, messing around directly in the DB is not something to be undertaken lightly. > I am only planning to fix what happens for future restores.
Yes, I understand that I just wanted to know which of the following you are planning to implement as a fix for this issue: 1/ if during the restore process the original wwwroot is different than the wwwroot of the target site, then CREATEDBY and MODIFIEDBY will be set to unknown OR 2/ if during the restore process the original wwwroot is different than the wwwroot of the target site, then CREATEDBY and MODIFIEDBY will be set to admin
Neither, read the patch.
If the backup includes users, then we will update the fields to point to the new userid of the user who created/modified the question. If the user is not in the file, we set it to null, unless $restore->original_wwwroot == $CFG->wwwroot. Thanks for the explanation.
Right, following discussion with Eloy and Nico in developer chat:
The if ($restore->original_wwwroot == $CFG->wwwroot) is dangerous because of this scenario: 1. Admin backs up everything important in their Moodle 1.9. In this case $restore->original_wwwroot == $CFG->wwwroot but it is a different moodle. However, there is a $CFG->siteidentifier, which is initialised on install to random_string(32).$_SERVER['HTTP_HOST']. It is used for registration, and a couple of other places. Unfortunately, at the moment, this is not stored in the backup file. So, the plan is: 1. Change backup, so $CFG->siteidentifier is stored in every backup file. Hopefully I will be able to do this on Monday. I'm looking for a code review on my revised patch: backupsamesite.patch.txt
I was suprised how many places were already using a nasty hack to see if this was the same site. I also refactored the three or four places where $CFG->siteidentifier was initialised, so they all called a function. Can we squeeze this into 1.9.4, Eloy and Petr?
About the backupsamesite.patch.txt, perfect IMO! Hashing the site identifier sounds like a great idea and "same site" detection will be now much better, being 100% compatible with old backups (where detection only can be done with wwwroot).
Also the questions part is ok, with those 2 lines we talked deleted. Perfect! +1 for stable |
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||