Forum categories

Cotonti Verona (Ошибка при обновлении) на локал

Fatal error: Uncaught TypeError: Cannot access offset of type string on string in .../install.php:119

webitproff
webitproff • 2026-04-28 19:56 #525

Что произошло 
На строке 119: 

$file['config'] = './datas/config.php';

PHP пытается сделать $file['config'] = ...,  
но переменная $file в этот момент — строка, а не массив. 

В PHP 8+ это строгое TypeError (в PHP 7 было только Warning). 

Почему так случилось
Скорее всего, где-то раньше в коде (в подключенных файлах: functions.php, config.php/config-sample.php, CotDB или Cot::init()) переменная $file была перезаписана строкой. 


Как быстро исправить 

Самое простое и рабочее решение — добавить принудительную инициализацию массива перед строкой 119:

 

// НАЧАЛО: указываем принудительно что переменная $file есть массив
if (!is_array($file)) {
   $file = [];
}
// КОНЕЦ: указываем принудительно

// больше никаких правок
$file['config'] = './datas/config.php';
$file['config_sample'] = './datas/config-sample.php';
$file['sql'] = './setup/install.sql';

 

 

 

🗿

🧙‍♂️ Well met, good traveler! Fate has guided your steps to our humble realm. Here, wise sages and masters of the coding craft ⚒️📜 gather to unravel the mysteries of the code ✨⚙️, share their knowledge, and add new chapters to our chronicles.
⬅️ To the left lie ancient scrolls 📚 filled with forgotten wisdom. ⬆️ Straight ahead, friendly folk offer counsel 💬 to those in need. ➡️ To the right, you may become a chronicler ✍️ yourself, sharing your craft and leaving words of wisdom for those yet to come.
📝 Delay no longer—tell us the name by which you are known, complete the rite of registration 🛡️, and join our fellowship!
🏰 Our brotherhood holds no secret initiation, yet many halls remain closed to wandering guests, for some knowledge 💎 is reserved for those who choose to walk this path beside us.