Fix build errors

| Q             | A
| ------------- | ---
| Doc fix?      | yes
| New docs?     | no
| Applies to    | 2.3/2.4
| Fixed tickets | 

This is a backport of #3544.