moosh icon indicating copy to clipboard operation
moosh copied to clipboard

coursecat is now alias to autoloaded class core_course_category

Open nobicycle opened this issue 5 years ago • 4 comments

Thank you very much for moosh - a fantastic tool.

  • moosh version:0.29
  • moodle version:3.6.3
    • database: mysql Ver 15.1 Distrib 10.3.13-MariaDB, for Linux (x86_64) using readline 5.1
  • php version: 7.3.3
  • operating system: Linux tower 4.19.32-1-MANJARO #1 SMP PREEMPT Wed Mar 27 18:55:07 UTC 2019 x86_64 GNU/Linux

When running various commands, there are deprecation warnings.

Example

[me@tower moodle]$ sudo -u http moosh category-export 0 ++ Class coursecat is now alias to autoloaded class core_course_category, course_in_list is an alias to core_course_list_element. Class coursecat_sortable_records is deprecated without replacement. Do not include coursecatlib.php ++

  • line 31 of /lib/coursecatlib.php: call to debugging()
  • line 26 of /opt/moosh/Moosh/Command/Moodle23/Category/CategoryExport.php: call to require_once()
  • line 297 of /opt/moosh/moosh.php: call to Moosh\Command\Moodle23\Category\CategoryExport->execute() ++ Class 'coursecat' has been renamed for the autoloader and is now deprecated. Please use 'core_course_category' instead. ++
  • line 120 of /lib/classes/component.php: call to debugging()
  • line ? of unknownfile: call to core_component::classloader()
  • line 46 of /opt/moosh/Moosh/Command/Moodle23/Category/CategoryExport.php: call to spl_autoload_call()
  • line 30 of /opt/moosh/Moosh/Command/Moodle23/Category/CategoryExport.php: call to Moosh\Command\Moodle23\Category\CategoryExport->get_category_tree()
  • line 297 of /opt/moosh/moosh.php: call to Moosh\Command\Moodle23\Category\CategoryExport->execute()

nobicycle avatar Apr 04 '19 04:04 nobicycle

Another deprecation error is as follows:

$ moosh 
PHP Deprecated:  strpos(): Non-string needles will be interpreted as strings in the future. Use an explicit chr() call to preserve the current behavior in /opt/moosh/moosh.php on line 105


nobicycle avatar Apr 04 '19 12:04 nobicycle

Confirming PHP Deprecated: strpos(): deprecation warning.

martignoni avatar Apr 15 '19 11:04 martignoni

Is someone working on this?

proedie avatar Mar 02 '21 16:03 proedie

Current code (Moosh/Command/Moodle39/Category/CategoryMove.php#44) :

    protected function move_category($category, $destcategory)
    {
        global $CFG;
        require_once $CFG->libdir . '/coursecatlib.php';
        return coursecat::get($category->id)->change_parent($destcategory->id);
    }

Suggestion :

    protected function move_category($category, $destcategory)
    {
        $cattomove = \core_course_category::get($category->id);
        if ($cattomove->can_change_parent($destcategory->id)) {
            return $cattomove->change_parent($destcategory->id);
        }
    }

vguede avatar Apr 15 '21 13:04 vguede