Skip to content

Cast default values to int to prevent null‐default TypeError in closure - #25

Open
ikramagix wants to merge 1 commit into
Vidalia:masterfrom
ikramagix:master
Open

Cast default values to int to prevent null‐default TypeError in closure#25
ikramagix wants to merge 1 commit into
Vidalia:masterfrom
ikramagix:master

Conversation

@ikramagix

Copy link
Copy Markdown

⚠️ Disclaimer: This is NOT A FIX (yet). This is a temporary unblock to let the upgrade or install complete.

This PR provides a workaround for Issue #22, preventing the fatal Argument #3 must be of type int, null given error on Moodle 4.5.1 when upgrading format_cards v1.5.0.

What it does:

  • In course/format/cards/lib.php, every default value passed into the createselect closure is explicitly cast to int (i.e. (int) $defaults->…) with FORMAT_CARDS_USEDEFAULT as the fallback.
  • No other rendering or course‐format logic is modified.

Why it’s only a workaround:

  • It unsticks the upgrade/install by stopping the crash, but subsections will NOT render as cards until a proper upstream fix is applied or you downgrade to a previous plugin version.

Image

  • Administrators can now regain access to the UI and uninstall or revert as needed.

How this PR can help you:

  1. Replace your lib.php with this patched version.
  2. Purge caches (Site Admin → Development → Purge all caches or php admin/cli/purge_caches.php).
  3. Proceed with upgrade, uninstall, or downgrade.

Purpose of this PR:
Provide the updated lib.php content as a base for anyone to restore their Moodle platform and as a starting point for fully fixing Issue #22.

…or) - lib.php

Ensure that each `$defaults->…` lookup in `course_format_options()` is explicitly cast to `int` (falling back to `FORMAT_CARDS_USEDEFAULT`), so the anonymous callback never receives `null` as its third parameter and prevents the TypeError during upgrade.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant