Jump to content

Undefined Variable


Yarnell

Recommended Posts

Hey folks,
I am getting the following error, any ideas why this would happen?

Hack: 1615340154.58800 --- Duration: 419 µs [ERROR - NOT CACHED]
INSERT INTO `cc6_CubeCart_system_error_log` (`message`,`time`) VALUES ('[<strong>Notice</strong>] /var/www/clients/client1/web3/web/includes/functions.inc.php:221 - Undefined variable: get','1615340154');

 

Link to comment
Share on other sites

The CubeCart programmers have adopted the programming style of not declaring a variable before using it. This is perfectly legit in PHP.

However, PHP will also log a Notice in the error log (unless specifically told to ignore such situations) when attempting to use a variable it knows nothing about -- yet.

Such notices serve as a clue to the programmers that this variable name needs to be checked as it could be a misspelling of some other variable name.

Also, "Hack" refers to a "time hack", as from a stop-watch, to indicate the universal time when this statement was executed.

Link to comment
Share on other sites

Doing this is an exercise in futility. There will be hundreds of instances of these kinds of Notices.

But, in the file /includes/functions.inc.php:

Near line 202 find:

function currentPage($excluded = null, $included = null, $remove_excluded = true)

A few lines later, find:

$get = $_GET;

Change that to:

$get = (array)$_GET;

Please let us know the exact version of CubeCart you are using. The error message is indicating line number 221, and yet, the line that has $get in it is line number 219 (for CC642).

Link to comment
Share on other sites

We'll i'll be :-)

You just fixed my logout problem. I was get a csrf error when I tried to logout. Genius ** Salute **

Thanks B

 

another quick question while I got you here.

When ever I submit a form in the backend the page will load, and then it tries to start auto scrolling to the top of the page.

Any idea what would cause it to try and auto scroll to the top of the page?

Link to comment
Share on other sites

There is a javascript action that, when the document is ready, the action will attempt to scroll to -81 pixels.

I do not recall why that was put in the javascript, but it did solve some kind of problem many versions ago.

 

Link to comment
Share on other sites

Nice, found the -81, awesome, thank you sir.

I'm using the latest version 6.4.2. Ahhh, didn't notice that, that makes a difference. the line it is referring to is

    if (is_array($get) && count($get) > 0) {
        $params = array_merge($params, $get);
    }

Specificcly the $params = array_merge($params, $get); part

I also get this notice at the top of my page

 Notice: Undefined variable: _GET in /var/www/clients/client1/web3/web/includes/functions.inc.php on line 208

 

Link to comment
Share on other sites

If the "superglobal" variable $_GET is not known to PHP - which it would be very strange if not - that means something is not set right with the PHP INI file regarding the variables_order setting (https://www.php.net/manual/en/ini.core.php#ini.variables-order) - which now you are getting an error: Undefined variable: _GET.

If the regular variable $get is not getting defined when skipped over because $_GET is not empty, then there might be problems later over an undefined $get.

 

Link to comment
Share on other sites

hmmm. the only changes i made to php.ini was

session.gc_maxlifetime=10800
max_input_time=10800
max_execution_time=10800
upload_max_filesize=110M
post_max_size=120M
max_input_vars=8000

Think I may have to reinstall.

That makes sense.

Link to comment
Share on other sites

In CubeCart's admin, PHP Info, scroll to the bottom of the Core table. Find the 'variables_order' directive. The values should be GPCS. The G stands for $_GET and if that letter is in the group, PHP will create that variable and make whatever it contains available to any script code, anywhere.

Link to comment
Share on other sites

  • 2 months later...

Archived

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

×
×
  • Create New...