hardcoded path information for example /var/www/mvhub

Bug #424505 reported by Dan MacNeil
10
This bug affects 2 people
Affects Status Importance Assigned to Milestone
MVHub
In Progress
Medium
Mansi

Bug Description

-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

 affects mvhub
 assignee mansi
 importance medium
 milestone 2009-09
 security no
 status confirmed

 tag refactor

Problems we are solving:

  Information is duplicated in apache.conf , test scripts, application
conf, env_vars.sh change requires modification of several files.

 ugly to hard code (emotionally very traumatic to read)

we will need to change paths to package software, easier if not hard coded

   other people will want to install in places other than our
   hard coded choices

In many places in the code there is hard coded path information for
example '/var/www/mvhub'

All this information should be in a single config file and the various
scripts and libraries should read this info from the config file

Some scripts should be generated from conf file.

For example lib-mvhub/lib/MVHub/CGIAppBase.pm should maybe setup
$BASE_DIR for project root and $SOURCE_DIR $BASE_DIR/link-to-live/code

Some paths are or should be calculated.

  For example cgi-bin is $BASE_DIR/$WEB_DOCUMENT_ROOT/cgi-bin/

Eric A says sprintf or interpolation is better/less dangerous than eval
for this.

Possible Steps to project:
  0) write tests:
     look for /var/www maybe?
    look for /.*/.*/ maybe?

   1) find and list all hard coded path info

  2) make a chart (spreadsheet ??) with current hardcoded info
       | ideal variable names

 3) list code to be written, probably
   lib-mvhub/lib/MVHub/Conf.pm
    mv_generate_conf
   modify: lib-mvhub/lib/MVhub/CGIAppBase.pm

4) modify all code to remove hard coded paths

5) remove conf files now generated from version control

6) Add test to be sure generated conf is older than master conf file

-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.9 (GNU/Linux)
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org

iEYEARECAAYFAkqhXoIACgkQLzI3mETyffzm6gCdEim71WA/alVUCsZNX+dIaVsy
J7gAn3BZZnepjakSGEqneD8A1+KemPk5
=gfDZ
-----END PGP SIGNATURE-----

Tags: refactor
Revision history for this message
Lee Goodrich (leegoodrich) wrote :

When completed the following query should only return the conf files:
grep /var/www/mvhub . -Rl | grep -v 'txt$'

Revision history for this message
Lee Goodrich (leegoodrich) wrote :

Made progress. Added path information to config file, and methods to extract the path from the config file within the code. Only developer-specific tools (mv_dump, env_vars_setup.sh, etc.), tests, and apache configuration (mvhub.conf) remain with hardcoded paths.

Changed in mvhub:
status: Confirmed → In Progress
Revision history for this message
Lee Goodrich (leegoodrich) wrote :

From refactor.txt:

in all .pl and .pm files replace all things like:
'cgi-bin/mvhub/' with $CGI-BIN_DIR
  /css/admin.css with $CSS_DIR

in HTML::Template files replace all hardcoded '/cgi-bin/mvhub/' with something
like tmpl_var name='cgi-bin'

Revision history for this message
Dan MacNeil (omacneil) wrote :

The ideal 'we are done grep is:'

   grep /var/www/mvhub . -R | egrep -v 'conf:|txt:' | more

the ":" replaces $ as filenames come at middle and always have ':'

To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Other bug subscribers

Remote bug watches

Bug watches keep track of this bug in other bug trackers.