Issue Details (XML | Word | Printable)

Key: MDL-19223
Type: Bug Bug
Status: Open Open
Priority: Major Major
Assignee: Eloy Lafuente (stronk7)
Reporter: Roger Robins
Votes: 0
Watchers: 1
Operations

Add/Edit UI Mockup to this issue
If you were logged in you would be able to see more operations.
Moodle

SCORM import hangs with Moodle running on Linux connected to an Oracle Database

Created: 18/May/09 02:41 PM   Updated: 20/May/09 10:18 AM
Return to search
Component/s: SCORM
Affects Version/s: 2.0
Fix Version/s: None

File Attachments: 1. Zip Archive NSWTHMN203B.zip (493 kB)

Environment: Moodle 2.0 running on Linix Redhat ES 3.0 connected to Oracle 10.2 (oci native)

Database: Oracle
Participants: Eloy Lafuente (stronk7), Petr Skoda and Roger Robins
Security Level: None
Difficulty: Moderate
Affected Branches: MOODLE_20_STABLE


 Description  « Hide
The hang is due to a database INSERT into the SCORM table returning the wrong record id.
The code is line 45 of mod/scorm/lib.php - if (!$id = $DB->insert_record('scorm', $scorm)) {

The problem only appears when the sequence MBL_SCOR_ID_SEQ (MBL_ default prefix) next_val reaches double figures, then only the first digit of the sequence number is returned from the insert_record at line 45 of lib.php.

I've traced the problem down to the php oracle oci plugin and have logged a bug with www.php.net. I'd still like to know if there is a work around for this problem.
B.T.W. The php I'm running is 5.2.9 compiled again oracle 10.2 client.


 All   Comments   Change History   Version Control      Sort Order: Ascending order - Click to sort in descending order
Roger Robins added a comment - 18/May/09 02:42 PM
I've attached the file I was trying to import to help reproduce the problem

Petr Skoda added a comment - 18/May/09 03:33 PM
assigning to our db guru

Roger Robins added a comment - 20/May/09 10:18 AM
This is the feedback from www.php.net

http://bugs.php.net/?id=48324&edit=2

ID: 48324
Updated by: sixd@php.net
Reported By: roger dot robins at det dot nsw dot edu dot au
-Status: Open
+Status: Bogus
Bug Type: OCI8 related
Operating System: Linux Redhat ES 3.0
PHP Version: 5.2.9
New Comment:

Passing a -1 length to the oci_bind_by_name call allocates only enough storage for the current size of $id at the time of the call. A size of 1 is used for a null.

Instead of -1, pass a length big enough to hold your largest expected return value.

Previous Comments:
------------------------------------------------------------------------

[2009-05-19 01:48:11] roger dot robins at det dot nsw dot edu dot au

Description:
------------
When INSERTing a record into a table that has a database sequence for calculating the table id (unique identifier) and that sequence's next_val has reached double figures; and you use oci_bind_by_name to return the id of the inserted row; then only the first digit of the two digit row id is returned.

Code:
$sql = "INSERT INTO {$this->prefix}$table ($fields) VALUES($values) $returning"; $id = null;

$this->query_start($sql, $params, SQL_QUERY_INSERT); $stmt = $this->parse_query($sql); $descriptors = $this->bind_params($stmt, $params, $table); if ($returning) { oci_bind_by_name($stmt, ":oracle_id", $id, -1, SQLT_LNG); } $result = oci_execute($stmt); $this->free_descriptors($descriptors);
$this->query_end($result, $stmt);
oci_free_statement($stmt);