Check availabilty field in BaseActiveRecord::populateRecord

check with Object::canSetProperty()

fixes #4305, close #4211
Better Windows detection
Improved strtr calls
Used substr_compare instead of substr when we don't care about result
Avoid method call in for condition
merge from master