Jump to content

Error installing modules [SOLVED]


maxf5
 Share

Recommended Posts

Clearing module cache usually helps

59a02c5d9e4a6_ClipboardImage(4).jpg.2e5041c85c8505331a38ef364987d168.jpg

 

Here's the relevant part from PW core. 

// ProcessModule.module

protected function renderEdit($moduleName, $moduleInfo) {
    // ...
    $moduleId = $this->modules->getModuleID($moduleName); 
    // ...
    if(!$moduleId) {
        $this->error("Unknown module"); 
        return $this->session->redirect('./'); 
    }
    // ...
}

And getModuleID() method:

// Modules.php

public function getModuleID($class) {
    
    $id = 0;

    if(is_object($class)) {
        if($class instanceof Module) {
            $class = $this->getModuleClass($class); 
        } else {
            // Class is not a module
            return $id; 
        }
    }

    if(isset($this->moduleIDs[$class])) {
        $id = (int) $this->moduleIDs[$class];
        
    } else foreach($this->moduleInfoCache as $key => $info) {	
        if($info['name'] == $class) {
            $id = (int) $key;
            break;
        }
    }
    
    return $id; 
}

If PW cannot get the module from the cache, it returns 0, which sets of the error you're receiving.

  • Like 1
Link to comment
Share on other sites

I'm still betting on cache. Modules.info cache holds information about which modules are installed. Mine looks like this:

// Modules.info cache

{
    "148": {
        "name": "AdminThemeDefault",
        "title": "Default",
        "version": 14,
        "autoload": "template=admin",
        "created": 1502621954,
        "configurable": 19,
        "namespace": "ProcessWire\\"
    },
    "97": {
        "name": "FieldtypeCheckbox",
        "title": "Checkbox",
        "version": 101,
        "singular": 1,
        "created": 1502621954,
        "namespace": "ProcessWire\\",
        "permanent": true
    },
    // ...
}

Try assigning an empty array to $config->preloadCacheNames in config.php to disable reading from module cache, and even manually removing Modules.info from caches table in DB.

/**
 * Cache names to preload
 * 
 * Consists of the cache name/token for any caches that we want to be preloaded at boot time.
 * This is an optimization that can reduce some database overhead. 
 *
 * @var array
 *
 */
$config->preloadCacheNames = array(
	'Modules.info',
	//'ModulesVerbose.info',
	'ModulesVersions.info',
	'Modules.wire/modules/',
	'Modules.site/modules/',
);

 

  • 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

×
×
  • Create New...