Issue Details (XML | Word | Printable)

Key: MDL-13661
Type: Bug Bug
Status: Resolved Resolved
Resolution: Fixed
Priority: Critical Critical
Assignee: Petr Skoda
Reporter: Eric Villard
Votes: 1
Watchers: 2
Operations

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

lib/dmllib.php - rcache_set function - array_shift php native function is corrupting cached data

Created: 25/Feb/08 11:47 PM   Updated: 26/Feb/08 05:25 AM
Return to search
Component/s: Lib, Performance
Affects Version/s: 1.8.5
Fix Version/s: 1.8.5, 1.9

Environment: php > 5.1.2, Apache > 2, windows vista business edition, linux Ubuntu > 6, moodle 2007021541 (1.8.4+)
Issue Links:
Relates
 

Participants: Eric Villard and Petr Skoda
Security Level: None
Resolved date: 26/Feb/08
Affected Branches: MOODLE_18_STABLE
Fixed Branches: MOODLE_18_STABLE, MOODLE_19_STABLE


 Description  « Hide
the cached data are referenced by their ids -> $rcache->data[$table][$id], $rcache->data[$table] is an associative array.
but some php native functions used to manage array data return indexed arrays. This is the case of the array_shift function.

the new rcache_set function has corrupted some cached data of our moodle making the script to enter in an infinite loop in the lib/accesslib.php - get_parent_cats function.

the problem is coming from this lines :

function rcache_set($table, $id, $rec) {
    global $CFG, $MCACHE, $rcache;

    if ($CFG->cachetype === 'internal') {
        if (!isset($rcache->data[$table])) {
            $rcache->data[$table] = array();
        }
        if (!isset($rcache->data[$table][$id]) and count($rcache->data[$table]) > $CFG->intcachemax) {
            array_shift($rcache->data[$table]);
        }
        $rcache->data[$table][$id] = clone($rec);

to resolve the problem we have to make our own array_shift function or replace the array_shift($rcache->data[$table]); line by something like :

$keys = array_keys($rcache->data[$table]);
$firstkey = $keys[0];
unset($rcache->data[$table][$firstkey]);

hope that's help


 All   Comments   Change History   Version Control      Sort Order: Ascending order - Click to sort in descending order
Petr Skoda made changes - 26/Feb/08 12:03 AM
Field Original Value New Value
Assignee Martin Dougiamas [ dougiamas ] Petr Skoda [ skodak ]
Petr Skoda made changes - 26/Feb/08 12:10 AM
Link This issue has been marked as being related by MDL-13237 [ MDL-13237 ]
Petr Skoda added a comment - 26/Feb/08 12:11 AM
eh, sorry - my fault, the 1.8.4+ and above are affected

Petr Skoda made changes - 26/Feb/08 12:11 AM
Affects Version/s 1.8.5 [ 10252 ]
Affects Version/s 1.8.4 [ 10242 ]
Petr Skoda committed 1 file to 'Moodle CVS' on branch 'MOODLE_19_STABLE' - 26/Feb/08 12:14 AM
MDL-13237, MDL-13661 - fixing rcache regression, sorry :-(
MODIFY lib/dmllib.php   Rev. 1.116.2.21    (+5 -2 lines)
Petr Skoda committed 1 file to 'Moodle CVS' - 26/Feb/08 12:15 AM
MDL-13237, MDL-13661 - fixing rcache regression, sorry :-(; merged from MOODLE_19_STABLE
MODIFY lib/dmllib.php   Rev. 1.138    (+5 -2 lines)
Petr Skoda committed 1 file to 'Moodle CVS' on branch 'MOODLE_18_STABLE' - 26/Feb/08 12:16 AM
MDL-13237, MDL-13661 - fixing rcache regression, sorry :-(; merged from MOODLE_19_STABLE
MODIFY lib/dmllib.php   Rev. 1.91.2.16    (+5 -2 lines)
Petr Skoda committed 1 file to 'Moodle CVS' on branch 'MOODLE_19_STABLE' - 26/Feb/08 05:21 AM
MDL-13661 - fixing incorrect use of array_shift
MODIFY lib/weblib.php   Rev. 1.970.2.63    (+8 -4 lines)
Petr Skoda committed 1 file to 'Moodle CVS' - 26/Feb/08 05:22 AM
MDL-13661 - fixing incorrect use of array_shift; merged from MOODLE_19_STABLE
MODIFY lib/weblib.php   Rev. 1.1038    (+8 -4 lines)
Petr Skoda added a comment - 26/Feb/08 05:24 AM
fixed similar problem is static format_text() cron cache,
big thanks for spotting of this silly bug!!

Petr Skoda made changes - 26/Feb/08 05:24 AM
Status Open [ 1 ] Resolved [ 5 ]
Fix Version/s 1.9 [ 10190 ]
Fix Version/s 1.8.5 [ 10252 ]
Resolution Fixed [ 1 ]
Petr Skoda added a comment - 26/Feb/08 05:25 AM
btw in 1.9 the rcache should not be needed anymore