Bug 323 - [Chameleon] MapFile path in index.phtml required to be absolute
: [Chameleon] MapFile path in index.phtml required to be absolute
Status: CLOSED FIXED
: Chameleon
Core
: 1.1
: PC Windows NT
: P1 normal
: 1.99 beta 2
Assigned To:
:
:
:
:
:
  Show dependency treegraph
 
Reported: 2004-03-23 16:15 by
Modified: 2004-06-24 10:27 (History)


Attachments


Note

You need to log in before you can comment on or make changes to this bug.


Description From 2004-03-23 16:15:33
When referring to your mapfile in index.phtml of a Chameleon application you
must specify your path absolutely.  If it is not specified with an absolute path
then a specific portion of map_session.php does not get executed (as per below):

lines 206 to 222 of map_session.php

        if ($szMapFilePath != "" && is_dir($szMapFilePath))
        {
            if (strncasecmp( "lmx.", strrev($szMapFile), 4 ) == 0)
            {
                $this->oMap = ms_newMapObj( "" );
                $this->oMap->loadMapContext( $szMapFile );
            }
            else
            {
                $this->oMap = ms_newMapObj($szMapFile, $szMapFilePath);
            }
        }
        else
        {
            // set the map object to be the phpmapscript map object
            $this->oMap = ms_newMapObj($szMapFile);
        }

map_ession should call the line that has ms_newMapObj($szMapFile,
$szMapFilePath); but it calls the last line in the if, the one with
ms_newMapObj($szMapFile);.  Missing the original mapfile path is what causes
MapServer to output an error.  What needs to be figured out is why the wrong
part of the if() is executed.

Note that using an absolute path DOES work.
------- Comment #1 From 2004-03-23 18:23:13 -------
I debugged that stuff with Jason. What happens is that if you pass a relative
path to a mapfile when you initialize your chameleon app (e.g. ../map/blah.map),
then you end up with $szMapFilePath equal to "../map", and the test on
is_dir($szMapFilePath) may fail.  Even if it didn't fail, you may still have
problems in the call to ms_newMapObj($szMapFile, $szMapFilePath) if you pass it
a relative path.

The solution: have chameleon turn the mapfile path into an absolute path when
you load the mapfile initially, and use the absolute path to set $szMapFilePath
------- Comment #2 From 2004-04-01 14:20:43 -------
we will need some code in chameleon.php to figure out if the map file path is
relative or absolute, and if it is relative, then calculate an absolute path
from gszAppPath.
------- Comment #3 From 2004-04-01 15:21:42 -------
I think it would be helpful to have functions available to any php code that
you can throw any kind of 
path or url at and get an absolute path or url back. Otherwise, we're going to
end up with several 
implementations of this scattered throughout our widgets. I just added one to
SECTPopup.widget.php 
last night.
------- Comment #4 From 2004-04-01 15:42:24 -------
There's realpaht() for filenames in PHP.  It wouldn't work for URLs though, but
I don't think we need that here anyway.
------- Comment #5 From 2004-04-05 13:55:29 -------
I copied a functoin from PHP doc site to resolve a relative path from an other
path. I added the code to resolve the absolute path of the map using the
gszAppPath var.
------- Comment #6 From 2004-06-22 14:40:42 -------
verfied with beta 2 2004-06-20 local copy of the hawaii demo and changes path to
mapfile to a reletive path.
------- Comment #7 From 2004-06-24 10:27:04 -------
closing bug and changing target to "1.99 beta 2" since it has be verified with
the beta 2.