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

How to run a xenforo class from PHP CLI

Discussion in 'XenForo Development Discussions' started by cedivad, Sep 4, 2011.

  1. cedivad

    cedivad Active Member

    I've created a file that using something like this:



    $fileDir dirname(__FILE__);



    $inputHandler = new XenForo_Input(new Zend_Controller_Request_Http());

    $input $inputHandler->filter(array(
    't' => XenForo_Input::UINT,
    'p' => XenForo_Input::UINT

    $importModel XenForo_Model::create('XenForo_Model_Import');

    $target false;
    if (
        if (
    $newId $importModel->mapThreadId($input['t']))
    $target XenForo_Link::buildPublicLink('canonical:threads', array('thread_id' => $newId));
    else if (
    $newId $importModel->mapPostId($input['p']);
        if (
    $target XenForo_Link::buildPublicLink('canonical:posts', array('post_id' => $newId));

    if (!
    $target XenForo_Link::buildPublicLink('canonical:index');


    $response = new Zend_Controller_Response_Http();
    $response->setRedirect(XenForo_Link::convertUriToAbsoluteUri($target), 301);
    The file call a class without the REQUEST parameter. (the file is copied as it is from the old vbulletin redirect plugin, nothing special).

    The problem is that while when i see the page on the browser everything works, when i look at it from the command line, it won't work:

    root@#:~# php -f /w/web/upload_to_youtube.php
    An unexpected error occurred. Please try again later.

    How can i fix this?
  2. Saarbruecken

    Saarbruecken Active Member

    What's the error message in the apache logs?
  3. cedivad

    cedivad Active Member

    Apache is not called during a php command line request.

    Anyway i solved without calling xenforo from my script.

Share This Page