Jump to content
Dirty Butter

Error Warning Non-Numeric Value

Recommended Posts

Posted (edited)

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.

 

Edited by Dirty Butter

Share this post


Link to post
Share on other sites

Posted (edited)

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.

Edited by Dirty Butter

Share this post


Link to post
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.

Share this post


Link to post
Share on other sites

Well, I was mistaken. I have a bunch of that same error message in the php error log today. It did not show up in the Admin Error Log.

Share this post


Link to post
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.

Share this post


Link to post
Share on other sites

The error message now points to

$catalogue_products_per_page

I still have the Store Settings set to a blank number of products per page. I'll put it back and see what happens.

 

Share this post


Link to post
Share on other sites

I tried going back to the Store Setting with a number in the products per page. It did not change the error message. Error message still points to $catalogue_products_per_page

Share this post


Link to post
Share on other sites
Posted (edited)

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.

Edited by bsmither

Share this post


Link to post
Share on other sites

I thought the More  procedure was doing it, but I cannot reproduce it by using More to go to the second page of a Category. It's something customers are doing, but I have no idea what.

Share this post


Link to post
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???

Share this post


Link to post
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.

Share this post


Link to post
Share on other sites

So does that mean it's not in our code, so there's nothing to do but ignore it? I have recently discovered that View All in admin will cause it, but it does not show the error on our stock test store.

Share this post


Link to post
Share on other sites

No I was just saying it appears in my log files with requests made by Google.

Google is probably more likely to follow all the available links than customers.

But I guess in a small way it does confirm that it happens to non-admins

 

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

×