Hiya Ciaran
If I add the debug just before the declaration in /totara/core/dialogs/dialog_content_courses.class.php
debug_print_backtrace();
class totara_dialog_content_courses extends totara_dialog_content {
and use
require_once($CFG->dirroot.'/totara/core/dialogs/dialog_content_courses.class.php');
class totara_dialog_content_cohort_rules_courses extends totara_dialog_content_courses {
then refresh the page at /totara/cohort/enrolledlearning.php?id=9 it displays the following at the top of the page
#0 require_once() called at [/var/www/totara/cohort/rules/ui.php:1044]
#1 require_once(/var/www/totara/cohort/rules/ui.php) called at [/var/www/totara/cohort/rules/settings.php:30]
#2 require_once(/var/www/totara/cohort/rules/settings.php) called at [/var/www/totara/cohort/rules/lib.php:32]
#3 require_once(/var/www/totara/cohort/rules/lib.php) called at [/var/www/cohort/lib.php:29]
#4 require_once(/var/www/cohort/lib.php) called at [/var/www/totara/cohort/enrolledlearning.php:31]
Then when I click add courses I get this error in the popup
( ! ) Fatal error: Class 'totara_dialog_content_courses' not found in /var/www/totara/cohort/rules/ui.php on line 1052
Call Stack
# Time Memory Function Location
1 0.0003 247912 {main}( ) ../browselearning.php:0
2 0.1011 17394816 require_once( '/var/www/totara/core/dialogs/dialog_content_courses.class.php' ) ../browselearning.php:26
3 0.1079 18374688 require_once( '/var/www/course/lib.php' ) ../dialog_content_courses.class.php:32
4 0.1096 18678856 require_once( '/var/www/lib/completionlib.php' ) ../lib.php:29
5 0.1112 18964920 require_once( '/var/www/completion/completion_completion.php' ) ../completionlib.php:36
6 0.1137 19463416 require_once( '/var/www/totara/plan/lib.php' ) ../completion_completion.php:50
7 0.1225 21166392 require_once( '/var/www/totara/program/lib.php' ) ../lib.php:33
8 0.1349 23723456 require_once( '/var/www/totara/program/program.class.php' ) ../lib.php:29
9 0.1801 32968400 require_once( '/var/www/totara/cohort/lib.php' ) ../program.class.php:38
10 0.1807 33081904 require_once( '/var/www/cohort/lib.php' ) ../lib.php:30
11 0.1824 33422800 require_once( '/var/www/totara/cohort/rules/lib.php' ) ../lib.php:29
12 0.1830 33572192 require_once( '/var/www/totara/cohort/rules/settings.php' ) ../lib.php:32
13 0.1857 34211336 require_once( '/var/www/totara/cohort/rules/ui.php' ) ../settings.php:30
If I try this
require_once($CFG->dirroot.'/totara/core/dialogs/dialog_content_courses.class.php');
if (!class_exists('totara_dialog_content_courses')) {
require($CFG->dirroot.'/totara/core/dialogs/dialog_content_courses.class.php');
}
class totara_dialog_content_cohort_rules_courses extends totara_dialog_content_courses {
Refreshing the page gives the same trace as the refresh page above but clicking add courses gives me this in the popup
#0 require() called at [/var/www/totara/cohort/rules/ui.php:1049]
#1 require_once(/var/www/totara/cohort/rules/ui.php) called at [/var/www/totara/cohort/rules/settings.php:30]
#2 require_once(/var/www/totara/cohort/rules/settings.php) called at [/var/www/totara/cohort/rules/lib.php:32]
#3 require_once(/var/www/totara/cohort/rules/lib.php) called at [/var/www/cohort/lib.php:29]
#4 require_once(/var/www/cohort/lib.php) called at [/var/www/totara/cohort/lib.php:30]
#5 require_once(/var/www/totara/cohort/lib.php) called at [/var/www/totara/program/program.class.php:38]
#6 require_once(/var/www/totara/program/program.class.php) called at [/var/www/totara/program/lib.php:29]
#7 require_once(/var/www/totara/program/lib.php) called at [/var/www/totara/plan/lib.php:33]
#8 require_once(/var/www/totara/plan/lib.php) called at [/var/www/completion/completion_completion.php:50]
#9 require_once(/var/www/completion/completion_completion.php) called at [/var/www/lib/completionlib.php:36]
#10 require_once(/var/www/lib/completionlib.php) called at [/var/www/course/lib.php:29]
#11 require_once(/var/www/course/lib.php) called at [/var/www/totara/core/dialogs/dialog_content_courses.class.php:32]
#12 require_once(/var/www/totara/core/dialogs/dialog_content_courses.class.php) called at [/var/www/totara/cohort/dialog/browselearning.php:26]
#0 require_once() called at [/var/www/totara/cohort/dialog/browselearning.php:26]
( ! ) Fatal error: Cannot redeclare class totara_dialog_content_courses in /var/www/totara/core/dialogs/dialog_content_courses.class.php on line 43
Call Stack
# Time Memory Function Location
1 0.0003 247912 {main}( ) ../browselearning.php:0
2 0.0997 17394816 require_once( '/var/www/totara/core/dialogs/dialog_content_courses.class.php' ) ../browselearning.php:26
I put the question on stack overflow and one answer was that it could be because of a namespace? But I couldn't see any namespaces being used - http://stackoverflow.com/questions/25571045/require-once-fatal-error-class-not-found
Not sure this is related but I've switched off opcache in php.ini - http://stackoverflow.com/questions/25199912/redeclare-class-condition-info
[opcache]
opcache.enable = 0
Clutching at straws but if I replace require with require_once I get class not found
require_once($CFG->dirroot.'/totara/core/dialogs/dialog_content_courses.class.php');
if (!class_exists('totara_dialog_content_courses')) {
require_once($CFG->dirroot.'/totara/core/dialogs/dialog_content_courses.class.php');
}
class totara_dialog_content_cohort_rules_courses extends totara_dialog_content_courses {
If I try replacing require_once with require I get the cannot redeclare class error
require($CFG->dirroot.'/totara/core/dialogs/dialog_content_courses.class.php');
class totara_dialog_content_cohort_rules_courses extends totara_dialog_content_courses {
I'm baffled...