• This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn more.

Fixed _setAutoIncrementValue checking/update wrong key

Jon W

Well-known member
#1
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:

Mike

XenForo developer
Staff member
#2
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).
 

Jon W

Well-known member
#3
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.