Gift Upgrades

Gift Upgrades [Paid] 2.5.0

No permission to buy ($35.00)
Bug 1:
As admin I tried to gift a free membership (not anonymous) from the profile card to a user that did not have one.
Code:
XF\Db\DuplicateKeyException: MySQL query error [1062]: Duplicate entry '15926-1' for key 'user_id_upgrade_id' src/XF/Db/AbstractStatement.php:230
Generated by:
Stack trace
INSERT  INTO `xf_user_upgrade_active` (`user_upgrade_id`, `user_id`, `start_date`, `pay_user_id`, `is_gift`, `nf_was_gifted_for_free`, `extra`, `end_date`, `user_upgrade_record_id`, `purchase_request_key`) VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?)
------------

#0 src/XF/Db/Mysqli/Statement.php(198): XF\Db\AbstractStatement->getException('MySQL query err...', 1062, '23000')
#1 src/XF/Db/Mysqli/Statement.php(79): XF\Db\Mysqli\Statement->getException('MySQL query err...', 1062, '23000')
#2 src/XF/Db/AbstractAdapter.php(96): XF\Db\Mysqli\Statement->execute()
#3 src/XF/Db/AbstractAdapter.php(220): XF\Db\AbstractAdapter->query('INSERT  INTO `x...', Array)
#4 src/XF/Mvc/Entity/Entity.php(1512): XF\Db\AbstractAdapter->insert('xf_user_upgrade...', Array, false)
#5 src/XF/Mvc/Entity/Entity.php(1244): XF\Mvc\Entity\Entity->_saveToSource()
#6 src/XF/Service/User/Upgrade.php(172): XF\Mvc\Entity\Entity->save(true, false)
#7 src/addons/NF/GiftUpgrades/XF/Service/User/Upgrade.php(231): XF\Service\User\Upgrade->upgrade()
#8 src/addons/NF/GiftUpgrades/XF/Pub/Controller/Purchase.php(105): NF\GiftUpgrades\XF\Service\User\Upgrade->upgrade()
#9 src/addons/Kirby/PublicAccountUpgrades/XF/Pub/Controller/Purchase.php(16): NF\GiftUpgrades\XF\Pub\Controller\Purchase->actionIndex(Object(XF\Mvc\ParameterBag))
#10 src/XF/Mvc/Dispatcher.php(352): Kirby\PublicAccountUpgrades\XF\Pub\Controller\Purchase->actionIndex(Object(XF\Mvc\ParameterBag))
#11 src/XF/Mvc/Dispatcher.php(259): XF\Mvc\Dispatcher->dispatchClass('XF:Purchase', 'Index', Object(XF\Mvc\RouteMatch), Object(Kirby\PublicAccountUpgrades\XF\Pub\Controller\Purchase), NULL)
#12 src/XF/Mvc/Dispatcher.php(115): XF\Mvc\Dispatcher->dispatchFromMatch(Object(XF\Mvc\RouteMatch), Object(Kirby\PublicAccountUpgrades\XF\Pub\Controller\Purchase), NULL)
#13 src/XF/Mvc/Dispatcher.php(57): XF\Mvc\Dispatcher->dispatchLoop(Object(XF\Mvc\RouteMatch))
#14 src/XF/App.php(2345): XF\Mvc\Dispatcher->run()
#15 src/XF.php(512): XF\App->run()
#16 index.php(20): XF::runApp('XF\\Pub\\App')
#17 {main}
Request state
array(4) {
  ["url"] => string(23) "/purchase/user_upgrade/"
  ["referrer"] => string(74) "https://*****"
  ["_GET"] => array(0) {
  }
  ["_POST"] => array(13) {
    ["user_upgrade_id"] => string(1) "1"
    ["payment_profile_id"] => string(1) "1"
    ["gift_for_free"] => string(1) "1"
    ["confirmed"] => string(1) "1"
    ["gift"] => string(1) "1"
    ["username"] => string(10) "*****"
    ["gift_to_user_id"] => string(5) "15926"
    ["content_id"] => string(5) "15926"
    ["content_type"] => string(4) "user"
    ["_xfToken"] => string(8) "********"
    ["_xfRequestUri"] => string(50) "/*****"
    ["_xfWithData"] => string(1) "1"
    ["_xfResponseType"] => string(4) "json"
  }
}

The second time I tried it it worked however, but!

Bug 2:
I went to acp Upgrades and it was given for 3 years! The upgrade itself is only 1.

Bug 3:
I clicked Edit to adjust back to 1 year and Saved. This worked but the (by __________) text was removed that shows the gift giver.

Thanks!
 
Last edited:
I see from the screenshots & description that a gift upgrade can be anonymous or not but when a gift upgrade is given can an optional message by sent to the recipient when they get the notice?
 
Bug 1:
As admin I tried to gift a free membership (not anonymous) from the profile card to a user that did not have one.
Code:
XF\Db\DuplicateKeyException: MySQL query error [1062]: Duplicate entry '15926-1' for key 'user_id_upgrade_id' src/XF/Db/AbstractStatement.php:230
Generated by:
Stack trace
INSERT  INTO `xf_user_upgrade_active` (`user_upgrade_id`, `user_id`, `start_date`, `pay_user_id`, `is_gift`, `nf_was_gifted_for_free`, `extra`, `end_date`, `user_upgrade_record_id`, `purchase_request_key`) VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?)
------------

#0 src/XF/Db/Mysqli/Statement.php(198): XF\Db\AbstractStatement->getException('MySQL query err...', 1062, '23000')
#1 src/XF/Db/Mysqli/Statement.php(79): XF\Db\Mysqli\Statement->getException('MySQL query err...', 1062, '23000')
#2 src/XF/Db/AbstractAdapter.php(96): XF\Db\Mysqli\Statement->execute()
#3 src/XF/Db/AbstractAdapter.php(220): XF\Db\AbstractAdapter->query('INSERT  INTO `x...', Array)
#4 src/XF/Mvc/Entity/Entity.php(1512): XF\Db\AbstractAdapter->insert('xf_user_upgrade...', Array, false)
#5 src/XF/Mvc/Entity/Entity.php(1244): XF\Mvc\Entity\Entity->_saveToSource()
#6 src/XF/Service/User/Upgrade.php(172): XF\Mvc\Entity\Entity->save(true, false)
#7 src/addons/NF/GiftUpgrades/XF/Service/User/Upgrade.php(231): XF\Service\User\Upgrade->upgrade()
#8 src/addons/NF/GiftUpgrades/XF/Pub/Controller/Purchase.php(105): NF\GiftUpgrades\XF\Service\User\Upgrade->upgrade()
#9 src/addons/Kirby/PublicAccountUpgrades/XF/Pub/Controller/Purchase.php(16): NF\GiftUpgrades\XF\Pub\Controller\Purchase->actionIndex(Object(XF\Mvc\ParameterBag))
#10 src/XF/Mvc/Dispatcher.php(352): Kirby\PublicAccountUpgrades\XF\Pub\Controller\Purchase->actionIndex(Object(XF\Mvc\ParameterBag))
#11 src/XF/Mvc/Dispatcher.php(259): XF\Mvc\Dispatcher->dispatchClass('XF:Purchase', 'Index', Object(XF\Mvc\RouteMatch), Object(Kirby\PublicAccountUpgrades\XF\Pub\Controller\Purchase), NULL)
#12 src/XF/Mvc/Dispatcher.php(115): XF\Mvc\Dispatcher->dispatchFromMatch(Object(XF\Mvc\RouteMatch), Object(Kirby\PublicAccountUpgrades\XF\Pub\Controller\Purchase), NULL)
#13 src/XF/Mvc/Dispatcher.php(57): XF\Mvc\Dispatcher->dispatchLoop(Object(XF\Mvc\RouteMatch))
#14 src/XF/App.php(2345): XF\Mvc\Dispatcher->run()
#15 src/XF.php(512): XF\App->run()
#16 index.php(20): XF::runApp('XF\\Pub\\App')
#17 {main}
Request state
array(4) {
  ["url"] => string(23) "/purchase/user_upgrade/"
  ["referrer"] => string(74) "https://*****"
  ["_GET"] => array(0) {
  }
  ["_POST"] => array(13) {
    ["user_upgrade_id"] => string(1) "1"
    ["payment_profile_id"] => string(1) "1"
    ["gift_for_free"] => string(1) "1"
    ["confirmed"] => string(1) "1"
    ["gift"] => string(1) "1"
    ["username"] => string(10) "*****"
    ["gift_to_user_id"] => string(5) "15926"
    ["content_id"] => string(5) "15926"
    ["content_type"] => string(4) "user"
    ["_xfToken"] => string(8) "********"
    ["_xfRequestUri"] => string(50) "/*****"
    ["_xfWithData"] => string(1) "1"
    ["_xfResponseType"] => string(4) "json"
  }
}
I'm fairly sure this is a race condition in XenForo due to how user upgrades are handled. The add-on should handle editing a gift upgrade better however.
 
Bug 2:
I went to acp Upgrades and it was given for 3 years! The upgrade itself is only 1.

Bug 3:
I clicked Edit to adjust back to 1 year and Saved. This worked but the (by __________) text was removed that shows the gift giver.
I haven't been able to reproduce the second one but there's probably some improvements that can be done for the third.
I see from the screenshots & description that a gift upgrade can be anonymous or not but when a gift upgrade is given can an optional message by sent to the recipient when they get the notice?
No message yet but that could be a nice addition.
 
Bug 1:
As admin I tried to gift a free membership (not anonymous) from the profile card to a user that did not have one.
Code:
XF\Db\DuplicateKeyException: MySQL query error [1062]: Duplicate entry '15926-1' for key 'user_id_upgrade_id' src/XF/Db/AbstractStatement.php:230
Generated by:
Stack trace
INSERT  INTO `xf_user_upgrade_active` (`user_upgrade_id`, `user_id`, `start_date`, `pay_user_id`, `is_gift`, `nf_was_gifted_for_free`, `extra`, `end_date`, `user_upgrade_record_id`, `purchase_request_key`) VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?)
------------

#0 src/XF/Db/Mysqli/Statement.php(198): XF\Db\AbstractStatement->getException('MySQL query err...', 1062, '23000')
#1 src/XF/Db/Mysqli/Statement.php(79): XF\Db\Mysqli\Statement->getException('MySQL query err...', 1062, '23000')
#2 src/XF/Db/AbstractAdapter.php(96): XF\Db\Mysqli\Statement->execute()
#3 src/XF/Db/AbstractAdapter.php(220): XF\Db\AbstractAdapter->query('INSERT  INTO `x...', Array)
#4 src/XF/Mvc/Entity/Entity.php(1512): XF\Db\AbstractAdapter->insert('xf_user_upgrade...', Array, false)
#5 src/XF/Mvc/Entity/Entity.php(1244): XF\Mvc\Entity\Entity->_saveToSource()
#6 src/XF/Service/User/Upgrade.php(172): XF\Mvc\Entity\Entity->save(true, false)
#7 src/addons/NF/GiftUpgrades/XF/Service/User/Upgrade.php(231): XF\Service\User\Upgrade->upgrade()
#8 src/addons/NF/GiftUpgrades/XF/Pub/Controller/Purchase.php(105): NF\GiftUpgrades\XF\Service\User\Upgrade->upgrade()
#9 src/addons/Kirby/PublicAccountUpgrades/XF/Pub/Controller/Purchase.php(16): NF\GiftUpgrades\XF\Pub\Controller\Purchase->actionIndex(Object(XF\Mvc\ParameterBag))
#10 src/XF/Mvc/Dispatcher.php(352): Kirby\PublicAccountUpgrades\XF\Pub\Controller\Purchase->actionIndex(Object(XF\Mvc\ParameterBag))
#11 src/XF/Mvc/Dispatcher.php(259): XF\Mvc\Dispatcher->dispatchClass('XF:Purchase', 'Index', Object(XF\Mvc\RouteMatch), Object(Kirby\PublicAccountUpgrades\XF\Pub\Controller\Purchase), NULL)
#12 src/XF/Mvc/Dispatcher.php(115): XF\Mvc\Dispatcher->dispatchFromMatch(Object(XF\Mvc\RouteMatch), Object(Kirby\PublicAccountUpgrades\XF\Pub\Controller\Purchase), NULL)
#13 src/XF/Mvc/Dispatcher.php(57): XF\Mvc\Dispatcher->dispatchLoop(Object(XF\Mvc\RouteMatch))
#14 src/XF/App.php(2345): XF\Mvc\Dispatcher->run()
#15 src/XF.php(512): XF\App->run()
#16 index.php(20): XF::runApp('XF\\Pub\\App')
#17 {main}
Request state
array(4) {
  ["url"] => string(23) "/purchase/user_upgrade/"
  ["referrer"] => string(74) "https://*****"
  ["_GET"] => array(0) {
  }
  ["_POST"] => array(13) {
    ["user_upgrade_id"] => string(1) "1"
    ["payment_profile_id"] => string(1) "1"
    ["gift_for_free"] => string(1) "1"
    ["confirmed"] => string(1) "1"
    ["gift"] => string(1) "1"
    ["username"] => string(10) "*****"
    ["gift_to_user_id"] => string(5) "15926"
    ["content_id"] => string(5) "15926"
    ["content_type"] => string(4) "user"
    ["_xfToken"] => string(8) "********"
    ["_xfRequestUri"] => string(50) "/*****"
    ["_xfWithData"] => string(1) "1"
    ["_xfResponseType"] => string(4) "json"
  }
}

The second time I tried it it worked however, but!

Bug 2:
I went to acp Upgrades and it was given for 3 years! The upgrade itself is only 1.

Bug 3:
I clicked Edit to adjust back to 1 year and Saved. This worked but the (by __________) text was removed that shows the gift giver.

Thanks!
I did another gift upgrade (free) and not anonymous. I was in a thread and did it from the member card upon hovering their name.

I got the same error as #1. But I refreshed and saw they were awarded it. I have no idea if they got the alert. But this would explain how they got 3 years last time, as the first time they were awarded it, even though I got the error. However I only remember doing it twice, not three times.

However, this time, there is no gifter name in the Upgrades section, and nothing was edited.
 
I've been getting the same errors. And upon testing it on a "test account", I can confirm that the user does NOT get the alert when the error appears. However, I do have an account that does not get the error, and she does get an alert. I really don't know what the difference is in the two accounts that would trigger the error on one, but not on the other.

I have also discovered another error, however, when downgrading the test account.

Code:
InvalidArgumentException: Accessed unknown getter 'PayUser' on XF:UserUpgradeExpired[11]
src/XF/Mvc/Entity/Entity.php:205
Generated by: Rene
Nov 5, 2021 at 10:19 AM

Stack trace
#0 src/XF/Mvc/Entity/Entity.php(117): XF\Mvc\Entity\Entity->get('PayUser')
#1 internal_data/code_cache/templates/l1/s0/admin/nixfifty_giftupgrades_giftedby_label.php(22): XF\Mvc\Entity\Entity->offsetGet('PayUser')
#2 src/XF/Template/Templater.php(1651): XF\Template\Templater->{closure}(Object(SV\StandardLib\XF\Template\Templater), Array, NULL)
#3 src/XF/Template/Templater.php(1680): XF\Template\Templater->renderTemplate('nixfifty_giftup...', Array)
#4 internal_data/code_cache/templates/l1/s0/admin/user_upgrade_list.php(40): XF\Template\Templater->includeTemplate('admin:nixfifty_...', Array)
#5 src/XF/Template/Templater.php(824): XF\Template\Templater->{closure}(Object(SV\StandardLib\XF\Template\Templater), Array, NULL)
#6 internal_data/code_cache/templates/l1/s0/admin/user_upgrade_list.php(242): XF\Template\Templater->callMacro('user_upgrade_li...', 'upgrade_list', Array, Array)
#7 src/XF/Template/Templater.php(1651): XF\Template\Templater->{closure}(Object(SV\StandardLib\XF\Template\Templater), Array, NULL)
#8 src/XF/Template/Template.php(24): XF\Template\Templater->renderTemplate('user_upgrade_li...', Array)
#9 src/XF/Mvc/Renderer/Html.php(50): XF\Template\Template->render()
#10 src/XF/Mvc/Dispatcher.php(460): XF\Mvc\Renderer\Html->renderView('XF:UserUpgrade\\...', 'admin:user_upgr...', Array)
#11 src/XF/Mvc/Dispatcher.php(442): XF\Mvc\Dispatcher->renderView(Object(XF\Mvc\Renderer\Html), Object(XF\Mvc\Reply\View))
#12 src/XF/Mvc/Dispatcher.php(402): XF\Mvc\Dispatcher->renderReply(Object(XF\Mvc\Renderer\Html), Object(XF\Mvc\Reply\View))
#13 src/XF/Mvc/Dispatcher.php(60): XF\Mvc\Dispatcher->render(Object(XF\Mvc\Reply\View), 'html')
#14 src/XF/App.php(2345): XF\Mvc\Dispatcher->run()
#15 src/XF.php(512): XF\App->run()
#16 admin.php(13): XF::runApp('XF\\Admin\\App')
#17 {main}
 
Last edited:
Ok! I found it. I did some more testing. Apparently, if I gift someone who is NOT on the default style/theme, the error occurs. If I gift a member who is on the same style/theme, no error.

I was doing a bit of thinking, and tried to figure out the difference in the accounts, and it came down to the different forum styles. So, I switched the test account to the non-default theme, BAM! Error...

I have NO idea why this would affect the add-on, but it does, and I am seriously happy to have found that. My members are not going to be very happy with having the non-default theme removed, but I have to do what I have to do until it's fixed.


However, the downgrading error still happens, no matter which forum style is used.

[edit] Nope... still happening. I don't know what is going on, then. I guess it was just a fluke that the test worked that first time. It works fine for 2 of my members. It doesn't work at all for the rest. I seriously don't understand what the difference is.
 
Last edited:
Can you gift recurring subscriptions? Meaning they only pay for the first period and it just expires. Does anyone have this working? Or is everyone making a separate plan for recurring subscriptions.
 
Hello, does this work with automated subscriptions? If yes, does the gifter has to unsubscribe instantly after gifting the upgrade, so he wont get recharged the next month ?
 
NixFifty updated Gift Upgrades with a new update entry:

Version 2.4.0

  • Allow recurring upgrades to be gifted. The first term will be paid for by the gifter and the giftee can choose to renew upon its expiration.
  • Expose Recent Gift Post's widget date limit as a configurable option.
  • Add missing relation to the UserUpgradeExpired entity.
  • Fix potential issues surrounding the giving of free gifts.

Read the rest of this update entry...
 
Hi @NixFifty these are the style settings I have:

1644019847744.png

Does this mean that when someone Gifts a specific post, that post will have this styling applied to it? (a yellow border around it, in this instance)
 
I know this is super minor but it looks like there is more space between the word Purchase and the credit card icon than there is between Gift and the gift icon, on the two buttons in Upgrades.
 
I'm thinking a conversation would be better so the alert does not get buried, dismissed, or disappear with more alerts.

Anyway, top work! Really like it so far.
Just made purchased. I also think that a conversation is a much better option than alert, do consider adding this option.
 
Top Bottom