Jump to content

"Bad configuration file" when installing a theme


Ed_03
 Share

Recommended Posts

I am running Prestashop on a local server, when i try to install a theme it gives the "Bad configuration file" error. I tried uploading the theme through the dashboard still it doesnt upload. 

 

Installing the same theme on a Prestashop running online works, but on localhost it doesnt work. What could be the problem? Please help.

Share this post


Link to post
Share on other sites

Hi Ed,

 

Error is initiated in file:  /controllers/admin/AdminThemesController.php

 

protected function extractTheme($theme_zip_file, $sandbox)
{
  if (!Tools::ZipExtract($theme_zip_file, $sandbox.'uploaded/'))
    $this->errors[] = $this->l('Error during zip extraction');
  else
  {
    if (!$this->checkXmlFields($sandbox))
      $this->errors[] = $this->l('Bad configuration file');
...
 
 
So, if function checkXMLFields has a problem.
 
This function is defined as follows (In same file):
 
private function checkXmlFields($sandbox)
{
  if (!file_exists($sandbox.'uploaded/Config.xml') || !$xml = simplexml_load_file($sandbox.'uploaded/Config.xml'))
    return false;
  if (!$xml['version'] || !$xml['name'])
    return false;
  foreach ($xml->variations->variation as $val)
  {
    if (!$val['name'] || !$val['directory'] || !$val['from'] || !$val['to'])
      return false;
  }
  foreach ($xml->modules->module as $val)
  {
    if (!$val['action'] || !$val['name'])
      return false;
  }
  foreach ($xml->modules->hooks->hook as $val)
  {
    if (!$val['module'] || !$val['hook'] || !$val['position'])
      return false;
  }
 
  return true;
}
 

See if there's anything in your case that would return false

Share this post


Link to post
Share on other sites

Thanx PascalVG

 

Below is my checkXmlFields function but I dont see any condition that would return false. I tried the same theme on a different localhost (on another computer) its working fine. Now im suspecting its something to do with security on the local server im running. Please help. I am stuck. :(

private function checkXmlFields($xml_file)
	{
		if (!file_exists($xml_file) || !$xml = simplexml_load_file($xml_file))
			return false;
		if (!$xml['version'] || !$xml['name'])
			return false;
		foreach ($xml->variations->variation as $val)
		{
			if (!$val['name'] || !$val['directory'] || !$val['from'] || !$val['to'])
				return false;
		}
		foreach ($xml->modules->module as $val)
		{
			if (!$val['action'] || !$val['name'])
				return false;
		}
		foreach ($xml->modules->hooks->hook as $val)
		{
			if (!$val['module'] || !$val['hook'] || !$val['position'])
				return false;
		}

		return true;
	}

Share this post


Link to post
Share on other sites

Is the theme file zipped? Maybe unzip and check if there's a file config.xml in there. If zo, rename to config.xml.bkp, re-compress and re-try to istall.

 

If the theme's already unzipped, just rename the config.xml file to config.xml.bkp

 

Then re-try to install.

Share this post


Link to post
Share on other sites

Thank you for your help PascalVG. Finally I was able to solve the issue. It turned out i needed to increase the upload_max_filesize in the php.ini file of my localhost. Now i can smile  :)  :D

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

×
×
  • Create New...

Important Information

Cookies ensure the smooth running of our services. Using these, you accept the use of cookies. Learn More