[Kirby 1] PHP fatal error, Cannot redeclare get() in /kirby/lib/kirby.php on line 2337

Hi everyone, I’m new working with Kirby. Been trying to put a Kirby site up. However I have encountered this issue with a fatal PHP error. The error log reads:

PHP fatal error, Cannot redeclare get() in /kirby/lib/kirby.php on line 2337

Any idea how I can resolve this? I could just check the public function get() to some other function and it will work, but surely it will break somewhere else.

PS: the Kirby site works locally, just when I put it online, this error shows.

Thanks a lot.


Oh, looks like you are using a deprecated version of Kirby (Kirby 1)? In the current version, the file in the error message does not exist.

does it mean that I shall just upgrade to the latest version of Kirby? That error basically render the site complete not working.

The old version of Kirby is no longer supported, so yes, it would be a good idea to update (that will mean more changes than just replacing the kirby and panel folders, though). But Kirby 2 has so much more to offer.

You should check your PHP version on your remote server.

I also found this workaround in the old kirby forum:

Text: As a Digital Pacific and Kirby user we ran into this problem too. With a little more help from the Digital Pacific team we were able to determine the issue and fix it.

This first occurred when DP upgraded to their cloud servers. I suspect that they also upgraded to PHP 5.3 at the same time which probably caused the error to appear. Without being able to go back to a previous version of PHP on their servers it is difficult to be certain.

In the lib/kirby.php file, at line 2337, the function “get” is redefined to be a shortcut to the get function in class r (defined immediately above). You need to comment out the new definition.

#function get($key=false, $default=null) {
# return r::get($key, $default);

This will get Kirby working. However a couple of optional packages also make use of this get function. Panel and Auth both use it, and there may be others. You need to edit any occurrences of get(…) to use the class override r::get(…)

I have found that you need to edit auth.php which uses get(‘password’) and get(‘username’), panel/lib/form.php which uses it in lots of places, panel/lib/user.php, panel/lib/actions.php and panel/lib/data.php. You will find lots of calls to get, but most have their own class override in place already, such as c::get(…). Leave those ones alone.

You will also find some in panel/snippets/pages.add.php panel/snippets/files.edit.php and so on.

This is a bit clumsy, but it works.

Hope this helps.