Jump to content

Slow backoffice BO


Recommended Posts

After searching through many threads related to slow backoffice, I enabled debugging and profiling and started the process of getting this fixed.

 

initContent is taking roughly 40 seconds, narrowed it down by adding "die('test');" in the initContent of classes/controller/AdminController.php

 

walking along the code and found that in "protected function filterTabModuleList()" the following take forever to complete:

static $list_is_filtered = null;

if ($list_is_filtered !== null)
return;

if (!$this->isFresh(Module::CACHE_FILE_DEFAULT_COUNTRY_MODULES_LIST, 86400))
file_put_contents(_PS_ROOT_DIR_.Module::CACHE_FILE_DEFAULT_COUNTRY_MODULES_LIST, Tools::addonsRequest('native'));

if (!$this->isFresh(Module::CACHE_FILE_ALL_COUNTRY_MODULES_LIST, 86400))
file_put_contents(_PS_ROOT_DIR_.Module::CACHE_FILE_ALL_COUNTRY_MODULES_LIST, Tools::addonsRequest('native_all'));

if (!$this->isFresh(Module::CACHE_FILE_MUST_HAVE_MODULES_LIST, 86400))
@file_put_contents(_PS_ROOT_DIR_.Module::CACHE_FILE_MUST_HAVE_MODULES_LIST, Tools::addonsRequest('must-have'));

Also the xml files in config/xml folder become 0 bytes

Why is this happening?

 

trusted and untrusted modules list are also replaced and their permissions are set to 644

replacing these files from backup and setting their permissions to something else just causes them to reset later on.

 

 

any help would be appreciated.

Edited by letmeins (see edit history)
Link to comment
Share on other sites

	function file_isvalid($file, $timeout = 5) {
		$t = 0;		
		$t = @filemtime($file);  // returns FALSE if file does not exist
		if($t > 0 && filesize($file) < 1) {
			$t = 0; //PS code says: 0 byte file is invalid
		}	  
		return $t;
   }
	
	public function isFresh($file, $timeout = 604800)
	{
		$t = $this->file_isvalid(realpath (_PS_ROOT_DIR_.$file));
		if ($t != 0)
		{		
			return ((time() - $t) < $timeout);
		}
		return false;
	}

Made some small alterations to isFresh in admincontroller

 

now init takes 30s, appearantly through some of the displayBackOfficeHeader hooks (16ms difference on a 20050).

Found it!

 

Merchant Expertise, disabling the hooks of this module and it all zips along again.

Well so much for that module, it looked like harmless fun, but it shall not be missed.

Edited by letmeins (see edit history)
Link to comment
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
×
×
  • Create New...