Jump to content

Error Warning Non-Numeric Value


Dirty Butter

Recommended Posts

I haven't been able to pin down what's happening when this error is logged:

PHP Warning:  A non-numeric value encountered in /xxx/public_html/plushcatalog/classes/catalogue.class.php on line 116

Lines 112-147:

	public function categoryPagination($page) {
		if ($this->_category_count) {
			//Pagination
			$catalogue_products_per_page = $GLOBALS['gui']->itemsPerPage('products', 'perpage');
			if (($page * $catalogue_products_per_page) > $this->_category_count) {
				$new_page = (int)ceil($this->_category_count / $catalogue_products_per_page);
				if ($new_page < $page) {
					httpredir(currentPage(null, array('page'=>$new_page)));
				}
			}
			if (($pages = $GLOBALS['db']->pagination($this->_category_count, $catalogue_products_per_page, $page)) !== false) {
				// Display pagination
				$GLOBALS['smarty']->assign('PAGINATION', $pages);
			}
		}
	}

I'm on  today's commit of 6.2.2.

 

Link to comment
Share on other sites

  • 4 weeks later...

I think I may have found it. The number of items per page in Store Settings>Layout is Deprecated. The actual settings for the number per page are in the skins config. So I deleted the old number I still had in Store Settings and left it blank. Then I opened a page of items, used More to load the next page of items on the store front, and there was no error message.

Link to comment
Share on other sites

Certain information says the admin setting is deprecated, but I see that it is still used if the skin config does not have the newer <products> node. So, the config file setting, then the admin setting, then 10 as the last fallback.

Link to comment
Share on other sites

Make an insignificant edit to line 116:

From:

if (($page * $catalogue_products_per_page) > $this->_category_count) {

To:

if (
($page
*
$catalogue_products_per_page
)
>
$this->_category_count
) {

PHP does not care about statements that break across many lines (one exception), so any further error messages should show exactly which variable PHP is complaining about.

Link to comment
Share on other sites

So these error messages are only appearing after you press the More button? But not on the initial page of a category listing (or search)?

Enable debugging.

In the file /classes/catalogue.class.php, near line 115:

Find:

$catalogue_products_per_page = $GLOBALS['gui']->itemsPerPage('products', 'perpage');

Change to:

$catalogue_products_per_page = $GLOBALS['gui']->itemsPerPage('products', 'perpage');$GLOBALS['debug']->debugMessage('$cppp is: ('.gettype($catalogue_products_per_page).')'.print_r($catalogue_products_per_page,true));

When you get a page of items that has the More button at the bottom of the list, and that you get error messages, scroll to the bottom of the Debug section.

There, you will find something like:

Debug Messages:
[0] $cppp is: (integer)6

This place in the code is just above where $catalogue_products_per_page gets used. So, if it is non-numeric, we can trace out why that is so.

Link to comment
Share on other sites

I just had a thought and hopefully this time I found it. I compared the time in the error log of the last occurrence  and checked it against the Users Online. No one had been recorded for that time. But when I looked at Webbots for that time and followed these type links, it created the error message every time:

https://dirtybutter.com/plushcatalog/russ-plush-animals.html?page=all

So maybe it's the page=all that's causing it???

Link to comment
Share on other sites

After making the edit above, use the suspect URL, and determine if page=all could cause this.

Please report back what the debug message says.

If page=all, then I suspect the $page variable, not the $catalogue_products_per_page variable.

Link to comment
Share on other sites

  • 1 month later...
  • 2 weeks later...
  • 2 weeks later...

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...