I actually managed to make an installation zip for a plugin that I made and in the installation script file, I included this code in the install function in order to copy some file in a folder within joomla in another directory.
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;
}
}
After the installation I keep getting an error in joomla, “unable to rename the file” and the file that was supposed to be moved commanded by the install function did not, despite the fact that the files within the installation.xml did actually get coppied and installed correctly.
Also within the installation script In the install function I included some sql which is executed normally without any problems.
and I also tried in the postflight function with no success.
Also I do not get any specific erros from the php_error.log
I also tried to create this weird test, with the above tester.php file in my root application of my joomla installation.
<?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);
?>
The file does not get moved from payeddownloads to controllers folder and it is not causing any error.
Also I need to mention that php.ini has error_reporting = E_ALL and display_errors = On.
Also the php_error.log captures the errors. If I type for example echo “lala”oo it will log the error and it will show it.
So I suspect that JFile::move has a bug and its not throwing any errors even though the file is not copied. Any suggestions please?
Try using the following instead. Few tweaks make to your code: