2009-03-29

PHP session bug

After a long time trying to fix a mystique bug in my CMS engine, I finally found myself trying to avoid another bug, related to my PHP (5.2.5) session. I would like to share my experience here.

What I was trying to do was to check whether a variable in session was present (using PHP is_set() function) or not. The reason why I was doing this was that this session variable was used for caching. If it was an empty array, it meant that empty information unit was cached and, on the other hand, non present array element should have meant that information had not yet been cached, and that should have triggered the caching mechanizm.

What actualy happened was some kind of a random bug. Sometimes (randomly), after clearing the session in my Firefox browser (3.0.8) or IE (7) the session still contained its array hierarchy. All array elements were cleared to empty arrays, but remained in memory. From the CMS point of view that meant that caching was already completed and there was no need to run one. And that's where the PHP bug is.

First of all, lets take a look to some other PHP bugs, related with session I found on the web that might be interesting to PHP programmers:

The second article describes an unset function bug that looks rather similar to my situation.

At first, it looks like clearing Firefox session (session id actually) should force PHP to generate a new session for me, but I guess that it tries to optimize something and leaves the hierarchy in memory, while it is quite likely that I will use the same one during the new connection.

What I am afraid of is that there is a little possibility that when some other user connects to the same system on the Web, such bug, as described above, might cause even security issues.

Tip: NEVER COUNT ON THE EXISTENCE OF AN ARRAY ELEMENT IN SESSION FACT!

To sum up, I can say that I really like PHP language and I truly hope that PHP6 will not contain these problems in the future.

2009-03-17

U programming language is still here

In the past I have published a message here, in this blog, about UPL (Universal Programming Language). To keep things going, I have decided to write a term paper on this issue in my university (Vilnius University). It shall be called "A better programming language" (yes, as simple as that). This paper will mainly discuss both good and bad sides of existant programming languages, trying to collect a list of features that a better PL of the future should have in it.

Yesterday (assuming that 0:33 is already the other day), I was talking to the lecturer who is a supervisor of this upcomming paper, and he didn't support this idea fully. He agreed that it is a good idea to analyse existing programming languages and paradigms, trying to find their hard points and weaknesses, but the idea of creating my own programming language was said to be unnecessary. To be honest, I really hope that I will be able to change my lecturer's mind, because I am going to write this language standards one way or another.

At the moment I am studying OOP (Object Oriented Programming), PBP (Prototype Based Programming) and FP (Functional Programming) paradigms. My idea is to make a careful mixture of those paradigms.

The progress is not as big as it should be, because I still got lots of work with my web page projects (there are already two of them simultaneously at this moment). CMS nearly has its main functionality built already and at the moment its interface is being developed. Anyway, I hope to finish this work on the beginning of April and UPL will then arise!

2009-03-07

CMS interface is comming soon

Finally, the last method, needed for the CMS engine, is written. The last class exceeded 4000 lines and is still not tested properly, but in a few days it will be tested and fixed if needed.

Interface development is promising to be an easy task and I really hope for that as CMS basic functionality must be available at the end of March already. This is a deadline of one great website that will be built on CMS framework.

Smarty 3 is not yet available, so I will not waste my time updating the template engine.

My nearest tasks will be:

  • Small login page fixes
  • Main CMS page layout and working login page
  • Multilanguage website creation tools (most of this functionality already exists, but it is still not possible to add a new language)
  • Interface for editing language constants
  • Element class testing