CMS MADE SIMPLE FORGE

Menu Manager

 

[#9671] includeprefix checks for substring anywhere in alias instead of at the beginning of the alias

avatar
Created By: Ryan Foster (RytoEX)
Date Submitted: Thu Nov 14 21:37:40 -0500 2013

Assigned To:
Version: None
CMSMS Version: 1.11.8
Severity: Minor
Resolution: None
State: Open
Summary:
includeprefix checks for substring anywhere in alias instead of at the beginning of the alias
Detailed Description:
In CMSMS 1.11.8 and 1.11.9, the includeprefix option doesn't actually match a
true prefix, but instead it matches a substring anywhere in the page aliases. 
In the CMSMS 1.11.9 code, this is found in
/modules/MenuManager/MenuManager.module.php on line 177.  In the CMSMS trunk,
this is found in /modules/MenuManager/MenuManager.module.php on line 128 (as of
this writing).

The line in each is nearly the same, minus spacing of characters:
if( strstr($content->Alias(),$oneprefix) !== FALSE ) {

If we actually want to search for a true prefix, the strstr should either
accompanied by a check of strpos or should be replaced with a substr call, such
as:
if( strstr($content->Alias(),$oneprefix) !== FALSE &&
strpos($content->Alias(),$oneprefix) === 0 ) {


Or maybe this:
if( substr($content->Alias(),0,strlen($oneprefix)) === $oneprefix ) {


Please note, I haven't had a chance to test these code snippets - I've only just
typed them up here as a train of thought.  As an aside, this sort of full
substring/wildcard searching in page aliases for building menus could be useful,
so perhaps we ought to move it to another parameter.


History

Comments
avatar
Date: 2013-11-14 21:38
Posted By: Ryan Foster (RytoEX)

May or may not be related to Bug #9543
(http://dev.cmsmadesimple.org/bug/view/9543).
      
avatar
Date: 2013-11-23 12:26
Posted By: Ryan Foster (RytoEX)

Now that I think about it, there should be no need for the double check I
initially proposed.  The following should suffice, since strpos() will return
boolean false if the needle (string to search for) is not found:

if( strpos($content->Alias(),$oneprefix) === 0 ) {


Again, I haven't tested this code yet, so I'm not 100% sure it's correct, but
I'm fairly confident that it will work.
      
Updates

Updated: 2013-11-14 21:38
resolution_id: => 5