Upgrading a Module

Hi,
I recently encountered an issue with one of my modules and contacted the developer to raise it as a ticket. The developer came back to say that the latest version addressed the issue and gave me a link to download. The README file included an “installation” section which was very straightforward. However, before I install the latest version, I wanted to check what the best practice is for upgrading a module?

  • I originally installed the module from the Magento Marketplace using the Web Setup Wizard.
  • The new version came zipped with instructions to copy to the app/code folder then;
    – Run bin/magento setup:upgrade to install the module
    – Run bin/magento setup:di:compile to generate dependency code
    – Run bin/magento cache:clean to clear the cache
  • No specific “upgrade” instructions were included (I’ve also checked the developer support site).

Would you uninstall the old module and then install the latest version, or will Magento detect that this is an upgrade and handle it accordingly? Does the fact that I installed one version via the Web Setup Wizard and this one via the CLI affect the upgrade process?

Hi @damianduffy,

Differences between module installation methods
It’s very important that you update your modules the same way that you originally installed them. For example, if you install something from the Web Setup Wizard or Composer then your files are installed in the following directory:

vendor/digitalstartup/module

However, if you install modules by uploading it via FTP then it gets installed in:

app/digitalstartup/module

Crossing over these installation methods will normally trigger some error along the way.

Back to the question
To answer your question, there is no need to uninstall a module in order to update it. In your case, you chose the “easiest” installation method to start with. Therefore upgrading will be a breeze.

When you next go into the Web Setup Wizard, you’ll want to choose the Extension Manager. This will have a direct link to your Magento Magento Marketplace Account.

From there, you should be able to find and follow the prompts required to update your module.

Side Note…
There were a few versions of Magento 2.2.x which resulted in parts of the Web Setup Wizard being broken. I think it resulted in some pages loading a blank screen. That might have been isolated to the Module Manager though.

Also, sometimes the Extension Manager can take a few minutes to load. Not 100% sure why this is. But just thought I’d make you aware just in case.

Finally, on some rare occasions Magento will forget your Public Access Key and Private Access Key. This results in the Web Setup Wizard not having access to your Magento Magento Marketplace Account. When this happens, just grab them from your Magento Account and re-enter them into the System Configuration.

I hope this answered your question? Let me know how you get on.

Thank Craig - I had a feeling there might be a ‘gotcha’ with this upgrade.

The latest version of the software isn’t actually available on the Magento Marketplace (as of today) so I’m not getting any upgrade options for the module. Is there a way I can point the Web Setup Wizard at the files/zip which the developer provided? If I dump the files in vendor/… will it be recognised as a valid upgrade?

No biggy. I’m pretty sure that both Web Setup Wizard and Composer act the same way. And there’s a trick you can do that will do what you ask. It’s just been nearly 2 years since I tried it… And I don’t have any examples to reverse-engineer anymore.

If you can wait till the weekend, then I’ll try to work it out. If not, then you’ll have to do what you originally suggested, which is uninstall via Web Setup Wizard and reinstall via FTP upload. Which sucks, cause you wouldn’t have to do this if the developer simply updated their Magento Marketplace repositories to begin with.

Ref your question… I have no idea. I’ve never tried it. My gut says that the folder structure may vary but I really couldn’t tell you. Not right now anyway…

If you can wait till the weekend, then I’ll try to work it out

Thanks for the offer Craig but there’s lots I can be doing to fix this without wasting your time doing testing!! :+1:

I’m going to log this with the developer and see if they come back with anything tomorrow. Failing that I might do some more research on the Web Wizard and as a last resort I’ll uninstall/reinstall the module.

I’ll pop back after to update with a solution (or a story about how big a mess I’ve made :joy:).

1 Like

7 posts were split to a new topic: Web Setup Wizard stuck after failed rollback

I’ve just seperated the latter half of this post into its own post to make it easier for new readers to follow who run into the same issue. Hope you don’t mind.

1 Like

I managed to uninstall the old Stripe module and then went through the installation process for the new module.

1. Upload the extension to your app/code/Magenest/Stripe (unzipped files into this directory).
2. Run bin/magento setup:upgrade to install the module
3. Run bin/magento setup:di:compile to generate dependency code
4. Run bin/magento cache:clean to clear the cache

Everything completed without any error messages but now I have a brand new issue. I can’t access the frontend or backend admin portal any more :persevere:.

If I modify app/etc/config.php from

'Magenest_Stripe' => 1

to

'Magenest_Stripe' => 0

will this disable the installed module?

If so, do I need to carry out any other actions in conjunction with it; such as clear cache, recompile, etc?

Thanks

Before I answer, I figured I’d start with a “Did you know…?”

Did you know
“There has been an error processing your request” is the “Customer Friendly” version of the error message. It hides some really useful information. This information can be accessed a number of ways. One of which is in the var/log/system.log file. If you open the file with the command below (which opens the file in a text editor called “vi”:

  1. nano var/log/system.log
  2. Then press Ctrl+_ which asks what line number to go to
  3. Then press Ctrl+V to go to the end of the file
  4. Then use Page Up/Down to find the error it’s normally pretty obvious what’s wrong
  5. You can exit vi by pressing Ctrl+X once you’re done

This should tell you exactly what the issue with rather than guessing/pressuming.

If you output the error, I’ll try to help “translate” it for you. It’ll probably start with the word “Exception” somewhere, followed by a few more lines of code. Usually the first 2-3 lines are the most relevant.

The way I’d install the new module (Assuming in Production Mode)

  1. Upload the extension to your app/code/Magenest/Stripe
  2. bin/magento module:status to find the “name” of the currently disabled module that you just uploaded
  3. bin/magento module:enable <Vendor_Module> Enable the new module you just uploaded (Replace last bit with name you grabbed from step 2)
  4. bin/magento setup:upgrade to install the module
  5. bin/magento setup:di:compile to compile
  6. bin/magento setup:static-content:deploy en_GB en_US to generate content for required languages
  7. bin/magento cache:flush to flush the cache

Editing app/etc/config.php would be the equivalent to step 3 (I believe). I never edit the config.php file directly.


(Step 3 Example)

This seems to be the only entry regarding an exception/error:

[2019-02-19 18:07:03] main.ERROR: Cron Job sales_send_order_invoice_emails has an error: Invalid configuration file: '/var/www/html/app/etc/env.php'. Statistics: {"sum":0,"count":1,"realmem":0,"emalloc":0,"realmem_start":46399488,"emalloc_start":44871008} [] []

That’s odd, because I’m pretty sure none of the commands you’ve listed so far would make any changes to env.php. Are there any other lines preceding this one in the log? Hopefully something that indicates what’s wrong with the env.php file.

This is a copy of my Magento 2.3 Sandbox env.php file if you want to compare files.

I loaded up a pre-stripe module install image and installed the newer version provided by the developer from the CLI. Everything went much better this time around, however I do now have a new issue.

The frontend is not loading the layout correctly. CSS seems to be loading ok (colours, fonts anyway) but the layout is not loading correctly. The admin login page isn’t loading any formatting but once I login it appears normal.

I’ve been doing some googling and some posts on stackexchange are suggesting to make changes to module PHP files. This seems a little extreme and will probably only make matters worse.

Has anyone else encountered this layout loading issue?

Man, that modules’ been the bane of your life :slight_smile:

Sounds like the Static Content hiccuped. Have you tried running this again?

  1. bin/magento setup:static-content:deploy en_GB en_US
  2. bin/magento cache:flush

If that doesn’t work, open Inspect Element in Google Chrome (F12), select “Network” and hit Refresh. I assume you get a load of red lines in the output? This should give a clue as to the type of files not loading and a potential reason for it.

1 Like

Yes, I had tried deploying static content and flushing the cache a number of times but it didn’t have any effect.

I hadn’t thought to check what was/wasn’t loading. It appears to be most of the scripts and CSS; although the CSS are cancelled rather than fail:

  • require.js (404)
  • mixins.js (404)
  • polyfill.js (404)
  • calendar.css (canceled)
  • styles-m.css (canceled)
  • styles-l.css (canceled)
  • print.css (canceled)

Craig,
I’m currently in Production mode. Would you think it’s worth while switching to Developer mode? Is it likely to force some of these static files to be generated?

It looks like these JS files should be in my pub/static folder but for some reason they’re not.

Fixed it. Here’s the detail …

  1. I’m a f#€king idiot
  2. I missed one of the locale parameters when I deployed the static content
  3. I missed it EVERY time I repeated this step
  4. I’m a f#€king idiot

I’m using en_IE but completely forgot to include it. Only noticed it when I was looking at the path for the missing .js files after you suggested checking the Chrome network console.

1 Like

Story of my life :slight_smile: But it’s things like this that help us learn from our mistakes. I bet you never make the same mistake again.

Glad you got it sorted :+1:

1 Like