Skip to content

Commit

Permalink
Fix #6744: Make sure to call humhub\components\Module::update() on Mo… (
Browse files Browse the repository at this point in the history
#6799)

* Fix #6744: Make sure to call humhub\components\Module::update() on Module update

* Added beforeUpdate and AfterUpdate deprecated

---------

Co-authored-by: Marc Farré <contact@marc.fun>
  • Loading branch information
luke- and marc-farre committed Jan 16, 2024
1 parent ac98aa3 commit c5322bd
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 8 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Expand Up @@ -5,6 +5,7 @@ HumHub Changelog
-------------------
- Enh #6779: Added Twig Sandbox Extension for Statistic Tracking Codes
- Fix #6791: Fix number of filtered modules on Marketplace
- Fix #6744: Make sure to call `humhub\components\Module::update()` on Module updates
- Fix #6796: Files in the RichText doesn't open as new tab

1.15.2 (December 19, 2023)
Expand Down
18 changes: 11 additions & 7 deletions protected/humhub/components/Module.php
Expand Up @@ -320,7 +320,7 @@ protected function getModuleInfo()
*/
public function update()
{
if($this->beforeUpdate() !== false) {
if ($this->beforeUpdate() !== false) {
$this->migrate();
$this->afterUpdate();
}
Expand All @@ -332,6 +332,8 @@ public function update()
* The update will cancel if this function does return false;
*
* @return bool
* @deprecated
*
*/
public function beforeUpdate()
{
Expand All @@ -341,6 +343,8 @@ public function beforeUpdate()

/**
* Called right after the module update.
*
* @deprecated
*/
public function afterUpdate()
{
Expand All @@ -364,9 +368,9 @@ public function getConfigUrl()
* This function should also make sure the module is installed on the given container in case the permission
* only affects installed features.
*
* @since 0.21
* @param \humhub\modules\content\components\ContentContainerActiveRecord $contentContainer optional contentcontainer
* @return array list of permissions
* @since 0.21
*/
public function getPermissions($contentContainer = null)
{
Expand All @@ -376,8 +380,8 @@ public function getPermissions($contentContainer = null)
/**
* Returns a list of notification classes this module provides.
*
* @since 1.1
* @return array list of notification classes
* @since 1.1
*/
public function getNotifications()
{
Expand Down Expand Up @@ -405,8 +409,8 @@ public function getNotifications()
/**
* Determines whether the module has notification classes or not
*
* @since 1.2
* @return boolean has notifications
* @since 1.2
*/
public function hasNotifications()
{
Expand All @@ -416,8 +420,8 @@ public function hasNotifications()
/**
* Returns a list of activity class names this modules provides.
*
* @since 1.2
* @return array list of activity class names
* @since 1.2
*/
public function getActivityClasses()
{
Expand Down Expand Up @@ -445,8 +449,8 @@ public function getActivityClasses()
/**
* Returns a list of asset class names this modules provides.
*
* @since 1.2.8
* @return array list of asset class names
* @since 1.2.8
*/
public function getAssetClasses()
{
Expand All @@ -461,7 +465,7 @@ public function getAssetClasses()
$assetDirectory = $this->getBasePath() . DIRECTORY_SEPARATOR . 'assets';
if (is_dir($assetDirectory)) {
foreach (FileHelper::findFiles($assetDirectory, ['recursive' => false,]) as $file) {
$assetClass = $assetNamespace . '\\' . basename($file, '.php');
$assetClass = $assetNamespace . '\\' . basename($file, '.php');
if (is_subclass_of($assetClass, AssetBundle::class)) {
$assets[] = $assetClass;
}
Expand Down
Expand Up @@ -173,7 +173,7 @@ public function update($moduleId)
$this->install($moduleId);

$updatedModule = Yii::$app->moduleManager->getModule($moduleId);
$updatedModule->migrate();
$updatedModule->update();

(new MarketplaceService())->refreshPendingModuleUpdateCount();

Expand Down

0 comments on commit c5322bd

Please sign in to comment.