3

私は実際に作成したプラグインのインストールzipを作成し、インストールスクリプトファイルに、別のディレクトリのjoomla内のフォルダーにあるファイルをコピーするために、このコードをインストール関数に含めました。

class plgVmCustomPayeddownloadsInstallerScript {

   function install($parent) {

        $src = "plugins/vmcustom/payeddownloads/payeddownloads.php";
        $destination = "components/com_virtuemart/controllers";     
        if(!JFile::move($src, $destination,JPATH_ROOT)){
            echo "tried to move from ".$src." to ".$destination;
            return false;
    }
}

インストール後、joomlaで「ファイルの名前を変更できません」というエラーが発生し続け、installation.xml内のファイルが実際にコピーされたにもかかわらず、インストール関数によってコマンドされて移動されるはずのファイルが発生しませんでした。正しくインストールされています。

また、インストールスクリプト内にインストール関数に、問題なく正常に実行されるSQLを含めました。

また、飛行後の機能も試しましたが、うまくいきませんでした。また、php_error.logから特定のエラーを取得しません

また、joomlaインストールのルートアプリケーションに上記のtester.phpファイルを使用して、この奇妙なテストを作成しようとしました。

<?php
/**
 * @package     Joomla.Site
 * @copyright   Copyright (C) 2005 - 2012 Open Source Matters, Inc. All rights reserved.
 * @license     GNU General Public License version 2 or later; see LICENSE.txt
 */

// Set flag that this is a parent file.
define('_JEXEC', 1);
define('DS', DIRECTORY_SEPARATOR);

if (file_exists(dirname(__FILE__) . '/defines.php')) {
    include_once dirname(__FILE__) . '/defines.php';
}

if (!defined('_JDEFINES')) {
    define('JPATH_BASE', dirname(__FILE__));
    require_once JPATH_BASE.'/includes/defines.php';
}

require_once JPATH_BASE.'/includes/framework.php';

// Mark afterLoad in the profiler.
JDEBUG ? $_PROFILER->mark('afterLoad') : null;

// Instantiate the application.
$app = JFactory::getApplication('site');

// Initialise the application.
$app->initialise();

// Mark afterIntialise in the profiler.
JDEBUG ? $_PROFILER->mark('afterInitialise') : null;

// Route the application.
$app->route();

// Mark afterRoute in the profiler.
JDEBUG ? $_PROFILER->mark('afterRoute') : null;

// Dispatch the application.
$app->dispatch();

// Mark afterDispatch in the profiler.
JDEBUG ? $_PROFILER->mark('afterDispatch') : null;

// Render the application.
$app->render();

// Mark afterRender in the profiler.
JDEBUG ? $_PROFILER->mark('afterRender') : null;


    //plugins/vmcustom/payeddownloads/payeddownloads.php to 
    //components/com_virtuemart/controllers
    jimport('joomla.filesystem.file');
    $src = JPATH_ROOT."/plugins/vmcustom/payeddownloads/payeddownloads.php";
    $destination = JPATH_ROOT."/components/com_virtuemart/controllers/";        
    echo $src."<br>";
    echo $destination."<br>";
    JFile::move($src,$destination);

?>

ファイルはpayeddownloadsからcontrollersフォルダーに移動されず、エラーは発生しません。

また、php.iniにはerror_reporting=E_ALLおよびdisplay_errors=Onがあることにも言及する必要があります。また、php_error.logはエラーをキャプチャします。たとえばecho"lala"ooと入力すると、エラーがログに記録され、表示されます。したがって、JFile :: moveにはバグがあり、ファイルがコピーされていなくてもエラーがスローされないのではないかと思います。何か提案はありますか?

4

2 に答える 2

1

代わりに以下を使用してみてください。コードに微調整を加えることはほとんどありません。

function install($parent) {

    $src = JPATH_SITE . "/plugins/vmcustom/payeddownloads/payeddownloads.php";
    $destination = JPATH_SITE . "/components/com_virtuemart/controllers";

    if(JFile::exists($src)){
       echo "File Exists!";
    }
    else{
       echo "File Doesn't Exist!";
    }
    if(JFolder::exists($destination)){
       echo "Destination Folder Exists!";
    }
    else{
       echo "Destination Folder Doesn't Exist!";
    }

    JFile::move($src, $destination); // Move file

    if(JFile::move($src, $destination)){
       echo "File Successfully Moved!";
    }
    else{
       echo "failed to move from ".$src." to ".$destination;
    }

}
于 2012-10-20T18:18:02.253 に答える