<div dir="ltr">Perhaps this line is causing the issue?<div><br></div><div>$this->originalSel = $sel->ToXml();</div><div><br></div><div>I've just tested the GetLayers() and they work well.<br><br>(after lauching from an InvokeURL in the Flexible Web Layout)<br>$configFilePath = "C:\Program Files\OSGeo\MapGuide\Web\www\webconfig.ini";<br>$mgSessionId = ($_SERVER['REQUEST_METHOD'] == "POST")? $_POST['session']: $_GET['session'];<br>$mapName = ($_SERVER['REQUEST_METHOD'] == "POST")? $_POST['mapname']: $_GET['mapname'];<br>MgInitializeWebTier($cofigFilePath);<br>$userInfo = new MgUserInformation($mgSessionId);<br>$siteConnection = new MgSiteConnection();<br>$siteConnection->Open($userInfo);<br>$resourceService = $siteConnection->CreateService(0);<br>$featureService = $siteConnection->CreateService(2);<br>$queryOptions = new MgFeatureQueryOptions();<br><br>$map = new MgMap($siteConnection);<br>$map->Open($mapName);<br>        $selection = new MgSelection($map); <br>              $selection->Open($resourceService, $mapName); <br>        $selectedLayers = $selection->GetLayers();  </div><div>      for ($i = 0; $i < $numberLayers; $i++) <br>        { <br>           $layer = $selectedLayers->GetItem($i); <br>           $layerName = $layer->GetName();<br>          echo $layerName . '<br>';<br>      } <br><br></div><div>Works well.</div><div><br></div><div>gordon</div><div><br></div></div><br><div class="gmail_quote gmail_quote_container"><div dir="ltr" class="gmail_attr">On Thu, May 28, 2026 at 11:27 AM David Bowen <<a href="mailto:dbowenrci@gmail.com">dbowenrci@gmail.com</a>> wrote:<br></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex"><div dir="ltr"><div>Hello Gordon,</div><div><br></div><div>Let me know if the following is what you're looking for. The script calls the class Mg_initialize,, with the relevant sections below.</div><div><br></div><div>init gets called when the class SelectionTools first gets initiated. the function getMap gets called in the line you called out.</div><div><br></div><div>function init( $MapName, $SessionId ) {</div>        $webconfig_ini ="PATH/OSGeo/MapGuide/Web/www/webconfig.ini";    <br>        $mgMapID = $MapName;<br>        $mgSessionId = $SessionId;<br><br>        try {<br>            MgInitializeWebTier( $webconfig_ini );<br>            $userInfo = new MgUserInformation( $mgSessionId );<br>            $this->siteConnection = new MgSiteConnection();<br>            $this->siteConnection->Open( $userInfo );<br>            $this->resourceService = $this->siteConnection->CreateService( MgServiceType::ResourceService );<br>            $this->featureService = $this->siteConnection->CreateService( MgServiceType::FeatureService );<br>            $this->map = new MgMap( $this->siteConnection );<br>            $this->map->Open( $mgMapID );<br>        } catch ( MgException $e ) {<br>            echo $e->GetMessage();<br>            echo $e->GetDetails();<br>            exit();<br>        }<br><div>    }</div><div><br></div><div>function getMap() {<br>        return $this->map;<br>    }</div></div><br><div class="gmail_quote"><div dir="ltr" class="gmail_attr">On Thu, May 28, 2026 at 9:15 AM Gordon Luckett <<a href="mailto:gordon.luckett@arrowgeomatics.com" target="_blank">gordon.luckett@arrowgeomatics.com</a>> wrote:<br></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex"><div dir="ltr">I would be curious about the line:<div><br></div><div>$this->MapGuideObject->getMap();</div><div><br></div><div>Share this definition?</div></div><br><div class="gmail_quote"><div dir="ltr" class="gmail_attr">On Mon, May 25, 2026 at 1:35 PM David Bowen via mapguide-users <<a href="mailto:mapguide-users@lists.osgeo.org" target="_blank">mapguide-users@lists.osgeo.org</a>> wrote:<br></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex"><div dir="ltr"><div>We're updating our application from using an MVC framework to being a PHP only application. We're getting an unexpected error when running a spatial query that looks for corresponding data, from a specified layer, that falls within a set distance of the geocoded coordinates. This function worked as expected in the MVC framework and the only code change, for this section of code, is how the MG_initialize library is loaded.</div><div><br></div>Going through the function step-by-step, it appears that it's failing when it attempts to retrieve the layers from MapGuide. Instead of returning something, it's returning NULL. This triggers a Fusion error, where 1 of 2 different error messages are displayed.<br><br>The first error message is:<br>Failed to retrieve message for "MgFileNotFoundException". Failed to retrieve message for "MgFileIoErrNo". - MgInitializeWebTier line 155 file C:\Workspace\mg-4.0\MgDev\Web\src\WebSupport\InitializeWebTier.cpp - MgInitializeWebTierInternal line 116 file C:\Workspace\mg-4.0\MgDev\Web\src\WebSupport\InitializeWebTier.cpp - MgResources.LoadResources line 388 file C:\Workspace\mg-4.0\MgDev\Common\Foundation\System\Resources.cpp - MgResources.ParseFile line 632 file C:\Workspace\mg-4.0\MgDev\Common\Foundation\System\Resources.cpp - ByteSourceFileImpl.LoadFile line 127 file C:\Workspace\mg-4.0\MgDev\Common\Foundation\System\ByteSourceFileImpl.cpp<br><br>The second error message is:<br>Fatal error: Uncaught TypeError: extract(): Argument #1 ($array) must be of type array, string given in PATH\map\view\page.php:116 Stack trace: #0 PATH\map\view\page.php(116): extract() #1 PATH\maptools\sel_action.php(154): require_once('...') #2 PATH\maptools\sel_action.php(56): Sel_Action->selectionReport_ql() #3 PATH\maptools\sel_action.php(290): Sel_Action->__construct() #4 {main} thrown in PATH\map\view\page.php on line 116<br><br>The script is:<br>    function __construct( $config ) {<br>        $mapName = $config[ 'mapname' ];<br>        $mgSessionID = $config[ 'mapsession' ];<br>        $this->mgMapID = $mapName;<br>        $this->mgSessionId = $mgSessionID;<br>        //Initialize a MapGuide object instance<br>        require_once('../library/mapguide/Mg_initialize.php');<br>        $this->MapGuideObject = new Mg_initialize();<br>        $this->MapGuideObject->init( $this->mgMapID, $this->mgSessionId );<br>  }<br>     <br>      function getSelection() { <br>            $myMap = $this->MapGuideObject->getMap();<br>        $session = $this->mgSessionId;<br>        $mapName = $this->mgMapID;<br>        $objkeys = '';<br>        $errorMsg = null;<br>        $siteConnection = $this->MapGuideObject->getSiteConnection();<br>        // Get an instance of the Resource and Mapping Services and use them to open the map and initialize a selection object.<br>        $resourceSrvc = $this->MapGuideObject->getResourceService();<br>        $featureSrvc = $this->MapGuideObject->getFeatureService();<br>        //Get selected map layers.<br>        $sel = new MgSelection( $myMap );<br>        $sel->Open( $resourceSrvc, $mapName );<br>        $this->originalSel = $sel->ToXml();<br>        // this is where it appears to fail<br>        $selLayers = $sel->GetLayers();<br>                        <br>              //script continues but likely not relevant <br>   }<br>                     <br>Any input would be greatly appreciated.</div>
_______________________________________________<br>
mapguide-users mailing list<br>
<a href="mailto:mapguide-users@lists.osgeo.org" target="_blank">mapguide-users@lists.osgeo.org</a><br>
<a href="https://lists.osgeo.org/mailman/listinfo/mapguide-users" rel="noreferrer" target="_blank">https://lists.osgeo.org/mailman/listinfo/mapguide-users</a><br>
</blockquote></div>
</blockquote></div>
</blockquote></div>