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

Don't use preg_replace for removing trailing words in strings

    XMLWordPrintable

    Details

    • Type: Task
    • Status: Closed
    • Priority: Minor
    • Resolution: Fixed
    • Affects Version/s: 5.0.0
    • Fix Version/s: 5.0.2
    • Component/s: Optimization
    • Labels:
      None

      Description

      Currently in some places we are using mentioned later code to strip trailing word from string:

      $pos_sql = preg_replace('/(.*) OR $/', '
      1', $pos_sql)

      This is not very efficient and should be replaced with code like this:

      $pos_sql = substr($pos_sql, -2); // "-2" is "(-1) * strlen('OR')"

        Attachments

          Issue Links

            Activity

              People

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

                Dates

                • Created:
                  Updated:
                  Resolved: