FAQ Переход на PHP7

Всем привет! Хочу перевести 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
Code:
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
Code:
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
Code:
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
Code:
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
Code:
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
Code:
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
Code:
function words_rate ()
исправляем на:
function __construct ()
 
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
Code:
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
Code:
function attach_posting()
исправляем на:
function __construct()
 
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
Code:
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
Code:
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
Code:
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
Code:
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
Code:
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
Code:
function datastore_xcache ($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_apc has a deprecated constructor in /library/includes/datastore/apc.php on line 5
Code:
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
Code:
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
Code:
function datastore_sqlite ($cfg, $prefix = null)
исправляем на:
function __construct ($cfg, $prefix = null)
 
Знатаки помогите решить проблему с отображением текста сообщения.?
1.webp
 
Знатаки помогите решить проблему с отображением текста сообщения.?
View attachment 4406
Проблема была в регулярных выражениях. Фикс (viewtopic.php):
Ищем:
Code:
// 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));
    }
Меняем:
Code:
    // 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));
    }
 
Last edited:
Новая пролема! не отображаются ссылки и изображения в тегах:
1.webp
А в режиме предпросмотра всё отображается:
2.webp
Подскажите. Куда капать?
 
Last edited:
Nikita11, в сторону все того же парсера бб-кодов. И нельзя просто так взять и парой замен поднять движок на php7, тут с переделками этими уже второй год идет.
 
Back
Top