Child pages
  • [in-news, in-bulletin] SQL error, when creating an Article/Topic [5.3.0-B1]
Skip to end of metadata
Go to start of metadata

Usually the creator (user, who created) of each record is stored CreatedById or OwnerId field of it. For the articles/topics additionally the username of that user (not only ID) is stored into another field. 

During  INP-1203 - Getting issue details... STATUS  task implementation code of kCatDBEventHandler::cacheItemOwner method was changed for no obvious reason and that now leads to several notices during item creation:

Notice (#2): Undefined variable: user_id in ...\core\kernel\db\cat_event_handler.php on line 2226

This in turn leads to following SQL error:

RuntimeException: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'LIMIT 0,1' at line 3 (1064)
SQL: 

    SELECT Username
    FROM 53x_Users
    WHERE PortalUserId =
    LIMIT 0,1 

 in ...\core\kernel\utility\logger.php on line 880

And that adds 5 more notices to the Debugger due incorrect stack trace processing, that was already described in [system log] SQL errors are not logged into System Log [5.3.0-B1].

Solution

Remove all but this content from "cacheItemOwner" method:

$object = $event->getObject();
/* @var $object kDBItem */

$object->SetDBField($cached_field, $object->GetField($id_field));

Related Tasks

INP-1518 - Getting issue details... STATUS