View Issue Details

IDProjectCategoryView StatusLast Update
0007879mantisbtadministrationpublic2007-04-05 17:52
Reportergiallu Assigned To 
PrioritynormalSeverityminorReproducibilityhave not tried
Status newResolutionopen 
Summary0007879: alternate position for mantis_offline.php
Description

The FHS on Linux systems impose putting configuration files under /etc; in particular, the Fedora package (but I think at least Debian is doing the same) uses /etc/mantis.

A patch allowing mantis to find mantis_offline.php when it is put into /etc/mantis would be a nice aid to linux packagers.

TagsNo tags attached.
Attached Files
mantis-alternate_path_for_config-files.patch (803 bytes)   
Index: mantisbt/core.php
===================================================================
--- mantisbt.orig/core.php
+++ mantisbt/core.php
@@ -28,7 +28,10 @@
 	#   If you have to test Mantis while it's offline, add the
 	#   parameter 'mbadmin=1' to the URL.
 	#
-	$t_mantis_offline = 'mantis_offline.php';
+	$t_mantis_offline = getenv( 'MANTIS_OFFLINE' );
+	if ( is_null( $t_mantis_offline ) ) {
+		$t_mantis_offline = 'mantis_offline.php';
+	}
 	if ( file_exists( $t_mantis_offline ) && !isset( $_GET['mbadmin'] ) ) {
 		include( $t_mantis_offline );
 		exit;
@@ -152,4 +155,6 @@
 	if ( !isset( $g_bypass_headers ) && !headers_sent() ) {
 		header( 'Content-type: text/html;charset=' . lang_get( 'charset' ) );
 	}
-?>
\ No newline at end of file
+
+# vim: noexpandtab tabstop=4 softtabstop=0:
+?>

Activities

giallu

giallu

2007-04-03 17:35

reporter   ~0014305

With the patch attached, mantis will scan the given array of alternate mantis_offline.php position, until the array ends or the file is found.

Of course the list could be expanded as needed

chillax

chillax

2007-04-03 19:30

reporter   ~0014306

Don't think that really makes sense for the offline file...
Maybe you misunderstand what that file is? Not exactly a configuration file that should be in /etc/ in my opinion.

vboctor

vboctor

2007-04-04 01:53

manager   ~0014308

Some questions relating to your change:

  1. What about other files like config_inc.php, custom_strings_inc.php, custom_functions_inc.php, etc?

  2. How much of a performance impact to check file_exists() on multiple paces with every page request? I would rather if we have a configuration option that specifies the position and we check for that location.

  3. There was a request somewhere here or on the forums to be able to rename this file. For example, offline.php or issuetracker_offline.php. This may be something that we want to tackle with this change as well.

giallu

giallu

2007-04-04 03:16

reporter   ~0014311

In reply to chillax:

AFAICT, when the file is present in the mantis root directory:

  1. the whole tracker is put offline
  2. the mantis_offline.php content is shown instead of the given page

Now, while 2 could be argued not being a configuration, but a customization, I think 1 definitely is a configuration thing, to the point we could decouple those semantics and have:

  1. a configuration switch for putting the tracker offline
  2. a mantis_offline.php file in the mantis root dir (in my case /usr/share/mantis)
giallu

giallu

2007-04-04 03:46

reporter   ~0014313

In reply to vboctor:

  1. I was pondering on the very same topic but IMO that is not a clear cut. In general, when you need to customize a RPM, you:
    • take the SRPM
    • add your files/patches
    • rebuild the RPM

the difference here is that mantis gives you a method to add easily some customizations w/o touching the source code. I think we could support looking for the custom* fields in an alternate path. However this is probably a topic for another bug/thread.

  1. w/o measuring before and after, I can't really know what impact to expect. However, I agree with this proposal, so I could refactor the patch to look for the offline file in a user supplied path (defaulting to the old location)

  2. will be possible with the above

giallu

giallu

2007-04-04 04:28

reporter   ~0014314

I just noticed the offline check is performed before searching and including the configuration parameters. Possible solutions:

  1. move to offline check after including config file, so we can use definitions from there

  2. use an environment variable (like it is done few lines later) to supply the path to the offline file

thoughts?

giallu

giallu

2007-04-05 17:52

reporter   ~0014324

OK. the attached revised patch lets the administrator choose the full path, including filename, to the mantis offline file.

If the env varbiable MANTIS_OFFLINE is not set, the behavior is unchanged