Cotonti / Cotonti

Fast, reliable and flexible PHP CMF/CMS
https://www.cotonti.com
BSD 3-Clause "New" or "Revised" License
92 stars 51 forks source link

Function cot_string_truncate() warning #1770

Closed Kabak closed 4 months ago

Kabak commented 4 months ago

Warning: Array to string conversion in /var/www/blog/system/cotemplate.php on line 1873

usage : {PAGE_ROW_TEXT|cot_string_truncate($this,150,true,false,'...')}

Not always , but if truncating text contains some sequence. For example blocks of code , but not every block containing code trigger that warning.

Alex300 commented 4 months ago

Can you please provide a text example which triggers this error?

Kabak commented 4 months ago

Как проверить наличие модуля PM в системе ?

( Аналогично по имени проверяется наличие и активность любого модуля. )

<!-- IF {PHP.cot_modules.pm} -->
    <!-- IF {PHP.usr.messages} -->
        <li><a class="glowing" href="{PHP|cot_url('pm')}" title=" 
                 {PHP.L.Private_messages}">{PHP.L.Private_Messages}</a></li>
    <!-- ELSE -->
    <li><a class="" href="{PHP|cot_url('pm')}" title="{PHP.L.Private_messages}"> 
                  {PHP.L.Private_Messages}</a></li>
    <!-- ENDIF -->
<!-- ENDIF -->
Kabak commented 4 months ago

seems that triggering image

https://i.gyazo.com/a69c0a2ab84bfaeffc3b4e39aaa38f0c.png

Alex300 commented 4 months ago

Хм. Похоже оно пытается переданный текст распарсить и выполнить.

Как быстрый фикс, могу предложить условие:

if (is_string($argument) && mb_strpos($argument, '{') !== false) {

заменить на

if (is_string($argument) && mb_strpos($argument, '{') === 0) {

Позже продебажу и сделаю постоянный фикс.

Kabak commented 4 months ago

Yes ,if (is_string($argument) && mb_strpos($argument, '{') === 0) { working

Alex300 commented 4 months ago

Thanks for bug report. I fixed CoTemplate. Please test it. If it is ok, I'll make fixed release next week.

Kabak commented 4 months ago

Seems it's working now

Thank you.