IntroductionPatcher Module is created as an extra module to apply code changes or fixes in between releases. This is a module for administrator. It connects to update.atutor.ca automatically, finds the available patches for the installed ATutor version, and displays all the available patches to allow administrators to install. Patch directory structure at update.atutor.ca http://update.atutor.ca Each ATutor version has a folder under "patch" folder. In version folder, patch_list.xml contains general information of all patches that are available for this version. One of the elements <patch_folder> in patch_list.xml specifies the name of the subfolder where all the details for the patch are located. Naming conventions:1_6: version folder for ATutor version 1.6, as so, 1_6_1 is for version 1.6.1 1_6-1: patch folder for ATutor 1.6 and patch sequence number 1. As so, 1_6-2 is for ATutor 1.6 with patch sequence 2. Please note that this naming convention is not mandatory as the script uses the name specified in patch_list.xml, element <patch_folder>. .new files: all .php files have to be rename to .new when being placed into patch folder, for example, login.php needs to be renamed to login.new. It's because PHP is installed in server where update.atutor.ca is located, when Patcher module fetch a .php file from update.atutor.ca, the file is parsed as a php script and only the output of execution of php script is returned. This is not we want, we want to have a straight text file. Note: 1. Patches are forced to be applied in the order of sequence to avoid conflicts. Patch_list.xmlPatch_list.xml is in version folder and contains summary information of all the patches that are available for this version When a new patch is available, related information has to be added into this file. Important element:<available_to>: values can be public or specific user; when public, available to all users Sample patch_list.xml<?xml version="1.0" encoding="ISO-8859-1"?> <patch> <patch> </patch_list> Patch Files in sub-patch folderThe files in patch folder, for example 1-6_1, are:
Patch.xmlpatch.xml is the most important file to apply patch, example attached in the next section. patch.xml describes all the changes on database and code. Includes: 1. all database operations 2. copy new file 3. delete old file 4. overwrite old file 5. modify file content: includes delete, replace Important element tags:<sql>: holds all SQL statements. <files>: holds all actions on scripts and files. <file> is the sub-element in <files> that holds all modifications on scripts and files. Its important sub-elements: <action>: alter, add, delete, overwrite <action_detail>: has to provide when <action> is "alter". <type> can be delete, replace Sample patch.xml<?xml version="1.0" encoding="ISO-8859-1"?> <sql> <files> <action>replace</action> </file> <file> <file> <file> Note: Some characters have a special meaning in XML. If you place a character like "<" inside an XML element, it will generate an error because the parser interprets it as the start of a new element.To avoid this error, replace the "<" character with an entity reference "<". There are 5 predefined entity references in XML:
New Tables3 new tables are required to keep track of patches that have been applied to current version of ATutor. They are: patchesFor general patch information. patches_filesTo keep track of all the files that are altered, added, deleted, overwritten for each patch. patches_files_actionsTo keep track of all actions that are done on files in patches_files Module Workflow
(1) Locate "patch.xml" in the sub-patch folder specified in patch_list.xml All informations about "files/folders to remove write permission", "backup files", "patch files" are kept in table patches. Users can retrieve these info any time by clicking button "View Message". |