Package Update/Upgrade Error

Permalink
Trying to figure out why I'm getting this error while adding new page attributes to a package. Everything works fine if I uninstall then reinstall the package, but I get this error if I try to upgrade it:
Fatal error: Call to a member function getAttributeTypeID() on a non-object in /Users/justrjlewis/RJLewisDesign/Sites/development(Themes)/updates/concrete5.6.3.1_updater/concrete/core/models/attribute/key.php on line 250

Everything works fine, but the attribute does not get added.

In my public function upgrade, I have:
$cak = CollectionAttributeKey::getByHandle('update');
          if (!is_object($cak)) {
            CollectionAttributeKey::add($dt,array('akHandle'=>'update','akName'=>t('Date Updated'),'akDateDisplayMode'=>'date'),$pkg)->setAttributeSet($eventpostSet);
          }

justrj
 
JohntheFish replied on at Permalink Best Answer Reply
JohntheFish
In the install method, the package doesn't exist and is created by:
$pkg=parent::install();


In the upgrade method,
parent::upgrade();

doesn't return anything because the package object already exists as $this, so if you replace $pkg in your code with $this, that should solve the problem.
justrj replied on at Permalink Reply
justrj
Worked like a charm. Thanks!

This website stores cookies on your computer. These cookies are used to improve your website experience and provide more personalized services to you, both on this website and through other media. To find out more about the cookies we use, see our Privacy Policy.