Uploaded image for project: 'Plugins'
  1. Plugins
  2. CONTRIB-3674

Capability to perform base64decode in SQL queries

    XMLWordPrintable

    Details

    • Type: Improvement
    • Status: Open
    • Priority: Minor
    • Resolution: Unresolved
    • Affects Version/s: 2.2.2
    • Fix Version/s: None
    • Labels:
      None
    • Affected Branches:
      MOODLE_22_STABLE

      Description

      Capability to perform the function of the proposed (but as yet not implemented AFAIK) mysql function FROM_BASE64() (http://bugs.mysql.com/bug.php?id=18861) in order to perform a query matching on attributes stored within the base64 encoded record, eg. the configuration of a Moodle block.

      For example,

      SELECT bi.blockname, bi.configdata
      FROM mdl_block_instances AS bi
      WHERE bi.blockname = 'html'
      AND BASE64DECODE(bi.configdata) LIKE '%About this Unit%'

      ...to find the configdata field record in block_instances containing the following base64 encoded string:

      Tzo4OiJzdGRDbGFzcyI6Mzp7czo1OiJ0aXRsZSI7czoxNToiQWJvdXQgdGhpcyBVbml0IjtzOjY6ImZvcm1hdCI7czoxOiIxIjtzOjQ6InRleHQiO3M6MTIxOiI8cD5UaGlzIHVuaXQgZGV2ZWxvcHMgdGhlIGtub3dsZWRnZSByZXF1aXJlZCB0byB1bmRlcnRha2UgZmluYW5jaWFsIG1hbmFnZW1lbnQgd2l0aGluIGEgd29yayB0ZWFtIGluIGFuIG9yZ2FuaXNhdGlvbi48L3A+Ijt9

      ...which base64 decoded contains the string "About this Unit" given as the title of the html block in question in the serialised data
      (effectively replacing within the SQL before execution, BASE64DECODE(bi.configdata), with a base64 decoded copy of the field contents)

        Attachments

          Activity

            People

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

              Dates

              • Created:
                Updated: