Moodle
  1. Moodle
  2. MDL-24207

Call to a member function getName() on a non-object in lib/dmllib.php on line 1515

    Details

    • Type: Bug Bug
    • Status: Closed
    • Priority: Minor Minor
    • Resolution: Fixed
    • Affects Version/s: 1.8.13, 1.9.9
    • Fix Version/s: 1.8.14, 1.9.10
    • Component/s: Database SQL/XMLDB
    • Labels:
      None
    • Environment:
      Win2003, IIS + FastCGI, PHP 5.3, Oracle XE 10
    • Database:
      Oracle
    • Difficulty:
      Easy
    • Affected Branches:
      MOODLE_18_STABLE, MOODLE_19_STABLE
    • Fixed Branches:
      MOODLE_18_STABLE, MOODLE_19_STABLE
    • Rank:
      27255

      Description

      When trying a clean install of Moodle 1.9.9+ on Oracle XE 10 (Windows)

      PHP Fatal error:
      Call to a member function getName() on a non-object in lib/dmllib.php on line 1515

      Caused by a typo in dmllip.php on line 1515:

      • change this: $table->getName()
      • to this: $xmldb_table->getName()
      • or just: $table

      But this error occurs when the code is trying to report and recover from the following problem:

      • Sequence name for table config not found

      The last screen output before the fatal error was:

      • (oci8po): INSERT INTO m_log_display(module, action, mtable, field) VALUES ('tag', 'update', 'tag', 'name')
        Success
      • (oci8po): select * from (SELECT /+FIRST_ROWS/ name FROM M_config WHERE name = 'unicodedb') where rownum <= ? [ (adodb_offset=>'1') ]
      • (oci8po): SELECT * FROM M_config WHERE id = '-1'
      • (oci8po): select lower(cname),coltype,width, SCALE, PRECISION, NULLS, DEFAULTVAL from col where tname='M_CONFIG' order by colno

        Activity

        Gordon Bateson created issue -
        Hide
        Eloy Lafuente (stronk7) added a comment -

        Hi Gordon,

        I've committed the change in the fallback method. But I guess the fallback won't detect the sequence either.

        Can you take a look to your BD schema and look for which triggers does the m_config table have? If you find the trigger, looking at its code, you'll see the name of the sequence. Does it exist?

        If the sequence doesn't exist you must recreate it manually, by following these steps:

        • drop the trigger (if it exists)
        • drop the sequence (if it exists)
        • create the sequence (don't forget to put its initial value to the max+1 currently in the m_config table.
        • create the trigger that will use the sequence.
          (note: for the last 2 steps, you can use the XMLDB editor that will generate the correct SQL code for you - but the initial value of the sequence that must be expressed by hand).

        Finally, sequences don't disappear magically... so I'd recommend you to investigate when/how is has been dropped.

        Ciao

        Show
        Eloy Lafuente (stronk7) added a comment - Hi Gordon, I've committed the change in the fallback method. But I guess the fallback won't detect the sequence either. Can you take a look to your BD schema and look for which triggers does the m_config table have? If you find the trigger, looking at its code, you'll see the name of the sequence. Does it exist? If the sequence doesn't exist you must recreate it manually, by following these steps: drop the trigger (if it exists) drop the sequence (if it exists) create the sequence (don't forget to put its initial value to the max+1 currently in the m_config table. create the trigger that will use the sequence. (note: for the last 2 steps, you can use the XMLDB editor that will generate the correct SQL code for you - but the initial value of the sequence that must be expressed by hand). Finally, sequences don't disappear magically... so I'd recommend you to investigate when/how is has been dropped. Ciao
        Eloy Lafuente (stronk7) made changes -
        Field Original Value New Value
        Fix Version/s 1.8.14 [ 10411 ]
        Fix Version/s 1.9.10 [ 10407 ]
        Affects Version/s 1.8.13 [ 10406 ]
        Difficulty Easy
        Hide
        Eloy Lafuente (stronk7) added a comment -

        Resolving this as fixed... thanks Gordon. If you find any reason for the sequence/trigger being lost... or need anything else, feel free to comment here.

        Thanks and ciao

        Show
        Eloy Lafuente (stronk7) added a comment - Resolving this as fixed... thanks Gordon. If you find any reason for the sequence/trigger being lost... or need anything else, feel free to comment here. Thanks and ciao
        Eloy Lafuente (stronk7) made changes -
        Status Open [ 1 ] Resolved [ 5 ]
        Resolution Fixed [ 1 ]
        Hide
        Gordon Bateson added a comment -

        Hi Eloy,
        thank you for fixing the typo, and for your kind and precise response. I must admit I am an Oracle newbie, so the instructions are very helpful. Thanks!

        As you say, "sequences don't disappear magically", but the puzzling thing for me is that this was a clean install in a brand new database, so it is not that the sequence disappeared, it seems it was not created when it should have been. Is that possible?

        Show
        Gordon Bateson added a comment - Hi Eloy, thank you for fixing the typo, and for your kind and precise response. I must admit I am an Oracle newbie, so the instructions are very helpful. Thanks! As you say, "sequences don't disappear magically", but the puzzling thing for me is that this was a clean install in a brand new database, so it is not that the sequence disappeared, it seems it was not created when it should have been. Is that possible?
        Hide
        Eloy Lafuente (stronk7) added a comment -

        Hi Gordon,

        well it could be caused by some conflict of names (if there are other objects in the schema). Or perhaps the DB user lacks permissions for creating triggers or sequences.

        But if that is the case, you should get some nasty errors on install (on screeen and/or in web server error logs).

        Did you notice anything?

        Ciao

        Show
        Eloy Lafuente (stronk7) added a comment - Hi Gordon, well it could be caused by some conflict of names (if there are other objects in the schema). Or perhaps the DB user lacks permissions for creating triggers or sequences. But if that is the case, you should get some nasty errors on install (on screeen and/or in web server error logs). Did you notice anything? Ciao
        Hide
        Gordon Bateson added a comment -

        Hello Eloy,
        you inspired me to try again.

        > Or perhaps the DB user lacks permissions

        This was a key point. When I made the user a DBA, and the error disappeared. Yay!

        However, although the tables (and sequences!) were successfully created, Moodle kept trying to recreate the tables (!?) - and failing because of course they were already there. I discovered this was because I had set the $CFG->prefix to use UPPERCASE letters, but an Oracle database only allows lowercase. When I changed the $CFG->prefix to use lowercase, everything worked.

        To summarize what I have learned about using Moodle with Oracle XE:

        • $CFG->dbtype = 'oci8po'
        • $CFG->dbuser must be UPPERCASE
        • $CFG->prefix be lowercase, and either 1 or 2 chars in length (i.e. cannot be empty)
        • $CFG->dbuser must be an Oracle DBA (in order to create sequences and triggers)
        • you can have different Moodle databases, if you create a different Oracle user for each database

        Thanks for your help and patience.

        This issue is closed.

        Show
        Gordon Bateson added a comment - Hello Eloy, you inspired me to try again. > Or perhaps the DB user lacks permissions This was a key point. When I made the user a DBA, and the error disappeared. Yay! However, although the tables (and sequences!) were successfully created, Moodle kept trying to recreate the tables (!?) - and failing because of course they were already there. I discovered this was because I had set the $CFG->prefix to use UPPERCASE letters, but an Oracle database only allows lowercase. When I changed the $CFG->prefix to use lowercase, everything worked. To summarize what I have learned about using Moodle with Oracle XE: $CFG->dbtype = 'oci8po' $CFG->dbuser must be UPPERCASE $CFG->prefix be lowercase, and either 1 or 2 chars in length (i.e. cannot be empty) $CFG->dbuser must be an Oracle DBA (in order to create sequences and triggers) you can have different Moodle databases, if you create a different Oracle user for each database Thanks for your help and patience. This issue is closed.
        Hide
        Eloy Lafuente (stronk7) added a comment -

        Hi Gordon, some comments to your conclusions:

        1) $CFG->dbuser must be UPPERCASE: Don't think so. In fact I've here my "stronk7" user working without problems.
        2) $CFG->dbuser must be an Oracle DBA: That's indeed, too much. Just having the RESOURCE role and the CREATE ANY OBJECT permission should be enough (along with UNLIMITED permission in case you are using quotas).

        Ciao

        Show
        Eloy Lafuente (stronk7) added a comment - Hi Gordon, some comments to your conclusions: 1) $CFG->dbuser must be UPPERCASE: Don't think so. In fact I've here my "stronk7" user working without problems. 2) $CFG->dbuser must be an Oracle DBA: That's indeed, too much. Just having the RESOURCE role and the CREATE ANY OBJECT permission should be enough (along with UNLIMITED permission in case you are using quotas). Ciao
        Martin Dougiamas made changes -
        Status Resolved [ 5 ] Closed [ 6 ]
        QA Assignee nobody
        Martin Dougiamas made changes -
        Workflow jira [ 38672 ] MDL Workflow [ 65544 ]
        Martin Dougiamas made changes -
        Workflow MDL Workflow [ 65544 ] MDL Full Workflow [ 94886 ]

          People

          • Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

            Dates

            • Created:
              Updated:
              Resolved: