Skip to content

Commit

Permalink
Fix issue Attempt to assign property "astroid_author_social0" on array
Browse files Browse the repository at this point in the history
  • Loading branch information
sonvnn committed Jun 13, 2024
1 parent bd50a3b commit 774520b
Show file tree
Hide file tree
Showing 2 changed files with 32 additions and 2 deletions.
4 changes: 2 additions & 2 deletions plugins/astroid/astroid.xml
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@
<extension type="plugin" method="upgrade" group="system">
<name>Astroid Plugin</name>
<author>Astroid Framework Team</author>
<creationDate>November 2023</creationDate>
<version>3.0.5</version>
<creationDate>June 2024</creationDate>
<version>3.1.0</version>
<url>https://www.astroidframe.work</url>
<copyright>Copyright (C) 2023 TemPlaza, Inc. All rights reserved.</copyright>
<license>GNU General Public License version 3 or later; see LICENSE.txt</license>
Expand Down
30 changes: 30 additions & 0 deletions plugins/astroid/src/Extension/AstroidPlugin.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
*/

namespace Joomla\Plugin\System\Astroid\Extension;
use Joomla\CMS\Factory;
use Joomla\CMS\Plugin\CMSPlugin;
use Joomla\CMS\Plugin\PluginHelper;

Expand Down Expand Up @@ -97,6 +98,35 @@ public function onAfterRespond()
echo Helper::str_lreplace('</body>', Helper::debug() . '</body>', $contents);
}

public function onContentPrepareData($context, $user)
{
if ($context == 'com_users.profile') {
$params = new \Joomla\Registry\Registry();
$params->loadArray($user->params);
if (is_array($params->get('astroid_author_social')) && !count($params->get('astroid_author_social'))) {
$params->remove('astroid_author_social');
$db = Factory::getContainer()->get(\Joomla\Database\DatabaseInterface::class);
$object = new \stdClass();
$object->id = $user->id;
$object->params = $params->toString();
$db->updateObject('#__users', $object, 'id');
}
}
}

public function onUserAfterSave($user, $isnew, $success, $msg): void
{
$params = new \Joomla\Registry\Registry($user['params']);
if (is_array($params->get('astroid_author_social')) && !count($params->get('astroid_author_social'))) {
$params->remove('astroid_author_social');
$db = Factory::getContainer()->get(\Joomla\Database\DatabaseInterface::class);
$object = new \stdClass();
$object->id = $user['id'];
$object->params = $params->toString();
$db->updateObject('#__users', $object, 'id');
}
}

public function onInstallerAfterInstaller($installmodel, $package, $installer, $result)
{
if (!$result || Framework::isSite()) {
Expand Down

0 comments on commit 774520b

Please sign in to comment.