This page is part of the BugReports series. Please go there to submit a new bug or to see the list of all existing reports.


back links to self and older versions

ewiki version R1.02b-rc1
operating system Linux
database backend mysql
php version 4.4.x
bug category aview plugin
status frozen

BobRomeo: The BackLinks show links to the same page and links to older versions of pages. If the links to older versions must be, maybe the can be in Italics or so, to let people know it is a *BackLink to an older version.

DanielD: Hi, I noticed the same annoying behaviour and solved it the quick & dirty way. Maybe someone of the developers can comment on this code snippet:

The original code from ewiki.php (Release 1.02b)

#-- get all pages, that are linking to $id
function ewiki_get_backlinks($id) {
   $result = ewiki_db::SEARCH("refs", $id);
   $pages = array();
   $id_i = EWIKI_CASE_INSENSITIVE ? strtolower($id) : $id;
   while ($row = $result->get(0, 0x0077)) {
      if (strpos(EWIKI_CASE_INSENSITIVE ?strtolower($row["refs"]) :$row["refs"], "\n$id_i\n") !== false) {
         $pages[] = $row["id"];
      }
   }
   return($pages);
}

Replace the line

         $pages[] = $row["id"];

with

         # very inefficient check to include only refs from the current version
         $data = ewiki_db::GET($row["id"]);
         $newest_ver = $data["version"];
         if ($row["version"] == $newest_ver) {
           $pages[] = $row["id"];
         }

so that you end up with

#-- get all pages, that are linking to $id
function ewiki_get_backlinks($id) {
   $result = ewiki_db::SEARCH("refs", $id);
   $pages = array();
   $id_i = EWIKI_CASE_INSENSITIVE ? strtolower($id) : $id;
   while ($row = $result->get(0, 0x0077)) {
      if (strpos(EWIKI_CASE_INSENSITIVE ?strtolower($row["refs"]) :$row["refs"], "\n$id_i\n") !== false) {
         # very inefficient check to include only refs from the current version
         $data = ewiki_db::GET($row["id"]);
         $newest_ver = $data["version"];
         if ($row["version"] == $newest_ver) {
           $pages[] = $row["id"];
         }
      }
   }
   return($pages);
}

That did it for me. This change affects the mpi-plugin and the backlinks-action. Have fun!

bottom corner