The Versioning module for Magento 1

Contents

  1. Module presentation
    1. Description
    2. Access and configuration
    3. Installation and uninstallation
  2. Install procedure
    1. With GIT
    2. With BZR
    3. With SVN
  3. Configuration
    1. Project manager
    2. Login page
    3. Maintenance pages
  4. Extra
    1. Events
    2. Output buffering
    3. SSH authentification
  5. Module download and demo
  6. Support

Don't forget that the present documentation is only about the latest version of the module.
Don't forget to read this page entirely.

Module presentation

Description

This module allows:

A doubt before updating? Check the diff!
Before going further, here is a presentation video: see the video.

Access and configuration

Configuration available in System » Configuration » Tools » Version control.
Available in Tools » Version control.

Screenshot of the configuration page
Screenshot of the configuration page (1/6)
Screenshot of the commits history
Screenshot of the commits history (2/6)
Screenshot of the differences between two commits
Screenshot of the differences between two commits (3/6)
Screenshot of the repository status
Screenshot of the repository status (4/6)
Screenshot of the updates history
Screenshot of the updates history (5/6)
Screenshot of the login page
Screenshot of the login page (6/6)

Installation and uninstallation

In order to complete the module installation, you have to follow the install procedure. After following the differents steps, all that remains is to install the module with Magento Connect (or by decompressing the module archive in the Magento root) before validating/committing all changes. The extension key is available at the end of this documentation.

For uninstallation, after canceling the module's commit, all that remains is to erase the configuration:

DELETE FROM core_config_data WHERE path LIKE "versioning/%";

Install procedure

Please note:
- you can move Magento in a subfolder of the repository
- all changes done will be cancelled during the updating process (except for the ignored files)
- it is important that the user who runs the web server has the possibility to modify all the files
- do not change branch using the module

Whatever the version manager used, this tutorial goes straight to the essential. After following the differents steps, all that remains is to install the module with Magento Connect (or by decompressing the module archive in the Magento root) before validating/committing all changes.

With GIT

(1) First, for the gitignore file:

/errors/config/*.ip
/errors/config/*.dat
/errors/config/*.csv
/maintenance.flag
/upgrade.flag

(2) Secondly, for the index.php file:

// replace
if (file_exists($maintenanceFile)) {
	include_once dirname(__FILE__).'/errors/503.php';
	exit;
}
// by
// https://www.luigifab.info/magento/versioning
if (is_file('./maintenance.flag') && (strpos(getenv('REQUEST_URI'), '/admin/') === false)) {
	$ips = './errors/config/error503.ip';
	if (!is_file($ips) || (is_file($ips) && (strpos(file_get_contents($ips), '-'.getenv('REMOTE_ADDR').'-') === false))) {
		include_once('./errors/503.php');
		exit(0);
	}
}
if (is_file('./upgrade.flag') && (strpos(getenv('REQUEST_URI'), '/admin/') === false)) {
	$ips = './errors/config/upgrade.ip';
	if (!is_file($ips) || (is_file($ips) && (strpos(file_get_contents($ips), '-'.getenv('REMOTE_ADDR').'-') === false))) {
		include_once('./errors/upgrade.php');
		exit(0);
	}
}

(3) Thirdly, you must delete the Magento errors folder.

(4) Fourthly, you must create the .git/hooks/prepare-commit-msg file that allows to save the branch name in each commit message. It is also necessary that each person who uses the repository creates it (otherwise, in the backend the branches representation will not work - the file must be executable).

#!/bin/bash
# https://www.luigifab.info/magento/versioning
NAME=$(git branch | grep "*" | cut -c3-)
echo "{$NAME}" >> "$1"

With BZR

Coming soon.

With SVN

Coming soon.

Configuration

In System » Configuration » Tools » Version control.

Project manager

If you complete the field for example with http://www.redmine.org/issues/, then the issues numbers in the commit messages will be transformed into HTML links.

Login page

Login page

Try the new backend login page or the new forgot password page and you'll like it!

Here is the new login page.
Example online.

Maintenance pages

Each page is configurable with its own options (mainly title and content), the configuration will be automatically saved in the errors/config folder.

When the site is locked, backend access is still possible:
- following addresses will not work: magento.xyz/admin - magento.xyz/index.php/admin
- following addresses will work: magento.xyz/admin/ - magento.xyz/index.php/admin/

Integrator, developer, it is possible to change the maintenance pages look by using rewrites.
To know more, read the readme file available in the errors/config folder.

Error 503 (maintenance.flag)

Error 503 (maintenance.flag)

This maintenance page can be enabled or disabled in the backend in Tools » Version control, or manually by creating the maintenance.flag file. It has priority on the update page.

Configuration options:

Here is the default page.
Example online.

Update (upgrade.flag)

Update (upgrade.flag)

This maintenance page can be enabled or disabled in the backend in Tools » Version control, or manually by creating the upgrade.flag file.

Configuration options:

Here is the default page.
Example online.

Error report

Error report

This page appears when Magento encounters an error. An error report was saved in the var/report folder (with a bonus, when available, the REQUEST_URI of the page that generated the error).

Configuration options:

Here is the default page.
Example online.

System error 404

System error 404

Warning, this page is not the same that the 404 error page when a category or product address does not exist.

Configuration options:

Here is the default page.
Example online.

Extra

Events

Three events are available:

An example is available in the Demo.php and config.xml files.

Output buffering

Very possibly:

# stop output buffering with apache
<Location ~ "admin/versioning_repository/upgrade/revision">
	php_flag zlib.output_compression off
</Location>
# stop output buffering with lighttpd
$HTTP["url"] =~ "admin/versioning_repository/upgrade/revision" {
	server.stream-response-body = 2
}

SSH authentification

Below, the essential to remember to run the SSH authentication by key when you are using one server for the repository (like GitHub), and another one for the web server. You must create a private key without passphrase and put it in the /xyz/.git/ssh folder on your web server.

(1) First, you must create the /xyz/.git/ssh/config.sh file:

#!/bin/bash
# https://www.luigifab.info/magento/versioning
ssh -o UserKnownHostsFile=/xyz/.git/ssh/known_hosts -i /xyz/.git/ssh/id_rsa $@

(2) Secondly, run these commands:

ssh-keyscan gitserver.xyz > /xyz/.git/ssh/known_hosts
chmod 400 /xyz/.git/ssh/*
chmod 500 /xyz/.git/ssh/config.sh
export GIT_SSH=/xyz/.git/ssh/config.sh
git clone ssh://user@gitserver.xyz/name.git -b master /xyz/

Module download and demo

Demo: configuration / commits history / updates history / repository status

Extension key: https://www.luigifab.info/magento/connect/luigifab/Luigifab_Versioning
Download of the latest version: luigifab-versioning-3.5.0.tgz (md5 1c2e75d4bbd2096ec3a0151ee75b9839)
GitHub repository: github.com

Tested with Firefox 27/45, Chrome 29/63, Opera 49, IE 11, Edge 14 on Magento 1.4.1.0 with PHP 7.1 and MariaDB 10.1.
Tested with Firefox 45 on Magento 1.5.0.1 / 1.6.0.0 / 1.7.0.0 / 1.8.0.0 / 1.9.0.0 / 1.9.3.7 with PHP 7.1 and MariaDB 10.1.

Support

Contact

A problem? A question? Is something not working? Is there a bug? Contact me (in French or in English), if I am not on holiday and not far from my mailbox, I will answer you within a few hours.

You will find my email address in the README file, read it!

Why choose us?

Because we are the best! You will like our minified files shipped with our modules.

Add the content of this file in the skin/adminhtml/default/default/css/custom.css file.
Add the following little piece of code at the start of the index.php file.

array_walk_recursive($_GET, function (&$val) { $val = trim($val); });
array_walk_recursive($_POST, function (&$val) { $val = trim($val); });