Juergen Posted April 26, 2023 Share Posted April 26, 2023 Hello @all I need a Hook that will run after a user updates a module from the PW module directory. The reason for that is, that the update only affects files which are inside the updated module itself. If a module creates files or directories on other places of the systen, they will never get affected during an update. In my case, my FrontendForms module copies a file (captchaimages.php) from the module to the root directory of the PW installation during the installation process of the module. The problem is, if I update this file, running an update will never updates the file in the root directory. So this file will never be touched again after the installation. For this reason I need a Hook, that will run after a module was updated successfully, so I can write a code to update this file manually (or in other words to replace the file inside the root with the file from the update version). Can anyone help me if there is an appropriate Hook. Thanks in advance Link to comment Share on other sites More sharing options...
monollonom Posted April 26, 2023 Share Posted April 26, 2023 Have you tried hooking after your module’s ___upgrade() ? You could also put your code in there like I did for one of mine 1 Link to comment Share on other sites More sharing options...
Juergen Posted April 26, 2023 Author Share Posted April 26, 2023 Yeah, I have tried that, but nothing had happened. But maybe I have done something wrong. I will take a look if owerwriting, as you have it done, will be the better way to go. Thanks for your help!!! 1 Link to comment Share on other sites More sharing options...
Juergen Posted April 26, 2023 Author Share Posted April 26, 2023 OK, other people have struggled with same problem too. Using the module upgrade() function is the way to go, that works. https://processwire.com/talk/topic/26912-module-update-function/#comment-222616 Problem solved ? 1 Link to comment Share on other sites More sharing options...
monollonom Posted April 26, 2023 Share Posted April 26, 2023 2 hours ago, Juergen said: OK, other people have struggled with same problem too. Using the module upgrade() function is the way to go, that works. https://processwire.com/talk/topic/26912-module-update-function/#comment-222616 Problem solved ? lol entirely forgot I provided the exact same answer... at least I'm consistent ? 1 Link to comment Share on other sites More sharing options...
Juergen Posted April 26, 2023 Author Share Posted April 26, 2023 You will pass every police interview! ? 1 Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now