Change author

Change author [Paid] 3.4

No permission to buy ($35.00)
[E_NOTICE] Undefined variable: nodeId
src/addons/Andy/ChangeAuthor/XF/Pub/Controller/Post.php:271


[E_NOTICE] Undefined variable: nodeId
src/addons/Andy/ChangeAuthor/XF/Pub/Controller/Post.php:286
 
Hi @AndyB,

I was going to install this add-on on the site of my customer.

I have few comments:
  • It seems to me that you are not updating the user post count
  • You are not updating the search index, though it works it doesn't seem optimized, as you know in the metadata there is the user_id.
  • Your code could deserve some optimization:
    • You retrieve the old user id by a query while you have it in $post->user_id
    • You check if the post is the last one of the thread through a query while you already have the id of the last post in thread in $post->Thread->last_post_id
    • To find the result and delete it in thread_user_post table, you use a finder, you could just use the \XF::db->delete()
    • Apart from these few comments on optimization, doing all this stuff in the controller is not compliant with the xF coding standards.

Clément
 
Currently using this add-on, recently when we go to change an author we are getting hit up with server errors. All changes do seem to go through for what it's worth though.


Code:
Error: Call to a member function fastUpdate() on null src/addons/Andy/ChangeAuthor/XF/Pub/Controller/Post.php:324
    
Stack trace

#0 src/XF/Mvc/Dispatcher.php(350): Andy\ChangeAuthor\XF\Pub\Controller\Post->actionChangeAuthorSave(Object(XF\Mvc\ParameterBag))
#1 src/XF/Mvc/Dispatcher.php(257): XF\Mvc\Dispatcher->dispatchClass('XF:Post', 'Changeauthorsav...', Object(XF\Mvc\RouteMatch), Object(SV\UserEssentials\XF\Pub\Controller\Post), NULL)
#2 src/XF/Mvc/Dispatcher.php(113): XF\Mvc\Dispatcher->dispatchFromMatch(Object(XF\Mvc\RouteMatch), Object(SV\UserEssentials\XF\Pub\Controller\Post), NULL)
#3 src/XF/Mvc/Dispatcher.php(55): XF\Mvc\Dispatcher->dispatchLoop(Object(XF\Mvc\RouteMatch))
#4 src/XF/App.php(2326): XF\Mvc\Dispatcher->run()
#5 src/XF.php(488): XF\App->run()
#6 index.php(20): XF::runApp('XF\\Pub\\App')
#7 {main}

array(4) {
  ["url"] => string(41) "/REDACTED/1988876/changeauthorsave"
  ["referrer"] => string(70) "REDACTED URL"
  ["_GET"] => array(1) {
    ["posts/1988876/changeauthorsave"] => string(0) ""
  }
  ["_POST"] => array(5) {
    ["new_post_author"] => string(11) "REDACTED_USER"
    ["_xfToken"] => string(8) "********"
    ["_xfRequestUri"] => string(43) "/REDACTED URL"
    ["_xfWithData"] => string(1) "1"
    ["_xfResponseType"] => string(4) "json"
  }
}
 
Please try this:

Add a thread and a second post as user "example";
now change the author of the second post to user "changed"
now watch /whats-new/latest-activity

in my case i see a new thread by example and a second post by example.
 
Back
Top Bottom