Installation of a module
Installation of a module
[Microsoft][SQL Server Native Client 11.0][SQL Server]Cannot insert the value NULL into column 'path', table '*****.dbo._menu'; column does not allow nulls. INSERT fails.SQL=INSERT INTO *******_menu VALUES ('1','1','281','282','*','main','***','index.php?option=**','component','0','','1','class:component','0','1')
Joomla 3.3.6
I insert a code in insertObject() inside JDatabaseDriverSqlsrv
/**
* Inserts a row into a table based on an object's properties.
*
* @param string $table The name of the database table to insert into.
* @param object &$object A reference to an object whose public properties match the table fields.
* @param string $key The name of the primary key. If provided the object property is updated.
*
* @return boolean True on success.
*
* @since 12.1
* @throws RuntimeException
*/
public function insertObject($table, &$object, $key = null)
{
$fields = array();
$values = array();
$statement = 'INSERT INTO ' . $this->quoteName($table) . ' (%s) VALUES (%s)';
foreach (get_object_vars($object) as $k => $v)
{
// Only process non-null scalars.
if (is_array($v) or is_object($v) or $v === null)
{
continue;
}
if (!$this->checkFieldExists($table, $k))
{
continue;
}
if ($k[0] == '_')
{
// Internal field
continue;
}
if ($k == $key && $key == 0)
{
continue;
}
$fields[] = $this->quoteName($k);
$values[] = $this->Quote($v);
}
// Check null and not null values if have values
if ($object instanceof JTable && $key !== null)
{
foreach ($object->getFields() AS $key_field => $value_field)
{
// if is not primary key set defaul value if not exist this value
// for evade error "Cannot insert the value NULL into column 'XXX',
// table 'XXX'; column does not allow nulls.
if (!in_array($this->quoteName($key_field), $fields) && $value_field->Null == "NO" && ((is_array($key) && !in_array($key_field, $key)) || (!is_array($key) && $key_field != $key)))
{
$fixed = null;
if (gettype($value_field->Default) !== null)
{
$fixed = preg_replace( "/(\A[\(][\'])|(\A[\(][\(])|([\)][\)]$)|([\'][\)]$)/i", "", $value_field->Default );
}
else
{
switch ($value_field->Type)
{
case "char": case "varchar": case "text":
case "nchar": case "nvarchar": case "ntext":
$fixed = '';
break;
case "bigint": case "numeric": case "bit":
case "smallint": case "decimal": case "smallmoney":
case "int": case "tinyint": case "money":
case "int": case "float": case "real":
$fixed = 0;
break;
default:
$fixed = '';
break;
}
}
if ($fixed !== null)
{
$fields[] = $this->quoteName($key_field);
$values[] = $this->Quote($value_field);
}
}
}
}
// die("");
// Set the query and execute the insert.
$this->setQuery(sprintf($statement, implode(',', $fields), implode(',', $values)));
if (!$this->execute())
{
return false;
}
$id = $this->insertid();
if ($key && $id)
{
$object->$key = $id;
}
return true;
}
Please can you retest against the current staging release that you can download here http://developer.joomla.org/cms-packages/
If you still have the error please can you submit a PR with your fix https://docs.joomla.org/Filing_bugs_and_issues#Issue_a_pull_request_directly_on_Joomla.21.27s_GitHub_repository
Status | New | ⇒ | Information Required |
Labels |
Added:
?
|
Labels |
Added:
?
|
I'm not sure how this is supposed to have been fixed in 3.4. A cursory glance at the affected files doesn't show any (relevant) changes.
No one said it had been. There have been changes obviously throughout 3.4 so it is important to confirm that an issue found in 3.3.6 can be repeated in 3.4 before spending any time on it.
If you still have the error please can you submit a PR with your fix https://docs.joomla.org/Filing_bugs_and_issues#Issue_a_pull_request_directly_on_Joomla.21.27s_GitHub_repository
Version 3.4 has a bug in IIS and MSSQL, this close the sessiĆ³n when you try to install components and can't check this.
I need free time for check this first. I'll check this when i have time at work.
Probably bug 5890 #5890
This is exposed by the extension installer because it ignores which dbms an extension is designed for (extensions are required to have this in their configuration file) and just passes whatever SQL it finds in to whatever dbms you're using with any kind of checking. (detailed here: http://forum.joomla.org/viewtopic.php?f=728&t=871724 ) I spent quite awhile trying to sort out why I couldn't get that particular extension to install. I'd be glad to file a bug for that, too, but I'm not quite sure how it should be filed. It's almost a feature request, but it seems like a feature that should've already been implemented. Moreover, it seems like support for non-MySQL systems is really poor overall, as there seem to be places in the code and documentation where it is just assumed you're using MySQL.
Status | Information Required | ⇒ | Closed |
Closed_Date | 0000-00-00 00:00:00 | ⇒ | 2015-07-29 08:06:56 |
Closed_By | ⇒ | brianteeman |
Change line
$values[] = $this->Quote($value_field);
for
$values[] = $this->Quote($fixed);
My Fault