error in moodle Invalid availability structure (->c, ->showc mismatch)

error in moodle Invalid availability structure (->c, ->showc mismatch)

by Daniel Maligat -
Number of replies: 3

Hello, can anyone help me how to fix this error below is more detailed errors when i run the debug. My moodle version is 3.8. thank you

Exception - Cannot access private property cm_info::$uservisible
Debug info:
Error code: generalexceptionmessage
Stack trace:
  • line 742 of /availability/classes/info.php: Error thrown
  • line ? of unknownfile: call to core_availability\info::core_availability\{closure}()
  • line 739 of /availability/classes/info.php: call to preg_replace_callback()
  • line 295 of /availability/classes/info.php: call to core_availability\info::format_info()
  • line 199 of /availability/classes/info.php: call to core_availability\info->warn_about_invalid_availability()
  • line 1892 of /lib/modinfolib.php: call to core_availability\info->is_available()
  • line 1921 of /lib/modinfolib.php: call to cm_info->obtain_dynamic_data()
  • line 1234 of /lib/modinfolib.php: call to cm_info->get_user_visible()
  • line 161 of /calendar/classes/local/event/container.php: call to cm_info->__get()
  • line 118 of /calendar/classes/local/event/factories/event_abstract_factory.php: call to core_calendar\local\event\container::core_calendar\local\event\{closure}()
  • line 357 of /calendar/classes/local/event/data_access/event_vault.php: call to core_calendar\local\event\factories\event_abstract_factory->create_instance()
  • line 172 of /calendar/classes/local/event/data_access/event_vault.php: call to core_calendar\local\event\data_access\event_vault->transform_from_database_record()
  • line 95 of /calendar/classes/local/api.php: call to core_calendar\local\event\data_access\event_vault->get_events()
  • line 3447 of /calendar/lib.php: call to core_calendar\local\api::get_events()
  • line 53 of /blocks/calendar_upcoming/block_calendar_upcoming.php: call to calendar_get_view()
  • line 336 of /blocks/moodleblock.class.php: call to block_calendar_upcoming->get_content()
  • line 230 of /blocks/moodleblock.class.php: call to block_base->formatted_contents()
  • line 1181 of /lib/blocklib.php: call to block_base->get_content_for_output()
  • line 1233 of /lib/blocklib.php: call to block_manager->create_block_contents()
  • line 374 of /lib/blocklib.php: call to block_manager->ensure_content_created()
  • line 3921 of /lib/outputrenderers.php: call to block_manager->region_has_content()
  • line 41 of /theme/eguru/layout/columns2.php: call to core_renderer->blocks()
  • line 1374 of /lib/outputrenderers.php: call to include()
  • line 1304 of /lib/outputrenderers.php: call to core_renderer->render_page_layout()
  • line 244 of /course/view.php: call to core_renderer->header()

Average of ratings: -
In reply to Daniel Maligat

Re: error in moodle Invalid availability structure (->c, ->showc mismatch)

by François Lizotte -
Picture of Particularly helpful Moodlers
Ran into something similar in a course section that has a lot of restrictions

Erreur de programmation détectée. Ceci doit être corrigé par un programmeur : Invalid availability structure (->c, ->showc mismatch)

Plus d'informations sur cette erreur
Info de débogage
Error code: codingerror
Trace de la pile

line 213 of /availability/classes/tree.php: coding_exception thrown
line 144 of /availability/classes/info.php: call to core_availability\tree->__construct()
line 114 of /availability/classes/info.php: call to core_availability\info->decode_availability()
line 248 of /availability/condition/completion/classes/condition.php: call to core_availability\info->get_availability_tree()
line 772 of /availability/classes/info.php: call to availability_completion\condition::completion_value_used()
line 493 of /course/renderer.php: call to core_availability\info::completion_value_used()
line 899 of /course/renderer.php: call to core_course_renderer->course_section_cm_completion()
line 801 of /course/renderer.php: call to core_course_renderer->course_section_cm()
line 993 of /course/renderer.php: call to core_course_renderer->course_section_cm_list_item()
line 316 of /course/format/grid/renderer.php: call to core_course_renderer->course_section_cm_list()
line 247 of /course/format/grid/format.php: call to format_grid_renderer->print_single_section_page()
line 290 of /course/view.php: call to require()
In reply to Daniel Maligat

Re: error in moodle Invalid availability structure (->c, ->showc mismatch)

by Brandon Jimenez -
Try
select id, course, module, instance as inst, section,completion,CASE completion WHEN 0 THEN "not" WHEN 1 THEN "manual" WHEN 2 THEN "auto" END comp,completiongradeitemnumber as item,completionview as view,availability,DATE_FORMAT(FROM_UNIXTIME(`added`), '%e-%b-%Y') AS 'when added' from mdl_course_modules where course = YOUR_COURSE and availability IS NOT NULL or id ORDER BY section asc,id asc;
from there on you should check the availability column, and you can locate the culprit: essentially you'll see that each record has several sections (e.g.):
{
"op":"&",
"showc":[true,false],
"c":[{"type":"date","d":">=","t":1608030000},{"type":"date","d":"<","t":1608041700}]
}
the function in PHP verifies if the arrays showc and c have the same number of elements, and if they don't, you'll see that error.
https://github.com/moodle/moodle/blob/6153be6850869cdc3a6ae925dcf6e688ac481333/availability/classes/tree.php
so locate the culprit and open it in moodle, it depends on the type, and re-save it, and the problem should be solved.

Hope it helps.
Average of ratings: Useful (2)
In reply to Brandon Jimenez

Re: error in moodle Invalid availability structure (->c, ->showc mismatch)

by heli g -
Thank you so much for this amazing query. In my case the first date was missing and once the activity was located, saving resolved it. 
I think there is a small typo in the query, this is what worked for me:
SELECT 
    id,
    course,
    module,
    instance AS inst,
    section,
    completion,
    CASE completion
        WHEN 0 THEN 'not'
        WHEN 1 THEN 'manual'
        WHEN 2 THEN 'auto'
    END comp,
    completiongradeitemnumber AS item,
    completionview AS view,
    availability,
    DATE_FORMAT(FROM_UNIXTIME(`added`), '%e-%b-%Y') AS 'when added'
FROM
    mdl_course_modules
WHERE
    course = YOUR_COURSE
        AND availability IS NOT NULL
ORDER BY section ASC , id ASC;
Average of ratings: Useful (1)