Making of the upgrade script
By Adam Patterson in: Article
The best scenario for keeping Tentacle up to date is using to use Git.
If for some reason you can not use git then for the majority of users we have you covered.
Tentacle updates are powered by the Serpent API. Serpent is designed to allow developers to continue their normal workflow and control when Updates are made available.
By creating a versioned git tag I can publish an archive file that is ready for public use.
Tentacle will have a look at its own internal version and compare it with what is available over the API at http://api.tentaclecms.com/get/core/
Update the source code
If they are different we kick off the upgrade.
- Download a new archive
- Extract the archive to a temp directory
- Build an object containing all the files in a temp folder
- Each file is represented as a string /folder/folder/folder/name.extension
- Each one of these strings is broken into a path and a file.
- Every path is tested to see if it exists, if not we create it.
- Then we test to see if the file exists, and if not we get the contents of the temp file create its destination file and write the contents.
- This happens until every file has been written.
- Cleanup the temp folder by deleting the zip and removing the extracted contents.
It is important to note that during this process folders are merged and not over written.
Update the database
At this point the version of the CMS will match, the next step is to check for any updates to the database.
We now look to the database for its version and compare it with what is listed as current in the source code.
If there is a difference we load the SQL model, and increment through any version changes, This is basically a forward migration.
The last step is to update the database version stored in the database.
After all is said and done, we downloaded the new source code from Github, Extracted the contents to a temp directory, updated the core CMS code and did a forward migration on the database.
File permission issues with PHP might exist with shared hosting environments.
If this is the case I would manually upgrade using FTP or even Git.
The major hosting companies like Dreamhost, Mediatemple and PhpFog work fine, if you run into issues with permissions then your best bet is to use Git or manullay update by FTP, should still see a prompt letting you know that the database has to be upgraded.