claudehohl / Stikked

An advanced and beautiful pastebin written in PHP
991 stars 219 forks source link

Function create_function() is deprecated #490

Closed linuxman closed 6 years ago

linuxman commented 6 years ago

Hi, there, I'm updating my version of Stikked (0.12.0). I'm using PHP 7.2 and LiteSpeed Webserver.

I'm having some problems. For example, I get a series of messages when I show information about a paste. ( https://linuxmanr4.com/paste/view/c63d128d )

Any suggestions?

Greetings

A PHP Error was encountered
Severity: 8192

Message: Function create_function() is deprecated

Filename: geshi/geshi.php

Line Number: 4698

Backtrace:

File: /home/linuxman/public_html/paste/application/libraries/geshi/geshi.php
Line: 4698
Function: _error_handler

File: /home/linuxman/public_html/paste/application/libraries/geshi/geshi.php
Line: 4621
Function: _optimize_regexp_list_tokens_to_string

File: /home/linuxman/public_html/paste/application/libraries/geshi/geshi.php
Line: 1655
Function: optimize_regexp_list

File: /home/linuxman/public_html/paste/application/libraries/geshi/geshi.php
Line: 2029
Function: optimize_keyword_group

File: /home/linuxman/public_html/paste/application/libraries/geshi/geshi.php
Line: 2168
Function: build_parse_cache

File: /home/linuxman/public_html/paste/application/libraries/Process.php
Line: 45
Function: parse_code

File: /home/linuxman/public_html/paste/application/models/Pastes.php
Line: 517
Function: syntax

File: /home/linuxman/public_html/paste/application/controllers/Main.php
Line: 693
Function: getPaste

File: /home/linuxman/public_html/paste/index.php
Line: 315
Function: require_once
DudleyKelso commented 6 years ago

Around line 4698 of the file: /home/linuxman/public_html/paste/application/libraries/geshi/geshi.php

Replace: $callback_2 = create_function( '$matches' , 'return "[" . str_replace("|", "", $matches[1]) . "]";' );

with

$callback_2 = function($matches) { return "[" . str_replace("|", "", $matches[1]) . "]"; };

It is untested, but it is logically equivalent, I believe.

linuxman commented 6 years ago

At first I tried to update geshi, but it didn't work.

Your advice has been very helpful and no longer shows the errors.

Thank you very much @DudleyKelso :)