Development

#3616 (sfSimpleCMSPagePeer getAllPagesWithLevel can raise error)

You must first sign up to be able to contribute.

Ticket #3616 (new defect)

Opened 6 months ago

Last modified 1 month ago

sfSimpleCMSPagePeer getAllPagesWithLevel can raise error

Reported by: rickb Assigned to: Kris.Wallsmith
Priority: minor Milestone:
Component: sfSimpleCMSPlugin Version: 1.0.16
Keywords: Cc:
Qualification: Unreviewed

Description

Hi,

I have sfSimpleCMSPlugin v0.7.3b. I was getting PHP errors on line 209 of sfSimpleCMSPagePeer.php due to problems working out parentage of pages I'd inserted using a script (rather than via the GUI). There may be problems with my script, but irrespective of that the sfSimpleCMSPagePeer should be better behaved IMHO.

I propose a simplification like this:

Index: sfSimpleCMSPagePeer.php
===================================================================
--- sfSimpleCMSPagePeer.php	(revision 1897)
+++ sfSimpleCMSPagePeer.php	(working copy)
@@ -191,23 +191,10 @@
     $pages = self::getAllOrderByTree();
     $page_names = array();
     $level = 0;
-    $previous = null;
     foreach ($pages as $page)
     {
-      if ($previous)
-      {
-        if ($page->getParentIdValue() == $previous->getId())
-        {
-          $level++;
+      $page_names[$page->getSlug()] = $page->getSlugWithLevel();
         }
-        elseif ($previous->getRightValue() != $page->getLeftValue() + 1)
-        {
-          $level = $level - $page->getLeftValue() + $previous->getRightValue() + 1;
-        }
-      }
-      $previous = $page;
-      $page_names[$page->getSlug()] = str_repeat($indent_string, $level) . $page->getSlug();
-    }
     return $page_names;
   }

This behaves just like I expect it should. Rick

Change History

10/31/08 19:37:52 changed by Kris.Wallsmith

  • owner changed from francois to Kris.Wallsmith.