Jump to content

Log showing a repetitive error


foz1234

Recommended Posts

As title suggests i am getting a repetitive error in my log:-

[28-Nov-2016 13:30:32 Europe/London] PHP Warning: array_keys() expects parameter 1 to be array, boolean given in /home/domain/public_html/admin/sources/dashboard.index.inc.php on line 311

this appears to be the line its referring to in the files (dashboard.index.inc.php)

 $extension_updates = $GLOBALS['db']->select('CubeCart_extension_info', false, array('file_id' => array_keys($extension_updates)));
any ideas?

thanks

Link to comment
Share on other sites

This is a known error with CC611.

A new feature that requests the version of installed extensions to determine if an update is available.

If you are running CC611 and do not have a table named CubeCart_extension_info, then the database has not been upgraded to match the code version of CC611.

Link to comment
Share on other sites

From GitHub https://github.com/cubecart/v6/pull/1107

Quote
Quote

It won't support extensions from 3rd party stores or marketplaces. Only extensions obtained from the CubeCart marketplace via install token will have new version notifications.

 

SemperFiWebServices extensions have a way to be informed of updates being available. Hopefully other developers will soon have something similar for plugins they do not have in the Extension Marketplace.

Link to comment
Share on other sites

"Is there a fix for [these errors getting logged] or must i wait?"

In the file /admin/sources/dashboard.index.inc.php, near line 134:

Find:

$version_check = true;

Change to:

$version_check = array('-1' => null); // true;

The variable $version_check is supposed to be an array. Plus, the key of the array cannot appear to be empty, nor can it be an extension code that might actually exist.

The array keys (extension codes) are used to get more data about extensions from the CubeCart_extension_info database table (added as of CC610). Empty array keys are discarded by CubeCart's database code.

So, an array key of -1 is used as the extension code, which is guaranteed to not interfere with actual extension codes.

Note: the value of $version_check is set in the Session and will persist during the session. So, now that the value of $version_check has changed, you will need to log out of admin (destroying the Session), and log back in to get the new value set into Session.

All of the new code for the new Extension Updates feature can be better written, but this small change is the most effective, least intrusive fix.

Link to comment
Share on other sites

  • 1 month later...

Well, no good news on this one yet :( As of 6.1.3 I'm still having to use your code change to keep from filling up the error log with these warnings.

I spoke too soon. I'm still getting this message (with your code edit from above near line 134).

Quote

[04-Jan-2017 13:39:54 America/Chicago] PHP Warning:  array_keys() expects parameter 1 to be array, boolean given in /home/butter01/public_html/plushcatalog/XXX/sources/dashboard.index.inc.php on line 321

 

Line 321 is

	$extension_updates = $GLOBALS['db']->select('CubeCart_extension_info', false, array('file_id' => array_keys($extension_updates)));

 

Link to comment
Share on other sites

Perhaps something like:

if($GLOBALS['session']->has('version_check')) {
	$extension_updates = $GLOBALS['session']->get('version_check');
	$file_ids = (is_array($extension_updates) && !empty($extension_updates) ? array_keys($extension_updates) : array(-1));
	$extension_updates = $GLOBALS['db']->select('CubeCart_extension_info', false, array('file_id' => $file_ids));

 

Link to comment
Share on other sites

Crashing when I tried to use it. Did I put it in the right place?

{*	if($GLOBALS['session']->has('version_check')) {
	$extension_updates = $GLOBALS['session']->get('version_check');
	$extension_updates = $GLOBALS['db']->select('CubeCart_extension_info', false, array('file_id' => array_keys($extension_updates)));
	if($extension_updates) {
		$GLOBALS['main']->addTabControl($lang['dashboard']['title_extension_updates'], 'extension_updates', null, null, count($extension_updates));
		$GLOBALS['smarty']->assign('EXTENSION_UPDATES', $extension_updates);
	}
} *}
## BRIANSANDAL IGNORE PLUGIN UPDATE ERROR MESSAGE *}
if($GLOBALS['session']->has('version_check')) {
	$extension_updates = $GLOBALS['session']->get('version_check');
	$file_ids = (is_array($extension_updates) && !empty($extension_updates) ? array_keys($extension_updates) : array(-1));
	$extension_updates = $GLOBALS['db']->select('CubeCart_extension_info', false, array('file_id' => $file_ids));
		}
## END BRIANSANDAL IGNORE PLUGIN UPDATE ERROR MESSAGE *}

 

Link to comment
Share on other sites

The lines I posted are meant to replace the first 3 lines in the section you commented out, so it should be:

if($GLOBALS['session']->has('version_check')) {
	$extension_updates = $GLOBALS['session']->get('version_check');
	$file_ids = (is_array($extension_updates) && !empty($extension_updates) ? array_keys($extension_updates) : array(-1));
	$extension_updates = $GLOBALS['db']->select('CubeCart_extension_info', false, array('file_id' => $file_ids));
	if($extension_updates) {
		$GLOBALS['main']->addTabControl($lang['dashboard']['title_extension_updates'], 'extension_updates', null, null, count($extension_updates));
		$GLOBALS['smarty']->assign('EXTENSION_UPDATES', $extension_updates);
	}
}

If that still crashes, try changing the `array(-1)` to `array(0)`.

If that also crashes, post the error message.

Also, '{*' is not correct syntax for PHP comments - you should use '/* .... */' instead. That could be why your code is crashing.

Link to comment
Share on other sites

15 hours ago, Dirty Butter said:

That seems to be working - THANKS!

I always have to try {* /* //  ## and <!-- ways to comment, as I have never understood when to use each one.

It depends on which language you are writing in - each one has its own syntax. PHP and most if not all C-based languages (among others) use `//` and `/* ... */` for comments; `#` is used in many languages as well, most notably SQL; `{* ... *}` is I believe a Smarty-only syntax; `<!-- ... -->` is HTML.

Anyway, glad that got rid of the error message for you - I'll make a PR in GitHub for it.

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...