Upgrading CodeIgniter from version 2 to 3 - what to watch out for?
2018-07-19 | 225 words
The CodeIgniter documentation describes the upgrade process in quite detail on this page. In addition to incremental upgrades, there is a longer article on upgrading from version 2.2.x to 3.0.x. Here are a few things that I had specific problems with:
- In case of not submitting a value/not finding a value, the methods of the Input, Session and Config classes now return NULL instead of FALSE as in version 2 - it makes more sense, but it can be a problem if you compare types and it’s hard to find it in the whole project, it’s a big change.
- Classes must start with a capital letter - it can be a problem if you work on Windows. Git distinguishes between uppercase and lowercase letters.
- Sessions are no longer stored in cookies. You can choose which session driver to use. The easiest is the file system and database, but for performance reasons we used memcached.
- There have been quite a few changes in the database config, but one thing is crucial - you must turn off ‘pconnect’ - persistent connection.
- The ‘xss_clean’ rule disappears from the Form_validation class. XSS should be applied to output, so it has been removed from validation.
- The ‘base_url’ item in the config cannot be empty. If you cannot set it in the config, you can change it later in the code.