luigifab.fr

The Versioning module for OpenMage

Contents (v4.6.0)

  1. Module presentation
    1. Description
    2. Access and configuration
    3. Compatible with OpenFileEditor
    4. Installation and uninstallation
  2. Install procedure
  3. Deploy procedure
  4. Configuration
    1. Project manager
    2. Login page
    3. Maintenance pages
    4. Hidden features
    5. Events
  5. Module download

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:

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:

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

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)

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 OpenMage encounters an error. An error report was saved in the var/report folder.

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.

Hidden features

These GET parameters can be modified or added to filter results of diff and status pages:

Example: .../versioning_repository/status/from/xyz/to/xyz/key/.../?dir=../abc/ ../def/&excl=min,csv,gallery.phtml,copyright.

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:

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

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.