WeaponOwl
Active member
- Affected version
- Beta 3, Beta 4
Beta 4 have next column for XF: Purchasable entity
As you see 'purchasable_type_id' have UINT type, but for database column type is VARCHAR(50), as this is right, because table already have row with id 'user_upgrade'.
Have next results:
* User Upgrade System can work wrong
* impossible add something to xf_purchasable table from create new XF: Purchasable entity, because validator cast any string to UINT type, and receive '0' as value, if string start from letter. As entity cast almost any string to '0', for validate unique id it trying receive row with 'purchasable_type_id = 0', and somewhy receive that one row with 'user_upgrade'. Validation fail.
I not know where else this wrong type can affect code, i found only XF: PurchaseRequest entity, and there 'purchasable_type_id' have right STR type.
For test try run next
PHP:
$structure->table = 'xf_purchasable';
$structure->shortName = 'XF:Purchasable';
$structure->primaryKey = 'purchasable_type_id';
$structure->columns = [
'purchasable_type_id' => ['type' => self::UINT, 'required' => true],
'purchasable_class' => ['type' => self::STR, 'maxLength' => 100, 'required' => true],
'addon_id' => ['type' => self::BINARY, 'maxLength' => 50, 'default' => '']
];
As you see 'purchasable_type_id' have UINT type, but for database column type is VARCHAR(50), as this is right, because table already have row with id 'user_upgrade'.
Have next results:
* User Upgrade System can work wrong
* impossible add something to xf_purchasable table from create new XF: Purchasable entity, because validator cast any string to UINT type, and receive '0' as value, if string start from letter. As entity cast almost any string to '0', for validate unique id it trying receive row with 'purchasable_type_id = 0', and somewhy receive that one row with 'user_upgrade'. Validation fail.
I not know where else this wrong type can affect code, i found only XF: PurchaseRequest entity, and there 'purchasable_type_id' have right STR type.
For test try run next
Code:
$package = \XF::em()->create('XF:Purchasable');
$package['purchasable_type_id'] = 'some_package';
$package['purchasable_class'] = 'YourAddon:SomePackage';
$package['addon_id'] = 'YourAddon';
$package->save();
Last edited: