FAQ Переход на PHP7

Nikita11

Пользователь
#1
Всем привет! Хочу перевести TorrentPier на PHP7. Так как скорость работы, превышает в 2 раза. И столкнулся с рядом ошибок Deprecated. Опишу как их исправлять:

Deprecated: Methods with the same name as their class will not be constructors in a future version of PHP; ads_common has a deprecated constructor in /library/includes/functions.php on line 119
Код:
function ads_common ()
исправляем на:
function __construct ()
Deprecated: Methods with the same name as their class will not be constructors in a future version of PHP; Date_Delta has a deprecated constructor in /library/includes/functions.phpon line 537
Код:
function Date_Delta()
исправляем на:
function __construct ()
Deprecated: Methods with the same name as their class will not be constructors in a future version of PHP; user_common has a deprecated constructor in /library/includes/sessions.php on line 8
Код:
function user_common ()
исправляем на:
function __construct ()
Deprecated: Methods with the same name as their class will not be constructors in a future version of PHP; Template has a deprecated constructor in /library/includes/template.php on line 36
Код:
function Template($root = '.')
исправляем на:
function __construct($root = '.')
Deprecated: Methods with the same name as their class will not be constructors in a future version of PHP; sql_db has a deprecated constructor in /library/includes/core/mysql.php on line 5
Код:
function sql_db ($cfg_values)
исправляем на:
function __construct ($cfg_values)
Deprecated: Methods with the same name as their class will not be constructors in a future version of PHP; bbcode has a deprecated constructor in /library/includes/bbcode.php on line 442
Код:
function bbcode ()
исправляем на:
function __construct ()
Deprecated: Methods with the same name as their class will not be constructors in a future version of PHP; words_rate has a deprecated constructor in /library/includes/bbcode.php on line 843
Код:
function words_rate ()
исправляем на:
function __construct ()
 

Nikita11

Пользователь
#2
Deprecated: Methods with the same name as their class will not be constructors in a future version of PHP; attach_parent has a deprecated constructor in /library/attach_mod/posting_attachments.php on line 11
Код:
function attach_parent()
исправляем на:
function __construct()
Deprecated: Methods with the same name as their class will not be constructors in a future version of PHP; attach_posting has a deprecated constructor in/library/attach_mod/posting_attachments.php on line 1260
Код:
function attach_posting()
исправляем на:
function __construct()
 

Nikita11

Пользователь
#3
PHP Deprecated: Methods with the same name as their class will not be constructors in a future version of PHP; DBS has a deprecated constructor in /library/includes/core/dbs.php on line 5
Код:
function DBS ($cfg)
исправляем на:
function __construct ($cfg)
PHP Deprecated: Methods with the same name as their class will not be constructors in a future version of PHP; datastore_common has a deprecated constructor in /library/includes/datastore/common.php on line 5
Код:
function datastore_common () {}
исправляем на:
function __construct () {}
PHP Deprecated: Methods with the same name as their class will not be constructors in a future version of PHP; CACHES has a deprecated constructor in /library/includes/core/caches.php on line 5
Код:
function CACHES ($cfg)
исправляем на:
function __construct ($cfg)
PHP Deprecated: Methods with the same name as their class will not be constructors in a future version of PHP; cache_memcache has a deprecated constructor in /library/includes/cache/memcache.php on line 5
Код:
function cache_memcache ($cfg, $prefix = null)
исправляем на:
function __construct ($cfg, $prefix = null)
PHP Deprecated: Methods with the same name as their class will not be constructors in a future version of PHP; datastore_file has a deprecated constructor in /library/includes/datastore/file.php on line 5
Код:
function datastore_file ($dir, $prefix = null)
исправляем на:
function __construct ($dir, $prefix = null)
PHP Deprecated: Methods with the same name as their class will not be constructors in a future version of PHP; datastore_xcache has a deprecated constructor in /library/includes/datastore/xcache.php on line 5
Код:
function datastore_xcache ($prefix = null)
исправляем на:
function __construct ($prefix = null)
 

Nikita11

Пользователь
#4
PHP Deprecated: Methods with the same name as their class will not be constructors in a future version of PHP; datastore_apc has a deprecated constructor in /library/includes/datastore/apc.php on line 5
Код:
function datastore_apc ($prefix = null)
исправляем на:
function __construct ($prefix = null)
PHP Deprecated: Methods with the same name as their class will not be constructors in a future version of PHP; datastore_redis has a deprecated constructor in /library/includes/datastore/redis.php on line 5
Код:
function datastore_redis ($cfg, $prefix = null)
исправляем на:
function __construct ($cfg, $prefix = null)
PHP Deprecated: Methods with the same name as their class will not be constructors in a future version of PHP; datastore_sqlite has a deprecated constructor in /library/includes/datastore/sqlite.php on line 5
Код:
function datastore_sqlite ($cfg, $prefix = null)
исправляем на:
function __construct ($cfg, $prefix = null)
 

Nikita11

Пользователь
#7
Знатаки помогите решить проблему с отображением текста сообщения.?
Посмотреть вложение 4406
Проблема была в регулярных выражениях. Фикс (viewtopic.php):
Ищем:
Код:
// Replace naughty words
    if (count($orig_word))
    {
        if ($user_sig) $user_sig = str_replace('\"', '"', substr(preg_replace('#(\>(((?>([^><]+|(?R)))*)\<))#se', "@preg_replace(\$orig_word, \$replacement_word, '\\0')", '>' . $user_sig . '<'), 1, -1));
        $message = str_replace('\"', '"', substr(preg_replace('#(\>(((?>([^><]+|(?R)))*)\<))#se', "@preg_replace(\$orig_word, \$replacement_word, '\\0')", '>' . $message . '<'), 1, -1));
    }
Меняем:
Код:
    // Replace naughty words
    if (count($orig_word))
    {
        if ($user_sig)
        {
            $user_sig = str_replace('\"', '"', substr(preg_replace_callback('#(\>(((?>([^><]+|(?R)))*)\<))#s', function($m)  use  ($orig_word, $replacement_word)  { return str_replace ($orig_word, $replacement_word , $m[0]);}, '>' . $user_sig . '<'), 1, -1));
        }

        $message = str_replace('\"', '"', substr(preg_replace_callback('#(\>(((?>([^><]+|(?R)))*)\<))#s', function($m)  use  ($orig_word, $replacement_word)  { return str_replace ($orig_word, $replacement_word , $m[0]);}, '>' . $message . '<'), 1, -1));
    }
 
Последнее редактирование:

Nikita11

Пользователь
#8
Новая пролема! не отображаются ссылки и изображения в тегах:
1.jpg
А в режиме предпросмотра всё отображается:
2.jpg
Подскажите. Куда капать?
 
Последнее редактирование:

Exile

Администратор
#9
Nikita11, в сторону все того же парсера бб-кодов. И нельзя просто так взять и парой замен поднять движок на php7, тут с переделками этими уже второй год идет.
 
Сверху