Field 'access' doesn't have a default value
attiks - May 8, 2009 - 13:32
| Project: | Chaos tool suite |
| Version: | 6.x-1.x-dev |
| Component: | Code |
| Category: | bug report |
| Priority: | normal |
| Assigned: | Unassigned |
| Status: | closed |
Description
While creating a new page in panels, I got this error:
user warning: Field 'access' doesn't have a default value query: INSERT INTO delegator_pages ...

#1
I've never run into something like this. I'm not actually sure how you can get access to be empty, it should be at least putting a blank value there. That makes it seem like maybe there's something a little weird with your installation, but I'm not sure what. I'm not sure how to proceed without understanding how you've got an empty access field.
#2
Merlin,
I'll try again with a clean install, as far as I can remember I just created a new page with primary menu and a view in it, but it wasn't on a clean install so i'll postpone this.
#3
I'm getting the same error.
Drupal 6.11, Panels 6.x-3.0-beta1, cTools 6.x-1.0-beta2. Tried to create a 2-col stacked page. Site data updated from D5, but Panels & cTools were installed after upgrade.
user warning: Field 'access' doesn't have a default value query: INSERT INTO delegator_pages (name, task, admin_title, path, multiple, arguments, conf) VALUES ('about_us', 'panel_page', 'About US', 'about-us', 0, 'a:0:{}', 'a:5:{s:9:\"no_blocks\";i:0;s:6:\"css_id\";s:7:\"aboutus\";s:3:\"css\";s:0:\"\";s:3:\"did\";s:1:\"1\";s:9:\"css_cache\";s:0:\"\";}') in C:\www\demo5\includes\common.inc on line 3431.#4
This is repeatable. On a clean clean 6.11 install:
user warning: Field 'access' doesn't have a default value query: INSERT INTO delegator_pages (name, task, admin_title, path, multiple, arguments, conf) VALUES ('test', 'panel_page', 'test', 'test', 0, 'a:0:{}', 'a:4:{s:9:\"no_blocks\";i:0;s:6:\"css_id\";s:4:\"test\";s:3:\"css\";s:0:\"\";s:3:\"did\";s:1:\"1\";}') in C:\www\clean\includes\common.inc on line 3431.I'm using php 5.2.6, mySQL 5.0.27
Here's an export of delegator_pages:
--
-- Table structure for table `delegator_pages`
--
CREATE TABLE IF NOT EXISTS `delegator_pages` (
`pid` int(11) NOT NULL auto_increment,
`name` varchar(255) default NULL,
`task` varchar(64) default 'page',
`admin_title` varchar(255) default NULL,
`path` varchar(255) default NULL,
`access` longtext NOT NULL,
`multiple` tinyint(4) default '0',
`menu` longtext NOT NULL,
`arguments` longtext NOT NULL,
`conf` longtext NOT NULL,
PRIMARY KEY (`pid`),
UNIQUE KEY `name` (`name`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8 AUTO_INCREMENT=1 ;
A related issue http://drupal.org/node/367962 speaks to the problem of adding a default value to 'access' - its a text/blob (longtext) field.
#5
Solved it. It's a MYSQL issue noted here: http://drupal.org/node/93123
To fix: Remove "STRICT_TRANS_TABLES" from the mySQL SQL mode startup variable list.
Under Windows using the MySQL Administrator this can be done by going to "Startup Variables" | Advanced, and editing "STRICT_TRANS_TABLES" out of SQL Mode
Then Apply changes and restart MySQL and start saving panels.
#6
Isn't it better to adapt the code so it works with mysql in strict mode?
#7
The code should be writing a value for access; the fact that it's not is a bug. I took a quick look at it last night and I think I just need to add an object default in the schema.
#8
I'm also getting a similar error on postgres on a fresh install of beta2:
#9
Am getting the same result as #8 on a fresh install of beta3 as well.
The fact that access is not in the insert is the problem, right?
And the work-around of removing the not-null constraint in the database is not smart
because the db constraints are part of how consistency is kept...so it makse sense to
me what merlinofchaos was saying about creating the default in the schema...
Wow...for once, I think I understand what is going on....
off to see if I can break it worse myself by trying to put a default in the schema for access...
of course, knowing my luck, it is already there and something else is causing the issue :)
oh...and here is what my error said...pretty much the same as number 8:
* warning: pg_query() [function.pg-query]: Query failed: ERROR: null value in column "access" violates not-null constraint in /var/www/includes/database.pgsql.inc on line 139.
* user warning: query: INSERT INTO delegator_pages (name, task, admin_title, path, multiple, arguments, conf) VALUES ('test', 'panel_page', 'test', 'test', 0, 'a:0:{}', 'a:4:{s:9:"no_blocks";i:0;s:6:"css_id";s:0:"";s:3:"css";s:0:"";s:3:"did";s:1:"1";}') in /var/www/includes/common.inc on line 3422.
#10
The work around ought to be to add
'object default' => serialize(array()),to the definition for that object in the .install file. I actually meant to put that in and fix this for the last release, and forgot about this issue. Sorry!#11
another thing I am noticing from looking at the sql insert statement and the database schema in postgresql is that menu is also set to not-null and is not being sent in the insert statement.
#12
It probably needs the same treatment. This never showed up as a bug for me because mysql doesn't seem to mind this error. =(
#13
cool!...and that solution would also solve what I was mentioning in #11... thx!
#14
Patch attached. I just set object default to array(), as it seems the serialize flag there will catch it:
drupaldb=> select menu, access from delegator_pages;menu | access
--------+--------
a:0:{} | a:0:{}
(1 row)
You will need to clear the cache after this patch. I can't recall at this hour of the night if you can use cache_clear_all from inside an update hook or not.
#15
Rerolled with an update hook. No action taken there, as the update page itself will clear the caches. Also fixed a coding issue - TextMate has spoiled me so I forget that tabs don't get converted to spaces automagically in every test editor.
#16
Patched to HEAD without conflicts.
update.php showed 6103 by default ran reporting no queries ran.
No changes to delegate_pages on database.
executed:
<?phpdb_query("INSERT INTO delegator_pages (name, task, admin_title, path, multiple) VALUES ('test', 'panel_page', 'test', 'test', 0)");
?>
With no errors.
Result in database:
mysql> select pid, name, access, menu from delegator_pages where pid = 2;
+-----+------+--------+------+
| pid | name | access | menu |
+-----+------+--------+------+
| 2 | test | | |
+-----+------+--------+------+
This is not the same result as in #14 on mysql 5.0.67.
Uninstalled, emptied cache, reinstalled, ran update. Results were the same.
Not sure if this is what was expected.
#17
@nickl
Your mysql is on the "loose" setting as described above. Expected behavior for that query should be a not null error, before or after this patch. The "object default" schema field is handled purely in the application layer, mysql knows nothing about it. You'll need to enable strict mode for mysql, and test by using the actual panels UI to create a page.
#18
Ok, checked in a fix. I fixed a few other fields too. I think this'll work, tho I don't have the necessary pgsql to be 100% sure.
#19
Automatically closed -- issue fixed for 2 weeks with no activity.