The Versioning module for OpenMage
Contents (v4.6.0)
Don't forget that the present documentation is only about the latest version of the module.
Don't forget to read this page entirely.
🌟🌟🌟🌟🌟 by Henri,
on 01/04/2020 This module isn't premium, isn't ultimate, isn't pro, it doesn't contain a spyware or a nice ad, and it won't increase by 165% your ROI. It's just better than anything else you've seen anywhere else. It's a revolution!
Module presentation
Description
This module allows:
- 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.
Access and 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 with OpenFileEditor
When OpenFileEditor browser extension is installed, when a PHP error trace is displayed, file paths can be clicked, to open them in your preferred file editor.
Installation and uninstallation
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 (or by decompressing the module archive) before validating/committing all changes.
For uninstallation, having uninstalled the module, all that remains is to erase the 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.
Module download
Installation with composer: composer require luigifab/openmage-versioning
Download of the latest version: openmage-versioning-4.6.0.tar.gz
See also: github - composer - geany - phpstorm
- Current version: 4.6.0 (01/01/2024)
- Compatibility: OpenMage 19.x / 20.x / 21.x, PHP 7.2 / 7.3 / 7.4 / 8.0 / 8.1 / 8.2 / 8.3 (with exec)
- Client compatibility: Firefox 36+, Chrome 32+, Opera 19+, Edge 16+, Safari 9+
- Translations: English (en), French (fr-FR/fr-CA), German (de), Italian (it), Portuguese (pt-PT/pt-BR), Spanish (es) / Chinese (zh), Czech (cs), Dutch (nl), Greek (el), Hungarian (hu), Japanese (ja), Polish (pl), Romanian (ro), Russian (ru), Slovak (sk), Turkish (tr), Ukrainian (uk)
- License: GNU GPL 2.0+
- Read absolutely: the README file
- 4.6.0
- Tested with Firefox 36/114, Chrome 32/109, Edge 109, Opera 19/95 on OpenMage 21.3.0 with PHP 7.2 - 8.3 and MariaDB 10.11.
If you like this module, take some of your time to improve the translations.