Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

RuntimeException - This query failed: SELECT directus_tables.* FROM directus_tables #1143

Closed
transiient opened this issue Apr 14, 2016 · 10 comments
Assignees

Comments

@transiient
Copy link

transiient commented Apr 14, 2016

Version Info

  • Directus version: 11889d1
  • PHP version: 5.6.15
  • MySQL version: 5.7.9
  • Web server: Apache 2.4.17
  • OS name and version: Windows 7 32bit

Expected Behavior

Loading home page after installation

Actual Behavior

Get the following on my page (not in a log):

{
  "code":0,
  "class":"RuntimeException",
  "message":"This query failed: SELECT `directus_tables`.* FROM `directus_tables`",
  "file":"C:\\wamp\\www\\SparkWare-Website-wordpress\\directus\\api\\core\\Directus\\Db\\TableGateway\\AclAwareTableGateway.php",
  "line":486,
  "trace":[
    {
      "file":"C:\\wamp\\www\\SparkWare-Website-wordpress\\directus\\api\\vendor\\zendframework\\zend-db\\src\\TableGateway\\AbstractTableGateway.php",
      "line":208,
      "function":"executeSelect",
      "class":"Directus\\Db\\TableGateway\\AclAwareTableGateway",
      "type":"->",
      "args":[
        {

        }
      ]
    },
    {
      "file":"C:\\wamp\\www\\SparkWare-Website-wordpress\\directus\\api\\vendor\\zendframework\\zend-db\\src\\TableGateway\\AbstractTableGateway.php",
      "line":195,
      "function":"selectWith",
      "class":"Zend\\Db\\TableGateway\\AbstractTableGateway",
      "type":"->",
      "args":[
        {

        }
      ]
    },
    {
      "file":"C:\\wamp\\www\\SparkWare-Website-wordpress\\directus\\api\\core\\Directus\\Bootstrap.php",
      "line":259,
      "function":"select",
      "class":"Zend\\Db\\TableGateway\\AbstractTableGateway",
      "type":"->",
      "args":[

      ]
    },
    {
      "file":"C:\\wamp\\www\\SparkWare-Website-wordpress\\directus\\api\\core\\Directus\\MemcacheProvider.php",
      "line":113,
      "function":"Directus\\{closure}",
      "class":"Directus\\Bootstrap",
      "type":"::",
      "args":[

      ]
    },
    {
      "file":"C:\\wamp\\www\\SparkWare-Website-wordpress\\directus\\api\\core\\Directus\\Bootstrap.php",
      "line":262,
      "function":"getOrCache",
      "class":"Directus\\MemcacheProvider",
      "type":"->",
      "args":[
        "directus_tables",
        {

        },
        1800
      ]
    },
    {
      "function":"acl",
      "class":"Directus\\Bootstrap",
      "type":"::",
      "args":[
        null
      ]
    },
    {
      "file":"C:\\wamp\\www\\SparkWare-Website-wordpress\\directus\\api\\core\\Directus\\Bootstrap.php",
      "line":40,
      "function":"call_user_func",
      "args":[
        "Directus\\Bootstrap::acl",
        null
      ]
    },
    {
      "file":"C:\\wamp\\www\\SparkWare-Website-wordpress\\directus\\api\\api.php",
      "line":125,
      "function":"get",
      "class":"Directus\\Bootstrap",
      "type":"::",
      "args":[
        "acl"
      ]
    },
    {
      "file":"C:\\wamp\\www\\SparkWare-Website-wordpress\\directus\\index.php",
      "line":13,
      "args":[
        "C:\\wamp\\www\\SparkWare-Website-wordpress\\directus\\api\\api.php"
      ],
      "function":"require"
    }
  ],
  "traceAsString":"#0 C:\\wamp\\www\\SparkWare-Website-wordpress\\directus\\api\\vendor\\zendframework\\zend-db\\src\\TableGateway\\AbstractTableGateway.php(208): Directus\\Db\\TableGateway\\AclAwareTableGateway->executeSelect(Object(Zend\\Db\\Sql\\Select))\n#1 C:\\wamp\\www\\SparkWare-Website-wordpress\\directus\\api\\vendor\\zendframework\\zend-db\\src\\TableGateway\\AbstractTableGateway.php(195): Zend\\Db\\TableGateway\\AbstractTableGateway->selectWith(Object(Zend\\Db\\Sql\\Select))\n#2 C:\\wamp\\www\\SparkWare-Website-wordpress\\directus\\api\\core\\Directus\\Bootstrap.php(259): Zend\\Db\\TableGateway\\AbstractTableGateway->select()\n#3 C:\\wamp\\www\\SparkWare-Website-wordpress\\directus\\api\\core\\Directus\\MemcacheProvider.php(113): Directus\\Bootstrap::Directus\\{closure}()\n#4 C:\\wamp\\www\\SparkWare-Website-wordpress\\directus\\api\\core\\Directus\\Bootstrap.php(262): Directus\\MemcacheProvider->getOrCache('directus_tables', Object(Closure), 1800)\n#5 [internal function]: Directus\\Bootstrap::acl(NULL)\n#6 C:\\wamp\\www\\SparkWare-Website-wordpress\\directus\\api\\core\\Directus\\Bootstrap.php(40): call_user_func('Directus\\\\Bootst...', NULL)\n#7 C:\\wamp\\www\\SparkWare-Website-wordpress\\directus\\api\\api.php(125): Directus\\Bootstrap::get('acl')\n#8 C:\\wamp\\www\\SparkWare-Website-wordpress\\directus\\index.php(13): require('C:\\\\wamp\\\\www\\\\Spa...')\n#9 {main}"
}

Steps to Reproduce

  1. Copy files to server
  2. Run through installation with correct data
  3. Voila

Logs or Screenshots

See above

The table directus_tables doesn't exist and wasn't automatically created.

@wellingguzman
Copy link

Hi @vhexs I've tried to reproduce this issue using almost your setup except windows 7 64bit, and I couldn't replicate.

So I have some questions:

  • Which tables did Directus created?
  • What's your api/config.php file like?
  • Are you using Directus under a subdirectory in your host/virtual host?

I'd like to help you resolve this.

@wellingguzman
Copy link

Another question, is NO_ZERO_DATE or NO_ZERO_IN_DATE enabled in MySQL modes?

You can check by execute one of these query:

SELECT @@GLOBAL.sql_mode;
SELECT @@SESSION.sql_mode;

Or perhaps in your mysql config file (my.ini).

@transiient
Copy link
Author

transiient commented Apr 22, 2016

@wellingguzman Sorry for my late reply, my GitHub notifications are full of things I need to stop watching.

Directus created the following tables:

  • directus_activity
  • directus_bookmarks
  • directus_columns
  • directus_files
  • directus_groups
  • directus_schema_migrations

I ended up deleting Directus from my project directory, so I'll quickly reinstall it and see if anything's changed (and so I can post the config file if it doesn't).

NO_ZERO_IN_DATE and NO_ZERO_DATE are both enabled on MySQL. And finally, yes, I was using a sub-directory - should I try again without it?


Update: Okay, I reinstalled it and I still have the same issue. All the dependencies are met (except for the optional image/thumbnail plugin. My config.php file is below:

<?php
date_default_timezone_set('America/New_York');

define('API_VERSION', 1);

/**
 * DIRECTUS_ENV - Possible values:
 *
 *   'production' => error suppression, nonce protection
 *   'development' => no error suppression, no nonce protection (allows manual viewing of API output)
 *   'staging' => no error suppression, no nonce protection (allows manual viewing of API output)
 *   'development_enforce_nonce' => no error suppression, nonce protection
 */
define('DIRECTUS_ENV',  'development');

// MySQL Settings
define('DB_HOST',        'localhost');
define('DB_NAME',        'directusnew');
define('DB_USER',        'directusnew');
define('DB_PASSWORD',    'pTZZjL3cLSnsL5da');
define('DB_PREFIX',      '');


define('DB_HOST_SLAVE',        ''); //Leave undefined to fall back on master
define('DB_USER_SLAVE',        '');
define('DB_PASSWORD_SLAVE',    '');

// Url path to Directus
define('DIRECTUS_PATH', '/SparkWare-Website-wordpress/directus-master/');


$host = 'www.example.com'; // (Make it work for CLI)
if(isset($_SERVER['SERVER_NAME'])) {
    $host = $_SERVER['SERVER_NAME'];
}

define('ROOT_URL', '//' . $host);
if (!defined('ROOT_URL_WITH_SCHEME')){
    //Use this for emailing URLs(links, images etc) as some clients will trip on the scheme agnostic ROOT_URL
    define('ROOT_URL_WITH_SCHEME', 'https://' . $host);
}

// Absolute path to application
define('APPLICATION_PATH', realpath(dirname(__FILE__) . '/..'));

//Memcached Server, operates on default 11211 port.
define('MEMCACHED_SERVER', '127.0.0.1');

//Namespaced the memcached keys so branches/databases to not collide
//options are prod, staging, testing, development
define('MEMCACHED_ENV_NAMESPACE', 'staging');


define('STATUS_DELETED_NUM', 0);
define('STATUS_ACTIVE_NUM', 1);
define('STATUS_DRAFT_NUM', 2);
define('STATUS_COLUMN_NAME', 'active');

@wellingguzman
Copy link

@vhexs What happened here is that if mysql has ZERO_IN_DATE enabled it doesn't allow zeros in dates.

It was fixed by 62176ac and 0b25ca1

@transiient
Copy link
Author

transiient commented Apr 23, 2016

@wellingguzman Thanks for fixing it! I'll update to the new version now 👍

Dammit, it still won't work for me. I'm going to try setting my SQL_MODE to use zero dates. In the mean time, I decided it might be a good idea if I sent my PHP error log too, might give some more info about the problem.

Sorry to bother you!

Setting my SQL_MODE to only STRICT_ALL_TABLES didn't work either. I don't know why this is happening. I did notice in the PHP log that the slashes in the filenames are mixed up. Not sure if that matters or not, but some were \ and others were /.

@dblooman
Copy link

dblooman commented Nov 1, 2016

@wellingguzman I just tried a fresh install of Directus from the latest release tag and getting this issue with AWS RDS MySQL.

@wellingguzman
Copy link

Hey @DaveBlooman, can please send me any logs, if any, on api/logs?

Are the rest of the table created? directus_* (What are all the tables prefixed with it)

@dblooman
Copy link

dblooman commented Nov 1, 2016

@wellingguzman I resolved my issue. For some reason, when supplying a config.php, it creates an error, but if you leave that file out, run the provisioning via the web UI, it works fine, even though the same file is output.

My use case is that I build Amazon Machine Images with code already in, this was the first time i tried the AMI with a new fresh database. I guess there is something for the docs, always run through the web UI with a new database, or provision the database first.

@wellingguzman
Copy link

Hey @DaveBlooman,

What was the actual problem, I didn't get it. So you meant that you created the config.php and configuration.php manually and it didn't work until you created Directus using the installer?

How did you create all the core tables, such as directus_tables?

I'd love to see what was the actual issue.

@dblooman
Copy link

dblooman commented Nov 2, 2016

I had previous done a setup of Directus in an AWS account by going through the web installer. Once I knew what files i needed, i automated the process and bake amazon images. I attempted to use the existing image with a new database. This didn't work, so i assumed it must be the config.php existence causes Directus to assume a bunch of things, the DB has everything setup for example.

I guess I should have a step to setup the DB before Direcuts attempts to start, but i don't intend to setup a third CMS right now.

@github-actions github-actions bot locked as resolved and limited conversation to collaborators Feb 5, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants