Jump to content

___install function not working?


Sebi
 Share

Recommended Posts

Hello!
I'm debugging for a few days because I noticed that my modules can no longer be installed without errors. If there is a ___install function in my module, an error is thrown when installing the module and the code in the ___install function is not executed. I am sure that it worked, because AppApi uses that function to initialize all database tables.

Here is the code of a simple test-module that is not installable without errors anymore:

<?php namespace ProcessWire;

class TestModule extends WireData implements Module {
	public static function getModuleInfo() {
		return [
			'title' => 'My Test module',
			'summary' => 'An example of creating a module',
			'version' => 1,
			'author' => 'Sebastian Schendel',
			'icon' => 'user-plus',
			'requires' => [
				'PHP>=7.2.0',
				'ProcessWire>=3.0.98'
			],
			'autoload' => true,
			'singular' => true
		];
	}

	public function ___install() {
		if (!parent::___install()) {
			return false;
		}

		return true;
	}
}

These errors occur for example:
Fatal error: Allowed memory size of 134217728 bytes exhausted (tried to allocate 262144 bytes) in /processwire/wire/core/WireHooks.php on line 912
Fatal error: Allowed memory size of 134217728 bytes exhausted (tried to allocate 262144 bytes) in Unknown on line 0

I have tested a ProcessWire version from a few weeks ago and the newest 3.0.212 dev. The error occurs in both versions and I do not know how long its present already... Tested with PHP 7.4, 8.0 & 8.1, too. 

How do you initialize your modules after install? Am I missing something here? 😳

Link to comment
Share on other sites

  • Sebi changed the title to ___install function not working?

Oh wow. Thank you @Robin S!

I've been looking for way too long, but I didn't come up with that. My AppApi module does not have the problem because it has Process extended. For that it even says in the documentation that parent::___install() has to be called. But for my simple module that only inherits from WireData, parent::___install() makes no sense. 

Thanks a lot!

  • 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...