dokuwiki-plugin-struct
dokuwiki-plugin-struct copied to clipboard
Using a struct dropdown field within bureaucracy creates blank page.
Based on the error_log it seems that dokuwiki tries to cache the PDO object. But fails since it can't be serialized.
[Thu Sep 15 13:57:00 2016] [warn] [client 109.90.224.33] mod_fcgid: stderr: PHP Fatal error: Uncaught exception 'PDOException' with message 'You cannot serialize or unserialize PDO instances' in /var/www/virtual/smmk/html/inc/cache.php:335 [Thu Sep 15 13:57:00 2016] [warn] [client 109.90.224.33] mod_fcgid: stderr: Stack trace: [Thu Sep 15 13:57:00 2016] [warn] [client 109.90.224.33] mod_fcgid: stderr: #0 [internal function]: PDO->__sleep() [Thu Sep 15 13:57:00 2016] [warn] [client 109.90.224.33] mod_fcgid: stderr: #1 /var/www/virtual/smmk/html/inc/cache.php(335): serialize(Array) [Thu Sep 15 13:57:00 2016] [warn] [client 109.90.224.33] mod_fcgid: stderr: #2 /var/www/virtual/smmk/html/inc/parserutils.php(168): cache_instructions->storeCache(Array) [Thu Sep 15 13:57:00 2016] [warn] [client 109.90.224.33] mod_fcgid: stderr: #3 /var/www/virtual/smmk/html/inc/parserutils.php(480): p_cached_instructions('/var/www/virtua...', false, 'inventar:instru...') [Thu Sep 15 13:57:00 2016] [warn] [client 109.90.224.33] mod_fcgid: stderr: #4 /var/www/virtual/smmk/html/inc/parserutils.php(270): p_render_metadata('inventar:instru...', Array) [Thu Sep 15 13:57:00 2016] [warn] [client 109.90.224.33] mod_fcgid: stderr: #5 /var/www/virtual/smmk/html/inc/common.php(245): p_get_metadata('inventar:instru...') [Thu Sep 15 13:57:00 2016] [warn] [client 109.90.224.33] mod_fcgid: stderr: #6 /var/www/virtual/smmk/html/doku.php(91): pageinfo() [Thu Sep 15 13:57:00 2016] [warn] [client 109.90.224.33] mod_fcgid: stderr: #7 {main} [Thu Sep 15 13:57:00 2016] [warn] [client 109.90.224.33] mod_fcgid: stderr: thrown in /var/www/virtual/smmk/html/inc/cache.php on line 335
Turns out it's for the dropdown and possible other types which incorperate a Schema object. This in the end contains a resource (PDO) which can't be serialized. Adding:
public function __sleep() {
$schema = null;
return array('column','config');
}
public function __wakeup() {
$this->schema = new Schema($this->config['schema']);
if(!$this->schema->getId()) {
// schema does not exist
msg(sprintf('Schema %s does not exist', $this->config['schema']), -1);
$this->schema = null;
$this->config['schema'] = '';
return;
}
}
to "types/Dropdown.php" kinda resolves the issue. But this is dirty it also breaks labels. I would have thought that it is possible to use __sleep() within "meta/Schema.php" to resolve this issue plugin wide but at least I can't seem to fix it there.
So at some point I was better in PHP but this inside "meta/Schema.php" this works.
public function __sleep(){
unset($this->sqlite);
return array('structversion', 'ts', 'maxsort', 'columns', 'chksum', 'islookup', 'table', 'user', 'id');
}
public function __wakeup(){
$helper = plugin_load('helper', 'struct_db');
$this->sqlite = $helper->getDB();
}
It sure isn't the cleanest code but it works. What are the requirements so I can create a Pull Request?
Thank you for your error report.
Could you post (a simplified version of) the wikitext you were using for that bureaucracy form? I would like to reproduce the error.
I think it would make sense to add the sleep/wakeup handling directly in the sqlite plugin.
@Maesto a simple test case would still be appreciated
Something like this:
struct_field "SCHEMA.DROPDOWN"
Where SCHEMA.DROPDOWN is a dropdown field that references a lookup shema.
But based on f74da4e you've seemed to found the Problem.
One thing though. The sqlite plugin on deserialisation doesn't check if the database exists or does it? Wouldn't the struct plugin need to check if if it was sucessfull to not work on uninitialized data in case the database got deleted during being serialized. Or something like that?
Hi, from the comments I thought this problem was solved back in 2016, however I came across the same or a similar problem when using a bureaucracy form to put data into a struct database.
I have a struct scheme with multiple fields of different types (lookup, text, date, user, wiki). Except of one field, all work as expected with bureaucracy. The one that doesn't work, uses the "Multi-input" option. It looks up entries in an other struct scheme with only one field of type text. So when I select one or multiple values in my bureaucracy form this data is not transferred to the struct database, so in the database it's empty. When I deselect the "Multi-input" option it works fine, so I believe it is connected to this option.
Hopefully the description of the error is understandable?! Any help is appreciated very much. Maybe someone can point me in the direction of the problem, so is it related to sqlite, struct, bureaucracy?
Thanks a lot!