Search

I have this data source that utilises ASDC to connect to a remote database and fetch bunch of user accounts. Everything seems to be working fine - the data is retrieved from the database, however an error message appears:

Fatal error: Uncaught exception 'DatabaseException' with message 'MySQL Error (1146): Table 'mydb.sym_sessions' doesn't exist in query: SELECT SQL_CACHE `session_data` FROM `sym_sessions` WHERE `session` = 'iqik5jvsei89knliepq2bofjn2' LIMIT 1' in /var/www/vhosts/example.com/htdocs/symphony/lib/toolkit/class.mysql.php:845 Stack trace: #0 /var/www/vhosts/example.com/htdocs/symphony/lib/toolkit/class.mysql.php(475): MySQL->__error() #1 /var/www/vhosts/example.com/htdocs/symphony/lib/toolkit/class.mysql.php(677): MySQL->query('SELECT `session...', 'ASSOC') #2 /var/www/vhosts/example.com/htdocs/symphony/lib/toolkit/class.mysql.php(765): MySQL->fetch('SELECT `session...') #3 /var/www/vhosts/example.com/htdocs/symphony/lib/core/class.session.php(215): MySQL->fetchVar('session_data', 0, 'SELECT `session...') #4 /var/www/vhosts/example.com/htdocs/symphony/lib/core/class.session.php(152): Session::read('iqik5jvsei89knl...') #5 [internal function]: Session::write('iqik5jvsei89knl...', ' in /var/www/vhosts/example.com/htdocs/symphony/lib/toolkit/class.mysql.php on line 845

It looks like it's trying to write into sym_sessions in the remote database instead of using symphony installation database. This is very strange and I have no idea how to resolve this... This also affects all other data-sources on the page. They fail to retrieve the info from symphony installation database now too.

My Data-source is following:

<?php

    require_once(EXTENSIONS . '/asdc/lib/class.asdc.php');

    Class datasourceAccounts extends Datasource{

        public $dsParamROOTELEMENT = 'accounts-all';

        public function about(){
            return array(
                     'name' => 'Accounts: All Accounts',
                     'author' => array(
                        'name' => 'John Doe',
                        'website' => 'http://example.com',
                        'email' => 'contact@example.com'),
                    'version' => 'Symphony 2.3.6',
                    'release-date' => '2014-03-29T05:54:14+00:00'   
        );
                }


        public function allowEditorToParse() {
            return false;
        }

        public function grab(&$param_pool){

            $result = new XMLElement($this->dsParamROOTELEMENT);

            $db = new ASDCMySQL;

            ### Optional ###
            $db->character_encoding = 'utf8';
            $db->character_set = 'utf8';
            $db->prefix = 'eh_';
            $db->force_query_caching = true;
            ###

            $db->connect('mysql://login:pass@123.123.123.123:3306/mydb/');

            try{
                $results = $db->query("SELECT * FROM `accounts` ORDER BY `id` ASC");
            }

            catch(Exception $e){
                $result->appendChild(new XMLElement('error', General::sanitize(vsprintf('%d: %s on query "%s"', $db->lastError()))));
                return $result;
            }

            foreach($results as $r){

                $entry = new XMLElement('entry', NULL, array('id' => $r->id, 'status' => $r->{'status'}));

                $entry->appendChild(new XMLElement('username', General::sanitize($r->username)));

                $entry->appendChild(new XMLElement('password', General::sanitize($r->password)));

                $entry->appendChild(new XMLElement('client-ip', General::sanitize($r->clientip)));

                $entry->appendChild(new XMLElement('server-ip', General::sanitize($r->serverip)));

                $result->appendChild($entry);
            }

            return $result;

    }

}

bump! can anybody point me in right direction? There is very little documentation about ASDC and effectively no examples... :'|

Hmm, bit tricky. Can you definitely confirm that your usual Symphony database has the sessions table? Does the error only occur on the page that has ASDC on it too?

If this has only recently started up, have you installed any new extensions? Can you confirm what your symphony prefix is for your usual installation?

There's nothing logical in the source that leads as to why Symphony would trip over itself here. You've initialised the database using new ASDCMySQL instead of the ASDCLoader, so that theoretically should result in two totally separate database connections.

Are you able to create a dummy sessions table on that remote database? Be interesting to see if it's actually used.

The error only occurs on a page where I attach either a ASDC data-source or event.

I might be wrong, but I think you can not establish remote mySQL connection with ASDCLoader, can I? And unfortunately, it is a must that it has to connect to a remote database as it's a centralised database of user accounts.

It's brand new website and I am just building it, so no new extensions or such that could've caused the issue. This leads to a conclusion that the problem must be in my data-source.

I checked and Symphony installation database has sessions table. What I did now is added a carbon copy of it to my remote (users) database as well and now the error I specified above is gone. However, now one of my symphony data-sources (without ASDC) is looking for sym_sections :

MySQL Error (1146): Table 'vpn.sym_sections' doesn't exist in query: SELECT SQL_CACHE `s`.*
                    FROM `sym_sections` AS `s`
                     WHERE `s`.`id` IN (3) on 845 of file /var/www/vhosts/example.com/htdocs/symphony/lib/toolkit/class.mysql.php

It looks like all the data-source and event queries are sent to the remote database...

You cannot use the ASDCLoader class if you want to have two database connections (one to your Symphony install, one to your remote store). ASDCLoader essentials creates another connection to the Symphony install using the ASDC API.

In your above code, the database prefix has been set at eh_, but in the SQL query you aren't using a table prefix at all (just SELECT * FROM accounts). Is that right?

Do you have an install of this or the source code you could share? This is going to be an interesting one to debug as I'm not overly familiar with how ASDC works, and I've never used it the way it's being used here (which is a perfectly valid use case!)

There is a very old thread which might have related information.

Thanks michael!!! The other thread shed light on my issue. The problem seemed to be that I was using the same user for both databases. For now, everything seems to be working. Thx!

Create an account or sign in to comment.

Symphony • Open Source XSLT CMS

Server Requirements

  • PHP 5.3-5.6 or 7.0-7.3
  • PHP's LibXML module, with the XSLT extension enabled (--with-xsl)
  • MySQL 5.5 or above
  • An Apache or Litespeed webserver
  • Apache's mod_rewrite module or equivalent

Compatible Hosts

Sign in

Login details