Fix incorrect hook implementation.

From #5178.