Jump to content

How do I block a module from checking for updates?


Boost
 Share

Recommended Posts

Hei,

I installed a module a while back and modified it to suit my needs. Now I'd like to prevent checking for updates so that I don't accidentally update it and lose all my modifications. Any suggestions?

Cheers

Link to comment
Share on other sites

Hello,

1 hour ago, Boost said:

I don't accidentally update it and lose all my modifications. Any suggestions?

You can do this: https://processwire.com/blog/posts/processwire-core-updates-2.5.14/#multiple-copies-of-the-same-module

1 hour ago, Boost said:

Now I'd like to prevent checking for updates so that I don't accidentally update

Maybe I'm missing something, but how can one accidentally upgrade a module? Besides, if you think that is an issues, your backups and/or git versions, etc... should cover you, shouldn't they?

  • Like 1
Link to comment
Share on other sites

22 minutes ago, szabesz said:

Hello,

You can do this: https://processwire.com/blog/posts/processwire-core-updates-2.5.14/#multiple-copies-of-the-same-module

Maybe I'm missing something, but how can one accidentally upgrade a module? Besides, if you think that is an issues, your backups and/or git versions, etc... should cover you, shouldn't they?

You would be surprised at what human beings are capable of.?

Thanks, but my module is not a core one.

  • Haha 1
Link to comment
Share on other sites

12 hours ago, Boost said:

Now I'd like to prevent checking for updates so that I don't accidentally update it and lose all my modifications.

When I modify a module that exists in the modules directory I put my initials in the module title or summary as a reminder, e.g. "Some Module: RPS mod".

Then I disable the download button and add a notice to the "Download and Update" form just in case I forget.

$wire->addHookAfter('ProcessModule::buildDownloadConfirmForm', function(HookEvent $event) {
	$data = $event->arguments(0);
	/* @var InputfieldForm $form */
	$form = $event->return;
	$modules = $event->wire()->modules;
	// Return early if the module isn't already installed
	if(!$modules->isInstalled($data['class_name'])) return;
	// Get info about the installed module
	$info = $modules->getModuleInfoVerbose($data['class_name']);
	// Return early if special string doesn't occur in the title or summary
	if(strpos($info['title'], 'RPS mod') === false && strpos($info['summary'], 'RPS mod') === false) return;
	// Disable download button and add warning notice
	$update_button = $form->getChildByName('godownload');
	if($update_button) {
		$update_button->value = 'Update disabled (RPS custom mod)';
		$update_button->attr('style', 'opacity:0.5;');
		$update_button->attr('disabled', 'disabled');
		$this->warning('Module has custom RPS modifications: update disabled');
	}
	$event->return = $form;

image.png.1829ed85488179b5a625d75ccfbc0fb6.png

  • Like 8
Link to comment
Share on other sites

8 hours ago, Robin S said:

When I modify a module that exists in the modules directory I put my initials in the module title or summary as a reminder, e.g. "Some Module: RPS mod".

Then I disable the download button and add a notice to the "Download and Update" form just in case I forget.

$wire->addHookAfter('ProcessModule::buildDownloadConfirmForm', function(HookEvent $event) {
	$data = $event->arguments(0);
	/* @var InputfieldForm $form */
	$form = $event->return;
	$modules = $event->wire()->modules;
	// Return early if the module isn't already installed
	if(!$modules->isInstalled($data['class_name'])) return;
	// Get info about the installed module
	$info = $modules->getModuleInfoVerbose($data['class_name']);
	// Return early if special string doesn't occur in the title or summary
	if(strpos($info['title'], 'RPS mod') === false && strpos($info['summary'], 'RPS mod') === false) return;
	// Disable download button and add warning notice
	$update_button = $form->getChildByName('godownload');
	if($update_button) {
		$update_button->value = 'Update disabled (RPS custom mod)';
		$update_button->attr('style', 'opacity:0.5;');
		$update_button->attr('disabled', 'disabled');
		$this->warning('Module has custom RPS modifications: update disabled');
	}
	$event->return = $form;

image.png.1829ed85488179b5a625d75ccfbc0fb6.png

Perfect! Thank you.

  • Like 1
Link to comment
Share on other sites

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 account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...