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

Unmaintained How to create a Cron Entry to move threads (with options!) 1.0

I will teach you how to create a new cron to move threads from a forum to another.

  1. Fuhrmann

    Fuhrmann Well-Known Member

    Fuhrmann submitted a new resource:

    How to create a Cron Entry to move threads (with options!) (version 1.0) - I will teach you how to create a new cron to move threads from a forum to another.

    Read more about this resource...
     
    Eldan Goldenberg likes this.
  2. tafreehm

    tafreehm Well-Known Member

    thanks, is it possible to setup a cron job where all x days old && soft deleted thread get move to a separate section ?
     
  3. ForestForTrees

    ForestForTrees Well-Known Member

    Excellent tutorial, @Fuhrmann , thanks for posting.

    I notice that it has been 2 years since the tutorial was updated. Has anything changed in terms of best practices since then?

    In particular, is it still a good idea to use a datawriter object to change the 'node_id' to move a thread from one forum to another? Or is there a higher level way of doing it?
     
  4. TheBigK

    TheBigK Well-Known Member

    Thanks a lot @Fuhrmann . I've a (noob) doubt -

    PHP:
    $threads $threadModel->getThreads($conditionals$fetchOptions);
    The arguments $conditionals and $fetchOptions basically hold the values set in the AdminCP and have already been fetched into $cronOptions array. Why not simply reference them in getThreads instead of first separating them out in '$conditionals' and '$fetchOptions'?

    Something like
    PHP:
    getThreads($cronOptions['fromForum'],$cronOptions['fromPrefix'],$cronOptions['amount'])
    ?

    PS: Not sure if above line makes any sense :) Would appreciate your response.
     
  5. Eldan Goldenberg

    Eldan Goldenberg New Member

    Thank you so much for making and sharing that tutorial! It got me over one of the hurdles for an add-on I'm working on.

    I do have one technical question: when I update the code in CronEntry.php, do I need to do anything to make xenForo refresh, or does it always read the latest version of that file?

    UPDATE: never mind, I just figured it out empirically by inserting a typo. In case anyone else has the same question: I can confirm that at least every time I manually run the cron job, the code is reloaded.
     
  6. ForestForTrees

    ForestForTrees Well-Known Member

    Does anyone else get the following error when they run this addon?
    Code:
    Server Error Log
    Error Info
    ErrorException: Cannot modify header information - headers already sent by (output started at /home/ouruser/public_html/forum/library/MoveThreadCron/CronEntry.php:1) - deferred.php:26
    Generated By: Unknown Account, Wednesday at 8:01 AM
    Stack Trace
    
    #0 [internal function]: XenForo_Application::handlePhpError(2, 'Cannot modify h...', '/home/ouruser/publ...', 26, Array)
    #1 /home/ouruser/public_html/forum/deferred.php(26): header('Content-Type: a...')
    #2 {main}
    
    Request State
    
    array(3) {
      ["url"] => string(41) "http://www.ourdomain.org/forum/deferred.php"
      ["_GET"] => array(0) {
      }
      ["_POST"] => array(3) {
        ["_xfRequestUri"] => string(7) "/forum/"
        ["_xfNoRedirect"] => string(1) "1"
        ["_xfResponseType"] => string(4) "json"
      }
    }
    
    I'd love to know how to modify the code to avoid it.
     

Share This Page