Uploaded image for project: 'Moodle'
  1. Moodle
  2. MDL-72967

excellibs typo mistake in insert_bitmap for variable $scalex and $scaley

    XMLWordPrintable

Details

    • Bug
    • Status: Closed
    • Major
    • Resolution: Fixed
    • 3.9.10, 3.10.7, 3.11.3, 3.11.4
    • 3.11.5
    • Libraries
    • MOODLE_310_STABLE, MOODLE_311_STABLE, MOODLE_39_STABLE
    • MOODLE_311_STABLE
    • MDL-72967-310
    • MDL-72967-311
    • MDL-72967-master
    • Hide
      1. Download attached test.php and give it permission to execute.
      2. Create a test image touch testimage.jpg and give it permission to write
      3. Go to your browser and execute the test script: http://localhost/stable_master/test.php
      4. Open the dowloaded spreadsheet.
      5. Make sure it displays the test image (small green square)
      6. Make sure you don't see any undefined variable notice:

        Notice: Undefined variable: scale_x in /home/simey/moodles/stable_master/moodle/lib/excellib.class.php on line 428
         
        Notice: Undefined variable: scale_y in /home/simey/moodles/stable_master/moodle/lib/excellib.class.php on line 432
        

      Show
      Download attached test.php and give it permission to execute. Create a test image touch testimage.jpg and give it permission to write Go to your browser and execute the test script: http://localhost/stable_master/test.php Open the dowloaded spreadsheet. Make sure it displays the test image (small green square) Make sure you don't see any undefined variable notice: Notice: Undefined variable: scale_x in /home/simey/moodles/stable_master/moodle/lib/excellib.class.php on line 428   Notice: Undefined variable: scale_y in /home/simey/moodles/stable_master/moodle/lib/excellib.class.php on line 432

    Description

      insert_bitmap function in excellib.php throws warning and due to that the insert_bitmap doesn't adds a bitmap or image file in excel file.

      Steps to reproduce:

      Create a new file say test.php and copy the following code in it.

       

      <?php

      require_once 'config.php';
      require_once($CFG->dirroot.'/lib/excellib.class.php');

      $workbook = new MoodleExcelWorkbook("-");
      $workbook->send('test.xlsx');

      $myxls = $workbook->add_worksheet('Test');

      $image = imagecreate(24, 24);
      $background_color = imagecolorallocate($image, 0, 153, 0);
      imagefill($image, 0, 0, $background_color);
      $bitmap = 'testimage.jpg';
      imagejpeg($image, $bitmap);

      $myxls->insert_bitmap(0, 0, $bitmap);
      $myxls->write_string(5, 0, "Do you see image?");
      $workbook->close();

      unlink('testimage.jpg');

       

      access the file in browser which will download an excel file.

      the file may have errors as the spreadsheet editor such as Microsoft Excel may not open this. (in case debugging is ON to display notices)

      OR there will no image in it.

      I have attached patch for this.

      Attachments

        Activity

          People

            faisalkaleem Faisal Kaleem
            faisalkaleem Faisal Kaleem
            Simey Lameze Simey Lameze
            Ilya Tregubov Ilya Tregubov
            Gladys Basiana Gladys Basiana
            Amaia Anabitarte, Carlos Escobedo, Ferran Recio, Ilya Tregubov, Sara Arjona (@sarjona)
            Votes:
            0 Vote for this issue
            Watchers:
            7 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved:
              17/Jan/22

              Time Tracking

                Estimated:
                Original Estimate - Not Specified
                Not Specified
                Remaining:
                Remaining Estimate - 0 minutes
                0m
                Logged:
                Time Spent - 1 hour, 50 minutes
                1h 50m