Moodle
  1. Moodle
  2. MDL-25049

Cannot use excellib.class.php's write_url method - fails with mb_strlen error

    Details

    • Type: Bug Bug
    • Status: Closed
    • Priority: Minor Minor
    • Resolution: Won't Fix
    • Affects Version/s: 1.9.10
    • Fix Version/s: None
    • Component/s: General, Libraries
    • Labels:
      None
    • Environment:
      LAMP, all up to date, Moodle 1.9.10+ (Build: 20101101)
    • Affected Branches:
      MOODLE_19_STABLE
    • Rank:
      6442

      Description

      I am using some copy-and-pasted code (from /mod/survey/download.php) to export an Excel spreadsheet.

      I was previously using the write_string method but changed one instance to write_url which (apparently) takes the same arguments

      When I opened the spreadsheet I received the following error:

      Warning: mb_strlen() expects parameter 1 to be string, object given in /var/www/sdcmoodle/lib/pear/Spreadsheet/Excel/Writer/Worksheet.php on line 1542
      Catchable fatal error: Object of class Spreadsheet_Excel_Writer_Format could not be converted to string in /var/www/sdcmoodle/lib/pear/Spreadsheet/Excel/Writer/Worksheet.php on line 1567

      Looking through the code, write_url (http://xref.moodle.org/nav.html?lib/excellib.class.php.source.html#l172) calls pear_excel_worksheet->writeUrl (http://xref.moodle.org/nav.html?lib/pear/Spreadsheet/Excel/Writer/Worksheet.php.source.html#l1791) with four arguments, wereas it appears it should take 5.

      It may be that the following patch needs to be applied, so at least the correct number of arguments are being passed through (even though the end result is still gibberish):
      @@ -177,11 +177,11 @@ class MoodleExcelWorksheet {

      • @param string $url The url to write
      • @param mixed $format The XF format for the cell
        */
      • function write_url($row, $col, $url, $format=null) {
        + function write_url($row, $col, $url, $string='', $format=null) { /// Calculate the internal PEAR format $format = $this->MoodleExcelFormat2PearExcelFormat($format); /// Add the url safely to the PEAR Worksheet - $this->pear_excel_worksheet->writeUrl($row, $col, $url, $format); + $this->pear_excel_worksheet->writeUrl($row, $col, $url, $string, $format); }

      /**

      This bug directly relates to MDL-13496 and MDL-19864.

        Activity

        Hide
        Paul Vaughan added a comment -

        Here is a the diff of the changes (which appears to include plain-text changes too, for some reason).

        Show
        Paul Vaughan added a comment - Here is a the diff of the changes (which appears to include plain-text changes too, for some reason).
        Hide
        Michael de Raadt added a comment -

        Thanks for reporting this issue.

        We have detected that this issue has been inactive for over a year has been recorded as affecting versions that are no longer supported.

        If you believe that this issue is still relevant to current versions (2.1 and beyond), please comment on the issue. Issues left inactive for a further month will be closed.

        Michael d;

        lqjjLKA0p6

        Show
        Michael de Raadt added a comment - Thanks for reporting this issue. We have detected that this issue has been inactive for over a year has been recorded as affecting versions that are no longer supported. If you believe that this issue is still relevant to current versions (2.1 and beyond), please comment on the issue. Issues left inactive for a further month will be closed. Michael d; lqjjLKA0p6
        Hide
        Michael de Raadt added a comment -

        I'm closing this issue as it appears to have become inactive and is probably not relevant to a current supported version. If you are encountering this problem or one similar, please launch a new issue.

        Show
        Michael de Raadt added a comment - I'm closing this issue as it appears to have become inactive and is probably not relevant to a current supported version. If you are encountering this problem or one similar, please launch a new issue.

          People

          • Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

            Dates

            • Created:
              Updated:
              Resolved: