|
List Info
Thread: theme/module name conflict
|
|
| theme/module name conflict |

|
2007-04-25 17:41:18 |
|
Hello all,
I ran into a very awkward bug today. I created a module and a theme for a client, and naturally, this module contained customizations and the theme was a custom made theme. I named the module and the theme with the client';s name. Let's say the client was named abc so I created an abc module and an abc theme. When I implemented the abc_block hook I was surprised to find that all blocks disappeared on all pages. Further investigation into the core and I found that the culprit was the call to theme(';block') which mistakingly called abc_block thinking it was a theme override function (rather than the hook it was).
I was wondering if this issue has been addressed before. I can think of three possible solutions: 1. Make it a standard that no theme and module should be named the same (weak solution) 2. Change all theme(';block') calls to something else so no chance of conflict could occur
3. Change the hook name so that it won't conflict with the theme call 4. Any suggestions???
Either 2 or 3 seem good enough to solve the problem. But I thought I'd gouge some opinions before wasting time on a less-than-optimal patch.
Thanks 
|
| Re: theme/module name conflict |

|
2007-04-25 17:58:48 |
|
On 4/25/07, Ashraf Amayreh < mistknight gmail.com">mistknight gmail.com> wrote:
Hello all,
I ran into a very awkward bug today. I created a module and a theme for a client, and naturally, this module contained customizations and the theme was a custom made theme. I named the module and the theme with the client';s name. Let's say the client was named abc so I created an abc module and an abc theme.
I have done the same in the past. A module called x.module, and a theme called x with a file page.tpl.php. Did not have problems.
I did not use hook_block in that module though.
So, to verify that you are facing an issue, I created the following:
garland.info name = Garland module description = Test gardland module version = "$Name: $"
garland.module
<?php function garland_block($op, $delta = 0) { }
When I implemented the abc_block hook I was surprised to find that all blocks disappeared on all pages.
The blocks disappeared like you found out, when I enabled the above module.
Further investigation into the core and I found that the culprit was the call to theme(';block') which mistakingly called abc_block thinking it was a theme override function (rather than the hook it was).
I was wondering if this issue has been addressed before. I can think of three possible solutions: 1. Make it a standard that no theme and module should be named the same (weak solution) 2. Change all theme(';block') calls to something else so no chance of conflict could occur
3. Change the hook name so that it won't conflict with the theme call 4. Any suggestions???
Either 2 or 3 seem good enough to solve the problem. But I thought I'd gouge some opinions before wasting time on a less-than-optimal patch.
I think 1 can be easiest path. Forbid enabling a module with the same name as an enabled theme and vice versa. So whoever is enabled first wins.
I am not sure what the impact on modules would be if 2 or 3 is done.
--
2bits.com http://2bits.com Drupal development, customization and consulting.
|
| Re: theme/module name conflict |

|
2007-04-25 19:28:15 |
When I setup our automated install scripts at work for
creating new Drupal
projects, I specifically set it up to have a site-specific
module named
<sitename> and a theme named <sitename>theme.
Since the majority of the code
in <sitename>theme/template.php has a phptemplate_
prefix anyway, it's not
really that weird to type.
Option 1 is the current standard, since PHP doesn't offer
true namespacing and
I don't think it's expected to for the foreseeable future.
If writing your
own code, keeping in mind potential permutations of the
things you name is
probably a good idea for that reason.
On Wednesday 25 April 2007 5:41 pm, Ashraf Amayreh wrote:
> Hello all,
>
> I ran into a very awkward bug today. I created a module
and a theme for a
> client, and naturally, this module contained
customizations and the theme
> was a custom made theme. I named the module and the
theme with the client's
> name. Let's say the client was named abc so I created
an abc module and an
> abc theme. When I implemented the abc_block hook I was
surprised to find
> that all blocks disappeared on all pages. Further
investigation into the
> core and I found that the culprit was the call to
theme('block') which
> mistakingly called abc_block thinking it was a theme
override function
> (rather than the hook it was).
>
> I was wondering if this issue has been addressed
before. I can think of
> three possible solutions:
> 1. Make it a standard that no theme and module should
be named the same
> (weak solution)
> 2. Change all theme('block') calls to something else so
no chance of
> conflict could occur
> 3. Change the hook name so that it won't conflict with
the theme call
> 4. Any suggestions???
>
> Either 2 or 3 seem good enough to solve the problem.
But I thought I'd
> gouge some opinions before wasting time on a
less-than-optimal patch.
>
> Thanks
--
Larry Garfield AIM: LOLG42
larry garfieldtech.com ICQ: 6817012
"If nature has made any one thing less susceptible than
all others of
exclusive property, it is the action of the thinking power
called an idea,
which an individual may exclusively possess as long as he
keeps it to
himself; but the moment it is divulged, it forces itself
into the possession
of every one, and the receiver cannot dispossess himself of
it." -- Thomas
Jefferson
|
|
| Re: theme/module name conflict |

|
2007-04-26 03:22:25 |
|
Khaled's solution seems to be the most logical. By enforcing that only one or the other be enabled we can avoid many problems. I can imagine a newbie doing something like that to find himself very confused from the result.
Furthermore, without really diving into the core, there's almost no way to figure out what's going on or to figure out that it has anything to do with a module/theme name conflict. We'd be getting loads of issues that simply can't be duplicated. If no one has any better ideas then I'll try to implement a patch for this. Thanks.
On 4/26/07, Larry Garfield < larry garfieldtech.com">larry garfieldtech.com> wrote:
When I setup our automated install scripts at work for creating new Drupal projects, I specifically set it up to have a site-specific module named <sitename> and a theme named <sitename>theme. Since the majority of the code
in <sitename>theme/template.php has a phptemplate_ prefix anyway, it's not really that weird to type.
Option 1 is the current standard, since PHP doesn't offer true namespacing and I don't think it's expected to for the foreseeable future. If writing your
own code, keeping in mind potential permutations of the things you name is probably a good idea for that reason.
On Wednesday 25 April 2007 5:41 pm, Ashraf Amayreh wrote: > Hello all, > > I ran into a very awkward bug today. I created a module and a theme for a
> client, and naturally, this module contained customizations and the theme > was a custom made theme. I named the module and the theme with the client';s > name. Let's say the client was named abc so I created an abc module and an
> abc theme. When I implemented the abc_block hook I was surprised to find > that all blocks disappeared on all pages. Further investigation into the > core and I found that the culprit was the call to theme(';block') which
> mistakingly called abc_block thinking it was a theme override function > (rather than the hook it was). > > I was wondering if this issue has been addressed before. I can think of > three possible solutions:
> 1. Make it a standard that no theme and module should be named the same > (weak solution) > 2. Change all theme(';block') calls to something else so no chance of > conflict could occur
> 3. Change the hook name so that it won't conflict with the theme call > 4. Any suggestions??? > > Either 2 or 3 seem good enough to solve the problem. But I thought I'd > gouge some opinions before wasting time on a less-than-optimal patch.
> > Thanks 
-- Larry Garfield AIM: LOLG42 larry garfieldtech.com">larry garfieldtech.com ICQ: 6817012
"If nature has made any one thing less susceptible than all others of
exclusive property, it is the action of the thinking power called an idea, which an individual may exclusively possess as long as he keeps it to himself; but the moment it is divulged, it forces itself into the possession
of every one, and the receiver cannot dispossess himself of it." -- Thomas Jefferson
|
| Re: theme/module name conflict |
  Hungary |
2007-04-26 03:58:13 |
Ashraf Amayreh wrote:
> I ran into a very awkward bug today. I created a module
and a theme for
> a client, and naturally, this module contained
customizations and the
> theme was a custom made theme. I named the module and
the theme with the
> client's name. Let's say the client was named abc so I
created an abc
> module and an abc theme. When I implemented the
abc_block hook I was
> surprised to find that all blocks disappeared on all
pages. Further
> investigation into the core and I found that the
culprit was the call to
> theme('block') which mistakingly called abc_block
thinking it was a
> theme override function (rather than the hook it was).
>
> I was wondering if this issue has been addressed
before. I can think of
> three possible solutions:
> 1. Make it a standard that no theme and module should
be named the same
> (weak solution)
> 2. Change all theme('block') calls to something else so
no chance of
> conflict could occur
> 3. Change the hook name so that it won't conflict with
the theme call
> 4. Any suggestions???
>
> Either 2 or 3 seem good enough to solve the problem.
But I thought I'd
> gouge some opinions before wasting time on a
less-than-optimal patch.
I did face the same module name and theme name problem a few
years back
with Drupal (I still prefer PHP based themes with that
.theme extension,
no PHPTemplate themes), so namespace clashing was evident.
The solution
is not to have the same named module and theme.
Gabor
|
|
| Re: theme/module name conflict |

|
2007-04-26 04:19:52 |
|
But enforcing it through code is the way to go. I frankly didn't see it as evident at all. What I saw was that I added hook_block and everything just went haywire without a warning or an error. Really didn't have the slightest idea the theme was involved. After I found that out it was simply intuitive of course.
On 4/26/07, Gabor Hojtsy < gabor hojtsy.hu">gabor hojtsy.hu> wrote:
Ashraf Amayreh wrote: > I ran into a very awkward bug today. I created a module and a theme for > a client, and naturally, this module contained customizations and the > theme was a custom made theme. I named the module and the theme with the
> client';s name. Let's say the client was named abc so I created an abc > module and an abc theme. When I implemented the abc_block hook I was > surprised to find that all blocks disappeared on all pages. Further
> investigation into the core and I found that the culprit was the call to > theme(';block') which mistakingly called abc_block thinking it was a > theme override function (rather than the hook it was).
> > I was wondering if this issue has been addressed before. I can think of > three possible solutions: > 1. Make it a standard that no theme and module should be named the same > (weak solution)
> 2. Change all theme(';block') calls to something else so no chance of > conflict could occur > 3. Change the hook name so that it won't conflict with the theme call > 4. Any suggestions???
> > Either 2 or 3 seem good enough to solve the problem. But I thought I'd > gouge some opinions before wasting time on a less-than-optimal patch.
I did face the same module name and theme name problem a few years back
with Drupal (I still prefer PHP based themes with that .theme extension, no PHPTemplate themes), so namespace clashing was evident. The solution is not to have the same named module and theme. 
Gabor
|
[1-6]
|
|