Jump to content

Getting database.php error on image fields creation / editing


Ovi
 Share

Recommended Posts

What i get is this error message, whenever i create a new image field, on a page with the URL sitename.com/processwire/setup/field/save

Error: Uncaught exception 'WireDatabaseException' with message 'Table 'dap_pw.field_testimage' doesn't exist' in /home/dap/public_html/wire/core/Database.php:118
Stack trace:
#0 /home/dap/public_html/wire/modules/Fieldtype/FieldtypeFile.module(261): Database->query('SHOW COLUMNS FR...')
#1 /home/dap/public_html/wire/core/Fieldtype.php(321): FieldtypeFile->getDatabaseSchema(Object(Field))
#2 [internal function]: Fieldtype->___createField(Object(Field))
#3 /home/dap/public_html/wire/core/Wire.php(271): call_user_func_array(Array, Array)
#4 /home/dap/public_html/wire/core/Wire.php(229): Wire->runHooks('createField', Array)
#5 /home/dap/public_html/wire/core/Fields.php(203): Wire->__call('createField', Array)
#6 /home/dap/public_html/wire/core/Fields.php(203): FieldtypeImage->createField(Object(Field))
#7 [internal function]: Fields->___save(Object(Field))
#8 /home/dap/public_html/wire/core/Wire.php(271): call_user_func_array(Array, Array)
#9 /home/dap/public_html/wire/core/Wire.php(229): Wire->runHooks('save', Array)
# (line 118 of /home/dap/public_html/wire/core/Database.php) 

This error message was shown because you are logged in as a Superuser. Error has been logged.

However, the field does get created, and i can use it, and i can save any configurations i make, but i can't rename or delete it (i get the same type of database error message).

This started happening after asking the Servint support team that manages my VPS to install APC and PDO on my server.


Any ideas how these things can be related, or what can i do to fix this?

Thanks,
Ovi

EDIT: 

Now i'm seeing that when trying to create a new page that uses an image field i get this error:

Error: Uncaught exception 'WireDatabaseException' with message 'Table 'dap_pw.field_event_image' doesn't exist' in /home/dap/public_html/wire/core/Database.php:118
Stack trace:
#0 /home/dap/public_html/wire/modules/Fieldtype/FieldtypeFile.module(261): Database->query('SHOW COLUMNS FR...')
#1 /home/dap/public_html/wire/core/Fieldtype.php(460): FieldtypeFile->getDatabaseSchema(Object(Field))
#2 /home/dap/public_html/wire/core/Fieldtype.php(415): Fieldtype->getLoadQuery(Object(Field), Object(DatabaseQuerySelect))
#3 [internal function]: Fieldtype->___loadPageField(Object(Page), Object(Field))
#4 /home/dap/public_html/wire/core/Wire.php(271): call_user_func_array(Array, Array)
#5 /home/dap/public_html/wire/core/Wire.php(229): Wire->runHooks('loadPageField', Array)
#6 /home/dap/public_html/wire/core/Page.php(651): Wire->__call('loadPageField', Array)
#7 /home/dap/public_html/wire/core/Page.php(651): FieldtypeCropImage->loadPageField(Object(Page), Object(Field))
#8 /home/dap/public_html/wire/core/Page.php(558): Page->getF (line 118 of /home/dap/public_html/wire/core/Database.php) 

This error message was shown because you are logged in as a Superuser. Error has been logged.
Link to comment
Share on other sites

When you are running APC a good function to know is apc_clear_cache(). Put that in a file and run it, or maybe added it to your homepage template file with some code like this:

if($user->isSuperuser() && $input->get->clear_apc) apc_clear_cache(); 

Then you could just access your site and do this: http://domain.com/?clear_apc=1. It's not often you'll need to clear the APC cache, but it's a good idea any time you see anything weird like this. 

However, I'm guessing that the table really doesn't exist and the error messages are correct. Though I'm also guessing the table creation process got screwed up by the APC cache somehow. I would go into PhpMyAdmin and create the table manually, so that you can either use it or delete it. Paste this into the PhpMyAdmin SQL tab and execute it: 

CREATE TABLE `field_event_image` (
  `pages_id` int(10) unsigned NOT NULL,
  `data` varchar(255) NOT NULL,
  `sort` int(10) unsigned NOT NULL,
  `description` text NOT NULL,
  `modified` datetime DEFAULT NULL,
  `created` datetime DEFAULT NULL,
  PRIMARY KEY (`pages_id`,`sort`),
  KEY `data` (`data`),
  KEY `modified` (`modified`),
  KEY `created` (`created`),
  FULLTEXT KEY `description` (`description`)
) ENGINE=MyISAM DEFAULT CHARSET=utf8;

After clearing the APC cache, try creating a new image field and see if it's still having problems?

  • Like 2
Link to comment
Share on other sites

Hi Ryan and thanks for your help!

I cleared the APC cache (even put <?php apc_clear_cache(); ?> in the header of the site, with no conditions, to make sure it clears.

The fields did start working once i manually created the missing table, but each time i create a new image field, it get the error again. For some reason the table for that field never gets created, and i get this error when trying to create a new field:

Error: Uncaught exception 'WireDatabaseException' with message 'Table 'dap_pw.field_testimage3' doesn't exist' in /home/dap/public_html/wire/core/Database.php:118
Stack trace:
#0 /home/dap/public_html/wire/modules/Fieldtype/FieldtypeFile.module(261): Database->query('SHOW COLUMNS FR...')
#1 /home/dap/public_html/wire/core/Fieldtype.php(321): FieldtypeFile->getDatabaseSchema(Object(Field))
#2 [internal function]: Fieldtype->___createField(Object(Field))
#3 /home/dap/public_html/wire/core/Wire.php(271): call_user_func_array(Array, Array)
#4 /home/dap/public_html/wire/core/Wire.php(229): Wire->runHooks('createField', Array)
#5 /home/dap/public_html/wire/core/Fields.php(203): Wire->__call('createField', Array)
#6 /home/dap/public_html/wire/core/Fields.php(203): FieldtypeCropImage->createField(Object(Field))
#7 [internal function]: Fields->___save(Object(Field))
#8 /home/dap/public_html/wire/core/Wire.php(271): call_user_func_array(Array, Array)
#9 /home/dap/public_html/wire/core/Wire.php(229): Wire->runHooks('save', Arr (line 118 of /home/dap/public_html/wire/core/Database.php) 

This error message was shown because you are logged in as a Superuser. Error has been logged. 

So far it only happens with image fields.

Link to comment
Share on other sites

It does seem odd to me that it started occurring after the server/PHP upgrade. The query that it says is failing "show columns from..." also reminds me a lot of a bug I just fixed this morning with FieldtypeMapMarker. Though I've never seen it occur with the images field, but the images field does do something very similar in terms of supporting DB schema changes to the field table. It looks like you are running PW 2.3.0 or earlier, based on the class names in the exception. I'd suggest upgrading to 2.3.2 (dev) and seeing if this resolves the issue. However, both PW 2.3.0 and 2.3.2 have the failing query mentioned here (FieldtypeFile.module line 261) wrapped in a try/catch block, which makes the exception here particularly unusual. You might want to wipe out your /wire/ directory completely and replace it with a brand new copy, then clear the APC cache. 

  • Like 1
Link to comment
Share on other sites

Did just that, wiped the wire directory, re-uploaded from a freshly downloaded copy of PW 2.3.0 - still the same behavior.

All the sites on that server have this problem. Maybe the switch from suPHP to FastCGI caused this? That was my best guess. So i asked Servint to switch to DSO - which should be what you're using too, Ryan, since you told me in another thread that you're not using FastCGI, and DSO is the only other alternative that allows APC.

Still no luck, even with DSO (i of course i changed the attributes of the /site/assets/) folder to 777 to account for PHP running as 'nobody" - but the error still appears after creating an image field.

My sites are so much faster with APC though, and i really don't want to go back to suPHP.

I even did a fresh install of PW on a new account on the server, and i still get this issue appearing. That's just weird. Maybe there's some obscure stuff in my server config that Servint screwed up...

Link to comment
Share on other sites

Figured it out finally: Servint bungled things up and installed APC and Eaccelerator together :) No wonder things got screwy.

Thanks for all your help Ryan, you rock.

  • Like 4
Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...