Menu

How are URL's stored?

Help
Nap
2020-07-26
2020-07-26
  • Nap

    Nap - 2020-07-26

    [WikiNDX 6.3.7]

    Rather than using attachments to store local copies of the papers I read, I use an Apache Alias within the virtual host that points to my papers folder. I simply point the URL to the paper in that folder.

    Before I migrated, I used to run WikiNDX in a sub-folder of DocumentRoot. During my migration, I decided to change this. So, right now, all my papers have the wrong relative url (because they include the sub-folder name).

    I though this would be easy to fix using find/replace, but it appears the URL is encoded somehow in the WikiNDX resource_text table resourcetextUrls (mediumtext :utf8mb4_unicode_520_ci) field.
    Is there a way I can easily decode the URL and update it? Say using BASH or a bespoke PHP script? Or should I go through each document and edit it manually.

     
    • Stéphane Aulery

      In resourcetextUrls, all urls of a resource are stored as an array of string, serialized and base64 encoded.

      You could query this field with SQL/PHP, decode it, replace, reencode, put in the db.

      To decode:

      function getUrls($field)
      {
          $array = unserialize(base64_decode($field));
          if (!is_array($array)) {
              $array = []; // empty array
          }
      
          return $array;
      }
      

      An exemple of a encoding in flie core/modules/urls/URLS.php, lines 218, function storeUrl(). Can't be used like that, is just an "inspiration".

       

      Last edit: Stéphane Aulery 2020-07-26
      • Nap

        Nap - 2020-07-26

        Thanks Stephane!!

         

Log in to post a comment.