update from 5.4.2.2 to 5.5.2.1 results in Fatal Error in Importer.php

Permalink
The site hasn't had any problems with updates till this point.
When updating this time using the update script from the dashboard I get

Fatal error: Call to a member function getController() on a non-object in /public_html/backup/updates/concrete5.5.2.1/concrete/libraries/content/importer.php on line 110

After this the site still works, but I can not login to it.

Is there anything I can do to fix this?
Why does it give this error, I havn't done anything to the core files.

I'm using the ecommerce plugin. I have other add-ons but I could remove them if they are causing the problem


Coin Slider - 1.12
Code Blocks - 1.2.1
Mailing List - 2.28
Traffic & Statistics - 2.36
Thumbview Template - 1.1.1
Galleria image gallery - 2.0

Thanks

107studio
 
ScottC replied on at Permalink Reply
ScottC
sure. I had to deal with this as well. It was a bit of a head scratcher for a minute since when it dies, it really screws up the site.

in that file in 5.5.2.1 starting at line 99

replace the function call for importSinglePageContent() with this:
protected function importSinglePageContent(SimpleXMLElement $sx) {
      Loader::model('single_page');
      if (isset($sx->singlepages)) {
         foreach($sx->singlepages->page as $px) {
            $page = Page::getByPath($px['path']);
            if (isset($px->area)) {
               $this->importPageAreas($page, $px);
            }
            if (isset($px->attributes)) {
               foreach($px->attributes->children() as $attr) {
                  $ak = CollectionAttributeKey::getByHandle($attr['handle']);
                  if(is_object($ak) && is_a($ak,'CollectionAttributeKey')) $page->setAttribute((string) $attr['handle'], $ak->getController()->importValue($attr));
               }
            }
         }


What apparently happens is that they assumed that a collection attribute would be installed, but it might not necessarily be installed for your installation. This causes the import to die about halfway through and it is kind of a mess.

This will solve it (being that issue). I promise.
andrew replied on at Permalink Reply
andrew
I've checked this tweak into the core
jasteele12 replied on at Permalink Reply
jasteele12
Hi Andrew,

I just ran into this problem from a dashboard upgrade from 5.4.2.2 to 5.5.2.1 - Scott's fix is *NOT* in the updates code.

FYI, John
107studio replied on at Permalink Reply
107studio
Thanks, I tried the fix and I assume it worked for that problem. This time when I tried I got another fatal error.

Fatal error: Call to a member function getController() on a non-object in /public_html/backup/updates/concrete5.5.2.1/concrete/libraries/content/importer.php on line 142
ScottC replied on at Permalink Reply
ScottC
I'd assume more or less the same thing here. My line #s don't match up perfectly, but replace
$ak = CollectionAttributeKey::getByHandle($attr['handle']);
   $page->setAttribute((string) $attr['handle'], $ak->getController()->importValue($attr));


with
//get our collection attribute key by the simplexmlelement attribute of handle
$ak = CollectionAttributeKey::getByHandle($attr['handle']);
//if we have a valid object, then we call the attribute's get controller method
//this returns an instance of the attribute controller if the attribute was found, then it calls importValue on it with the $attr as the value we would like to set
if(is_object($ak) && is_a($ak,'CollectionAttributeKey')){ 
$page->setAttribute((string) $attr['handle'], $ak->getController()->importValue($attr)); }


Again it is just that its calling something on an assumed return of object for when it does the CollectionAttributeKey::getByHandle call.

If you run into any issues like that again, the code is fairly easy to understand and you can probably do something similar to above.

On my particular upgrade I only ran into the issue on your first error, i never received your second.

Do you have a bunch of stuff removed from your install?

Please note that any time you the upgrade process has a problem you should roll back your database and clear the cache.

Hope that helps,
107studio replied on at Permalink Reply
107studio
That code fixed the problem, the site updated to 5.5.2.1
Sadly I have other problems with the site now.

Certain ecommerce products no longer load, page stops loading once it gets to a bad product. This also causes the C5 edit bar to not load.
I can't delete the non loading products because the product search page also stops loading and won't show the whole list or products.

Thanks for getting me this far.

Edit:
It's been a few years since I set this site up. I know I modified the ecommerce display template. Also made a custom autonav template. Everything else should be the same. I started with version 5.4.0.5