Opened 15 years ago

Closed 15 years ago

#3146 closed defect (fixed)

Problem with removeMetaData()

Reported by: dmorissette Owned by: aboudreault
Priority: normal Milestone: 5.6 release
Component: MapScript-PHP Version: unspecified
Severity: normal Keywords:
Cc: assefa

Description

Robert Pivalone wrote to mapserver-dev:

Hi,

I have a problem with PHP Mapscript.

When I remove one metadata, two metadata are removed.

Mapserver : 5.2.1

Mapfile :
  LAYER
    NAME "Layer0"
 ...
    METADATA
      "PPPP"    "pppp"
      "rrrr"    "rrrr"
      "eeee"    "eeee"
      "description"    "mmmm"
      "type_aa"    "dddd"
      "ayyy_aa"    "aaaa"
    END
...
  END

Source code :
$oMap = ms_newMapObj($szMapFile);
$oLayer = $oMap->getLayerByName('Layer0');
$oLayer->removeMetaData('type_aa');
$oMap->save($szMapFile);

Expected result in the mapfile :
  LAYER
 ...
    METADATA
      "PPPP"    "pppp"
      "rrrr"    "rrrr"
      "eeee"    "eeee"
      "description"    "mmmm"
      "ayyy_aa"    "aaaa"
    END
...
  END

My result :
  LAYER
 ...
    METADATA
      "ayyy_aa"    "aaaa"
      "description"    "mmmm"
      "rrrr"    "rrrr"
      "PPPP"    "pppp"
    END
...
  END

Any idea ?

Thanks

Change History (3)

comment:1 by aboudreault, 15 years ago

Cc: assefa added

The problem is that the key "eeee" and "type_aa" have the same hash value. So, both metadata are placed in the same linked list. In the code, the linked list was not properly updated for that specific case. I've made the change in r9376.

Assefa, may you confirm that the fix is ok ?

comment:2 by assefa, 15 years ago

It seems good from what I can see. Tests are also successful with the example provided in this bug.

comment:3 by aboudreault, 15 years ago

Resolution: fixed
Status: newclosed

Fixed and committed in r9376. The linked list is not updated properly when it contains more than 1 element.

Note: See TracTickets for help on using tickets.