[Tiki-devel] SQL error with tiki 29.1

Philip Jollans <[email protected]> Sun, 5 Apr 2026 22:06:52 +0200
Newsgroups gmane.comp.cms.tiki.devel
Message-ID <[email protected]>
--===============7690434113061688216==
Content-Type: multipart/alternative;
 boundary="------------l3Tosn05SRNCv7oOVKZe7Z1l"
Content-Language: en-US

--------------l3Tosn05SRNCv7oOVKZe7Z1l
Content-Type: text/plain; charset=UTF-8; format=flowed
Content-Transfer-Encoding: 8bit

Hi,

I got this error after updating to tiki 29.1 (from tiki 25.0)

--------------------------------------------------------------------------------------------
System error.

The following error message was returned:

You have an error in your SQL syntax; check the manual that corresponds 
to your MariaDB server version for the right syntax to use near '' at line 1

The query was:
SELECT 0 as `isgal`, tf.`fileId` as `id`, tf.`galleryId` as `parentId`, 
tf.`name`, tf.`description`, tf.`filesize` as `size`, tf.`created`, 
tf.`filename`, tf.`filetype` as `type`, tf.`user` as `creator`, 
tf.`author`, tf.`hits`, tf.`lastDownload`, tf.`votes`, tf.`points`, 
tf.`path`, tf.`reference_url`, tf.`is_reference`, tf.`hash`, 
tf.`search_data`, tf.`metadata`, tf.`lastModif` as `lastModif`, 
tf.`lastModifUser` as `last_user`, tf.`lockedby`, tf.`comment`, 
tf.`deleteAfter`, tf.`maxhits`, tf.`archiveId`, tf.`ocr_state`, '' as 
`visible`, '' as `public`, '' as `source`, '' as `files`, tf.`fileId`, 
tf.`galleryId`, tf.`filesize`, tf.`filetype`, tf.`user`, 
tf.`lastModifUser`, 0 as `icon_fileId` FROM `tiki_files` as tf WHERE 
tf.`archiveId`=0 AND tf.`created` > ? ORDER BY `isgal` desc, `created` 
desc LIMIT 0,

Values:

     1775381416

The built query was likely:
SELECT 0 as `isgal`, tf.`fileId` as `id`, tf.`galleryId` as `parentId`, 
tf.`name`, tf.`description`, tf.`filesize` as `size`, tf.`created`, 
tf.`filename`, tf.`filetype` as `type`, tf.`user` as `creator`, 
tf.`author`, tf.`hits`, tf.`lastDownload`, tf.`votes`, tf.`points`, 
tf.`path`, tf.`reference_url`, tf.`is_reference`, tf.`hash`, 
tf.`search_data`, tf.`metadata`, tf.`lastModif` as `lastModif`, 
tf.`lastModifUser` as `last_user`, tf.`lockedby`, tf.`comment`, 
tf.`deleteAfter`, tf.`maxhits`, tf.`archiveId`, tf.`ocr_state`, '' as 
`visible`, '' as `public`, '' as `source`, '' as `files`, tf.`fileId`, 
tf.`galleryId`, tf.`filesize`, tf.`filetype`, tf.`user`, 
tf.`lastModifUser`, 0 as `icon_fileId` FROM `tiki_files` as tf WHERE 
tf.`archiveId`=0 AND tf.`created` > '1775381416' ORDER BY `isgal` desc, 
`created` desc LIMIT 0,
--------------------------------------------------------------------------------------------


I'm pretty sure that the trailing comma is the problem.

I'm also pretty certain that the query comes from FileGalLib.php in the 
function get_files. I hacked the code to remove the comma, using:
$query = preg_replace('/LIMIT\s+(\d+),\s*$/i', 'LIMIT $1', $query);
but that's not really a solution.

Phil

--------------l3Tosn05SRNCv7oOVKZe7Z1l
Content-Type: text/html; charset=UTF-8
Content-Transfer-Encoding: 8bit

<!DOCTYPE html><html><head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
  </head>
  <body>
    <p><font face="Calibri">Hi,</font></p>
    <p><font face="Calibri">I got this error after updating to tiki 29.1
        (from tiki 25.0)</font></p>
    <p><font face="Calibri">--------------------------------------------------------------------------------------------<br>
        System error.<br>
        <br>
        The following error message was returned:<br>
        <br>
        You have an error in your SQL syntax; check the manual that
        corresponds to your MariaDB server version for the right syntax
        to use near '' at line 1<br>
        <br>
        The query was:<br>
        SELECT 0 as `isgal`, tf.`fileId` as `id`, tf.`galleryId` as
        `parentId`, tf.`name`, tf.`description`, tf.`filesize` as
        `size`, tf.`created`, tf.`filename`, tf.`filetype` as `type`,
        tf.`user` as `creator`, tf.`author`, tf.`hits`,
        tf.`lastDownload`, tf.`votes`, tf.`points`, tf.`path`,
        tf.`reference_url`, tf.`is_reference`, tf.`hash`,
        tf.`search_data`, tf.`metadata`, tf.`lastModif` as `lastModif`,
        tf.`lastModifUser` as `last_user`, tf.`lockedby`, tf.`comment`,
        tf.`deleteAfter`, tf.`maxhits`, tf.`archiveId`, tf.`ocr_state`,
        '' as `visible`, '' as `public`, '' as `source`, '' as `files`,
        tf.`fileId`, tf.`galleryId`, tf.`filesize`, tf.`filetype`,
        tf.`user`, tf.`lastModifUser`, 0 as `icon_fileId` FROM
        `tiki_files` as tf WHERE tf.`archiveId`=0 AND tf.`created` &gt;
        ? ORDER BY `isgal` desc, `created` desc LIMIT 0,<br>
        <br>
        Values:<br>
        <br>
        &nbsp; &nbsp; 1775381416<br>
        <br>
        The built query was likely:<br>
        SELECT 0 as `isgal`, tf.`fileId` as `id`, tf.`galleryId` as
        `parentId`, tf.`name`, tf.`description`, tf.`filesize` as
        `size`, tf.`created`, tf.`filename`, tf.`filetype` as `type`,
        tf.`user` as `creator`, tf.`author`, tf.`hits`,
        tf.`lastDownload`, tf.`votes`, tf.`points`, tf.`path`,
        tf.`reference_url`, tf.`is_reference`, tf.`hash`,
        tf.`search_data`, tf.`metadata`, tf.`lastModif` as `lastModif`,
        tf.`lastModifUser` as `last_user`, tf.`lockedby`, tf.`comment`,
        tf.`deleteAfter`, tf.`maxhits`, tf.`archiveId`, tf.`ocr_state`,
        '' as `visible`, '' as `public`, '' as `source`, '' as `files`,
        tf.`fileId`, tf.`galleryId`, tf.`filesize`, tf.`filetype`,
        tf.`user`, tf.`lastModifUser`, 0 as `icon_fileId` FROM
        `tiki_files` as tf WHERE tf.`archiveId`=0 AND tf.`created` &gt;
        '1775381416' ORDER BY `isgal` desc, `created` desc LIMIT 0,&nbsp;<br>
      </font><font face="Calibri">--------------------------------------------------------------------------------------------<br>
        <br>
        <br>
        I'm pretty sure that the trailing comma is the problem.<br>
        <br>
        I'm also pretty certain that the query comes from FileGalLib.php
        in the function get_files. I hacked the code to remove the
        comma, using:<br>
      </font><font face="monospace">$query =
        preg_replace('/LIMIT\s+(\d+),\s*$/i', 'LIMIT $1', $query);</font><font face="Calibri"><br>
        but that's not really a solution.</font></p>
    <p><font face="Calibri">Phil</font></p>
  </body>
</html>

--------------l3Tosn05SRNCv7oOVKZe7Z1l--


--===============7690434113061688216==
Content-Type: text/plain; charset="us-ascii"
MIME-Version: 1.0
Content-Transfer-Encoding: 7bit
Content-Disposition: inline


--===============7690434113061688216==
Content-Type: text/plain; charset="us-ascii"
MIME-Version: 1.0
Content-Transfer-Encoding: 7bit
Content-Disposition: inline

_______________________________________________
TikiWiki-devel mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/tikiwiki-devel

--===============7690434113061688216==--