Change date

Change date [Paid] 2.9

No permission to buy ($35.00)
InvalidArgumentException: Attempted to convert NULL to integer [content_id] in src/XF/Mvc/Entity/Entity.php at line 759

  1. XF\Mvc\Entity\Entity->_castValueToType() in src/XF/Mvc/Entity/Entity.php at line 637
  2. XF\Mvc\Entity\Entity->set() in src/XF/Mvc/Entity/Entity.php at line 567
  3. XF\Mvc\Entity\Entity->__set() in src/addons/Andy/ChangeDate/XF/Pub/Controller/Post.php at line

Something wrong here!
$newsFeed->content_id = $result['post_id'];


  1. Andy\ChangeDate\XF\Pub\Controller\Post->actionChangeDateSave() in src/XF/Mvc/Dispatcher.php at line 350
  2. XF\Mvc\Dispatcher->dispatchClass() in src/XF/Mvc/Dispatcher.php at line 257
  3. XF\Mvc\Dispatcher->dispatchFromMatch() in src/XF/Mvc/Dispatcher.php at line 113
  4. XF\Mvc\Dispatcher->dispatchLoop() in src/XF/Mvc/Dispatcher.php at line 55
  5. XF\Mvc\Dispatcher->run() in src/XF/App.php at line 2326
  6. XF\App->run() in src/XF.php at line 488
  7. XF::runApp() in index.php at line 20
 
I have problems with this addon:

Sometimes i copy a post from A to B.
Then i set the date of this post in thread B to the past.
The post will be at position #1 now.
But if i edit the post, there is no edit for the thread.
Just now, i know that something is wrong.
The older #1 is still the first one, but now shown at the top. And when i delete the older post, i delete the thread.


I dont do a screenshot now, just imagine that:

Post #1, Edit, edits the post
Post #2, Edit edits the post
Post #3, Edit edits the post and the thread.
 
Ok, checked the table. The problem is that xf_thread.first_post_id is not set.
I will check this now.

I have changed your code to the following, now it works for me.

Code:
        // update thread post date

        // check condition
        if ($post->position == 0)
        {
            // save thread
            $thread->post_date = $newDate;
            $thread->saveIfChanged();
        }

to

Code:
        //########################################
        // update thread post date

        // check condition
        $finder = \XF::finder('XF:Post');
        $result = $finder
            ->where('thread_id', $threadId)
            ->order('position', 'ASC')
            ->fetchOne();

        // save thread
        $thread->post_date = $newDate;
        $thread->first_post_id = $post->post_id;
        $thread->saveIfChanged();
 
Last edited:
Keep getting this error when trying to change the time of a post, although it DOES change the time before throwing up the error…

InvalidArgumentException: Attempted to convert NULL to integer [user_id] in src/XF/Mvc/Entity/Entity.php at line 763
  1. XF\Mvc\Entity\Entity->_castValueToType() in src/XF/Mvc/Entity/Entity.php at line 641
  2. XF\Mvc\Entity\Entity->set() in src/XF/Mvc/Entity/Entity.php at line 570
  3. XF\Mvc\Entity\Entity->__set() in src/addons/Andy/ChangeDate/XF/Pub/Controller/Post.php at line 226
  4. Andy\ChangeDate\XF\Pub\Controller\Post->actionChangeDateSave() in src/XF/Mvc/Dispatcher.php at line 352
  5. XF\Mvc\Dispatcher->dispatchClass() in src/XF/Mvc/Dispatcher.php at line 259
  6. XF\Mvc\Dispatcher->dispatchFromMatch() in src/XF/Mvc/Dispatcher.php at line 115
  7. XF\Mvc\Dispatcher->dispatchLoop() in src/XF/Mvc/Dispatcher.php at line 57
  8. XF\Mvc\Dispatcher->run() in src/XF/App.php at line 2352
  9. XF\App->run() in src/XF.php at line 524
  10. XF::runApp() in index.php at line 20
 
Top Bottom