Child pages
  • [In-Bulletin] Error during new topic posting [5.3.0-B1]
Skip to end of metadata
Go to start of metadata

I'm getting SQL error, when attempting to post a new topic on Front-End.

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  

Here is the stack trace:

It seems, that during some kind of refactoring we've left $user_id variable, but have never put any value in it.

Related Tasks

1 Comment

  1. This looks like fixed version of cacheItemOwner method:

    /**
     * Stores item's owner login into separate field together with id
     *
     * @param kEvent $event
     * @param string $id_field
     * @param string $cached_field
     */
    function cacheItemOwner($event, $id_field, $cached_field)
    {
    	$object = $event->getObject();
    	/* @var $object kDBItem */
    
    	$user_id = $object->GetDBField($id_field);
    	$options = $object->GetFieldOptions($id_field);
    
    	if ( isset($options['options'][$user_id]) ) {
    		$object->SetDBField($cached_field, $options['options'][$user_id]);
    	}
    	else {
    		$user_config = $this->Application->getUnitConfig('u');
    		$sql = 'SELECT ' . USER_TITLE_FIELD . '
    				FROM ' . $user_config->getTableName() . '
    				WHERE ' . $user_config->getIDField() . ' = ' . $user_id;
    		$object->SetDBField($cached_field, $this->Conn->GetOne($sql));
    	}
    }