I'm attaching a long but trivial script that triggers misbehaviors, describing what's wrong at each touch-activated step. What llReplaceEnvironment does wrong to the actual environment settings is to set Day Length to 4.0 and Day Offset to 0.0 despite being called with values of -1, which should retain the values unchanged. More confusing, though, is it leaves the parcel environment in a state that the viewer cannot report the names of the new Settings it has installed.
Note: For convenient test setup, the script uses UUIDs to represent Settings, but it gets the same results using names of those Settings in the object inventory, so whatever is preventing the proper naming of those Settings in the viewer, it happens whether or not a name is supplied in the function call.