Support Forums

Support Offline : Mon - Fri / 10am - 6pm (GMT +6)

Your Time: Our Time:

Bug about article and module id conflicts

Featured Lock Resolved Bug
When I have an article created with sp and a module of the sp type,
changing the article affects the module when they have the same id.

After inspection, found the problem was with SppagebuilderHelper: : updatePage method.

I'm trying to come up with solutions


private static function updatePage($extension, $extension_view, $view_id, $content)
{
$db = JFactory::getDbo();
$query = $db->getQuery(true);
$condition = array(
$db->qn('extension') . ' = ' . $db->q($extension),
$db->qn('extension_view') . ' = ' . $db->q($extension_view),
$db->qn('view_id') . ' = ' . $db->q($view_id)
);
$query->update($db->qn('#__sppagebuilder'))->set($content)->where($condition);
$db->setQuery($query);
$db->execute();
}



// 3rd party
public static function onAfterIntegrationSave($attribs)
{

if (!self::getIntegration($attribs['option'])) return;

$db = JFactory::getDbo();

if (self::checkPage($attribs['option'], $attribs['view'], $attribs['id'])) {

if ($attribs['action'] == 'stateChange') {
$fields = array(
$db->quoteName('published') . ' = ' . $db->quote($attribs['published'])
);
self::updatePage($attribs['option'], $attribs['view'], $attribs['id'], $fields);
} elseif ($attribs['action'] == 'delete') {
self::deleteArticlePage($attribs);
} else {
$fields = array(
$db->quoteName('title') . ' = ' . $db->quote($attribs['title']),
$db->quoteName('text') . ' = ' . $db->quote($attribs['text']),
$db->quoteName('published') . ' = ' . $db->quote($attribs['published']),
$db->quoteName('catid') . ' = ' . $db->quote($attribs['catid']),
$db->quoteName('access') . ' = ' . $db->quote($attribs['access']),
$db->quoteName('modified') . ' = ' . $db->quote($attribs['modified']),
$db->quoteName('modified_by') . ' = ' . $db->quote($attribs['modified_by']),
$db->quoteName('active') . ' = ' . $db->quote($attribs['active'])
);
self::updatePage($attribs['option'], $attribs['view'], $attribs['id'], $fields);
}

} else {
$values = array(
$db->quote($attribs['title']),
$db->quote($attribs['text']),
$db->quote($attribs['option']),
$db->quote($attribs['view']),
$db->quote($attribs['id']),
$db->quote($attribs['active']),
$db->quote($attribs['published']),
$db->quote($attribs['catid']),
$db->quote($attribs['access']),
$db->quote($attribs['created_on']),
$db->quote($attribs['created_by']),
$db->quote($attribs['modified']),
$db->quote($attribs['modified_by']),
$db->quote($attribs['language'])
);

self::insertPage($values);
}

return true;
}

2 Answers

Al Mamun - Staff

More than a month ago #Permalink
Hi,

We are checking three thing here:

if (self::checkPage($attribs['option'], $attribs['view'], $attribs['id'])) {//here we are taking three thing to check so it should not be same
....
}


By the way we can be wrong, please share your solution if you have.

Thanks,
Mamun

joomlass

More than a month ago #Permalink
There is no problem with your above judgment, the problem was found in the updatePage method after the this judgment, which did not identify the item type and only used id as a condition, so any id with duplicate data will be updated

The rewriting I have tried is mentioned in the question of the main post, which is briefly described as follows again:

1、Modify updatePage method to add parameters

private static function updatePage($extension, $extension_view, $view_id, $content)
{
$db = JFactory::getDbo();
$query = $db->getQuery(true);
$condition = array(
$db->qn('extension') . ' = ' . $db->q($extension),
$db->qn('extension_view') . ' = ' . $db->q($extension_view),
$db->qn('view_id') . ' = ' . $db->q($view_id)
);
$query->update($db->qn('#__sppagebuilder'))->set($content)->where($condition);
$db->setQuery($query);
$db->execute();
}


2. Add parameters when run this updatePage method

if (self::checkPage($attribs['option'], $attribs['view'], $attribs['id'])) {//here we are taking three thing to check so it should not be same
....
self::updatePage($attribs['option'], $attribs['view'], $attribs['id'], $fields);
....
self::updatePage($attribs['option'], $attribs['view'], $attribs['id'], $fields);
....
}


My test was ok, and my english is very pool, excuse me.


There are no replies made for this post yet.
Be one of the first to reply to this post!

Leaderboard (30 days)

Sifat

Sifat

Total Accepted Answers: 119
Paul Frankowski

Paul Frankowski

Total Accepted Answers: 110
Toufiq

Toufiq

Total Accepted Answers: 89
Kamruzzaman Alam

Kamruzzaman Alam

Total Accepted Answers: 4
FUTURECLIENT

FUTURECLIENT

Total Accepted Answers: 2

115

Templates

296154

Community Users

Newsletter

Don’t miss any updates of our new templates and extensions and all the astonishing offers we bring for you.
We never spam

Joomla! ® name is used under a limited license from Open Source Matters in the United States and other countries. JoomShaper.com is not affiliated with or endorsed by Open Source Matters or the Joomla! Project.

Connect Us