MDLSITE-3076 fix for preg_match notices during upgrade
MDLSITE-3076 added debugging() calls to provides clues in the event of an error