[Chameleon-dev] [Bug 1113] New: MLT function does not check for empty array

bugzilla-daemon at bugzilla.maptools.org bugzilla-daemon at bugzilla.maptools.org
Thu Jul 14 11:53:16 EDT 2005


http://bugzilla.maptools.org/show_bug.cgi?id=1113

           Summary: MLT function does not check for empty array
           Product: Chameleon
           Version: 2.2
          Platform: PC
        OS/Version: Windows 2000
            Status: NEW
          Severity: normal
          Priority: P2
         Component: Core
        AssignedTo: chameleon-dev at lists.maptools.org
        ReportedBy: bartvde at xs4all.nl


Trying to use a different language than the default language without having a
multilingual template, an empty array is put into the loadResource function in
mlt.php. There are checks in the function on empty strings but not on empty arrays.

function loadResource( $szName, $mLang = "" )

so $mLang is an empty array of size 0.

If this happens I made a change to default back to the original language, ie:

       elseif ($mLang != "")
       {
           // Bart, if array size is 0, back to default language
           if (sizeof($mLang) == 0) { $mLang = $this->szLanguage; }
           foreach ($mLang as $szKey => $szLang)
           {
               $mLang[$szKey] = preg_replace("/(\W)/", "_", $szLang);
           }
       }

This is caused by:

In session.inc.php resources are loaded using:

$oMLT->loadResource( $GLOBALS["szLanguageResource"], $_SESSION['aszLang'] );

$_SESSION['aszLang'] is filled up in chameleon.php with a list of regional
templates.

       // build list of languages to load
       $_SESSION['aszLang'] = array_keys( $this->maszTemplates );

But my application does not have regional templates (one language app) so this
is an empty array which is being passed into loadResource.

In summary, fix for mlt.php is:

        elseif ($mLang != "")
        {
            // if array size is 0, back to szLanguage
            if (sizeof($mLang) == 0) { $mLang = $this->szLanguage; }
            foreach ($mLang as $szKey => $szLang)



------- You are receiving this mail because: -------
You are the assignee for the bug, or are watching the assignee.


Please do NOT reply to this email, use the link above instead to 
login to bugzilla and submit your comment. Any email reply to this
address will be lost.


More information about the Chameleon-dev mailing list