Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Array to string conversion (notice on php 5.4) #438

Open
jrencz opened this issue Jan 28, 2013 · 3 comments
Open

Array to string conversion (notice on php 5.4) #438

jrencz opened this issue Jan 28, 2013 · 3 comments

Comments

@jrencz
Copy link
Contributor

jrencz commented Jan 28, 2013

Notice: Array to string conversion in lib/vendor/diem/dmFrontPlugin/lib/pager/dmFrontPagerView.php on line 134

PHP 5.4.11
apache 2.2
OSX 10.8

@TheCelavi
Copy link
Member

protected function calculateCacheKey()
{
$options = array();
foreach($this->getOptions() as $key => $option)
{
$options[$key] = $option; // <-- remove string conversion
}

return md5(var_export($options, true).$this->getBaseHref().$this->getPage());

}

Try this and let me know if it works...

Best.
THC

@jrencz
Copy link
Contributor Author

jrencz commented Jan 28, 2013

made it other way:
protected function calculateCacheKey()
{
$options = array();
foreach($this->getOptions() as $key => $option)
{
$options[$key] = (is_array($option) && (count($option) > 0)) ? (string) $option : "";
}
return md5(var_export($options, true).$this->getBaseHref().$this->getPage());
}

somehow (I did not check how, it's custom widget, not diem one) $option was an empty array.
This is just temporary solution since I don't know what to do with not empty array. Maybe joint their contents into one string? Should probably work

@TheCelavi
Copy link
Member

  1. $options[$key] = (is_array($option) && (count($option) > 0)) ? (string) $option : "";

vs.

  1. $options[$key] = $option;
  2. is better because it is less CPU and memory greedy, and anyway it will be obusfucated with MD5, see:

return md5(var_export($options, true).$this->getBaseHref().$this->getPage());

to be honest, this would be the best solution:

protected function calculateCacheKey() {

 return md5(var_export($this->getOptions(), true).$this->getBaseHref().$this->getPage());

}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants