The Versioning module for Magento

Contents

  1. Module presentation
    1. Description
    2. Access and configuration
    3. Installation and uninstallation
  2. Install procedure
    1. With GIT
    2. With SVN
    3. With Bazaar
    4. With Darcs
    5. With Mercurial
  3. Configuration
    1. Project manager
    2. Login page
    3. Maintenance pages
  4. Extra
    1. Events
    2. 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:

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
Screenshot of the configuration (1/5)
Screenshot of the revisions history
Screenshot of the revisions history (2/5)
Screenshot of the differences between two revisions
Screenshot of the differences between two revisions (3/5)
Screenshot of the repository status
Screenshot of the repository status (4/5)
Screenshot of the updates history
Screenshot of the updates history (5/5)

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

Very important:

With GIT

First, for the gitignore file:

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

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';
	$ip = (!empty(getenv('HTTP_X_FORWARDED_FOR'))) ? explode(',', getenv('HTTP_X_FORWARDED_FOR')) : false;
	$ip = (!empty($ip)) ? array_pop($ip) : getenv('REMOTE_ADDR');
	$ip = (preg_match('#^::ffff:[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}$#', $ip) === 1) ? substr($ip, 7) : $ip;
	if (!is_file($ips) || (is_file($ips) && (strpos(file_get_contents($ips), '-'.$ip.'-') === false))) {
		include_once('./errors/503.php');
		exit(0);
	}
}
if (is_file('./upgrade.flag') && (strpos(getenv('REQUEST_URI'), '/admin/') === false)) {
	$ips = './errors/config/upgrade.ip';
	$ip = (!empty(getenv('HTTP_X_FORWARDED_FOR'))) ? explode(',', getenv('HTTP_X_FORWARDED_FOR')) : false;
	$ip = (!empty($ip)) ? array_pop($ip) : getenv('REMOTE_ADDR');
	$ip = (preg_match('#^::ffff:[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}$#', $ip) === 1) ? substr($ip, 7) : $ip;
	if (!is_file($ips) || (is_file($ips) && (strpos(file_get_contents($ips), '-'.$ip.'-') === false))) {
		include_once('./errors/upgrade.php');
		exit(0);
	}
}

Thirdly, for the app/Mage.php file (this change is not required):

// replace all
	    require_once(self::getBaseDir() . DS . 'errors' . DS . '404.php');
// by
	    // https://www.luigifab.info/magento/versioning
	    // require_once(self::getBaseDir().DS.'errors'.DS.'404.php');
	    self::printException($e);

Fourthly, you must delete the Magento errors folder.

Fifthly, 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"

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 SVN

Coming soon.

With Bazaar

Coming soon.

With Darcs

Coming soon.

With Mercurial

Coming soon.

Configuration

In System » Configuration » Tools » Version control.

Project manager

By completing 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.

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.

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 $@

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 / revisions history / updates history / repository status

Extension key: https://www.luigifab.info/magento/connect/luigifab/Luigifab_Versioning
Download of the latest version: luigifab-versioning-3.6.3.tgz (md5 b578c7b31a5e0a9db86fba14a99ef681)
Public repositories: github.com / sourceforge.net

Tested with Firefox 27/45, Chrome 29/65, Opera 52, 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.8 with PHP 7.1 and MariaDB 10.1.

Support

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!