Classes extending another class won't use extension system

mattrogowski

Well-known member
Affected version
2.2, 2.3
Can't think how else to word that.

Not sure if this is strictly speaking a bug but it's a general design issue I think.

Take following example:

XF\Service\User\PasswordReset holds most of the logic for resetting passwords. XF\Service\User\SecurityLockReset extends PasswordReset

If you extend XF\Service\User\PasswordReset and extend say resetLostPassword(), your extended version will not run when called via XF\Service\User\SecurityLockReset. This is because this directly extends the base PasswordReset class and not the extended version of it. You have to extend them both and override the same function twice.

This makes sense from a PHP perspective obviously but when it comes to XF's class extension system it's not always clear if or when a different class directly extends the one you're extending with the class extensions system. As in, you can't tell that XF\Service\User\PasswordReset is further extended elsewhere unless you specifically go looking for it or know about it already.

Ideally, the instance of the XF\Service\User\SecurityLockReset service would be based on the extended version of XF\Service\User\PasswordReset. Just not sure if that is practical and/or possible at all. If it's just a limitation of the system then can close.
 
Back
Top Bottom