Hello, i am experimenting
You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near '' at line 1 Query: INSERT INTO gw6wm_template_overrides
during a complex extension update on joomla 4.
it seems that code in \plugins\installer\override\override.php
does "continue" when an update is detected but still allows to proceed with insert which gives the SQL error.
current code:
private function saveOverrides($pks)
{
// Insert columns.
$columns = [
'template',
'hash_id',
'action',
'created_date',
'modified_date',
'extension_id',
'state',
'client_id',
];
// Create an insert query.
$insertQuery = $this->db->getQuery(true)
->insert($this->db->quoteName('#__template_overrides'))
->columns($this->db->quoteName($columns));
foreach ($pks as $pk)
{
$date = new Date('now');
$createdDate = $date->toSql();
if (empty($pk->coreFile))
{
$modifiedDate = null;
}
else
{
$modifiedDate = $createdDate;
}
if ($this->load($pk->id, $pk->extension_id))
{
$updateQuery = $this->db->getQuery(true)
->update($this->db->quoteName('#__template_overrides'))
->set(
[
$this->db->quoteName('modified_date') . ' = :modifiedDate',
$this->db->quoteName('action') . ' = :pkAction',
$this->db->quoteName('state') . ' = 0',
]
)
->where($this->db->quoteName('hash_id') . ' = :pkId')
->where($this->db->quoteName('extension_id') . ' = :exId')
->bind(':modifiedDate', $modifiedDate)
->bind(':pkAction', $pk->action)
->bind(':pkId', $pk->id)
->bind(':exId', $pk->extension_id, ParameterType::INTEGER);
// Set the query using our newly populated query object and execute it.
$this->db->setQuery($updateQuery);
$this->db->execute();
continue;
}
// Insert values, preserve order
$bindArray = $insertQuery->bindArray(
[
$pk->template,
$pk->id,
$pk->action,
$createdDate,
$modifiedDate,
],
ParameterType::STRING
);
$bindArray = array_merge(
$bindArray,
$insertQuery->bindArray(
[
$pk->extension_id,
0,
(int) $pk->client,
]
)
);
$insertQuery->values(implode(',', $bindArray));
}
$this->db->setQuery($insertQuery);
$this->db->execute();
}
possible fix:
private function saveOverrides($pks)
{
// Insert columns.
$columns = [
'template',
'hash_id',
'action',
'created_date',
'modified_date',
'extension_id',
'state',
'client_id',
];
// Create an insert query.
$insertQuery = $this->db->getQuery(true)
->insert($this->db->quoteName('#__template_overrides'))
->columns($this->db->quoteName($columns));
foreach ($pks as $pk)
{
$date = new Date('now');
$createdDate = $date->toSql();
if (empty($pk->coreFile))
{
$modifiedDate = null;
}
else
{
$modifiedDate = $createdDate;
}
if ($this->load($pk->id, $pk->extension_id))
{
$updateQuery = $this->db->getQuery(true)
->update($this->db->quoteName('#__template_overrides'))
->set(
[
$this->db->quoteName('modified_date') . ' = :modifiedDate',
$this->db->quoteName('action') . ' = :pkAction',
$this->db->quoteName('state') . ' = 0',
]
)
->where($this->db->quoteName('hash_id') . ' = :pkId')
->where($this->db->quoteName('extension_id') . ' = :exId')
->bind(':modifiedDate', $modifiedDate)
->bind(':pkAction', $pk->action)
->bind(':pkId', $pk->id)
->bind(':exId', $pk->extension_id, ParameterType::INTEGER);
// Set the query using our newly populated query object and execute it.
$this->db->setQuery($updateQuery);
$this->db->execute();
continue;
}
// Insert values, preserve order
$bindArray = $insertQuery->bindArray(
[
$pk->template,
$pk->id,
$pk->action,
$createdDate,
$modifiedDate,
],
ParameterType::STRING
);
$bindArray = array_merge(
$bindArray,
$insertQuery->bindArray(
[
$pk->extension_id,
0,
(int) $pk->client,
]
)
);
$insertQuery->values(implode(',', $bindArray));
}
if (!empty($bindArray)) {
$this->db->setQuery($insertQuery);
$this->db->execute();
}
}
I do not know how to reproduce this exactly as i came on this one during intensive testing of other parts and extensions.
Best regards, stan
Labels |
Removed:
?
|
Labels |
Added:
No Code Attached Yet
|
Status | New | ⇒ | Closed |
Closed_Date | 0000-00-00 00:00:00 | ⇒ | 2021-08-30 17:44:29 |
Closed_By | ⇒ | alikon |
duplicate of #35427