شعار Moodle Upgrade Migration

Moodle Upgrade Migration

المجتمع
SaadRahman01
moodle-upgrade-migration

Use when upgrading a Moodle plugin across versions, fixing deprecated API usage, or migrating to Moodle 4.x/5.x (incl. 5.1/5.2) conventions — print_error, add_to_log, formslib changes, external_api namespace, Hooks API, /public doc-root, Routing Engine, PSR-4 migration, PHP 8.1–8.4 upgrades, and required upgrade.txt notes.

نظرة عامة

الناشرSaadRahman01
المستودعclaude-moodle-dev
اسم المهارةmoodle-upgrade-migration
النجوم
42
التفريعات
7
الملفات المرفقة
تعليمات فقط
الترخيصMIT
الروابط
  • تعليمات بصيغة Markdown

    ملف SKILL.md يُحمّله النموذج عند الحاجة، فلا يستهلك توكنات إلا عندما يَرِد طلب ذو صلة فعلًا.

  • تعمل مع أي نموذج لغوي كبير

    مهارات الذكاء الاصطناعي مكتوبة بصيغة Markdown وليست شيفرة خاصة بمزوّد معيّن، لذا تعمل مع GPT أو Claude أو Gemini أو Grok أو نموذج محلي.

  • مكتفية بذاتها

    كل ما يحتاجه النموذج موجود في التعليمات — لا ملفات إضافية لمزامنتها.

  • مفتوحة المصدر

    نشرها SaadRahman01 على GitHub. اطّلع على المصدر قبل تثبيتها.

التثبيت

ثبّت مهارة الذكاء الاصطناعي Moodle Upgrade Migration في TypingMind لاستخدامها مع أي نموذج لغوي كبير، أو أضفها إلى وكيل ذكاء اصطناعي آخر يقرأ SKILL.md.

1

التثبيت في TypingMind

يُثبّت TypingMind المهارة مباشرةً من مجلدها على GitHub — فيقرأ SKILL.md، ويجمع ملفات الموارد في حزمة، ويحفظ النتيجة محليًا.

  1. افتح التطبيق وانتقل إلى «الإضافات» ثم «المهارات».
  2. اختر «تثبيت من GitHub».
  3. الصق رابط مجلد المهارة الموضّح أدناه وأكّد التثبيت.
    https://github.com/SaadRahman01/claude-moodle-dev/tree/main/skills/moodle-upgrade-migration
  4. فعّل المهارة في كل محادثة تريد إتاحتها فيها.
الإضافات ← المهارات ← إضافة مهارة ← من رابط GitHub، ثم الصق رابط المجلد واضغط على «متابعة».
2

التثبيت في وكيل ذكاء اصطناعي آخر

يمكن لأي وكيل ذكاء اصطناعي يقرأ تنسيق Agent Skills استخدام هذه المهارة — انسخ المجلد إلى مجلد المهارات الخاص بذلك الوكيل.

Claude Code — .claude/skills
git clone --depth 1 https://github.com/SaadRahman01/claude-moodle-dev.git /tmp/claude-moodle-dev
mkdir -p .claude/skills
cp -r /tmp/claude-moodle-dev/skills/moodle-upgrade-migration .claude/skills/moodle-upgrade-migration
أعد تشغيل Claude Code بعد النسخ ليتعرّف على المهارة الجديدة.

استخدمها في TypingMind

فعّل Moodle Upgrade Migration في أي محادثة على TypingMind وسيتولى النموذج الباقي. تتضمن مطالبة النظام اسمها ووصفها، وبمجرد ورود طلب ذي صلة، يُحمّل النموذج التعليمات الكاملة تلقائيًا — فلا تحتاج إلى استدعائها يدويًا، ولا تستهلك أي توكنات حتى تُستخدم فعليًا.

يُحمّل النموذج مهارة Moodle Upgrade Migration تلقائيًا بمجرد ورود طلب ذي صلة بها.

تعمل مع أي نموذج ذكاء اصطناعي

مهارات الذكاء الاصطناعي هي تعليمات بصيغة Markdown وليست شيفرة خاصة بمزوّد معيّن، لذا لا ترتبط Moodle Upgrade Migration بالنموذج الذي كُتبت له. ثبّتها مرة واحدة في TypingMind واستخدمها مع GPT-5 أو Claude أو Gemini أو Grok أو DeepSeek أو Mistral أو Llama أو نموذج محلي تشغّله بنفسك — كل ذلك باستخدام مفاتيح API الخاصة بك.

  • تُحمَّل عند الحاجة فقط

    تتضمن مطالبة النظام الاسم والوصف فقط. وتُجلب التعليمات عند أول طلب ذي صلة، لذا لا تستهلك تعليمات المهارة أي توكنات ما دامت المهارة غير مستخدمة.

  • بدّل النماذج أثناء المحادثة

    لأن المهارة تعليمات وليست شيفرة، فإن تغيير النموذج لا يعطّلها — فالنموذج التالي يقرأ ملف SKILL.md نفسه.

تعليمات المهارة

هذا هو محتوى SKILL.md الذي يُحمّله النموذج. اقرأه قبل التثبيت — فالمهارة عبارة عن تعليمات سيتبعها نموذجك.

Moodle Upgrade & Migration

Overview

Moodle deprecates aggressively but rarely removes. Code from Moodle 2.x often still runs in 4.5 — but uses APIs that emit warnings, fail PHP 8 strict checks, or block plugin directory acceptance. This skill catalogs the migration path from each generation.

When to Use

  • Upgrading a plugin to support a newer Moodle version
  • Resolving deprecation warnings
  • Migrating to PHP 8.1 / 8.2 / 8.3 / 8.4
  • Plugin directory submission rejection ("uses deprecated API")
  • Cross-version compat ($plugin->requires bump)

Strategy

  1. Bump $plugin->requires to your minimum target Moodle version
  2. Replace deprecated APIs (table below)
  3. Add upgrade.txt to document changes
  4. Run phpcs --standard=moodle + visual smoke test
  5. Bump $plugin->version + add db/upgrade.php step if schema changed

Deprecation table

OldNewSince
print_error('errkey', 'comp')throw new \moodle_exception('errkey', 'comp')3.7
add_to_log()Trigger an event class2.7
notify('text', 'notifyproblem')\core\notification::error('text')3.0
redirect($url, 'msg', 0)redirect($url, 'msg', null, \core\notification::INFO)3.0
external_api (bare)\core_external\external_api4.2
external_function_parameters etc.\core_external\...4.2
$mform->setHelpButton()$mform->addHelpButton()2.0
Magic callbacks <comp>_extend_navigationHooks API \core\hook\... (where applicable)4.4
\core\session\manager::write_close()Same — but check if needed—
mtrace() in non-CLIUse debugging() or proper logger—
cleardoubleslashesUse clean_param($url, PARAM_URL)—
addslashes() for DBUse $DB->... placeholders2.0
mysql_* functions$DB always2.0
userdate($t, '', false) (no timezone)Pass timezone or use core_date::get_user_timezone_object()3.2
create_function()Closures function() { }PHP 7.2 removed
each($array)foreachPHP 7.2 removed
assert($string)Real expressionPHP 7.2+
(unset) castPlain unset()PHP 7.2+
\Mustache_Engine direct$OUTPUT->render_from_template—
cm_info::get_modinfo second argAPI change in 3.43.4
format_text no contextAlways pass ['context' => $context]2.0
\html_writer::nonempty_tagUse html_writer::tag with check3.5
\stdClass w/o : \stdClass return type in PHP 8.1+Add return types8.1

PHP version migrations

→ PHP 8.0

  • each(), create_function() removed
  • 'string' . null warns — explicit cast
  • Negative string offset behavior changed
  • Named arguments — Moodle prohibits in public APIs (positional only)

→ PHP 8.1

  • Implicit nullable parameters (string $x = null) deprecated → (?string $x = null)
  • Returning by reference from a void function
  • Internal classes #[\AllowDynamicProperties] if you set undeclared properties
  • tempnam, parse_url minor signature changes

→ PHP 8.2

  • Dynamic properties on user classes deprecated
  • ${...} string interpolation deprecated → {$...}
  • utf8_encode/utf8_decode deprecated

→ PHP 8.3

  • #[\Override] attribute encouraged
  • Date_Create_From_Format strict-ness
  • Typed class constants supported

→ PHP 8.4

  • Implicit nullable params now hard-deprecated: function f(string $x = null) → function f(?string $x = null)
  • Optional param before required param deprecated — reorder so optionals come last
  • E_STRICT constant removed (was already a no-op)
  • trigger_error(..., E_USER_ERROR) deprecated — throw an exception instead
  • CSV functions: fputcsv() / fgetcsv() / str_getcsv() default $escape deprecated — pass '' explicitly to opt out of legacy escape
  • xml_set_*_handler string-callable form deprecated — pass [$obj, 'method'] or first-class callable
  • mysqli_kill(), mysqli_refresh(), mysqli_ping() deprecated — irrelevant to Moodle ($DB layer), but flag in custom code
  • DatePeriod ISO8601 string constructor deprecated → DatePeriod::createFromISO8601String()
  • mb_trim(), mb_ltrim(), mb_rtrim() added — prefer over manual regex trimming for multibyte

Moodle 3.x → 4.x

Theme

  • 3.x default theme Clean removed; use Boost
  • 4.0 introduced course index, secondary navigation, drawers
  • Layouts: frontpage, mydashboard, incourse, course may need overrides

Hooks API (4.4+)

Old:

php
function local_example_extend_navigation(global_navigation $nav) { /* ... */ }

New (where supported):

php
// db/hooks.php
$callbacks = [
    [
        'hook'     => \core\hook\navigation\primary_extend::class,
        'callback' => '\local_example\hooks\navigation::extend_primary',
    ],
];
php
// classes/hooks/navigation.php
namespace local_example\hooks;
class navigation {
    public static function extend_primary(\core\hook\navigation\primary_extend $hook): void {
        $hook->get_primary_view()->add(/* ... */);
    }
}

Magic callbacks still work in 4.4+; Hooks API is preferred for new code, required for some new extension points.

External API namespace

php
// Pre-4.2
class get_items extends external_api { /* ... */ }

// 4.2+
use core_external\external_api;
use core_external\external_function_parameters;
class get_items extends external_api { /* ... */ }

Compatibility shim: 4.2+ aliases bare names to namespaced for back-compat — but new code should use namespaced.

Course format API

format_<name> plugins migrated from format_base to \core_courseformat\base:

php
// classes/output/courseformat/content.php
namespace format_yourname\output\courseformat;
class content extends \core_courseformat\output\local\content { /* ... */ }

3.x format plugins need full rewrite for 4.0+.

Moodle 4.x → 5.x

5.0 (2025-04)

  • PHP 8.2 minimum
  • Bootstrap 5 fully replaces Bootstrap 4 utility classes
    • .sr-only → .visually-hidden
    • .float-left → .float-start
    • .ml-* → .ms-*
    • data-toggle → data-bs-toggle
  • Some 4.x deprecations finalize
  • New AI subsystem (\core_ai)

5.1 (2025-10-06)

  • PHP 8.2 min, 8.3 & 8.4 supported. Sodium ext required. 64-bit only. max_input_vars ≥ 5000.
  • /public document root. Web server must point at <moodleroot>/public. Plugins still live above (/local/..., /mod/...) — installer relocates; manual moves needed for in-place upgrades.
  • Routing Engine (optional, BC-safe) — new request dispatcher + cleaner URLs.
  • Deprecations:
    • file_encode_url() deprecated → use moodle_url::make_pluginfile_url()
    • Device-related theme functions final-deprecated
    • Quiz callback classes/functions deprecated (see mod/quiz/UPGRADING.md)
    • course/changenumsections.php page removed
    • Course "max sections" setting removed
  • DB prefix max length now 10 chars.
  • Always check per-component UPGRADING.md (5.1 replaces upgrade.txt for API change notes).

5.2 (2026-04-20)

  • PHP 8.3 min, 8.4 supported.
  • Upgrade path: must come from 4.4 or later. Older → upgrade through 4.4/5.0/5.1 first.
  • Oracle DB removed. Minimums bumped: PostgreSQL 16, MySQL 8.4, MariaDB 10.11, SQL Server 2019.
  • React in core — base library available via importmaps; new UI code may use React components.
  • Composer support for third-party library installation in plugins.
  • OpenTelemetry integration.
  • Final deprecations:
    • core/modal_factory, core/modal_registry (AMD) — use core/modal directly
    • Pre-PHP 7 style constructors removed (no method named after class)
    • Everything in lib/deprecatedlib.php from ≤ 4.4 removed
  • New/expanded web services: site_info, mobile_config, choice_results.

Always check /public/lib/upgrade.txt (path changed in 5.1) and per-component UPGRADING.md for the target version.

upgrade.txt convention

<plugin>/upgrade.txt:

This files describes API changes in /local/example/*,
information provided here is intended especially for developers.

=== 1.5.0 ===
* The deprecated function local_example_old_thing() has been removed. Use local_example_new_thing() instead.
* New \local_example\hooks\foo class for the navigation hook (Moodle 4.4+).

=== 1.4.0 ===
* New web service local_example_export_csv.

Mirrors Moodle's own lib/upgrade.txt. Plugin directory reviewers read it.

db/upgrade.php cumulative example

php
<?php
defined('MOODLE_INTERNAL') || die();

function xmldb_local_example_upgrade($oldversion) {
    global $DB;
    $dbman = $DB->get_manager();

    if ($oldversion < 2024010100) {
        $table = new xmldb_table('local_example_items');
        $field = new xmldb_field('status', XMLDB_TYPE_INTEGER, '4', null,
            XMLDB_NOTNULL, null, '0', 'name');
        if (!$dbman->field_exists($table, $field)) {
            $dbman->add_field($table, $field);
        }
        upgrade_plugin_savepoint(true, 2024010100, 'local', 'example');
    }

    if ($oldversion < 2024050100) {
        // Drop legacy index
        $table = new xmldb_table('local_example_items');
        $index = new xmldb_index('legacy_idx', XMLDB_INDEX_NOTUNIQUE, ['userid']);
        if ($dbman->index_exists($table, $index)) {
            $dbman->drop_index($table, $index);
        }
        upgrade_plugin_savepoint(true, 2024050100, 'local', 'example');
    }

    if ($oldversion < 2025010100) {
        // Data migration — chunked to avoid memory blow
        $rs = $DB->get_recordset_select('local_example_items', 'metadata IS NULL');
        foreach ($rs as $r) {
            $r->metadata = json_encode([]);
            $DB->update_record('local_example_items', $r);
        }
        $rs->close();
        upgrade_plugin_savepoint(true, 2025010100, 'local', 'example');
    }

    return true;
}

Each if block targets one historical version. Never delete past blocks — sites may upgrade through multiple versions.

Compatibility shim pattern

For plugins supporting multiple Moodle versions:

php
if (class_exists('\core_external\external_api')) {
    class_alias('\core_external\external_api', '\local_example\compat\external_api');
} else {
    class_alias('\external_api', '\local_example\compat\external_api');
}

Or guard with \core\plugin_manager::get_remote_plugin_info and moodle_major_version():

php
if (version_compare(moodle_major_version(), '4.4', '>=')) {
    // Hooks API path
} else {
    // Magic callback fallback
}

Common Mistakes

MistakeFix
Bumping $plugin->requires without testing on min versionTest against $plugin->requires Moodle release
Removing db/upgrade.php blocksKeep all historical blocks
Skipping upgrade_plugin_savepointRequired — marks step as done
Adding new field without field_exists guardUse guard in case site is mid-upgrade
Forgetting upgrade.txtPlugin directory reviewers expect it
Removing deprecated function used by other pluginsMark deprecated for one major, then remove
Using PHP 8.2 features without bumping $plugin->requires MoodleMatch Moodle's PHP min
print_error left after migrationReplace with throw new moodle_exception
external_api namespace mismatch breaking 4.1Use compatibility alias

Tools

bash
# Find deprecated API usage
phpcs --standard=moodle --report=summary local/example
moodle-cs/standards/Moodle/...

# Find PHP version issues
phpcompatinfo analyser:run local/example
phpstan analyse local/example --level=5

References

الأسئلة الشائعة

ماذا تفعل مهارة الذكاء الاصطناعي Moodle Upgrade Migration؟

Use when upgrading a Moodle plugin across versions, fixing deprecated API usage, or migrating to Moodle 4.x/5.x (incl. 5.1/5.2) conventions — print_error, add_to_log, formslib changes, external_api namespace, Hooks API, /public doc-root, Routing Engine, PSR-4 migration, PHP 8.1–8.4 upgrades, and required upgrade.txt notes.

لماذا تستخدم Moodle Upgrade Migration على TypingMind؟

لأنك تثبّتها مرة واحدة وتستخدمها مع أي نموذج. مهارة Moodle Upgrade Migration عبارة عن نص Markdown وليست شيفرة خاصة بمزود بعينه، لذا تعمل المهارة نفسها مع GPT-5 أو Claude أو Gemini أو Grok أو نموذج محلي، ويمكنك تبديل النموذج أثناء المحادثة دون تعطّل المهارة. يعمل TypingMind بمفاتيح API الخاصة بك، فتدفع للمزودين مباشرةً بدلًا من اشتراك لكل مقعد، وتبقى مهاراتك ومحادثاتك في مساحة التخزين الخاصة بك.

كيف أثبّت Moodle Upgrade Migration في TypingMind؟

في TypingMind، افتح «الإضافات»، ثم «المهارات»، ثم اختر «التثبيت من GitHub» والصق https://github.com/SaadRahman01/claude-moodle-dev/tree/main/skills/moodle-upgrade-migration. يقرأ TypingMind ملف SKILL.md الخاص بالمهارة ويثبّتها كمهارة يمكنك تفعيلها لكل محادثة على حدة.

ما نماذج الذكاء الاصطناعي التي يمكنها استخدام Moodle Upgrade Migration؟

أي نموذج تربطه في TypingMind. مهارات الذكاء الاصطناعي عبارة عن تعليمات Markdown وليست شيفرة خاصة بمزود بعينه، لذا يمكن لكل من GPT وClaude وGemini وGrok والنماذج المحلية تحميل هذه المهارة عندما يتوافق الطلب معها.

كم نموذج ذكاء اصطناعي يمكنني استخدامه مع Moodle Upgrade Migration؟

أي عدد تريده. ما دام النموذج يدعم المهارات، يمكنك استخدام Moodle Upgrade Migration معه، سواء كان GPT أو Claude أو Gemini أو Grok أو DeepSeek أو Mistral أو Llama أو غيرها، وكل ذلك على TypingMind باستخدام مفاتيح API الخاصة بك.

هل مهارة الذكاء الاصطناعي Moodle Upgrade Migration مجانية؟

نعم. نشرها SaadRahman01 على GitHub بموجب ترخيص MIT. لا تدفع إلا لمزود الذكاء الاصطناعي الخاص بك مقابل التوكنات التي تستخدمها.

ما هي مهارات الذكاء الاصطناعي؟

مهارة الذكاء الاصطناعي حزمة تعليمات قابلة لإعادة الاستخدام تعلّم نموذج الذكاء الاصطناعي كيفية تنفيذ مهمة محددة. وتتبع تنسيق Agent Skills المفتوح: ملف SKILL.md يتضمن اسمًا ووصفًا، إلى جانب أي نصوص برمجية أو قوالب أو ملفات مرجعية قد يحتاج إليها النموذج. لا يقرأ النموذج التعليمات إلا عندما يتوافق طلبك مع المهارة، لذا لا تترتب على المهارة المثبتة أي تكلفة حتى تُستخدم.

كيف تختلف مهارات الذكاء الاصطناعي عن الإضافات أو موصلات MCP؟

تمنح الإضافة أو موصل MCP النموذج أدوات جديدة يمكنه استدعاؤها، وهي شيفرة تُنفَّذ في مكان ما وتُرجع نتيجة. أما مهارة الذكاء الاصطناعي فتزوّد النموذج بالمعرفة ومنهجية العمل: كيفية التعامل مع مهمة، والخطوات التي ينبغي اتباعها، وما ينبغي أن تكون عليه المخرجات الجيدة. المهارات عبارة عن نصوص Markdown، لذا لا تحتاج إلى خادم أو مفتاح API أو بيئة تشغيل، وتعمل مع أي نموذج.

عرض الكل

أنشئ مساحة عملك للذكاء الاصطناعي الآن

اشترك في نشرتنا الإخبارية لتصلك أخبار الميزات الجديدة والهدايا القادمة 👇