Le module Versioning pour OpenMage
Sommaire (v4.6.0)
N'oubliez pas que cette documentation ne concerne que la dernière version du module.
N'oubliez pas de lire cette page entièrement.
🌟🌟🌟🌟🌟 par Henri,
le 01/04/2020 Ce module n'est pas premium, n'est pas ultimate, n'est pas pro, il ne contient pas un mouchard ni un jolie panneau de publicité, et il n'augmentera pas votre ROI de 165%. Il est tout simplement mieux que tout ce que vous avez pu voir ailleurs. C'est une révolution !
Présentation du module
Description
Ce module permet :
- to update your OpenMage website via a version control system (GIT)
- to use a multilingual and configurable maintenance page
- to show differences between two revisions
- to show repository status
- to keep updates history
Before going further, here is a presentation video: see the video.
Accès et configuration
Configuration available in System » Configuration » Tools » Version control.
Available in Tools » Version control.
Very important:
- OpenMage must be at the root or in a subfolder
- 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
- be careful that it is not possible to
git clone https://www.your-website.xyz/.git
Compatible avec OpenFileEditor
Lorsque l'extension pour navigateur OpenFileEditor est installée, lors de l'affichage d'une trace d'erreur PHP, les chemins des fichiers sont cliquables, afin de les ouvrirs directement dans votre éditeur de fichier préféré.
Installation et désinstallation
In order to complete the module installation, it is necessary to follow the install procedure. After following the differents steps, all that remains is to install the module with composer before validating/committing all changes.
Pour la désinstallation, après avoir désinstallé le module, il ne reste plus qu'à effacer la configuration :
sqlDELETE FROM core_config_data WHERE path LIKE "versioning/%";
Install procedure
1) For the gitignore file:
gitignore/errors/config/*.ip
/errors/config/*.dat
/errors/config/*.csv
/maintenance.flag
/upgrade.flag
2) For the index.php and api.php files:
php// replace
if (file_exists($maintenanceFile)) {
include_once dirname(__FILE__).'/errors/503.php';
exit;
}
// by
// @see https://github.com/luigifab/openmage-versioning
if (is_file('./maintenance.flag') && (mb_stripos(getenv('REQUEST_URI'), '/admin/') === false)) {
$ips = './errors/config/error503.ip';
$ip = empty(getenv('HTTP_X_FORWARDED_FOR')) ? false : explode(',', getenv('HTTP_X_FORWARDED_FOR'));
$ip = empty($ip) ? getenv('REMOTE_ADDR') : reset($ip);
$ip = (preg_match('# ::f{4}:\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3}$#', $ip) === 1) ? substr($ip, 7) : $ip;
if (!is_file($ips) || (is_file($ips) && (stripos(file_get_contents($ips), '-'.$ip.'-') === false))) {
include_once('./errors/503.php');
exit(0);
}
}
if (is_file('./upgrade.flag') && (mb_stripos(getenv('REQUEST_URI'), '/admin/') === false)) {
$ips = './errors/config/upgrade.ip';
$ip = empty(getenv('HTTP_X_FORWARDED_FOR')) ? false : explode(',', getenv('HTTP_X_FORWARDED_FOR'));
$ip = empty($ip) ? getenv('REMOTE_ADDR') : reset($ip);
$ip = (preg_match('# ::f{4}:\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3}$#', $ip) === 1) ? substr($ip, 7) : $ip;
if (!is_file($ips) || (is_file($ips) && (stripos(file_get_contents($ips), '-'.$ip.'-') === false))) {
include_once('./errors/upgrade.php');
exit(0);
}
}
3) For app/Mage.php file (this change is not required):
difdiff --git a/app/Mage.php b/app/Mage.php
index 051804580..6210ad9cd 100644
--- a/app/Mage.php
+++ b/app/Mage.php
@@ -647,7 +647,9 @@ final class Mage
header('Location: ' . self::getBaseUrl());
die;
} catch (Mage_Core_Model_Store_Exception $e) {
- require_once(self::getBaseDir() . DS . 'errors' . DS . '404.php');
+ // @see https://github.com/luigifab/openmage-versioning
+ // require_once(self::getBaseDir().DS.'errors'.DS.'404.php');
+ self::printException($e);
die;
} catch (Exception $e) {
self::printException($e);
@@ -690,7 +692,9 @@ final class Mage
header('Location: ' . self::getBaseUrl());
die();
} catch (Mage_Core_Model_Store_Exception $e) {
- require_once(self::getBaseDir() . DS . 'errors' . DS . '404.php');
+ // @see https://github.com/luigifab/openmage-versioning
+ // require_once(self::getBaseDir().DS.'errors'.DS.'404.php');
+ self::printException($e);
die();
} catch (Exception $e) {
if (self::isInstalled() || self::$_isDownloader) {
4) It is necessary to 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).
bash#!/bin/bash
# https://www.luigifab.fr/openmage/versioning
NAME=$(git branch | grep "*" | cut -c3-)
echo "{$NAME}" >> "$1"
5) It is necessary to delete the OpenMage errors folder.
6) It only remains to install the module:
shellcomposer require luigifab/openmage-versioning
git add .
git commit
git push
Deploy procedure
On the production (or preproduction, or local) server, when the GIT repository requires key authentication (below id_rsa, without password), there is a little configuration to do.
1) It is necessary to create the /xyz/.git/ssh/config.sh file:
bash#!/bin/bash
ssh -o UserKnownHostsFile=/xyz/.git/ssh/known_hosts -i /xyz/.git/ssh/id_rsa $@
2) It is necessary to create the /xyz/.git/ssh/known_hosts file:
shellssh-keyscan gitserver.xyz > /xyz/.git/ssh/known_hosts
3) It is necessary to apply permissions:
shellchmod 400 /xyz/.git/ssh/*
chmod 500 /xyz/.git/ssh/config.sh
4) It only remains to load the configuration and to clone the repository:
shellexport GIT_SSH=/xyz/.git/ssh/config.sh
git clone gitserver.xyz/repo.git /xyz/
mkdir /xyz/htdocs/media/ /xyz/htdocs/var/
chown www-data. -R /xyz/
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

Try the new backend login page or the new forgot password page and you'll like it!
Here is the new login page.
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: openmage.xyz/admin - openmage.xyz/index.php/admin
- following addresses will work: openmage.xyz/admin/ - openmage.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)

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:
- Titles
- Content text or HTML
- Text with automatic reload period
- Disable the page from these IP addresses
Here is the default page.
Example: online.
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:
- Titles
- Content text or HTML
- Text with automatic reload period
- Disable the page from these IP addresses
Here is the default page.
Example: online.
Error report

This page appears when OpenMage encounters an error. An error report was saved in the var/report folder.
Configuration options:
- Titles
- Content text or HTML
- Show the report from these IP addresses
- Send report by email to
Here is the default page.
Example: online.
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:
- Titles
- Content text or HTML
Here is the default page.
Example: online.
Hidden features
These GET parameters can be modified or added to filter results of diff and status pages:
- from: can by empty
- to: can by empty
- excl: can be added to exclude files (by extension or by name)
- dir: can be added to filter directories
To enable diff at character level with diff-highlight, with Debian:
bashcd /usr/share/doc/git/contrib/diff-highlight/
sudo make
Events
Three events are available:
- admin_versioning_add_fields: to add options to the confirmation request
- admin_versioning_upgrade_before: to perform any action before the update
- admin_versioning_upgrade_after: to perform any action after the update
An example is available in the Demo.php and config.xml files.
Téléchargement du module
Installation avec composer : composer require luigifab/openmage-versioning
Téléchargement de la dernière version : openmage-versioning-4.6.0.tar.gz
Voir aussi : github - composer - geany - phpstorm
- Version actuelle : 4.6.0 (01/01/2024)
- Compatibilité : OpenMage 19.x / 20.x / 21.x - PHP 7.2 / 7.3 / 7.4 / 8.0 / 8.1 / 8.2 / 8.3 ~ (PHP avec exec)
- Compatibilité client : Firefox 36+, Chrome 32+, Opera 19+, Edge 16+, Safari 9+
- Traductions : allemand (de), anglais (en), espagnol (es), français (fr-FR/fr-CA), italien (it), portugais (pt-PT/pt-BR) / chinois (zh), grec (el), hongrois (hu), japonais (ja), néerlandais (nl), polonais (pl), roumain (ro), russe (ru), slovaque (sk), tchèque (cs), turc (tr), ukrainien (uk)
- Licence : GNU GPL 2.0+
- À lire absolument : le fichier README
Si vous aimez ce module, prenez un peu de votre temps pour améliorer les traductions.