Fixed Possible to install add-on more than once through CLI

Jake B.

Well-known member
Affected version
2.0.0 Beta 3
Screen Shot 2017-09-22 at 9.04.45 AM.webp

On case insensitive systems it doesn't validate the case of the add-on ID so I can run

xf xf:addon-install ThemeHouse/UIX to install it once
xf xf:addon-install ThemeHouse/Uix to install it a second time
xf xf:addon-install ThemeHouse/UIx to install it a third time

Only time it doesn't let me install it more than once is if I use the exact same case of one of the versions already installed, so if I run xf xf:addon-install ThemeHouse/UIX again it'll give me an error This add-on is already installed. Please upgrade it instead.

DB values:
Screen Shot 2017-09-22 at 9.05.13 AM.webp
 
Found a temporary fix for this on case insensitive systems (such as Windows and MacOS):

\XF\Addon\Manger:getById:

Code:
public function getById($addOnId)
{
   $installedList = $this->getInstalledEntities();
   $installed = isset($installedList[$addOnId]) ? $installedList[$addOnId] : null;
   $jsonInfo = $this->getAddOnJsonInfo($addOnId);

   if (!$installed && !$jsonInfo)
   {
      return null;
   }

   if (!isset($this->getAllAddOns()[$addOnId]))
       {
           return null;
       }

   return $this->loadAddOnClass($installed, $jsonInfo);
}

I'm sure there's a more efficient way to do this, but it works and keeps someone from accidentally installing an add-on with the wrong case and then running into issues later
 
Top Bottom