Jump to content

[SOLVED] Prestashop 1.5.3.1 ObjectModel class changes


doubleD

Recommended Posts

Hi,

 

I've upgraded from 1.5.2 to 1.5.3.1 and one of my modules gives me an error like

 

Warning: preg_match() expects parameter 2 to be string, array given in Validate.php on line 383

Fatal error: Uncaught exception 'PrestaShopException' with message 'Property [CLASSNAME]->title is not valid' in ObjectModel.php:837 Stack trace: #0 [(44): ObjectModelCore->validateFields() #1 ObjectModel.php(598): [CLASSNAME]->getFields() #2 [CLASSNAME](84): ObjectModelCore->update() #3 [CLASSNAME](483): [CLASSNAME]->update() #4 [ADMINFOLDER]/functions.php(528): [CLASSNAME]->postProcess() #5 /classes/Dispatcher.php(328): runAdminTab('[CLASSNAME]...', false) #6 [ADMINFOLDER]/index.php(51): DispatcherCore->dispatch() #7 {main} thrown in classes/ObjectModel.php on line 837

 

Found out that the "problem" is due to one part of the ObjectModel.php class which is '// Retrocompatibility with $fieldsValidate,....':

Prestashop 1.5.2

else
 {
  $this->def['fields'] = array();
  $suffix = (isset($data['lang']) && $data['lang']) ? 'Lang' : '';
  foreach ($this->{'fieldsValidate'.$suffix} as $field => $validate)
$this->def['fields'][$field]['validate'] = $validate;
  foreach ($this->{'fieldsRequired'.$suffix} as $field)
$this->def['fields'][$field]['required'] = true;
  foreach ($this->{'fieldsSize'.$suffix} as $field => $size)
$this->def['fields'][$field]['size'] = $size;
 }

 

And Prestashop 1.5.3.1

 

else
 {
  $this->def['fields'] = array();
  $suffixs = array('', 'Lang');
  foreach($suffixs as $suffix)
  {
foreach ($this->{'fieldsValidate'.$suffix} as $field => $validate)
 $this->def['fields'][$field]['validate'] = $validate;

foreach ($this->{'fieldsRequired'.$suffix} as $field)
 $this->def['fields'][$field]['required'] = true;

foreach ($this->{'fieldsSize'.$suffix} as $field => $size)
 $this->def['fields'][$field]['size'] = $size;
  }
		  }

 

 

If i remove Lang from

$suffixs = array('', 'Lang');

 

so it looks like

$suffixs = array('', '');

 

the error is gone and everything works fine.

 

I'd like to understand where my mistake is...

 

Maybe the 'Lang' validation changed in 1.5.3.1?

 

Thank's

Edited by doubleD (see edit history)
  • Like 2
Link to comment
Share on other sites

  • 3 months later...
  • 3 weeks later...

I'm also having a problem to both of my 2 different stores. All of a sudden the error occurred.

 

Fatal error: Class 'Cache' not found in classes/ObjectModel.php on line 1470 - (Prestashop 1.5.4.1)

 

Fatal error: Class 'Cache' not found in classes/ObjectModel.php on line 195 - (Prestashop 1.5.3.1)

 

 

My BO and FO are empty. Any help please..

 

Thanks.

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

  • 2 months later...

i'm in 1.5.4 and on the line 1470 there is :

 

if ($field !== null || !Cache::isStored($cache_id))

{

$reflection = new ReflectionClass($class);

$definition = $reflection->getStaticPropertyValue('definition');

 

$definition['classname'] = $class;

 

if (!empty($definition['multilang']))

$definition['associations'][Collection::LANG_ALIAS] = array(

'type' => self::HAS_MANY,

'field' => $definition['primary'],

'foreign_field' => $definition['primary'],

);

 

if ($field)

return isset($definition['fields'][$field]) ? $definition['fields'][$field] : null;

 

Cache::store($cache_id, $definition);

return $definition;

}

 

 

Any solution ?

Link to comment
Share on other sites

  • 2 months later...

I notice this post is marked "SOLVED" but I don't see the solution to this problem of

"Fatal error: Class 'Cache' not found in /home/content....html/classes/ObjectModel.php on line 1470"

 

I have the same problem - what was the solution?

Link to comment
Share on other sites

I notice this post is marked "SOLVED" but I don't see the solution to this problem of

"Fatal error: Class 'Cache' not found in /home/content....html/classes/ObjectModel.php on line 1470"

 

The line 1470 is below:

if ($field !== null || !Cache::isStored($cache_id))

 

What is the solution to this problem?

Link to comment
Share on other sites

  • 5 weeks later...
  • 3 months later...

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...