Fixed _setAutoIncrementValue checking/update wrong key

Jon W

Well-known member
In XenForo_DataWriter, the following line:
PHP:
                    if ($fieldType['default'][0] == $tableName && !$this->get($field, $table))
                    {
                        $this->_newData[$table][$field] = $insertId;
                    }
should be:
PHP:
                    if ($fieldType['default'][0] == $tableName && $fieldType['default'][1] == $field && !$this->get($fieldName, $table))
                    {
                        $this->_newData[$table][$fieldName] = $insertId;
                    }

I'm trying to extend a datawriter and add a table where two columns both have the default value that is the primary key of the main table, but it will only do it if I name the column the same as the main primary key. Not sure if this is as designed.
 
Last edited:
I believe this is a safe change (and it's passed my tests) so I've changed it, though I wouldn't really recommend on relying on it as joining like that with a different field name isn't really the XF way and your code would be depending on 1.4.4+ (rather than just 1.4+, say).
 
Thanks. I've overidden the method in my code for now, but I will turn off the override for 1.4.4+ so my code will now be more future proof.
 
Top Bottom