mirror of
https://github.com/processwire/processwire.git
synced 2025-08-08 15:57:01 +02:00
Update in Modules to correct fatal error when upgrading from a much older version of ProcessWire
This commit is contained in:
@@ -1506,7 +1506,6 @@ class Modules extends WireArray {
|
|||||||
* #pw-internal
|
* #pw-internal
|
||||||
*
|
*
|
||||||
* @return array
|
* @return array
|
||||||
* @deprecated Use $modules->info->getNamespaces() instead
|
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
public function getNamespaces() {
|
public function getNamespaces() {
|
||||||
@@ -1524,7 +1523,6 @@ class Modules extends WireArray {
|
|||||||
* - `noCache` (bool): Specify true to force reload namespace info directly from module file. (default=false)
|
* - `noCache` (bool): Specify true to force reload namespace info directly from module file. (default=false)
|
||||||
* - `noLoad` (bool): Specify true to prevent loading of file for namespace discovery. (default=false) Added 3.0.170
|
* - `noLoad` (bool): Specify true to prevent loading of file for namespace discovery. (default=false) Added 3.0.170
|
||||||
* @return null|string Returns namespace, or NULL if unable to determine. Namespace is ready to use in a string (i.e. has trailing slashes)
|
* @return null|string Returns namespace, or NULL if unable to determine. Namespace is ready to use in a string (i.e. has trailing slashes)
|
||||||
* @deprecated Use $modules->info->getModuleNamespace() instead
|
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
public function getModuleNamespace($moduleName, $options = array()) {
|
public function getModuleNamespace($moduleName, $options = array()) {
|
||||||
@@ -1538,7 +1536,6 @@ class Modules extends WireArray {
|
|||||||
*
|
*
|
||||||
* @param string $namespace
|
* @param string $namespace
|
||||||
* @return bool|string
|
* @return bool|string
|
||||||
* @deprecated Use $modules->info->getNamespacePath() instead
|
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
public function getNamespacePath($namespace) {
|
public function getNamespacePath($namespace) {
|
||||||
|
@@ -326,6 +326,14 @@ class ModulesFiles extends ModulesClass {
|
|||||||
$success = false;
|
$success = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if(!$success) {
|
||||||
|
// handle case where module has moved from /modules/Foo.module to /modules/Foo/Foo.module
|
||||||
|
// which can only occur during upgrades from much older versions.
|
||||||
|
// examples are FieldtypeImage and FieldtypeText which moved to their own directories.
|
||||||
|
$file2 = preg_replace('!([/\\\\])([^/\\\\]+)(\.module(?:\.php)?)$!', '$1$2$1$2$3', $file);
|
||||||
|
if($file !== $file2) $success = @include_once($file2);
|
||||||
|
}
|
||||||
|
|
||||||
// set instance back, if multi-instance
|
// set instance back, if multi-instance
|
||||||
if($wire1 !== $wire2) ProcessWire::setCurrentInstance($wire1);
|
if($wire1 !== $wire2) ProcessWire::setCurrentInstance($wire1);
|
||||||
|
|
||||||
|
@@ -1096,14 +1096,14 @@ class ModulesInfo extends ModulesClass {
|
|||||||
$fromVersion = $this->modules->formatVersion($moduleVersions[$id]);
|
$fromVersion = $this->modules->formatVersion($moduleVersions[$id]);
|
||||||
$toVersion = $this->modules->formatVersion($moduleInfo['version']);
|
$toVersion = $this->modules->formatVersion($moduleInfo['version']);
|
||||||
$versionChanges[$moduleName] = "$fromVersion => $toVersion: $moduleName";
|
$versionChanges[$moduleName] = "$fromVersion => $toVersion: $moduleName";
|
||||||
$editUrl = $this->modules->configs->getModuleEditUrl($moduleName, false);
|
$editUrl = $this->modules->configs->getModuleEditUrl($moduleName, false) . '&upgrade=1';
|
||||||
$this->modulesLastVersions[$id] = $moduleVersions[$id];
|
$this->modulesLastVersions[$id] = $moduleVersions[$id];
|
||||||
if(strpos($moduleName, 'Fieldtype') === 0) {
|
if(strpos($moduleName, 'Fieldtype') === 0) {
|
||||||
// apply update now, to Fieldtype modules only (since they are loaded differently)
|
// apply update now, to Fieldtype modules only (since they are loaded differently)
|
||||||
$this->modules->getModule($moduleName);
|
$this->modules->getModule($moduleName);
|
||||||
} else {
|
} else {
|
||||||
$upgradeLinks[$moduleName] = "<a class='pw-modal' target='_blank' href='$editUrl'>" .
|
$upgradeLinks[$moduleName] = "<a class='pw-modal' target='_blank' href='$editUrl'>" .
|
||||||
$sanitizer->entities1($this->_('Apply now')) . "</a>";
|
$sanitizer->entities1($this->_('Apply')) . "</a>";
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@@ -721,8 +721,8 @@ class ModulesLoader extends ModulesClass {
|
|||||||
return false;
|
return false;
|
||||||
|
|
||||||
} else if($module instanceof ModulePlaceholder) {
|
} else if($module instanceof ModulePlaceholder) {
|
||||||
$this->modules->files->includeModuleFile($module->file, $moduleName);
|
// the ModulePlaceholder indicates what file to load
|
||||||
return true;
|
return $this->modules->files->includeModuleFile($module->file, $moduleName);
|
||||||
|
|
||||||
} else if($module instanceof Module) {
|
} else if($module instanceof Module) {
|
||||||
// it's already been included, since we have a real module
|
// it's already been included, since we have a real module
|
||||||
|
@@ -1681,6 +1681,11 @@ class ProcessModule extends Process {
|
|||||||
$form->add($field);
|
$form->add($field);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if($input->get('upgrade')) {
|
||||||
|
// force it to do an upgrade check
|
||||||
|
$this->wire()->modules->getModule($moduleName, array('configOnly' => true));
|
||||||
|
}
|
||||||
|
|
||||||
$fields = $modules->getModuleConfigInputfields($moduleName, $form);
|
$fields = $modules->getModuleConfigInputfields($moduleName, $form);
|
||||||
if($fields) {
|
if($fields) {
|
||||||
foreach($fields as $field) {
|
foreach($fields as $field) {
|
||||||
|
Reference in New Issue
Block a user