Fixed XF\Extension::removeClassExtensions doesn't check existence

pegasus

Well-known member
Affected version
2.2.13
In XF\Extension::removeClassExtensions, we have:
Code:
foreach ($this->classExtensions[$class] AS $subclass)
{
   unset($this->inverseExtensionMap[$subclass]);
}
However, this does not check that the key $this->classExtensions[$class] exists before looping it, which throws an invalid key error and a foreach error. Since XF\Extension also provides no getter for $this->classExtensions, there is no easy way for an add-on to know whether this key exists if they need to call ::removeClassExtensions (e.g. inside a setup method to ensure no other add-ons affect the installer's use of a class).

This bug was introduced in 2.2.13.

If it's not too much to ask, ideally we would also have a way to make safer temporary changes like this.
Code:
$tmp = $extension->getClassExtensions($forClass);
$extension->removeClassExtensions($forClass);
// do stuff
$extension->setClassExtensionsForClass($forClass, $tmp);
 
Last edited:
Thank you for reporting this issue, it has now been resolved. We are aiming to include any changes that have been made in a future XF release (2.2.14).

Change log:
Provide a getter for class extensions, and check for class extensions before attempting to remove them
There may be a delay before changes are rolled out to the XenForo Community.
 
Back
Top Bottom