11/11/09

[development] Doing hook_update_N() when module is installed

I'm doing a module for infrastructure which is all about applying configuration updates, and it does only configuration, nothing else. 

I'd like to create hook_update_N() functions, but I'd also like all of them to be run when the module is installed.

Is there any "correct" way to do this?  Many modules implement the functionality in both hook_install and hook_update_N, and that's fine for database-only issues, which is what these were built around (like schema changes). But it doesnt' really make sense for site config changes.

Obviously, I can run the hook functions from hook_install(), in direct or indirect ways. 

Suggestions?

Thanks,
-Randy

--
Randy Fay
Drupal Development, troubleshooting, and debugging
randy@randyfay.com
+1  970.462.7450

Re: [development] PHP Standards Group

I agree whole heartedly with you on this. 

FYI:  The document appears to have been removed.  I'd be interested in reading it if it ever appears again. 

Dave
On Nov 11, 2009, at 9:19 AM, larry@garfieldtech.com wrote:

It seems to cover fewer things than they used to, but the one it does cover is the one that is least Drupal-friendly; specifically it mandates a direct Java-style mapping from namespace and class name to file name.  I dislike that and find it fundamentally Drupal-incompatible, but we'll see.


Re: [development] PHP Standards Group

+1 to Larry for the reasons already enumerated.

The only thing I have to add that may be of value, is an observation of
the past. The appearance of a standard that does not appear to (a) be in
the best interests of the product, (b) best interests of the user,
and/or (c) make much sense other than a standard for standard's sake, is
a phenomenon that happens from time to time.

It makes every bit of sense in these cases to tread lightly, and not
employ the standards that fall under (a) and (b), perhaps even (c),
especially if (c) looks like it could cause unwanted limitations ongoing.

The warning is I've seen this done with, for example, HP clinging to
HP-UX when Linux was starting to get loaded on servers, IBM with DB2, QB
with XML, and I could go on for a long time. Granted, some examples are
come down to Open or Proprietary, but the rationale for being one
instead of the other was the same (with the addition of (d) Revenue),
and usually came down to a belief that the standard would probably go
nowhere, and wherever it *did* go would be outweighed by (a) and (b).

The result, though, in many cases was that by the time clients started
griping about the solution not meeting a standard, and by the time it
became a problem for the company's marketing that could not be ignored,
they were way behind the curve in terms of meeting the standard,
sometimes with disastrous results (for the original product and people
who had lived it, at least).

So, my advice is to look at whatever standard emerges with two
corrective lenses, one for near-sightedness, and one for far-, but
definitely not with tunnel vision...not that you would :-)

Jeff

Re: [development] PHP Standards Group

I'm going to go out on a limb and say that any framework that anybody would really care about is extensible and will support extensions in different locations. And +1 to the thing about adopting standards wherever feasible.
-----
Cameron Eagans
Owner, Black Storms Studios, LLC
http://www.blackstormsstudios.com


On Wed, Nov 11, 2009 at 12:37 PM, Daniel F. Kudwien <news@unleashedmind.com> wrote:
> "we'll be involved in developing such standards and will
> adopt them wherever feasible, but we do not commit to
> following all standards if they are incompatible with
> Drupal's basic architecture."
>
> --Larry Garfield

+1  Yes, that makes sense.  I think it is what we (sometimes silently) did
anyway.  Some of our standards are self-made (for good reason), but there
are also a couple that were directly derived from example code snippets on
php.net's documentation pages.  In some cases, when there was no consistent
standard on php.net, we even asked them for the proper standard and to fix
their docs.

I'm not quite sure how they can ignore an architecture like Drupal.  I'm not
sure whether I know of a PHP framework/CMS that is NOT extensible and
doesn't support extensions to be placed in various locations, and therefore
wouldn't support this strict filepath based namespacing.

Thanks for staying involved, Crell!

sun


Re: [development] PHP Standards Group

> "we'll be involved in developing such standards and will
> adopt them wherever feasible, but we do not commit to
> following all standards if they are incompatible with
> Drupal's basic architecture."
>
> --Larry Garfield

+1 Yes, that makes sense. I think it is what we (sometimes silently) did
anyway. Some of our standards are self-made (for good reason), but there
are also a couple that were directly derived from example code snippets on
php.net's documentation pages. In some cases, when there was no consistent
standard on php.net, we even asked them for the proper standard and to fix
their docs.

I'm not quite sure how they can ignore an architecture like Drupal. I'm not
sure whether I know of a PHP framework/CMS that is NOT extensible and
doesn't support extensions to be placed in various locations, and therefore
wouldn't support this strict filepath based namespacing.

Thanks for staying involved, Crell!

sun

Re: [development] PHP Standards Group

2009/11/11 Alex Bronstein <alex@craftyspace.com>
+1 for requiring PHP 5.3 for D8 (that's obviously not a community decision yet, just me saying I'd support a GoPHP 5.3 project)

-1 as it kind of involves abandoning a majority of the current user base.

Let's see how the 5.2 thing is handled first - the latest RHEL release is still on 5.1.6 (with maybe patches that may or may not give it enough functionality). If RHEL 6 does not get a move on, there could be many users crying foul on the support forums, and this is with what-I-assume-is-a-special-case ultra extended 2 year development cycle for Drupal 7 instead of the previous 6 to 9 month cycles.

Re: [development] PHP Standards Group

+1 for one or more members of the Drupal community being involved in
developing these standards
+1 for Larry being one of these members
+1 for making a serious effort to adopt the standards that make sense
for Drupal (especially for D8)
+1 for not adopting the standards that don't make sense for Drupal
+1 for requiring PHP 5.3 for D8 (that's obviously not a community
decision yet, just me saying I'd support a GoPHP 5.3 project)
+1 for using real namespaces once PHP 5.3 is a requirement, and
following standards that support interoperability and prevent collision
with other frameworks (it is so presumptuous of us to have global
functions named url(), show(), hide(), etc., and we occasionally run
into problems because of the overloading of underscores and hyphens to
be pseudo-namespace delimiters and word separators).

Thanks so much, Larry. I'm glad you're involved.

larry@garfieldtech.com wrote:
> The current draft is here, I think:
> http://groups.google.com/group/php-standards/web/final-proposal
>
> It seems to cover fewer things than they used to, but the one it does
> cover is the one that is least Drupal-friendly; specifically it
> mandates a direct Java-style mapping from namespace and class name to
> file name. I dislike that and find it fundamentally
> Drupal-incompatible, but we'll see.
>
> As for the level of workload, that depends on what the standards end
> up as and how much of them we decide to adopt. Some of the earlier
> bits (I don't know what's happened to them in the past few months),
> like always naming an interface *Interface, are already part of our
> coding standards because I started doing that for DBTNG, which became
> most of our OO standards. (That was coincidental at first, and later
> on deliberate.) There's already some exception-related changes we'll
> need to make to conform to our own standards, but those should be
> low-impact.
>
> The big impact, I think, will be related to namespaces. We're not
> using those yet, and can't until we require PHP 5.3. The odds of us
> doing that for Drupal 8 are, I think, slim. Hopefully by Drupal 9 we
> can do so, but that will depend on how the PHP market evolves. (I
> wonder if I need to start a GoPHP 5.3 project... <g>) TBD. If we
> know what the standard is going to be, though, we can certainly look
> at moving ourselves in a direction that will be easy to migrate to
> namespaces when we get there. I've been giving that a fair bit of
> thought recently (mostly relating to treating modules as a namespace,
> or sub-namespace), but there's no game plan there yet. If we can use
> the work of this group as a long-term roadmap planning tool, that
> would be great.
>
> Ken Winters: Yep, I'm all over that thread. ;-) ("Crell" is me.)
>
> Brian Vuyk wrote:
>> Larry,
>>
>> Your approach on the matter sounds reasonable.
>>
>> In the abstract, as far as it meshes with the current architecture,
>> we should try to comply in the interests of accessibility and
>> interoperability of our codebase.
>>
>> That said, I have no idea what their standards actually entail. what
>> would we be looking at in terms of code modifications to match up
>> with these new standards? What kind of refactoring and rewriting
>> would this take? Would this be a relatively simple job, or would we
>> be looking at a good portion of the D8 or D9 development cycle to
>> come to compatibility? What kind of workload will this place on the
>> Drupal dev community?
>>
>> Either way, you are a good person to have in that discussion.
>>
>> Brian Vuyk
>> http://www.brianvuyk.com
>>
>>
>> larry@garfieldtech.com wrote:
>>> Back in the spring, a group of PHP developers from several popular
>>> "pure frameworks" got together and started a PHP standards working
>>> group. Their goal was to standardize certain OO coding standards, in
>>> particular the use of namespaces, across PHP projects, even if such
>>> standards necessitated some changes in the participating projects'
>>> existing code bases.
>>>
>>> There was some fallout about the group being self-declared and
>>> trying to establish project standards by fiat, with a number of
>>> people, myself included, objecting to either the fait accomplis
>>> presentation, the details of the proposed standards, or both.
>>> Eventually the core team moved off to an invite-only list, and I
>>> largely lost track of them.
>>>
>>> Yesterday, they decided they should invite in representatives from a
>>> few other frameworks and projects, including Drupal. I discovered
>>> this when I suddenly found myself on the list and getting messages,
>>> as I'd been sitting in the pending membership queue for months. :-)
>>> So apparently I'm now the "Drupal representative". Goodie...
>>>
>>> So before I open my big mouth, to what degree are we interested in
>>> being involved, and to what degree are we willing to play by the
>>> standards this group develops?
>>>
>>> Personally, I think we should try to do so where possible. It's
>>> good for inter-operability, reduces the learning curve for
>>> PHP-knowledgeable developers coming into Drupal, and frankly a lot
>>> of these people have been working with OO PHP a lot longer than we
>>> have so there's much to be learned from them. It also means that we
>>> can begin to shift ourselves in the "right" direction for whenever
>>> we're able to drop PHP 5.2 and rely on PHP 5.3 namespaces, which
>>> will open up all sorts of new and exciting power and weirdness.
>>>
>>> However, I'm not sure that we should commit to following the
>>> developed standards, period. As of the last draft I saw, some of
>>> them would not, I think, even be compatible with a modular
>>> full-stack framework like Drupal to begin with, mostly regarding a
>>> universally-applicable autoload pattern.
>>>
>>> So I would like to go into the process with a statement of "we'll be
>>> involved in developing such standards and will adopt them wherever
>>> feasible, but we do not commit to following all standards if they
>>> are incompatible with Drupal's basic architecture."
>>>
>>> +1, -1, feedback, flames, recriminations, encouragements, death
>>> threats...?
>>>
>>> --Larry Garfield
>>

Re: [development] PHP Standards Group

The current draft is here, I think:
http://groups.google.com/group/php-standards/web/final-proposal

It seems to cover fewer things than they used to, but the one it does
cover is the one that is least Drupal-friendly; specifically it mandates
a direct Java-style mapping from namespace and class name to file name.
I dislike that and find it fundamentally Drupal-incompatible, but
we'll see.

As for the level of workload, that depends on what the standards end up
as and how much of them we decide to adopt. Some of the earlier bits (I
don't know what's happened to them in the past few months), like always
naming an interface *Interface, are already part of our coding standards
because I started doing that for DBTNG, which became most of our OO
standards. (That was coincidental at first, and later on deliberate.)
There's already some exception-related changes we'll need to make to
conform to our own standards, but those should be low-impact.

The big impact, I think, will be related to namespaces. We're not using
those yet, and can't until we require PHP 5.3. The odds of us doing
that for Drupal 8 are, I think, slim. Hopefully by Drupal 9 we can do
so, but that will depend on how the PHP market evolves. (I wonder if I
need to start a GoPHP 5.3 project... <g>) TBD. If we know what the
standard is going to be, though, we can certainly look at moving
ourselves in a direction that will be easy to migrate to namespaces when
we get there. I've been giving that a fair bit of thought recently
(mostly relating to treating modules as a namespace, or sub-namespace),
but there's no game plan there yet. If we can use the work of this
group as a long-term roadmap planning tool, that would be great.

Ken Winters: Yep, I'm all over that thread. ;-) ("Crell" is me.)

Brian Vuyk wrote:
> Larry,
>
> Your approach on the matter sounds reasonable.
>
> In the abstract, as far as it meshes with the current architecture, we
> should try to comply in the interests of accessibility and
> interoperability of our codebase.
>
> That said, I have no idea what their standards actually entail. what
> would we be looking at in terms of code modifications to match up with
> these new standards? What kind of refactoring and rewriting would this
> take? Would this be a relatively simple job, or would we be looking at a
> good portion of the D8 or D9 development cycle to come to compatibility?
> What kind of workload will this place on the Drupal dev community?
>
> Either way, you are a good person to have in that discussion.
>
> Brian Vuyk
> http://www.brianvuyk.com
>
>
> larry@garfieldtech.com wrote:
>> Back in the spring, a group of PHP developers from several popular
>> "pure frameworks" got together and started a PHP standards working
>> group. Their goal was to standardize certain OO coding standards, in
>> particular the use of namespaces, across PHP projects, even if such
>> standards necessitated some changes in the participating projects'
>> existing code bases.
>>
>> There was some fallout about the group being self-declared and trying
>> to establish project standards by fiat, with a number of people,
>> myself included, objecting to either the fait accomplis presentation,
>> the details of the proposed standards, or both. Eventually the core
>> team moved off to an invite-only list, and I largely lost track of them.
>>
>> Yesterday, they decided they should invite in representatives from a
>> few other frameworks and projects, including Drupal. I discovered
>> this when I suddenly found myself on the list and getting messages, as
>> I'd been sitting in the pending membership queue for months. :-) So
>> apparently I'm now the "Drupal representative". Goodie...
>>
>> So before I open my big mouth, to what degree are we interested in
>> being involved, and to what degree are we willing to play by the
>> standards this group develops?
>>
>> Personally, I think we should try to do so where possible. It's good
>> for inter-operability, reduces the learning curve for
>> PHP-knowledgeable developers coming into Drupal, and frankly a lot of
>> these people have been working with OO PHP a lot longer than we have
>> so there's much to be learned from them. It also means that we can
>> begin to shift ourselves in the "right" direction for whenever we're
>> able to drop PHP 5.2 and rely on PHP 5.3 namespaces, which will open
>> up all sorts of new and exciting power and weirdness.
>>
>> However, I'm not sure that we should commit to following the developed
>> standards, period. As of the last draft I saw, some of them would
>> not, I think, even be compatible with a modular full-stack framework
>> like Drupal to begin with, mostly regarding a universally-applicable
>> autoload pattern.
>>
>> So I would like to go into the process with a statement of "we'll be
>> involved in developing such standards and will adopt them wherever
>> feasible, but we do not commit to following all standards if they are
>> incompatible with Drupal's basic architecture."
>>
>> +1, -1, feedback, flames, recriminations, encouragements, death
>> threats...?
>>
>> --Larry Garfield
>

Re: [development] PHP Standards Group

Larry,

Your approach on the matter sounds reasonable.

In the abstract, as far as it meshes with the current architecture, we
should try to comply in the interests of accessibility and
interoperability of our codebase.

That said, I have no idea what their standards actually entail. what
would we be looking at in terms of code modifications to match up with
these new standards? What kind of refactoring and rewriting would this
take? Would this be a relatively simple job, or would we be looking at a
good portion of the D8 or D9 development cycle to come to compatibility?
What kind of workload will this place on the Drupal dev community?

Either way, you are a good person to have in that discussion.

Brian Vuyk
http://www.brianvuyk.com


larry@garfieldtech.com wrote:
> Back in the spring, a group of PHP developers from several popular
> "pure frameworks" got together and started a PHP standards working
> group. Their goal was to standardize certain OO coding standards, in
> particular the use of namespaces, across PHP projects, even if such
> standards necessitated some changes in the participating projects'
> existing code bases.
>
> There was some fallout about the group being self-declared and trying
> to establish project standards by fiat, with a number of people,
> myself included, objecting to either the fait accomplis presentation,
> the details of the proposed standards, or both. Eventually the core
> team moved off to an invite-only list, and I largely lost track of them.
>
> Yesterday, they decided they should invite in representatives from a
> few other frameworks and projects, including Drupal. I discovered
> this when I suddenly found myself on the list and getting messages, as
> I'd been sitting in the pending membership queue for months. :-) So
> apparently I'm now the "Drupal representative". Goodie...
>
> So before I open my big mouth, to what degree are we interested in
> being involved, and to what degree are we willing to play by the
> standards this group develops?
>
> Personally, I think we should try to do so where possible. It's good
> for inter-operability, reduces the learning curve for
> PHP-knowledgeable developers coming into Drupal, and frankly a lot of
> these people have been working with OO PHP a lot longer than we have
> so there's much to be learned from them. It also means that we can
> begin to shift ourselves in the "right" direction for whenever we're
> able to drop PHP 5.2 and rely on PHP 5.3 namespaces, which will open
> up all sorts of new and exciting power and weirdness.
>
> However, I'm not sure that we should commit to following the developed
> standards, period. As of the last draft I saw, some of them would
> not, I think, even be compatible with a modular full-stack framework
> like Drupal to begin with, mostly regarding a universally-applicable
> autoload pattern.
>
> So I would like to go into the process with a statement of "we'll be
> involved in developing such standards and will adopt them wherever
> feasible, but we do not commit to following all standards if they are
> incompatible with Drupal's basic architecture."
>
> +1, -1, feedback, flames, recriminations, encouragements, death
> threats...?
>
> --Larry Garfield

Re: [development] PHP Standards Group

On Nov 11, 2009, at 11:29 AM, larry@garfieldtech.com wrote
>
> So I would like to go into the process with a statement of "we'll be
> involved in developing such standards and will adopt them wherever
> feasible, but we do not commit to following all standards if they
> are incompatible with Drupal's basic architecture."
>

+1 here, sounds like a reasonable approach and adhering to common
standards where possible is a good thing for the reasons you mentioned.

Are there resources online to read up on the status quo of the
conversation?

> +1, -1, feedback, flames, recriminations, encouragements, death
> threats...?
>
> --Larry Garfield

Alex Barth
http://www.developmentseed.org/blog
tel (202) 250-3633

Re: [development] PHP Standards Group

http://drupal.org/node/576248 contains the coding standards changes
suggested for D7 (mostly because of PHP5). Between that and the
handbook coding standards pages you should have all the info you need.

I'd also say that "we'll participate" is about the best we can /
should promise. Well-thought-out standards are good, but as always
they might not apply to Drupal very well.

- Ken Winters

On Nov 11, 2009, at 11:29 AM, larry@garfieldtech.com wrote:

> Back in the spring, a group of PHP developers from several popular
> "pure frameworks" got together and started a PHP standards working
> group. Their goal was to standardize certain OO coding standards, in
> particular the use of namespaces, across PHP projects, even if such
> standards necessitated some changes in the participating projects'
> existing code bases.
>
> There was some fallout about the group being self-declared and
> trying to establish project standards by fiat, with a number of
> people, myself included, objecting to either the fait accomplis
> presentation, the details of the proposed standards, or both.
> Eventually the core team moved off to an invite-only list, and I
> largely lost track of them.
>
> Yesterday, they decided they should invite in representatives from a
> few other frameworks and projects, including Drupal. I discovered
> this when I suddenly found myself on the list and getting messages,
> as I'd been sitting in the pending membership queue for months. :-)
> So apparently I'm now the "Drupal representative". Goodie...
>
> So before I open my big mouth, to what degree are we interested in
> being involved, and to what degree are we willing to play by the
> standards this group develops?
>
> Personally, I think we should try to do so where possible. It's
> good for inter-operability, reduces the learning curve for PHP-
> knowledgeable developers coming into Drupal, and frankly a lot of
> these people have been working with OO PHP a lot longer than we have
> so there's much to be learned from them. It also means that we can
> begin to shift ourselves in the "right" direction for whenever we're
> able to drop PHP 5.2 and rely on PHP 5.3 namespaces, which will open
> up all sorts of new and exciting power and weirdness.
>
> However, I'm not sure that we should commit to following the
> developed standards, period. As of the last draft I saw, some of
> them would not, I think, even be compatible with a modular full-
> stack framework like Drupal to begin with, mostly regarding a
> universally-applicable autoload pattern.
>
> So I would like to go into the process with a statement of "we'll be
> involved in developing such standards and will adopt them wherever
> feasible, but we do not commit to following all standards if they
> are incompatible with Drupal's basic architecture."
>
> +1, -1, feedback, flames, recriminations, encouragements, death
> threats...?
>
> --Larry Garfield

Re: [development] PHP Standards Group

+1 and I would expect that your input would help shape the standards
so that they are compatible with our architecture as well since coding
standards should be pretty agnostic to a programs architecture. Thanks
for taking this on, Larry!

[development] PHP Standards Group

Back in the spring, a group of PHP developers from several popular "pure
frameworks" got together and started a PHP standards working group.
Their goal was to standardize certain OO coding standards, in particular
the use of namespaces, across PHP projects, even if such standards
necessitated some changes in the participating projects' existing code
bases.

There was some fallout about the group being self-declared and trying to
establish project standards by fiat, with a number of people, myself
included, objecting to either the fait accomplis presentation, the
details of the proposed standards, or both. Eventually the core team
moved off to an invite-only list, and I largely lost track of them.

Yesterday, they decided they should invite in representatives from a few
other frameworks and projects, including Drupal. I discovered this when
I suddenly found myself on the list and getting messages, as I'd been
sitting in the pending membership queue for months. :-) So apparently
I'm now the "Drupal representative". Goodie...

So before I open my big mouth, to what degree are we interested in being
involved, and to what degree are we willing to play by the standards
this group develops?

Personally, I think we should try to do so where possible. It's good
for inter-operability, reduces the learning curve for PHP-knowledgeable
developers coming into Drupal, and frankly a lot of these people have
been working with OO PHP a lot longer than we have so there's much to be
learned from them. It also means that we can begin to shift ourselves
in the "right" direction for whenever we're able to drop PHP 5.2 and
rely on PHP 5.3 namespaces, which will open up all sorts of new and
exciting power and weirdness.

However, I'm not sure that we should commit to following the developed
standards, period. As of the last draft I saw, some of them would not,
I think, even be compatible with a modular full-stack framework like
Drupal to begin with, mostly regarding a universally-applicable autoload
pattern.

So I would like to go into the process with a statement of "we'll be
involved in developing such standards and will adopt them wherever
feasible, but we do not commit to following all standards if they are
incompatible with Drupal's basic architecture."

+1, -1, feedback, flames, recriminations, encouragements, death threats...?

--Larry Garfield

11/10/09

Re: [development] Can .htaccess discard part of a path?

Hi Nancy,

Your existing rewrite rules do nothing to match your QUERY_STRING. You need a combination of matching the REQUEST_URI and QUERY_STRING.

I would suggest the following as a starting point *before* the standard drupal rewrite rules.

RewriteCond %{REQUEST_URI} ^/cgi-bin/printOriginal.pl$
RewriteCond %{QUERY_STRING} ^file=(.*)$
RewriteRule ^(.*)$ %1? [R=301,L]

You may need to adjust the RewriteRule line to

RewriteRule ^(.*)$ /PATH/TO/LEGACY/FILESDIR/%1? [R=301,L]

That way if a  user requests:

They should be redirected with a 301 (permanently moved) to:

The key here is that filepath and files are matched via REQUEST_URI, but any parameters passed must be matched via QUERY_STRING. Also, the QUERY_STRING regex may need to be adjusted appropriately based on your incoming requests. (eg. if more than 'file' appears in the parameter list)

I suggest using wget or similar to test your 301's as you write them as it will spit out the 301 if you trigger one, and show you the rewritten URL client side. This is useful for debugging the corresponding regex's.

I didn't test any of the above so I hope that helps get you started,

Jeff

PS. the 'regular' in regular expression is a reference to regular languages: http://en.wikipedia.org/wiki/Regular_language


On Nov 10, 2009, at 11:55 AM, Nancy Wichmann wrote:

Wow, how did you know about MomsTeam (now YouthSportsParents)?
 
I put this in there already    RewriteRule ^cgi-bin/printOriginal.pl/$ http://www.youthsportsparents.com[R=301,L]
And I am still seeing these come through to the Drupal log.
 
There might be a clue in RewriteRule ^alpha/sports/(.*) http://www.youthsportsparents.com/sports/$1[R=301,L] if I really understood regular [sic] expressions.
 
Nancy E. Wichmann, PMP  
Injustice anywhere is a threat to justice everywhere. -- Dr. Martin L. King, Jr.
 
From: development-bounces@drupal.org [mailto:development-bounces@drupal.org] On Behalf Of Seth Freach
Sent: Tuesday, November 10, 2009 11:26 AM
To: development@drupal.org
Subject: Re: [development] Can .htaccess discard part of a path?
 
Nancy,

I'm assuming this is a leftover from the moms team site?  The incoming requests are coming from the fact that Google appears to have lots of these links in its index still to these URLs and sites which still link to these URLs.

Instead of a rewrite, I'd suggest a a response code 301 redirect.  This will be more Google friendly.

look in the default .htaccess file for the (commented out by default) lines that deal with www. redirection (ie, you always want people to see "www" or never do, regardless of how they access the site.)  Using those patterns should help show you how to redirect to the same content but without the "cgi-bin/printOriginal.pl&file=/"

Seth


Nancy Wichmann wrote:
I am getting lots of requests like this:

http://www.example.com/index.php?q=cgi-bin/printOriginal.pl&file=/alpha/beta/gamma/rage_prevention.shtml

The file argument is a valid page on our old site and is itself redirected with a ReWriteRule in .htaccess. However, cgi-bin/printOriginal.pl does not exist and I have no idea what it was supposed to do (well, I can guess print the page). We get lots of these requests for different pages. I have tried a simple rewrite rule and a URL alias to prevent the 404 processing, but neither has fixed it.

Is it possible to design a rewriterule that essentially discards the "cgi-bin/printOriginal.pl" and just serves up the requested page (well, after its own rewrite rule has worked)? So this would become

http://www.example.com/index.php/alpha/beta/gamma/rage_prevention.shtml

 
 
Nancy E. Wichmann, PMP
Injustice anywhere is a threat to justice everywhere. -- Dr. Martin L. King, Jr.
 

No virus found in this incoming message.
Checked by AVG - www.avg.com
Version: 9.0.704 / Virus Database: 270.14.59/2494 - Release Date: 11/10/09 02:38:00


Re: [development] Can .htaccess discard part of a path?

I know this might sound crazy, but you ming consider a custom module that responds to cgi-bin and decides what to do from there.  Or one that responds to cgi-bin/printOriginal.pl.    Then you don't have to work out funky rewrite logic, and you can decide what to do from there. 

I've done some pretty crazy custom modules.... even wrote one once that generated dynamic css :) 
On Nov 10, 2009, at 8:08 AM, Nancy Wichmann wrote:

I am getting lots of requests like this:

http://www.example.com/index.php?q=cgi-bin/printOriginal.pl&file=/alpha/beta/gamma/rage_prevention.shtml

The file argument is a valid page on our old site and is itself redirected with a ReWriteRule in .htaccess. However, cgi-bin/printOriginal.pl does not exist and I have no idea what it was supposed to do (well, I can guess print the page). We get lots of these requests for different pages. I have tried a simple rewrite rule and a URL alias to prevent the 404 processing, but neither has fixed it.

Is it possible to design a rewriterule that essentially discards the "cgi-bin/printOriginal.pl" and just serves up the requested page (well, after its own rewrite rule has worked)? So this would become

http://www.example.com/index.php/alpha/beta/gamma/rage_prevention.shtml

 
 
Nancy E. Wichmann, PMP
Injustice anywhere is a threat to justice everywhere. -- Dr. Martin L. King, Jr.
 

Re: [development] new content type appear in admin/content/types but doesn't appear node/add

This is a common problem. If your node type does not implement hook_form(), it will not show up in the list. This function can return node_content_form($node) if you have nothing to add to the default node form.

On Nov 10, 2009, at 3:01 PM, Matias Carranza wrote:

Hi developers!!

I've created a new content type (drupal 5) and it appears in admin/content/types, but for some reason (that I cant understand) it doesn't appear in node/add list...

And if I go to node/add/[content-type], the result is the same page of node/add, but in the title shows the title of the new content-type instead of  "Create Content"

Well.... I've checked the permissions in Control Access, and these are ok...

Somebody had has this bug some time??

Thanks!!



--
------------------------
Matias Carranza

Re: [development] Help with custom_url_rewrite_outboud(), url(), and l() because external URLs need rewriting too

The limitation of a completely frozen API once a major version is
released causes these kinds of frustrations. I'd like to know what
people think of http://drupal.org/node/535612#comment-2250926. If you
have thoughts about it, please share them on the issue rather than by
email. Thanks.

Dave Reid wrote:
> It is already fixed in Drupal as it lives as hook_url_outbound_alter()
> now, as well as replacing taxonomy_term_path and hook_term_path().
>
> As I explained in the issue that MT posted, the only way to fix this
> in D5 or D6 is to patch common.inc to move the
> custom_url_rewrite_outbound up in the execution of ulr(), before the
> url alias lookups and the return line for external links. However, I
> doubt this change would ever be approved since it's basically an API
> change because of when the function is called. This would be like
> changing hook_nodeapi('update') to be called before a node is updated
> instead of afterwards.
>
> We just probably have to live with the fact that this was a poorly
> implemented feature, and at least look forward to things happening
> correctly now with D7+.
>
> Dave Reid
> dave@davereid.net <mailto:dave@davereid.net>
>
>
> On Mon, Nov 9, 2009 at 4:56 PM, Ken Rickard <agentrickard@gmail.com
> <mailto:agentrickard@gmail.com>> wrote:
>
> I think you may need a patch. We had something similar come up in
> Drupal 5, and obviously missed this use-case when we had the call to
> custom_url_rewrite_outbound() inserted in the url() function.
>
> The D5 version of Domain Access shipped with a functional backport of
> the patch, so best practice suggests fixing this against Drupal 8 (or
> 7 if we can call it an API bug) and then backport the patch to D6.
>
> /me will vote that this is a bug in the API.
>
> - Ken Rickard
> agentrickard
>
>
> On Mon, Nov 9, 2009 at 11:25 PM, Mlen-Too Wesley
> <mlen.too.wesley@gmail.com <mailto:mlen.too.wesley@gmail.com>> wrote:
> > Hello,
> >
> > I am currently developing a module to help libraries rewrite
> links to
> > external databases, such as ProQuest and LexisNexis, routing
> those links
> > through an EZProxy or other proxy referral server.
> >
> > For example, consider a resource located at:
> > http://www.books24x7.com/marc.asp?bookid=30164
> >
> > If accessed from an on-campus IP address, the resource will be
> available to
> > the student. However, if off-campus, the student would either
> have to use
> > VPN to route all their internet traffic through a university IP
> address or
> > use an proxy referral server, such as EZProxy.
> >
> > EZProxy is easier, so from the library home page, the link is
> rewritten to
> > something such as:
> >
> http://ezproxy.example-library.edu/login?url=http://www.books24x7.com/marc.asp?bookid=30164
> >
> > This way, the student is presented with a login screen for
> authentication
> > and then directed to the resource.
> >
> > An easy module to make... or so I thought. Given the
> > custom_url_rewrite_outbound() function, this kind of stuff
> should be easy to
> > do in Drupal, but it is not. The url() function in common.inc
> returns the
> > $path variable without any attempts to call
> custom_url_rewrite_outbout().
> >
> > All would be well, if line 1408 of common.inc added the same
> functionality
> > to external links in the url() function as it does for internal
> links. It
> > just needs 3 lines:
> >
> > if (function_exists('custom_url_rewrite_outbound')) {
> > // Modules may alter outbound links by reference.
> > custom_url_rewrite_outbound($path, $options, $original_path);
> > }
> >
> > Other than applying a patch, does anyone know another way around
> this issue?
> >
> > I am not talking about Apache mod_rewrite or anything similar,
> Clean URLs,
> > or the Path module and URL aliases. I am looking for a way to
> rewrite
> > external URLs in anchor tags (links) without creating a wrapper
> function for
> > url() or l()... or using JavaScript or AJAX.
> >
> > Thanks!
> >
> > MT
> >
> >
> >
> >
> >
> >
>
>
>
> --
> Ken Rickard
> agentrickard@gmail.com <mailto:agentrickard@gmail.com>
> http://ken.therickards.com
>
>

Re: [development] Can .htaccess discard part of a path?

a module based solution is possible too, but I'd point out a couple of
caveats:
- a module to handle this will require a Drupal bootstrap to take
place. Depending on your site load and resources, this may or may not
be negligible, and might not be desirable if it can be avoided. This
might be a non-issue for small or even medium traffic sites...
- drupal_goto will return a 302 http response code by default. Be sure
to specify '301' as the 4th arg to drupal_goto to tell it that this
resource has moved permanently, not temporarily.

Seth

Jamie Holly wrote:
> If there is no real way to figure out the new page from the old string
> then you could redirect it to a generic 404 page, or an internal
> Drupal page (or anything really):
>
> RewriteEngine on
> RewriteBase /
> Rewritecond %{QUERY_STRING} ^q=cgi-bin(.*)$
> RewriteRule .* {put your new URL here - keep the space between the *
> and URL}? [R=301,L]
>
> That would redirect any query that has q=cgi-bin at the beginning to
> the new page (static 404, the front page, etc.).
>
> If there is a way to figure up your own content then a simple module
> would come into play here. Check for $_GET['q'] equaling the cgi-bin
> line and for $_GET['file']. Do it on something like hook_init and then
> have some code figure the post from the $_GET['file'] and do a
> drupal_goto based on the result. If nothing is found then just do a 404.
>
>
> Jamie Holly
> http://www.intoxination.net http://www.hollyit.net
>
>
>
> Jennifer Hodgdon wrote:
>> Nancy Wichmann wrote:
>> > I put this in there already RewriteRule
>> ^cgi-bin/printOriginal.pl/$ http://www.youthsportsparents.com [R=301,L]
>> > And I am still seeing these come through to the Drupal log.
>>
>> You said the URLs that were problems looked like this:
>>
>> http://www.example.com/index.php?q=cgi-bin/printOriginal.pl&file=/alpha/beta/gamma/rage_prevention.shtml
>>
>>
>> The regular expression above ends in $, which is the regexp special
>> character meaning "end of the string/line". So it would only match a
>> URL that ended with "printOriginal.pl/". You need something after
>> that to match the rest of the URL... Something like:
>>
>> ^cgi-bin/printOriginal.pl/.*
>>
>> Might work a bit better... (Caveat: I'm not an expert on Apache
>> .htaccess redirects either.)
>>
>> -- Jennifer
>>
>>

Re: [development] Can .htaccess discard part of a path?

Hi Nancy.

I haven't tested this, but try:

  RewriteCond %{REQUEST_URI} ^/index.php?q=cgi-bin/printOriginal\.pl&file=.*$ [NC]
  RewriteRule ^/index.php?q=cgi-bin/printOriginal\.pl&file=/(.*)$ /$1 [L,R=301]


And see if that can give you a place to start.  The above assumes that clean URLs will translate it to 'index.php?q=' later.  This is so that the 301 redirect (which google will remember) will be to a Clean URL.  If not desired to function like this, you can change the last "/$1" in the above example to: "/index.php?q=$1" .

You can throw some "RewriteCond %{HTTP_HOST}" lines in there too and change those also if you want to preserve the SEO value of links to old domains as well, but that's probably a topic for another list, I'd guess.

Seth

(A google search for "printOriginal.pl" turned up a few momsteam.com links.)

Nancy Wichmann wrote:

Wow, how did you know about MomsTeam (now YouthSportsParents)?

 

I put this in there already    RewriteRule ^cgi-bin/printOriginal.pl/$ http://www.youthsportsparents.com [R=301,L]

And I am still seeing these come through to the Drupal log.

 

There might be a clue in RewriteRule ^alpha/sports/(.*) http://www.youthsportsparents.com/sports/$1 [R=301,L] if I really understood regular [sic] expressions.

 

Nancy E. Wichmann, PMP  

Injustice anywhere is a threat to justice everywhere. -- Dr. Martin L. King, Jr.

 

From: development-bounces@drupal.org [mailto:development-bounces@drupal.org] On Behalf Of Seth Freach
Sent: Tuesday, November 10, 2009 11:26 AM
To: development@drupal.org
Subject: Re: [development] Can .htaccess discard part of a path?

 

Nancy,

I'm assuming this is a leftover from the moms team site?  The incoming requests are coming from the fact that Google appears to have lots of these links in its index still to these URLs and sites which still link to these URLs.

Instead of a rewrite, I'd suggest a a response code 301 redirect.  This will be more Google friendly.

look in the default .htaccess file for the (commented out by default) lines that deal with www. redirection (ie, you always want people to see "www" or never do, regardless of how they access the site.)  Using those patterns should help show you how to redirect to the same content but without the "cgi-bin/printOriginal.pl&file=/"

Seth


Nancy Wichmann wrote:

I am getting lots of requests like this:

http://www.example.com/index.php?q=cgi-bin/printOriginal.pl&file=/alpha/beta/gamma/rage_prevention.shtml

The file argument is a valid page on our old site and is itself redirected with a ReWriteRule in .htaccess. However, cgi-bin/printOriginal.pl does not exist and I have no idea what it was supposed to do (well, I can guess print the page). We get lots of these requests for different pages. I have tried a simple rewrite rule and a URL alias to prevent the 404 processing, but neither has fixed it.

Is it possible to design a rewriterule that essentially discards the "cgi-bin/printOriginal.pl" and just serves up the requested page (well, after its own rewrite rule has worked)? So this would become

http://www.example.com/index.php/alpha/beta/gamma/rage_prevention.shtml

 

 

Nancy E. Wichmann, PMP

Injustice anywhere is a threat to justice everywhere. -- Dr. Martin L. King, Jr.

 

No virus found in this incoming message.
Checked by AVG - www.avg.com
Version: 9.0.704 / Virus Database: 270.14.59/2494 - Release Date: 11/10/09 02:38:00

Re: [development] Can .htaccess discard part of a path?

If there is no real way to figure out the new page from the old string
then you could redirect it to a generic 404 page, or an internal Drupal
page (or anything really):

RewriteEngine on
RewriteBase /
Rewritecond %{QUERY_STRING} ^q=cgi-bin(.*)$
RewriteRule .* {put your new URL here - keep the space between the * and
URL}? [R=301,L]

That would redirect any query that has q=cgi-bin at the beginning to the
new page (static 404, the front page, etc.).

If there is a way to figure up your own content then a simple module
would come into play here. Check for $_GET['q'] equaling the cgi-bin
line and for $_GET['file']. Do it on something like hook_init and then
have some code figure the post from the $_GET['file'] and do a
drupal_goto based on the result. If nothing is found then just do a 404.


Jamie Holly
http://www.intoxination.net
http://www.hollyit.net

Jennifer Hodgdon wrote:
> Nancy Wichmann wrote:
> > I put this in there already
> RewriteRule ^cgi-bin/printOriginal.pl/$
> http://www.youthsportsparents.com [R=301,L]
> > And I am still seeing these come through to the Drupal log.
>
> You said the URLs that were problems looked like this:
>
> http://www.example.com/index.php?q=cgi-bin/printOriginal.pl&file=/alpha/beta/gamma/rage_prevention.shtml
>
> The regular expression above ends in $, which is the regexp special
> character meaning "end of the string/line". So it would only match a
> URL that ended with "printOriginal.pl/". You need something after that
> to match the rest of the URL... Something like:
>
> ^cgi-bin/printOriginal.pl/.*
>
> Might work a bit better... (Caveat: I'm not an expert on Apache
> .htaccess redirects either.)
>
> -- Jennifer
>
>