Error creating wiki link page

Error creating wiki link page

by Rafa Veiga -
Number of replies: 12

Hi I'm having some errors after upgrading to the latest version in Moodle: Moodle 2.2.3 (Build: 20120514)

Problem is when creating a new link with the code [ [ New Link ] ] after saving and clicking in the new link I get the error: Error writing to database with the following link error information:  http://docs.moodle.org/22/en/error/moodle/dmlwriteexception

Any idea or solution about this?

Thank you very much.

 

 

Average of ratings: -
In reply to Rafa Veiga

Re: Error creating wiki link page

by Mike Jaroch -

Was getting ready to ask this same thing. Please turn debugging on and see if we are getting similar errors.

System info Ubuntu 64bit, Postgresql 9.1 Moodle V 2.2.3+

Debug info: ERROR: duplicate key value violates unique constraint "mdl_wikisubw_wikgrouse_uix"
DETAIL: Key (wikiid, groupid, userid)=(8, 0, 0) already exists.
INSERT INTO mdl_wiki_subwikis (wikiid,groupid,userid) VALUES($1,$2,$3) RETURNING id
[array (
'wikiid' => '8',
'groupid' => '0',
'userid' => '0',
)]
Stack trace:

line 397 of /lib/dml/moodle_database.php: dml_write_exception thrown
line 232 of /lib/dml/pgsql_native_moodle_database.php: call to moodle_database->query_end()
line 781 of /lib/dml/pgsql_native_moodle_database.php: call to pgsql_native_moodle_database->query_end()
line 833 of /lib/dml/pgsql_native_moodle_database.php: call to pgsql_native_moodle_database->insert_record_raw()
line 104 of /mod/wiki/locallib.php: call to pgsql_native_moodle_database->insert_record()
line 950 of /mod/wiki/pagelib.php: call to wiki_add_subwiki()
line 115 of /mod/wiki/create.php: call to page_wiki_create->create_page()

In reply to Mike Jaroch

Re: Error creating wiki link page

by Rafa Veiga -
Yes the same debug info but with MySQL database.


Debug info: Duplicate entry '7-0-0' for key 'mdl_wikisubw_wikgrouse_uix'
INSERT INTO mdl_wiki_subwikis (wikiid,groupid,userid) VALUES(?,?,?)
[array (
0 => '7',
1 => '0',
2 => '0',
)]
Stack trace:
  • line 397 of /lib/dml/moodle_database.php: dml_write_exception thrown
  • line 893 of /lib/dml/mysqli_native_moodle_database.php: call to moodle_database->query_end()
  • line 935 of /lib/dml/mysqli_native_moodle_database.php: call to mysqli_native_moodle_database->insert_record_raw()
  • line 104 of /mod/wiki/locallib.php: call to mysqli_native_moodle_database->insert_record()
  • line 950 of /mod/wiki/pagelib.php: call to wiki_add_subwiki()
  • line 115 of /mod/wiki/create.php: call to page_wiki_create->create_page()
In reply to Rafa Veiga

Re: Error creating wiki link page

by Bernd Bosbach -

I also got the same problem and debug info:

 

 

Debug info: Duplicate entry '12-0-0' for key 'mdl_wikisubw_wikgrouse_uix'
INSERT INTO mdl_wiki_subwikis (wikiid,groupid,userid) VALUES(?,?,?)
[array (
0 => '12',
1 => '0',
2 => '0',
)]
Stack trace:
  • line 397 of /lib/dml/moodle_database.php: dml_write_exception thrown
  • line 893 of /lib/dml/mysqli_native_moodle_database.php: call to moodle_database->query_end()
  • line 935 of /lib/dml/mysqli_native_moodle_database.php: call to mysqli_native_moodle_database->insert_record_raw()
  • line 104 of /mod/wiki/locallib.php: call to mysqli_native_moodle_database->insert_record()
  • line 950 of /mod/wiki/pagelib.php: call to wiki_add_subwiki()
  • line 115 of /mod/wiki/create.php: call to page_wiki_create->create_page()
In reply to Rafa Veiga

Re: Error creating wiki link page

by Scott Tester -

If my issue is the same as yours, it is caused when the 'Force format' checkbox is checked.  I believe I have isolated the portion of code.  Before creating a page, there is a check to see if the subwiki exists or not.  It uses the variable $this-wid, as the wiki id.  However, under certain conditions, (force format checked), this variable does not exists.

This is my hack patch (Although I am not familiar enough with moodle's API to guarentee that I've done this right...)

--- orig/mod/wiki/pagelib.php    2012-05-12 11:26:46.000000000 +1000
+++ mtest/mod/wiki/pagelib.php    2012-05-30 07:42:26.000000000 +1000
@@ -946,7 +946,7 @@
         } else {
             $groupid = '0';
         }
-        if (!$this->subwiki = wiki_get_subwiki_by_group($this->wid, $groupid)) {
+        if (!$this->subwiki = wiki_get_subwiki_by_group((empty($this->wid)?$PAGE->activityrecord->id:$this->wid), $groupid)) {
             $swid = wiki_add_subwiki($PAGE->activityrecord->id, $groupid, $this->uid);
             $this->subwiki = wiki_get_subwiki($swid);
         }

I'll look at creating a ticket, to see if one of the devs can confirm that my patch is the right way to go about it, or not...

In reply to Scott Tester

Re: Error creating wiki link page

by Scott Tester -

Found issue under http://tracker.moodle.org/browse/MDL-33343 and have submitted my patch attempt there.

In reply to Scott Tester

Re: Error creating wiki link page

by Jeffrey Jones -

Scott:
       I've just confronted this issue. I used your code snippet in our 2.2.3 install, and it cured the error for me. However, I just heard from one of my teachers with a Wiki assignment, and of a class of about 20, a little more than half are still getting the error. The PHP error logs show exactly the same error as before,...

[14-Sep-2012 19:23:48 UTC] Default exception handler: Error writing to database Debug: Duplicate entry '662-0-2500' for key 'mdl_wikisubw_wikgrouse_uix'
INSERT INTO mdl_wiki_subwikis (wikiid,groupid,userid) VALUES(?,?,?)

Is there something else I can do to nudge this along? I won't be able to take the system down for an upgrade until October, and I've got at least that teacher desperate for this to work.
       Thanks.
                             Jeff

 

In reply to Jeffrey Jones

Re: Error creating wiki link page

by Jeffrey Jones -
An upgrade to 2.2.5 helped some, but not all of these problems. I'm extremely frustrated, as are teachers who previously used the wiki extensively.
In reply to Scott Tester

Re: Error creating wiki link page

by Rafa Veiga -

Hi Scott.

!! It worked for me !!

I made the changes and it looks like everything is working fine.

Hope admins can upload your changes for the next daily version. clown

 

Thank you very much.

In reply to Rafa Veiga

Re: Error creating wiki link page

by DANIEL BERNAL -

The problem continue I recived this

 

Error al escribir a la base de datos

Más información sobre este error

Debug info: Duplicate entry '628-0-2398' for key 'mdl_wikisubw_wikgrouse_uix'
INSERT INTO mdl_wiki_subwikis (wikiid,groupid,userid) VALUES(?,?,?)
[array (
0 => '628',
1 => '0',
2 => 2398,
)]
Error code: dmlwriteexception
Stack trace:
  • line 410 of /lib/dml/moodle_database.php: dml_write_exception thrown
  • line 1029 of /lib/dml/mysqli_native_moodle_database.php: call to moodle_database->query_end()
  • line 1071 of /lib/dml/mysqli_native_moodle_database.php: call to mysqli_native_moodle_database->insert_record_raw()
  • line 104 of /mod/wiki/locallib.php: call to mysqli_native_moodle_database->insert_record()
  • line 952 of /mod/wiki/pagelib.php: call to wiki_add_subwiki()
  • line 115 of /mod/wiki/create.php: call to page_wiki_create->create_page()
In reply to DANIEL BERNAL

Re: Error creating wiki link page

by Jeffrey Jones -

Me too. This remains a bug, as far as I can tell....

In reply to Jeffrey Jones

Re: Error creating wiki link page

by DANIEL BERNAL -

The problem continues. This is horrible, I've updated to the latest version available. The problem arises when the user has already created and has used his wiki, it is detected that the problem started when he tries to check the wiki another user which is empty and you receive the following error:

Debug info:
Error code: nocontent
Stack trace:
line 467 of / lib / setuplib.php: moodle_exception thrown
line 200 of / mod / wiki / view.php: call to print_error ()

after that it is impossible to re-enter your wiki and show the following error:

 

Debug info: Duplicate entry '657-0-9078' for key 'mdl_wikisubw_wikgrouse_uix'
INSERT INTO mdl_wiki_subwikis (wikiid,groupid,userid) VALUES(?,?,?)
[array (
0 => '657',
1 => '0',
2 => 9078,
)]
Error code: dmlwriteexception

Stack trace:

  • line 410 of /lib/dml/moodle_database.php: dml_write_exception thrown
  • line 1050 of /lib/dml/mysqli_native_moodle_database.php: call to moodle_database->query_end()
  • line 1092 of /lib/dml/mysqli_native_moodle_database.php: call to mysqli_native_moodle_database->insert_record_raw()
  • line 104 of /mod/wiki/locallib.php: call to mysqli_native_moodle_database->insert_record()
  • line 952 of /mod/wiki/pagelib.php: call to wiki_add_subwiki()
  • line 115 of /mod/wiki/create.php: call to page_wiki_create->create_page()


The configuration used is: Wiki single, Forcing HTML format and mode Group Groups Visible, Visible: show

Ubuntu Server 11.10 64 bits.

Moodle 2.3.2+ (Build: 20121018)
Mysql 5.1.63.0.0.11.10.1
PHP 5.3.6.13.3.9



Help!