Uploaded image for project: 'In-Portal CMS'
  1. In-Portal CMS
  2. INP-1001

Storing function "crc32" results in database problem

    XMLWordPrintable

    Details

    • Additional information:
      Hide

      We have 54 places, where crc32 function is used (across all modules) and each place needs to be inspected.

      How to perform conversion in MySQL:
      -----------------------------------

      ALTER TABLE TableName CHANGE FieldName FieldName BIGINT(11) NOT NULL DEFAULT '0';

      UPDATE TableName
      SET FieldName = CAST((FieldName & 0xFFFFFFFF) AS UNSIGNED INTEGER)
      WHERE FieldName < 0;

      Show
      We have 54 places, where crc32 function is used (across all modules) and each place needs to be inspected. How to perform conversion in MySQL: ----------------------------------- ALTER TABLE TableName CHANGE FieldName FieldName BIGINT(11) NOT NULL DEFAULT '0'; UPDATE TableName SET FieldName = CAST((FieldName & 0xFFFFFFFF) AS UNSIGNED INTEGER) WHERE FieldName < 0;
    • Change Log Message:
      Fixes problems with crc32 function usage on 64bit web servers
    • Story Points:
      1
    • External issue ID:
      1226
    • Copy Issue Key:
    • Patch Instructions:

      Patches must be submitted through Phabricator.

      Description

      When web server OS is 32bit, then results of crc32 functions are positive and negative numbers in range, that fits nicely in "signed int" column in MySQL database.

      However, when web server OS is 64bit, then same crc32 function produces only positive numbers (internally converts negative results to positive, not by removing sign from them) producing number is no longer fits into "signed it" range and will fit only in:

      • unsigned int
      • signed/unsigned bigint

      Since we can't guess what architecture of web server, that will run In-Portal, would be then we need to:
      convert all negative results of crc32 function to positive using $positive_crc = printf('%u', $crc) code
      make all db columns, that can store such numbers either "int unsigned" or "bigint"

      In 5.2.0-B2 this was noticed after tag <inp2:st_ContentBlock name="logos"/> was executed and produced content block number was stored incorrectly resulting inability to save content block changes.

        Attachments

          Issue Links

            Activity

              People

              • Assignee:
                alex Alex
                Reporter:
                alex Alex
                Developer:
                Alex
              • Votes:
                0 Vote for this issue
                Watchers:
                0 Start watching this issue

                Dates

                • Created:
                  Updated:
                  Resolved: