0

I have a commercial website, built on CodeIgniter framework. The cart controller is used to generate the data of the cart contents, and load it in one of two views: either a full cart page, or a sidebar within other pages (in that case, the sidecart view is being called into a designated div via ajax).

All of this has been up and functioning well for over a year now. Three days ago, all of a sudden, the cart page stopped working. By "stopped working" I mean no output is being served to the browser.

I am not aware of any changes being made to the code on my website, so I don't even know how to start debugging...

What I did discover is that when I use https to call the cart, it gets served OK. So the problem exists only with http calls (even though up until now I used http calls and all was well).

To make things complicated, if I force https on all calls to the cart controller - the cart page works well, but the sidecart isn't showing at all. If I use http on all calls to the cart function, it's the other way around: the sidecart works well, but the full page doesn't show. I should say I'm using a hook to force/unforce ssl, depending on the uri segment,so I would very much like all calls to mydomain.com/cart to use the same protocol.

Don't know if it's relevant or not, but my SSL certificate was renewed a few days before the problem appeared. The hosting company insists nothing has changed, but I don't know if I can trust them completely.

Also, at the same time the problem started, the following message started appearing in my error_log:

[13-Jul-2015 08:48:16 UTC] PHP Fatal error: Allowed memory size of 33554432 bytes exhausted (tried to allocate 72 bytes) in /home/temphao1/public_html/system/core/Loader.php on line 807

line 807 in Loader.php is this: extract($this->_ci_cached_vars);

Any pointers as to how to start debugging this weird issue would be highly appreciated!

einav
  • 553
  • 9
  • 27
  • 1
    if a running system starts to stop the service after nothing "happened" usually your data have been grown to a state where one of your scripts crashes because of a bad query - and an allowed memory size error could be an indicator (even if its in your error log) – Atural Jul 13 '15 at 13:26
  • Without code of htaccess, config, controller and view files, I doubt someone could guess what is going on. – Tpojka Jul 13 '15 at 13:41
  • @sintakonte, thanks for the pointer. Any tips on how to start debugging something like this? The problem is that the error points to a file that's part of Codeigniter's framework, not to a code I've written. – einav Jul 13 '15 at 14:21
  • @Tpojka, since I can't pinpoint the problem, I didn't know what code to post here. Didn't think it would be very helpful to post tons of code, so I'm trying to narrow it down before I post any code. – einav Jul 13 '15 at 14:29
  • 1
    CI doesn't do anything- it just reports `extract($this->_ci_cached_vars);` costs too much memory which means one of your arrays, objects or variables are simply to big (300mb+) - this is what i meant with the growing data problem Find the affecting Controller and his function and print out any variable - you'll see that one of them is a really large one - after that you've to adapt your DB queries or whatever data source you use – Atural Jul 13 '15 at 14:57
  • 1
    OMG Your variable length is so high. See this [question's](http://stackoverflow.com/questions/561066/fatal-error-allowed-memory-size-of-134217728-bytes-exhausted-codeigniter-xml) answers – Shaiful Islam Jul 13 '15 at 18:47

1 Answers1

0

Almost too embarrassed to admit, but found the answer.

It had nothing to do with https vs http.

I had a page counter which was sending all the data of the page counts to all pages, and I was doing the counting within the php script, instead of using MySQL COUNT, and sending only the result to the page...

So the http cart stopped working because it was the most popular page, and the counter data was huge. The https cart wasn't used as often, so the counter data wasn't as big, and still manageable.

Thanks @sintakonte and @Shaiful Islam for pointing me in the right direction! It was just what I needed to help me reach a solution.

einav
  • 553
  • 9
  • 27