Development
Threads by month
- ----- 2026 -----
- July
- June
- May
- April
- March
- February
- January
- ----- 2025 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2024 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2023 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2022 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2021 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2020 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2019 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2018 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2017 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2016 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2015 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2014 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2013 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2012 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2011 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2010 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2009 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2008 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2007 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2006 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2005 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- 9354 discussions
[drupal-devel] [feature] Prevent accidentally navigating away from pages where content has changed
by m3avrck 12 Sep '05
by m3avrck 12 Sep '05
12 Sep '05
Issue status update for
http://drupal.org/node/30220
Post a follow up:
http://drupal.org/project/comments/add/30220
Project: Drupal
Version: cvs
Component: base system
Category: feature requests
Priority: normal
Assigned to: Anonymous
Reported by: m3avrck
Updated by: m3avrck
Status: patch (code needs work)
Attachment: http://drupal.org/files/issues/formcheck.js (1.54 KB)
And here is the JS to throw in misc/.
m3avrck
Previous comments:
------------------------------------------------------------------------
Thu, 01 Sep 2005 22:47:42 +0000 : m3avrck
How many times have you been posting a comment or working on a new post
when you click on a link in another application and you navigate away
from the content you are editing, losing all of your changes?
Well I say we introduce a script, much similiar to that of Blogger,
that uses the Javascript window.onbeforeunload handler to prevent this
from happening. We can set this handler to call a function that
compares the contents of all forms when the page loads and then quickly
compares that to the current contents just before the user is about to
leave the page. If they have changed, we should prompt the user so they
don't lose their work. This would save many headaches and degrade nicely
for users without Javascript.
Additionally, this script should work with the newly introduced
JS-based upload feature to prevent navigating away as a file is being
uploaded as well.
If I have sometime I'll start work on a patch tomorrow, just wanted to
get the idea into the queue right now :)
------------------------------------------------------------------------
Sat, 10 Sep 2005 23:48:33 +0000 : StuartDH
Sounds like a great feature to me. We regularly get authors and editors
telling us that they've lost the last hour of work by accidentally
navigating away, and I've even just had one of them email me about it a
few minutes ago, so it'd be great if you could put something together
for this.
Cheers
------------------------------------------------------------------------
Mon, 12 Sep 2005 14:33:58 +0000 : MichelleC
Sounds great to me, too. I often have several tabs open doing stuff and
it's easy to lose my place and leave a page with unfinished edits.
Would this alert you when you're going to close an unsaved tab/window
as well?
Michelle
------------------------------------------------------------------------
Mon, 12 Sep 2005 14:34:19 +0000 : MrMattles
Great for us multitaskers that rush and click the wrong thing
------------------------------------------------------------------------
Mon, 12 Sep 2005 14:36:52 +0000 : chx
Very strong -1 as this is IE only.
------------------------------------------------------------------------
Mon, 12 Sep 2005 14:38:40 +0000 : praseodymium
Konqueror already does this, +1 for the idea in general.
------------------------------------------------------------------------
Mon, 12 Sep 2005 15:07:21 +0000 : webchick
Yeah, I think chx is correc that onbeforeunload is an extension
developed by MS [1] (it's not in the ECMAScript specification [2].
However, I found out that this is implemented in Mozilla since 1.7 [3]
(which corresponds to Firefox 1.0, I think?) and I've tested
Blogger.com's version of this functionality in:
Firefox 1.0.6 (working)
Firefox Deer Park Alpha 1 (working)
Opera 8.0.2 (working)
Safari 1.3 (does NOT work)
Safari 2.0.1 (working)
So it seems to be a 'de facto' standard if nothing else.
[1]
http://msdn.microsoft.com/workshop/author/dhtml/reference/events/onbeforeun…
[2]
http://www.ecma-international.org/publications/standards/Ecma-262.htm
[3] http://www.mozilla.org/status/2004-03-01.html
------------------------------------------------------------------------
Mon, 12 Sep 2005 15:09:15 +0000 : webchick
Also, I should clarify... that "does NOT work" in Safari doesn't display
any errors or anything, it just doesn't save the form results as
expected (so pre-Tiger Safari users are going to be used to this). So I
don't see any harm in including this functionality since it seems to
degrade gracefully in non-supporting browsers.
------------------------------------------------------------------------
Mon, 12 Sep 2005 21:10:18 +0000 : m3avrck
Attachment: http://drupal.org/files/issues/node.module_11.patch (951 bytes)
And a patch is ready! Code was based on many example, including this [4]
and this [5] along with adding my own thoughts and what not ;)
[4]
http://www.codestore.org/store.nsf/cmnts/451FA051398A9AF486256EE0000FB7D1?O…
[5] http://www.blogger.com/app/scripts/formcheck.js
1
0
[drupal-devel] [feature] Prevent accidentally navigating away from pages where content has changed
by m3avrck 12 Sep '05
by m3avrck 12 Sep '05
12 Sep '05
Issue status update for
http://drupal.org/node/30220
Post a follow up:
http://drupal.org/project/comments/add/30220
Project: Drupal
Version: cvs
Component: base system
Category: feature requests
Priority: normal
Assigned to: Anonymous
Reported by: m3avrck
Updated by: m3avrck
-Status: active
+Status: patch (code needs work)
Attachment: http://drupal.org/files/issues/node.module_11.patch (951 bytes)
And a patch is ready! Code was based on many example, including this [1]
and this [2] along with adding my own thoughts and what not ;)
[1]
http://www.codestore.org/store.nsf/cmnts/451FA051398A9AF486256EE0000FB7D1?O…
[2] http://www.blogger.com/app/scripts/formcheck.js
m3avrck
Previous comments:
------------------------------------------------------------------------
Thu, 01 Sep 2005 22:47:42 +0000 : m3avrck
How many times have you been posting a comment or working on a new post
when you click on a link in another application and you navigate away
from the content you are editing, losing all of your changes?
Well I say we introduce a script, much similiar to that of Blogger,
that uses the Javascript window.onbeforeunload handler to prevent this
from happening. We can set this handler to call a function that
compares the contents of all forms when the page loads and then quickly
compares that to the current contents just before the user is about to
leave the page. If they have changed, we should prompt the user so they
don't lose their work. This would save many headaches and degrade nicely
for users without Javascript.
Additionally, this script should work with the newly introduced
JS-based upload feature to prevent navigating away as a file is being
uploaded as well.
If I have sometime I'll start work on a patch tomorrow, just wanted to
get the idea into the queue right now :)
------------------------------------------------------------------------
Sat, 10 Sep 2005 23:48:33 +0000 : StuartDH
Sounds like a great feature to me. We regularly get authors and editors
telling us that they've lost the last hour of work by accidentally
navigating away, and I've even just had one of them email me about it a
few minutes ago, so it'd be great if you could put something together
for this.
Cheers
------------------------------------------------------------------------
Mon, 12 Sep 2005 14:33:58 +0000 : MichelleC
Sounds great to me, too. I often have several tabs open doing stuff and
it's easy to lose my place and leave a page with unfinished edits.
Would this alert you when you're going to close an unsaved tab/window
as well?
Michelle
------------------------------------------------------------------------
Mon, 12 Sep 2005 14:34:19 +0000 : MrMattles
Great for us multitaskers that rush and click the wrong thing
------------------------------------------------------------------------
Mon, 12 Sep 2005 14:36:52 +0000 : chx
Very strong -1 as this is IE only.
------------------------------------------------------------------------
Mon, 12 Sep 2005 14:38:40 +0000 : praseodymium
Konqueror already does this, +1 for the idea in general.
------------------------------------------------------------------------
Mon, 12 Sep 2005 15:07:21 +0000 : webchick
Yeah, I think chx is correc that onbeforeunload is an extension
developed by MS [3] (it's not in the ECMAScript specification [4].
However, I found out that this is implemented in Mozilla since 1.7 [5]
(which corresponds to Firefox 1.0, I think?) and I've tested
Blogger.com's version of this functionality in:
Firefox 1.0.6 (working)
Firefox Deer Park Alpha 1 (working)
Opera 8.0.2 (working)
Safari 1.3 (does NOT work)
Safari 2.0.1 (working)
So it seems to be a 'de facto' standard if nothing else.
[3]
http://msdn.microsoft.com/workshop/author/dhtml/reference/events/onbeforeun…
[4]
http://www.ecma-international.org/publications/standards/Ecma-262.htm
[5] http://www.mozilla.org/status/2004-03-01.html
------------------------------------------------------------------------
Mon, 12 Sep 2005 15:09:15 +0000 : webchick
Also, I should clarify... that "does NOT work" in Safari doesn't display
any errors or anything, it just doesn't save the form results as
expected (so pre-Tiger Safari users are going to be used to this). So I
don't see any harm in including this functionality since it seems to
degrade gracefully in non-supporting browsers.
1
0
Is anyone actually working on mail.inc and if so, how far along are you?
thanks,
Robert
1
0
12 Sep '05
Issue status update for
http://drupal.org/node/28420
Post a follow up:
http://drupal.org/project/comments/add/28420
Project: Drupal
Version: cvs
Component: comment.module
Category: bug reports
Priority: normal
Assigned to: Jeremy(a)kerneltrap.org
Reported by: Jeremy(a)kerneltrap.org
Updated by: Abalieno
Status: patch (code needs review)
Well, it worked.
No spam at all in more than a day. I don't know if other users are
having problem but this patch broke the tool the spammer was using.
:)
Abalieno
Previous comments:
------------------------------------------------------------------------
Mon, 08 Aug 2005 01:55:34 +0000 : Jeremy(a)kerneltrap.org
Setting "Preview comment" to "Required" does not strictly require that
the comment be previewed first. This is being abused by spammers to
quickly and efficiently post spam comments.
I discovered this after I added a new feature to my new spam module [1]
to auto-blacklist spammer IP addresses, allowing me to block comment
spammers when they preview a comment and thus preventing them from ever
inserting their spam into my database. I configured my comment module
to "require" comment previews, and yet found that the comments were
slipping past my filter. I finally realized what the spammer is doing
is setting $_POST['op'] to 'Post comment', effectively bypassing the
preview phase.
I'm currently looking for a clean solution to this. At the moment the
only idea I have is to generate a token at the preview phase, and
validate the token at the post phase. Unfortunately the token would
have to be stored in the databse between the preview and the post,
which adds overhead.
Alternatively, I've considered using a time-based hash which would
constantly update depending on the time of day. This could easily be
validated without storing anything in the database. If too long has
gone between the preview and the post, an additional preview step would
be required... The down side here is that the time-based hash would be
publically available, and thus the spammer could easily duplicate it in
their script. A private key could solve for that, but increases the
complexity as it adds a configuration step.
I have the feeling I'm missing a simpler, cleaner solution.
Suggestions?
[1] http://kerneltrap.org/jeremy/drupal/spam/
------------------------------------------------------------------------
Mon, 08 Aug 2005 02:26:21 +0000 : moshe weitzman
even if you get this fixed, won't these bots just add a preview step?
this 'preview required' feature is designed to maintain high quality
submissions by forcing users to proof read. it isn;t designed for
security.
i think you want to hook into comment_validate(). just add a hook here
- there is already a hook_comment() waiting for you to add an
operation.
------------------------------------------------------------------------
Mon, 08 Aug 2005 08:49:30 +0000 : Eaton
I posted a patch a few days ago (http://drupal.org/node/28255) that adds
validation and form construction hooks for comments. It's similar to the
one that the captcha module uses, though it adds comment form_pre and
form_post hooks instead of a single comment form hook.
------------------------------------------------------------------------
Mon, 08 Aug 2005 13:30:34 +0000 : Jeremy(a)kerneltrap.org
Attachment: http://drupal.org/files/issues/comment.module_11.patch (2.5 KB)
> even if you get this fixed, won't these bots just add a preview step?
Eventually, yes, but it drastically changes their ability to fling spam
at a site. As is, they simply have a script that shoots data out at
high speed without having to wait for messages to return from the
server. It is the server that is doing all the work, thus making it
simple for a spammer to DoS a site.
If "preview required" really meant "preview required", they would be
forced to first automate clicking "preview", and then wait for a
response before clicking "submit". This requires more resources on
their side, and allows us to add delays after clicking "preview" (if we
detect that they are a spammer) further using their resources.
> this 'preview required' feature is designed to maintain high quality
> submissions by forcing users to proof read. it isn;t designed for
security.
Regardless of the intention, I was misled to believe that configuring
my site to require previews would require that all comments were first
previewed. As a site administrator, I would prefer to know that
"required" really means "required".
> i think you want to hook into comment_validate(). just add a hook
here -
> there is already a hook_comment() waiting for you to add an
operation.
Yes and no. Ultimately yes that will work and will allow my spam
module to prevent the spam from ever being posted. But it still leaves
the greatest burden on the web server, instead of on the spammer. The
spammer can still use a very simple script that only pushes data, and
thus can generate spam at an unbelievable rapid rate.
Here is an example patch to enforce "preview required". It's one idea,
I'm sure there are better ones.
------------------------------------------------------------------------
Mon, 08 Aug 2005 14:01:38 +0000 : Jeremy(a)kerneltrap.org
Attachment: http://drupal.org/files/issues/comment.module_12.patch (1.4 KB)
Here's a second version of the patch that doesn't require any manual
configuration.
------------------------------------------------------------------------
Mon, 08 Aug 2005 16:27:27 +0000 : Jose A Reyero
I like this idea, and the patch looks good
Still, I think it misses something, like some timestamp related hash,
because once you get the hash code you can post multiple comments with
that.
Another problem I can think of is, what happens when a cron run happens
between the preview and the post?? I'm afraid comments would get lost
For this second problem, I think a key generated only once after module
activation could do. About the first one....mmm... I'll sit down for a
while and think.....
------------------------------------------------------------------------
Tue, 09 Aug 2005 12:27:20 +0000 : Jeremy(a)kerneltrap.org
Attachment: http://drupal.org/files/issues/comment.module_13.patch (1.33 KB)
> I think it misses something, like some timestamp related hash, because
> once you get the hash code you can post multiple comments with that.
Using a timestamp will mean that the comment form "expires". That is,
if you wait too long to preview your comment, it will generate an error
when you try to post.
Yes, technically a spammer could post one real comment, then based on
what was in the session from that they could post the same identical
comment over and over, so long as it was attached to the same node.
But this is not what they do, they try and spread their spam throughout
your webpage. Furthermore, the spam module is perfectly capable of
detecting and preventing this.
> Another problem I can think of is, what happens when a cron run
happens
> between the preview and the post?? I'm afraid comments would get lost
The key is only generated once, that's what the first test is about.
In any case, in the unlikely event that the key were to change between
preview and post they would simply have to post a second time.
My earlier patch wasn't quite right, I was testing the token in the
wrong place. This patch fixes that.
BTW: This is beneficial for maintaining high quality submissions too,
as prior to this change someone could:
1) enter a comment
2) press preview
3) completely change their comment (introducing a mistake)
4) press submit and the comment (mistake and all) would go into the
database unpreviewed
After this change:
1) enter a comment
2) press preview
3) completely change their comment (introducing a mistake)
4) press submit and they get an error because they didn't preview
their changes - forcing them to preview once after any change
------------------------------------------------------------------------
Wed, 10 Aug 2005 03:50:33 +0000 : Jeremy(a)kerneltrap.org
FWIW: I've been getting slammed by spam attacks this whole week.
Installing this patch has made a huge difference. Well over 100 spam
attempts per minute (sometimes two and three times that) and I hardly
notice the spammer, whereas before it was choking my database.
(Granted, the spammer has not yet upgraded his script to first preview,
then submit. But even if he did it wouldn't help him as testing has
verified that the new spam module would prevent the comments from ever
getting to the database.)
Additionally, user and anonymous (nonspam) comments continue to show up
at a normal rate.
------------------------------------------------------------------------
Tue, 16 Aug 2005 14:08:04 +0000 : Jeremy(a)kerneltrap.org
I would love to see _any_ discussion on this. Drupal is currently too
easy to spam, with little effort on the spammer's side, and lots of
resources wasted on the Drupal side. A patch like this will greatly
increase the spammer's burden, and make it possible to effectively
block even the most aggressive spammer attacks.
------------------------------------------------------------------------
Wed, 17 Aug 2005 16:24:04 +0000 : Jose A Reyero
Well, this patch is definitely better than what we have, and would save
some spam for sure.
But maybe keeping track, at the session level, of generated hashes for
a user, and then removing them when the comment is sent, could do the
work.
This way we can forget about previewing comments or not, and also the
"permission" to post the comment would expire when the session expires.
Any randomly generated value could do for this, no need for complex
hashes, but having nid and pid in the hash would add some extra
security.
------------------------------------------------------------------------
Wed, 17 Aug 2005 19:58:02 +0000 : breyten
Jeremy, a big +1 on the idea, but why not generate the private key when
it is actually needed (Ie, when displaying the comment form), instead
of wasting a _cron() hook on it?
------------------------------------------------------------------------
Thu, 18 Aug 2005 03:20:02 +0000 : Jeremy(a)kerneltrap.org
> Well, this patch is definitely better than what we have, and would
save some spam for sure.
It is continuing to work very well on my site, which seems to be under
nearly perpetual spam attacks from multiple sources.
> But maybe keeping track, at the session level, of generated hashes
for a user, and then
> removing them when the comment is sent, could do the work.
The catch is: the key has to be something unique to the server, not
guessable or learnable from the outside Simply storing the hash data
in the session alone is not enough, as then the spammer could create
any random data and store it in the session.
That said, the hash could be generated off something other than the
text of the comment as it is now, so that a preview is not required.
I'll look at doing something like that and submit another patch.
> This way we can forget about previewing comments or not, and also the
"permission" to
> post the comment would expire when the session expires. Any randomly
generated value
> could do for this, no need for complex hashes, but having nid and pid
in the hash would
> add some extra security.
nid and pid alone are worthless, as they are easy to learn. The pid
can always be 0 (spam is rarely attached to a pre-existing comment).
The nid is obtained in the path of where the spam is being posted.
The solution is a "private-key", which is what my patch adds. Then
sure, hash the private key plus the nid and the pid, and you've got
enough protection to prevent most spammers. To make it even more
secure, automatic rey-keying could be easily accomplished.
------------------------------------------------------------------------
Thu, 18 Aug 2005 04:09:10 +0000 : Jeremy(a)kerneltrap.org
Attachment: http://drupal.org/files/issues/comment.module_15.patch (1.18 KB)
The attached patch:
1) gets rid of the _cron() hook
2) no longer requires that comments be previewed
Prior to this patch, comment spammers were able to send data to a
Drupal server acting as though they'd filled out a comment form and
pressed submit. As they didn't actually use the form, they could
submit spam comments at an obscene rate.
With this patch, comment spammers will have to actually load the form,
enter text, and press submit. Yes, that can still be automated, but it
takes much more work and slows them down, as they have to wait for the
entry form to load each time.
Unfortunately a spammer could manually submit one comment, then re-use
that same session info over and over to attach repeated spam comments
to the same node. Such an attempt would be detected and blocked by the
spam module if enabled, but again such a session re-use attack could be
done without loading the form each time. Fortunately there is much
less gain for a spammer to submit 100 spam comments on the same page,
versus submitting 100 spam comments each on a different page as they do
now.
Ideas to improve upon this concept include:
- re-key every day or week, changing the private key regularly to be
sure it couldn't ever be permanently cracked
- add a key table, and generate a unique key for every comment form.
essentially, upon comment form creation generate a random key which is
stored both in a database table and in the session. when a comment is
submited, look for the key from the session in the database table, if a
match is found delete it from the database table and post the comment.
this would prevent session re-use, but adds overhead. i don't know if
it's worth it, perhaps as an external module if the hooks were
available.
------------------------------------------------------------------------
Fri, 19 Aug 2005 18:55:11 +0000 : drumm
<?php
form_set_error('error', t('Validation error, please be sure cookies are enabled on your browser.'));
?>
form_set_error [2]()'s fist argument should be the name of a form
field, not 'error.' Using (..., 'error') would be better in this case.
And the actual message needs work. Since this is a hidden field I don't
think it has anything to do with cookies.
[2] http://drupaldocs.org/api/head/function/form_set_error
------------------------------------------------------------------------
Fri, 19 Aug 2005 18:56:41 +0000 : drumm
The unclosed link in my last update was supposed to say
drupal_set_message(..., 'error')
------------------------------------------------------------------------
Sat, 20 Aug 2005 16:00:15 +0000 : Jeremy(a)kerneltrap.org
Attachment: http://drupal.org/files/issues/comment.module_16.patch (1.11 KB)
drupal_set_message(..., 'error') isn't sufficient to prevent the comment
from being posted. I have instead updated the patch to set the error on
the hidden 'token' form field.
I have updated the message to read:
"Unable to validate your comment, please try again. If this error
persists, please contact the site administrator."
If you don't like the error message, better suggestions are welcome.
------------------------------------------------------------------------
Fri, 09 Sep 2005 03:16:06 +0000 : Jeremy(a)kerneltrap.org
Any feedback on this patch? I have been running it on my website for a
couple of weeks, and it has completely stopped the most persistent
auto-spam scripts that had been posting poker type comments constantly
to my site.
------------------------------------------------------------------------
Sat, 10 Sep 2005 18:12:15 +0000 : Zed Pobre
This patch is against HEAD? It doesn't want to apply to my 2.6.3
comment.module.
------------------------------------------------------------------------
Sun, 11 Sep 2005 18:09:08 +0000 : Abalieno
It's is for cvs but I'm trying to manually apply it to 4.6.3.
Will comment later to tell how it went.
1
0
Issue status update for
http://drupal.org/node/10888
Post a follow up:
http://drupal.org/project/comments/add/10888
Project: Drupal
Version: cvs
Component: base system
Category: bug reports
Priority: normal
Assigned to: Bèr Kessels
Reported by: jhriggs
Updated by: jsloan
Status: patch (code needs work)
Attachment: http://drupal.org/files/issues/external_urls_463.patch (4.16 KB)
Here is the patch for 4.6.3;
It contains a rewrite of the url() function and the $external parameter
is added to the l() function. I have tested on Apache2/Linux and
IIS5/WIndws 2000 and with clean url's on Apache2/Linux.
A little later I will submit a patch for menu.inc to enable external
url's.
jsloan
Previous comments:
------------------------------------------------------------------------
Thu, 16 Sep 2004 15:01:24 +0000 : jhriggs
Attachment: http://drupal.org/files/issues/full_url.patch (1.97 KB)
This little patch allows full URLs to be used for the url() and l()
functions, giving modules a single interface for creating links.
Currently, modules must use l() for drupal links and raw HTML for
external links. This patch changes url() to handle -- basically pass
through -- full URLs while still doing the proper handling of internal
paths and works with clean URLs enabled or disabled. It also shortens
(and hopefully simplifies) the url() code a bit.
Some examples of calls that now work:
<?php
l('a link', 'some/path'); // same as before
l('an external link', 'http://drupal.org/');
l('full with query', 'http://google.com/search?q=define:foo');
l('full with separate query', 'http://google.com/search', array(), 'q=define:foo'); // same link as above
l('full with fragment', 'http://drupal.org/node/5942#comment-12374');
l('full with separate fragment', 'http://drupal.org/node/5942', array(), NULL, 'comment-12374'); // same link as above
?>
------------------------------------------------------------------------
Thu, 30 Sep 2004 11:09:30 +0000 : moshe weitzman
+1. less HTML in code is a good thing for readability, if nothing else.
------------------------------------------------------------------------
Mon, 24 Jan 2005 20:06:26 +0000 : mathias
Attachment: http://drupal.org/files/issues/external_urls.patch (838 bytes)
Revisiting this issue one year later shows we're almost there. The only
thing that's left is the ability to handle external urls when
clean_urls is disabled. Once implemented, menu.module can happily
accept external urls and not just Drupal paths, making the menu system
much more attractive to end users.
I'll update the menu.module docs if this patch (or an alternative
solution) is accepted.
------------------------------------------------------------------------
Sun, 13 Mar 2005 22:36:34 +0000 : killes(a)www.drop.org
Attachment: http://drupal.org/files/issues/external_urls_0.patch (909 bytes)
Updated from Drupal root directory.
------------------------------------------------------------------------
Mon, 14 Mar 2005 00:05:17 +0000 : gordon
+1 This is a good thing for people who can't using clean urls.
------------------------------------------------------------------------
Sat, 02 Apr 2005 06:23:10 +0000 : TDobes
This patch seems like a good idea, but does not apply anymore. Also,
shouldn't the comments for l() and url() be updated to indicate that
the functions will work with both internal and external URL's?
------------------------------------------------------------------------
Sat, 02 Apr 2005 07:25:13 +0000 : asimmonds
Attachment: http://drupal.org/files/issues/external_urls_1.patch (897 bytes)
The &'s had been changed to & amp; , here's a valid patch
------------------------------------------------------------------------
Thu, 12 May 2005 14:57:07 +0000 : adrian
This is a new patch against cvs that allows url() to create external
links, with the side-effect that menu can now be used to make external
links.
Also closes http://drupal.org/node/10177
This will be even more important with the primary links menu
integration. (This patch already cleans up a special case in
phptemplate for that).
Killes benchmarked this, and it turns out the difference is negligible.
Requests per second: 1.33 [#/sec] (mean) = with patch
Requests per second: 1.31 [#/sec] (mean) = without patch.
------------------------------------------------------------------------
Thu, 12 May 2005 14:59:57 +0000 : killes(a)www.drop.org
I had benchmarked /node as anon user without cache.
------------------------------------------------------------------------
Wed, 25 May 2005 04:50:08 +0000 : Steven
+1 on the idea of this patch. It allows people to use l() for external
links.
However, I don't like the implementation. Running that complicated
regexp for every url() call is simply wasteful. 95% or more of url()
calls have a fixed string as parameter and point to Drupal's own paths.
I suggest we create an url_external() wrapper around url() which allows
external URLs. Any path which we want to allow external URLs in can use
url_external() instead. The places where we use it will not be many
anyway.
------------------------------------------------------------------------
Wed, 25 May 2005 05:05:55 +0000 : gordon
splitting into url() url_external is not a good idea. The main reason
for this patch that I see is for putting external urls into the
navigation menu using the menu.module, and if all goes to plan, the
primary and secondary menus.
------------------------------------------------------------------------
Wed, 25 May 2005 06:00:01 +0000 : Steven
gordon: I still think this is a bit excessive. Perhaps instead of
valid_url() we could use a simpler regexp !^[a-z]://!i or even
strpos('://').
------------------------------------------------------------------------
Wed, 25 May 2005 06:15:36 +0000 : gordon
I am not says that it is or is not excessive. I was just saying that
this is where it is going to be used, so creating url() and
url_external() is not really an option
------------------------------------------------------------------------
Wed, 25 May 2005 06:57:53 +0000 : Bèr Kessels
we /do/ need an external_url() thing.
The links bundle (handling weblinks and the likes) willprovide this
/and/ need this.
People will get all sorts of tools to do /stuff/ with external links,
like add permissions, track clicks etc. depending on the modules they
have and the settings. All outgoing weblinks, should somehow respect
those. Patches for core are coming, though.
On top of that, a external_l() finction is simple. And if people want
them in primary links they can do the regexping /before/ the function,
not /in/ the function. The calling code can decide whether to call l()
or external_l(), instead of putting logic in l() that is unneded 95% of
the times.
But i hereby promise to introduce such a function tbefore the end of
this week :)
------------------------------------------------------------------------
Wed, 25 May 2005 07:17:47 +0000 : gordon
The only thing I do not see in this plan is how with this work with the
menu module and the navigation menu.
------------------------------------------------------------------------
Wed, 25 May 2005 10:04:12 +0000 : adrian
Attachment: http://drupal.org/files/issues/url_external_links.patch (1.75 KB)
What happened to the patch i uploaded ?
It doesn't use a complex regexp, but uses strpos($url, '://') < 5.
------------------------------------------------------------------------
Thu, 26 May 2005 06:19:32 +0000 : Bèr Kessels
Allthough this works, is clean AND does what it should do, I still am in
favour of a better nitegrated solution. So please do not yet commit
this, untill I upload my patch. We can then discuss what solution to
take. It will not differ a big lot though.
------------------------------------------------------------------------
Thu, 26 May 2005 08:39:32 +0000 : adrian
is this the patch where you want to introduce an el() to allow for
counting of external links ?
That's a different patch altogether. This is primarily about stopping
url() from not handling external links when there is no good reason for
it to do so. Your el() has a very specific use in the weblinks api, and
should probably be included with it.
------------------------------------------------------------------------
Thu, 26 May 2005 16:18:31 +0000 : Bèr Kessels
Yes, that el()
But let me explain why i am anxious for my solution: el(), by default
will not do much, in fact it will just be an URL()-clone but one that
allows outgoing links. But it has a hook-caller. Again: by default it
does nothing much, for there will not be any hooks around in core.
It will allow, for example, weblinks, to track clicks, or to look up a
permission and allow or disallow users to follow a link.
Now, the whole issue, IMO is, that we should *not* provide two ways for
handling external URLS, but rather a single one, that is weblink-safe.
If we would introduce URL() with outgoing links-capabilities, we can no
longer track any outgoing URLs trough them. We will then have two ways
for handling outgoing URLs, resulting in inconsistencies, and confused
users. (hey, my anonymous users can follow link foo, while i have
"follow outgig links" permission disabled for them).
(BTW weblink will soon be renamed into links, just for reference)
------------------------------------------------------------------------
Thu, 30 Jun 2005 11:06:11 +0000 : adrian
Attachment: http://drupal.org/files/issues/url_external_links_0.patch (824 bytes)
I've updated the patch.
------------------------------------------------------------------------
Mon, 18 Jul 2005 14:12:36 +0000 : adrian
spoke to dries about this patch, and apart from the incomplete patch I
uploaded, there are about a dozen instances where in-line html is used
were l() would suffice.
I will be cleaning them up and submitting a new patch soon.
------------------------------------------------------------------------
Fri, 05 Aug 2005 18:44:03 +0000 : moshe weitzman
hopefully adrian or someone else will chase down the remaining urls
which should use this function.
------------------------------------------------------------------------
Fri, 05 Aug 2005 19:25:08 +0000 : jsloan
I've come to this party late but would like to see a patch soon... I've
used the patch from Adrian (#15) but this did not work correctly in my
setup (IIS 5.0 / no clean urls) I applied it against 4.6.2 and cvs.
Where is the latest patch that I can test ... I'll throw some time at
this because I need it for a module used within our Intranet.
------------------------------------------------------------------------
Mon, 08 Aug 2005 20:06:03 +0000 : jsloan
Attachment: http://drupal.org/files/issues/external_urls_2.patch (3.67 KB)
I'm not sure what the final plans are for this in the CVS so I have
developed a patch for use on 4.6.2
I decided to add a parameter named $external that is passed to url()
function. The default is FALSE so this should not break any existing
calls to either l() or url(). I have also refactored url() so that it
is much easier to understand and extend --- I'm thinking of Bèr
Kessels intention to
"allow, for example, weblinks, to track clicks, or to look up a
permission and allow or disallow users to follow a link"
"
Since the parameter is passed to activate the external url there is no
need for regex or strpos, this should be handled by the calling
function and then set the $external parameter to TRUE
For example I have patched the theme_menu_item_link() function in
menu.inc to accept external urls:
<?php
function theme_menu_item_link($item, $link_item) {
// this next line was added so that a menu item could point to the default home
$link_item['path'] = preg_replace('/^\/$/','',$link_item['path']);
// this next line was added so that a menu item could point to an external url
$external = (preg_match('<^[a-z]+://>', $link_item['path'])) ? TRUE : FALSE ;
return l($item['title'], $link_item['path'], array_key_exists('description', $item) ? array('title' => $items['description']) : array(),NULL,NULL,FALSE,FALSE,$external);
}
?>
I hope that this patch will spur some solutions - I'm using this now in
production but have not tested extensively across every scenario.
thanks
jim sloan
------------------------------------------------------------------------
Fri, 19 Aug 2005 12:10:50 +0000 : jsloan
... are there any thoughts on this? What is the status of the final
patch?
------------------------------------------------------------------------
Sun, 28 Aug 2005 15:48:08 +0000 : adrian
The problem with this patch is that we still need to fix all the inline
occurrences of the <a href tag.
I don't think we should confuse the issue and implement a hook at this
point, as url() breaking with external links is a bug, pure and simple.
------------------------------------------------------------------------
Thu, 08 Sep 2005 15:24:16 +0000 : robertDouglass
Attachment: http://drupal.org/files/issues/theme.inc.patch.txt (1.16 KB)
Adrian, your second patch for theme.inc looks wrong to me. Don't you
still need the line
$settings[$type .'_links'][] = l($text, $link, $attributes); ?
I also got rid of unset($attributes); Where was that supposed to come
from that it needed unsetting?
------------------------------------------------------------------------
Thu, 08 Sep 2005 15:48:02 +0000 : robertDouglass
Attachment: http://drupal.org/files/issues/theme.common.inc.patch.txt (1.83 KB)
Here is a unified patch that I updated to fix a bug in Adrian's
common.inc code (everything was being handled as absolute), plus the
update to theme.inc that I questioned in the previous post.
In my initial testing, this works perfectly. I can put absolute URLs in
for the paths in menu items and it handles them fine, and changes no
other behavior. I searched core for all uses of url() and http:// and
found no more violating code such as that in theme.inc.
Net change in core with this patch: 0 lines of code.
Please review quickly, I'm writing in the upcoming book about this
functionality as if it is in. =)
------------------------------------------------------------------------
Thu, 08 Sep 2005 15:49:43 +0000 : robertDouglass
Correction: net change to core -1 line of code.
------------------------------------------------------------------------
Thu, 08 Sep 2005 18:58:01 +0000 : adrian
What needs to be removed from core are not uses of url() and l(), but
all occurences of the anchor tag.
The anchor tag was mostly used because l() didn't do external links.
Also, in the case of phptemplate , that is the line that creates the
array that is passed to the template.
------------------------------------------------------------------------
Thu, 08 Sep 2005 20:58:13 +0000 : robertDouglass
Good - that needs to be removed too, but is there anything that doesn't
work right if we don't remove them? Lots of the $output = '<a href....'
instances in the code use url() for href and these are not broken. They
can't be seen as a reason not to commit this particular patch. If
anyone point out things that break with the patch I made, I'll fix
them. I can't go through and clean up anchor tags on idealistic grounds
at the moment (as much as I would otherwise like to).
------------------------------------------------------------------------
Sat, 10 Sep 2005 20:11:08 +0000 : jsloan
I think that using strpos($path, '://') to trigger the external url is a
bad idea.
My patch implements a new parameter to url() and l() that will let the
calling function decided if it is an external url. And it is backward
compatible with all existing calls.
I also rewrote the logic of builing the url to make it simple.
Adrian, I do not agree that it was a bug; url() never intended to
handle external url´s and also, the clean up of the inline anchor tags
are not dependent on this feature.
Can this be considered for the solution to this feature?
------------------------------------------------------------------------
Sun, 11 Sep 2005 02:14:10 +0000 : jsloan
... the patch I am referring to is above at # 23
------------------------------------------------------------------------
Sun, 11 Sep 2005 07:27:14 +0000 : robertDouglass
"I think that using strpos($path, '://') to trigger the external url is
a bad idea.
"
Please explain why. The only thing that your regexp does that is
different is check to see if the part of the string before the :// is
within the range a-z, and for that you use a more expensive PHP
function. Please indicate the cases where strpos($path, '://') won't
work correctly.
"My patch implements a new parameter to url() and l() that will let the
calling function decided if it is an external url. And it is backward
compatible with all existing calls.
"
This means that instead of doing one check in a centralized place,
programmers now have to write checks anytime they want to call this
function with an either/or case. I don't see why this is better.
"I also rewrote the logic of builing the url to make it simple.
"
This is good.
"Adrian, I do not agree that it was a bug; url() never intended to
handle external url´s and also, the clean up of the inline anchor tags
are not dependent on this feature.
"
I'm still unclear on why anything else in the code base needs to be
changed before this functionality can be accepted. I stick with my
patch as the preferred solution.
------------------------------------------------------------------------
Sun, 11 Sep 2005 14:58:55 +0000 : jsloan
"Please explain why
"
My post #23 has confused you. The patch itself does not add a strpos()
or regexp() ... the code snippet I posted is an example of the calling
function´s responsibility of determining the use of the external link
and then passing that parameter on to the l() or url() function.
I believe it is a bad idea to use string parsing at this low level to
determine functionality because it will impose this behavior on all
calls. There could be a case in which this would be a problem; such as
a url that could contain another url as a parameter.
index.php?q=module¶m=http://example.com
... and there are some who would balk at the processing overhead of
pattern matching at his level.
"This means that instead of doing one check in a centralized place,
programmers now have to write checks anytime they want to call this
function with an either/or case. I don't see why this is better.
"
This is better because the module author is the proper person to
determine whether the link is external. Note that in the case of all
internal links there is no change of coding practice at all. It is
when the module function must handle external links that module´s
author can include the various context and string pattern tests to set
the $external parameter for the l() or url() call. This is what I was
demonstrating in the code example of post #23.
"I'm still unclear on why anything else in the code base needs to be
changed before this functionality can be accepted. I stick with my
patch as the preferred solution.
"
I think that we agree on this point. Nothing needs to be changed in
the code base – my patch is backward compatible to all existing calls
and the clean up work on the in-line anchor tags can (and should) take
place regardless of this patch.
------------------------------------------------------------------------
Sun, 11 Sep 2005 15:04:13 +0000 : robertDouglass
Thanks for the clarification.
1) does your patch still apply well?
2) could you please add the update to the theme menu item to the main
patch so that menu items can be external?
I had forgotten about urls containing urls. That's clearly a
showstopper.
-Robert
------------------------------------------------------------------------
Sun, 11 Sep 2005 15:07:36 +0000 : robertDouglass
You might update the bit in theme.inc as well and include that in the
patch.
------------------------------------------------------------------------
Mon, 12 Sep 2005 19:33:15 +0000 : jsloan
Attachment: http://drupal.org/files/issues/external_urls_cvs.patch (4.24 KB)
Here is the patch for CVS;
It contains a rewrite of the url() function and the $external parameter
is added to the l() function. I have tested on Apache2/Linux and
IIS5/WIndws 2000 and with clean url's on Apache2/Linux.
The patch fails on version 4.6.3 so that will be posted seperate.
A little later I will submit a patch for menu.inc to enable external
url's.
1
0
Issue status update for
http://drupal.org/node/10888
Post a follow up:
http://drupal.org/project/comments/add/10888
Project: Drupal
Version: cvs
Component: base system
Category: bug reports
Priority: normal
Assigned to: Bèr Kessels
Reported by: jhriggs
Updated by: jsloan
Status: patch (code needs work)
Attachment: http://drupal.org/files/issues/external_urls_cvs.patch (4.24 KB)
Here is the patch for CVS;
It contains a rewrite of the url() function and the $external parameter
is added to the l() function. I have tested on Apache2/Linux and
IIS5/WIndws 2000 and with clean url's on Apache2/Linux.
The patch fails on version 4.6.3 so that will be posted seperate.
A little later I will submit a patch for menu.inc to enable external
url's.
jsloan
Previous comments:
------------------------------------------------------------------------
Thu, 16 Sep 2004 15:01:24 +0000 : jhriggs
Attachment: http://drupal.org/files/issues/full_url.patch (1.97 KB)
This little patch allows full URLs to be used for the url() and l()
functions, giving modules a single interface for creating links.
Currently, modules must use l() for drupal links and raw HTML for
external links. This patch changes url() to handle -- basically pass
through -- full URLs while still doing the proper handling of internal
paths and works with clean URLs enabled or disabled. It also shortens
(and hopefully simplifies) the url() code a bit.
Some examples of calls that now work:
<?php
l('a link', 'some/path'); // same as before
l('an external link', 'http://drupal.org/');
l('full with query', 'http://google.com/search?q=define:foo');
l('full with separate query', 'http://google.com/search', array(), 'q=define:foo'); // same link as above
l('full with fragment', 'http://drupal.org/node/5942#comment-12374');
l('full with separate fragment', 'http://drupal.org/node/5942', array(), NULL, 'comment-12374'); // same link as above
?>
------------------------------------------------------------------------
Thu, 30 Sep 2004 11:09:30 +0000 : moshe weitzman
+1. less HTML in code is a good thing for readability, if nothing else.
------------------------------------------------------------------------
Mon, 24 Jan 2005 20:06:26 +0000 : mathias
Attachment: http://drupal.org/files/issues/external_urls.patch (838 bytes)
Revisiting this issue one year later shows we're almost there. The only
thing that's left is the ability to handle external urls when
clean_urls is disabled. Once implemented, menu.module can happily
accept external urls and not just Drupal paths, making the menu system
much more attractive to end users.
I'll update the menu.module docs if this patch (or an alternative
solution) is accepted.
------------------------------------------------------------------------
Sun, 13 Mar 2005 22:36:34 +0000 : killes(a)www.drop.org
Attachment: http://drupal.org/files/issues/external_urls_0.patch (909 bytes)
Updated from Drupal root directory.
------------------------------------------------------------------------
Mon, 14 Mar 2005 00:05:17 +0000 : gordon
+1 This is a good thing for people who can't using clean urls.
------------------------------------------------------------------------
Sat, 02 Apr 2005 06:23:10 +0000 : TDobes
This patch seems like a good idea, but does not apply anymore. Also,
shouldn't the comments for l() and url() be updated to indicate that
the functions will work with both internal and external URL's?
------------------------------------------------------------------------
Sat, 02 Apr 2005 07:25:13 +0000 : asimmonds
Attachment: http://drupal.org/files/issues/external_urls_1.patch (897 bytes)
The &'s had been changed to & amp; , here's a valid patch
------------------------------------------------------------------------
Thu, 12 May 2005 14:57:07 +0000 : adrian
This is a new patch against cvs that allows url() to create external
links, with the side-effect that menu can now be used to make external
links.
Also closes http://drupal.org/node/10177
This will be even more important with the primary links menu
integration. (This patch already cleans up a special case in
phptemplate for that).
Killes benchmarked this, and it turns out the difference is negligible.
Requests per second: 1.33 [#/sec] (mean) = with patch
Requests per second: 1.31 [#/sec] (mean) = without patch.
------------------------------------------------------------------------
Thu, 12 May 2005 14:59:57 +0000 : killes(a)www.drop.org
I had benchmarked /node as anon user without cache.
------------------------------------------------------------------------
Wed, 25 May 2005 04:50:08 +0000 : Steven
+1 on the idea of this patch. It allows people to use l() for external
links.
However, I don't like the implementation. Running that complicated
regexp for every url() call is simply wasteful. 95% or more of url()
calls have a fixed string as parameter and point to Drupal's own paths.
I suggest we create an url_external() wrapper around url() which allows
external URLs. Any path which we want to allow external URLs in can use
url_external() instead. The places where we use it will not be many
anyway.
------------------------------------------------------------------------
Wed, 25 May 2005 05:05:55 +0000 : gordon
splitting into url() url_external is not a good idea. The main reason
for this patch that I see is for putting external urls into the
navigation menu using the menu.module, and if all goes to plan, the
primary and secondary menus.
------------------------------------------------------------------------
Wed, 25 May 2005 06:00:01 +0000 : Steven
gordon: I still think this is a bit excessive. Perhaps instead of
valid_url() we could use a simpler regexp !^[a-z]://!i or even
strpos('://').
------------------------------------------------------------------------
Wed, 25 May 2005 06:15:36 +0000 : gordon
I am not says that it is or is not excessive. I was just saying that
this is where it is going to be used, so creating url() and
url_external() is not really an option
------------------------------------------------------------------------
Wed, 25 May 2005 06:57:53 +0000 : Bèr Kessels
we /do/ need an external_url() thing.
The links bundle (handling weblinks and the likes) willprovide this
/and/ need this.
People will get all sorts of tools to do /stuff/ with external links,
like add permissions, track clicks etc. depending on the modules they
have and the settings. All outgoing weblinks, should somehow respect
those. Patches for core are coming, though.
On top of that, a external_l() finction is simple. And if people want
them in primary links they can do the regexping /before/ the function,
not /in/ the function. The calling code can decide whether to call l()
or external_l(), instead of putting logic in l() that is unneded 95% of
the times.
But i hereby promise to introduce such a function tbefore the end of
this week :)
------------------------------------------------------------------------
Wed, 25 May 2005 07:17:47 +0000 : gordon
The only thing I do not see in this plan is how with this work with the
menu module and the navigation menu.
------------------------------------------------------------------------
Wed, 25 May 2005 10:04:12 +0000 : adrian
Attachment: http://drupal.org/files/issues/url_external_links.patch (1.75 KB)
What happened to the patch i uploaded ?
It doesn't use a complex regexp, but uses strpos($url, '://') < 5.
------------------------------------------------------------------------
Thu, 26 May 2005 06:19:32 +0000 : Bèr Kessels
Allthough this works, is clean AND does what it should do, I still am in
favour of a better nitegrated solution. So please do not yet commit
this, untill I upload my patch. We can then discuss what solution to
take. It will not differ a big lot though.
------------------------------------------------------------------------
Thu, 26 May 2005 08:39:32 +0000 : adrian
is this the patch where you want to introduce an el() to allow for
counting of external links ?
That's a different patch altogether. This is primarily about stopping
url() from not handling external links when there is no good reason for
it to do so. Your el() has a very specific use in the weblinks api, and
should probably be included with it.
------------------------------------------------------------------------
Thu, 26 May 2005 16:18:31 +0000 : Bèr Kessels
Yes, that el()
But let me explain why i am anxious for my solution: el(), by default
will not do much, in fact it will just be an URL()-clone but one that
allows outgoing links. But it has a hook-caller. Again: by default it
does nothing much, for there will not be any hooks around in core.
It will allow, for example, weblinks, to track clicks, or to look up a
permission and allow or disallow users to follow a link.
Now, the whole issue, IMO is, that we should *not* provide two ways for
handling external URLS, but rather a single one, that is weblink-safe.
If we would introduce URL() with outgoing links-capabilities, we can no
longer track any outgoing URLs trough them. We will then have two ways
for handling outgoing URLs, resulting in inconsistencies, and confused
users. (hey, my anonymous users can follow link foo, while i have
"follow outgig links" permission disabled for them).
(BTW weblink will soon be renamed into links, just for reference)
------------------------------------------------------------------------
Thu, 30 Jun 2005 11:06:11 +0000 : adrian
Attachment: http://drupal.org/files/issues/url_external_links_0.patch (824 bytes)
I've updated the patch.
------------------------------------------------------------------------
Mon, 18 Jul 2005 14:12:36 +0000 : adrian
spoke to dries about this patch, and apart from the incomplete patch I
uploaded, there are about a dozen instances where in-line html is used
were l() would suffice.
I will be cleaning them up and submitting a new patch soon.
------------------------------------------------------------------------
Fri, 05 Aug 2005 18:44:03 +0000 : moshe weitzman
hopefully adrian or someone else will chase down the remaining urls
which should use this function.
------------------------------------------------------------------------
Fri, 05 Aug 2005 19:25:08 +0000 : jsloan
I've come to this party late but would like to see a patch soon... I've
used the patch from Adrian (#15) but this did not work correctly in my
setup (IIS 5.0 / no clean urls) I applied it against 4.6.2 and cvs.
Where is the latest patch that I can test ... I'll throw some time at
this because I need it for a module used within our Intranet.
------------------------------------------------------------------------
Mon, 08 Aug 2005 20:06:03 +0000 : jsloan
Attachment: http://drupal.org/files/issues/external_urls_2.patch (3.67 KB)
I'm not sure what the final plans are for this in the CVS so I have
developed a patch for use on 4.6.2
I decided to add a parameter named $external that is passed to url()
function. The default is FALSE so this should not break any existing
calls to either l() or url(). I have also refactored url() so that it
is much easier to understand and extend --- I'm thinking of Bèr
Kessels intention to
"allow, for example, weblinks, to track clicks, or to look up a
permission and allow or disallow users to follow a link"
"
Since the parameter is passed to activate the external url there is no
need for regex or strpos, this should be handled by the calling
function and then set the $external parameter to TRUE
For example I have patched the theme_menu_item_link() function in
menu.inc to accept external urls:
<?php
function theme_menu_item_link($item, $link_item) {
// this next line was added so that a menu item could point to the default home
$link_item['path'] = preg_replace('/^\/$/','',$link_item['path']);
// this next line was added so that a menu item could point to an external url
$external = (preg_match('<^[a-z]+://>', $link_item['path'])) ? TRUE : FALSE ;
return l($item['title'], $link_item['path'], array_key_exists('description', $item) ? array('title' => $items['description']) : array(),NULL,NULL,FALSE,FALSE,$external);
}
?>
I hope that this patch will spur some solutions - I'm using this now in
production but have not tested extensively across every scenario.
thanks
jim sloan
------------------------------------------------------------------------
Fri, 19 Aug 2005 12:10:50 +0000 : jsloan
... are there any thoughts on this? What is the status of the final
patch?
------------------------------------------------------------------------
Sun, 28 Aug 2005 15:48:08 +0000 : adrian
The problem with this patch is that we still need to fix all the inline
occurrences of the <a href tag.
I don't think we should confuse the issue and implement a hook at this
point, as url() breaking with external links is a bug, pure and simple.
------------------------------------------------------------------------
Thu, 08 Sep 2005 15:24:16 +0000 : robertDouglass
Attachment: http://drupal.org/files/issues/theme.inc.patch.txt (1.16 KB)
Adrian, your second patch for theme.inc looks wrong to me. Don't you
still need the line
$settings[$type .'_links'][] = l($text, $link, $attributes); ?
I also got rid of unset($attributes); Where was that supposed to come
from that it needed unsetting?
------------------------------------------------------------------------
Thu, 08 Sep 2005 15:48:02 +0000 : robertDouglass
Attachment: http://drupal.org/files/issues/theme.common.inc.patch.txt (1.83 KB)
Here is a unified patch that I updated to fix a bug in Adrian's
common.inc code (everything was being handled as absolute), plus the
update to theme.inc that I questioned in the previous post.
In my initial testing, this works perfectly. I can put absolute URLs in
for the paths in menu items and it handles them fine, and changes no
other behavior. I searched core for all uses of url() and http:// and
found no more violating code such as that in theme.inc.
Net change in core with this patch: 0 lines of code.
Please review quickly, I'm writing in the upcoming book about this
functionality as if it is in. =)
------------------------------------------------------------------------
Thu, 08 Sep 2005 15:49:43 +0000 : robertDouglass
Correction: net change to core -1 line of code.
------------------------------------------------------------------------
Thu, 08 Sep 2005 18:58:01 +0000 : adrian
What needs to be removed from core are not uses of url() and l(), but
all occurences of the anchor tag.
The anchor tag was mostly used because l() didn't do external links.
Also, in the case of phptemplate , that is the line that creates the
array that is passed to the template.
------------------------------------------------------------------------
Thu, 08 Sep 2005 20:58:13 +0000 : robertDouglass
Good - that needs to be removed too, but is there anything that doesn't
work right if we don't remove them? Lots of the $output = '<a href....'
instances in the code use url() for href and these are not broken. They
can't be seen as a reason not to commit this particular patch. If
anyone point out things that break with the patch I made, I'll fix
them. I can't go through and clean up anchor tags on idealistic grounds
at the moment (as much as I would otherwise like to).
------------------------------------------------------------------------
Sat, 10 Sep 2005 20:11:08 +0000 : jsloan
I think that using strpos($path, '://') to trigger the external url is a
bad idea.
My patch implements a new parameter to url() and l() that will let the
calling function decided if it is an external url. And it is backward
compatible with all existing calls.
I also rewrote the logic of builing the url to make it simple.
Adrian, I do not agree that it was a bug; url() never intended to
handle external url´s and also, the clean up of the inline anchor tags
are not dependent on this feature.
Can this be considered for the solution to this feature?
------------------------------------------------------------------------
Sun, 11 Sep 2005 02:14:10 +0000 : jsloan
... the patch I am referring to is above at # 23
------------------------------------------------------------------------
Sun, 11 Sep 2005 07:27:14 +0000 : robertDouglass
"I think that using strpos($path, '://') to trigger the external url is
a bad idea.
"
Please explain why. The only thing that your regexp does that is
different is check to see if the part of the string before the :// is
within the range a-z, and for that you use a more expensive PHP
function. Please indicate the cases where strpos($path, '://') won't
work correctly.
"My patch implements a new parameter to url() and l() that will let the
calling function decided if it is an external url. And it is backward
compatible with all existing calls.
"
This means that instead of doing one check in a centralized place,
programmers now have to write checks anytime they want to call this
function with an either/or case. I don't see why this is better.
"I also rewrote the logic of builing the url to make it simple.
"
This is good.
"Adrian, I do not agree that it was a bug; url() never intended to
handle external url´s and also, the clean up of the inline anchor tags
are not dependent on this feature.
"
I'm still unclear on why anything else in the code base needs to be
changed before this functionality can be accepted. I stick with my
patch as the preferred solution.
------------------------------------------------------------------------
Sun, 11 Sep 2005 14:58:55 +0000 : jsloan
"Please explain why
"
My post #23 has confused you. The patch itself does not add a strpos()
or regexp() ... the code snippet I posted is an example of the calling
function´s responsibility of determining the use of the external link
and then passing that parameter on to the l() or url() function.
I believe it is a bad idea to use string parsing at this low level to
determine functionality because it will impose this behavior on all
calls. There could be a case in which this would be a problem; such as
a url that could contain another url as a parameter.
index.php?q=module¶m=http://example.com
... and there are some who would balk at the processing overhead of
pattern matching at his level.
"This means that instead of doing one check in a centralized place,
programmers now have to write checks anytime they want to call this
function with an either/or case. I don't see why this is better.
"
This is better because the module author is the proper person to
determine whether the link is external. Note that in the case of all
internal links there is no change of coding practice at all. It is
when the module function must handle external links that module´s
author can include the various context and string pattern tests to set
the $external parameter for the l() or url() call. This is what I was
demonstrating in the code example of post #23.
"I'm still unclear on why anything else in the code base needs to be
changed before this functionality can be accepted. I stick with my
patch as the preferred solution.
"
I think that we agree on this point. Nothing needs to be changed in
the code base – my patch is backward compatible to all existing calls
and the clean up work on the in-line anchor tags can (and should) take
place regardless of this patch.
------------------------------------------------------------------------
Sun, 11 Sep 2005 15:04:13 +0000 : robertDouglass
Thanks for the clarification.
1) does your patch still apply well?
2) could you please add the update to the theme menu item to the main
patch so that menu items can be external?
I had forgotten about urls containing urls. That's clearly a
showstopper.
-Robert
------------------------------------------------------------------------
Sun, 11 Sep 2005 15:07:36 +0000 : robertDouglass
You might update the bit in theme.inc as well and include that in the
patch.
1
0
[drupal-devel] [feature] Replace core archive.module w/ codemonkeyx archive.module
by m3avrck 12 Sep '05
by m3avrck 12 Sep '05
12 Sep '05
Issue status update for
http://drupal.org/node/29676
Post a follow up:
http://drupal.org/project/comments/add/29676
Project: Drupal
Version: cvs
Component: archive.module
Category: feature requests
Priority: normal
Assigned to: Morbus Iff
Reported by: Morbus Iff
Updated by: m3avrck
Status: patch (ready to be committed)
Bump to the top, freeze coming soon!!!
m3avrck
Previous comments:
------------------------------------------------------------------------
Thu, 25 Aug 2005 21:08:49 +0000 : Morbus Iff
Over at http://drupal.org/node/8287, Berkes mentions that the core
archive.module was considered being removed, per a discussion at the
Drupal Sprint. Kjartan also mentions he would "love to have the archive
module improved in general." In chatting with chx about this, he
mentioned codemonkeyx's rewrite sitting in contrib/modules/archive/.
I'll be doing some work with the archive.module over the next few days,
and will be basing my changes around codemonkeyx's version, and making
it compatible with HEAD. This general Issue is to move codemonkeyx's
version into HEAD as a replacement to the existing archive.module. An
unknown version of his replacement can be seen at
http://www.codemonkeyx.net/archive. I'll be running a live HEAD version
soon as well.
These patches were made during the customization of Drupal by
http://www.NHPR.org. In loving support of open source software,
http://www.NHPR.org will continue to contribute patches they feel the
community will benefit from. Questions about this patch should be
directed to morbus(a)disobey.com.
------------------------------------------------------------------------
Fri, 26 Aug 2005 19:45:59 +0000 : Morbus Iff
Attachment: http://drupal.org/files/issues_2 (9.56 KB)
As an example of a very early revision, see the attached, with the
following changes from the current contrib CVS:
* removed the year offset from theme_archive_navigation_years, which
controlled how many year links to show at once in the top nav. For
those with sites with more than five years, they'll WANT people to
notice that they have five years, not to have to click on the earliest
date and then have their expectations changed.
* made the "created > $date" in archive_buildQuery "created >= $date"
instead, to allow posts that were created at exactly midnight that day
(like me, by design).
* since there's no block, I made the menu item visible upon first load.
this menu item is given "access content" permissions.
More to come, including doxygen and gmt considerations.
------------------------------------------------------------------------
Fri, 26 Aug 2005 19:47:41 +0000 : Morbus Iff
Might as well start getting a review of it so I can fix 'em as they come
in.
------------------------------------------------------------------------
Fri, 26 Aug 2005 19:56:49 +0000 : Tobias Maier
cant you provide a patch file?
thanks for your work
------------------------------------------------------------------------
Fri, 26 Aug 2005 20:04:01 +0000 : Morbus Iff
The codemonkeyx version is a complete rewrite of the core
archive.module. If I were to create a patch file against core, every
line would be deleted, and every line would be new. Once I finish my
revisions to codemonkey's version, I'll post the final version here, as
well as a patch against his current CVS.
------------------------------------------------------------------------
Fri, 26 Aug 2005 20:09:13 +0000 : Tobias Maier
ok, thanks again :D
------------------------------------------------------------------------
Mon, 29 Aug 2005 13:41:43 +0000 : Junyor
+1 for this change. The archive.module in core is dead.
------------------------------------------------------------------------
Mon, 29 Aug 2005 16:14:30 +0000 : adrian
What is the progress on this morbus ?
------------------------------------------------------------------------
Mon, 29 Aug 2005 16:29:13 +0000 : Morbus Iff
Adrian - I'll be attaching a new version either later today or tomorrow,
with a CHANGELOG. I'll also be running a live version of it over on
NHPR.org for people to play with. The three major things I'm worried
about right now are a) doxygen, b) variable/function naming, c) GMT
considerations. After those, I'll be exploring a patch for my own
needs: the ability to get archives for particular term.
------------------------------------------------------------------------
Mon, 29 Aug 2005 18:53:34 +0000 : Morbus Iff
Attachment: http://drupal.org/files/issues/archive.module (9.93 KB)
Here's the latest, with the following changelog:
* reordered some routines to be a little more workflowish.
* renamed archive_buildQuery to archive_build_query.
* general whitespace and formatting cleanup.
* HEADish update: returning $output, not page templating it.
* removed the reference of &$ad in archive_build_query.
* test for the existence of arg(#)'s before validating them.
* archive_validSomething changed to archive_valid_something.
* removed unused vars: cur_date, cur_date_end.
* renamed archive_buildURL to archive_build_url.
* removed the HTML whitespace from the theming.
* twiddled a lot of quotes and apostraphes.
* removed 'future' CSS class. ill-defined.
* reordered/renamed the CSS classes.
------------------------------------------------------------------------
Mon, 29 Aug 2005 18:54:08 +0000 : Morbus Iff
Attachment: http://drupal.org/files/issues/_p_29676_archive_css.patch (1.56 KB)
And the drupal.css patch.
------------------------------------------------------------------------
Mon, 29 Aug 2005 18:56:29 +0000 : Morbus Iff
This version of the module is currently running live at
http://www.nhpr.org/archive/.
------------------------------------------------------------------------
Mon, 29 Aug 2005 19:59:57 +0000 : Tobias Maier
if i click for example on 2003 it would be good if this would go to
january or december
and marks them that this one will be shown now
as you can see it if you click on january 2003.
it has to select
* on the first:
the first month of writing
* on the last:
the last month of writing
* on every else:
january
I hope you can understand what I mean...
greets tobias
------------------------------------------------------------------------
Mon, 29 Aug 2005 20:17:40 +0000 : Morbus Iff
Attachment: http://drupal.org/files/issues/archive_0.module (11.28 KB)
Alright. I've attached another new version that adds a new feature that
wasn't part of the original codemonkeyx CVS, but was chatted about on
the devel list back in April. If this particular feature has bad code
or needs heavy refactoring, certainly consider ONLY the version in
comment #9 (and the matching drupal.css patch in #10).
This new version supports dated archives based on taxonomy tids. It was
a quick addition which NHPR.org needed (for the date nav; the normal tid
archive pager wasn't strong enough for our needs). Since it was a quick
addition, it supports only ONE tid at a time - the 'and/or' syntax for
the taxonomy.module was not brought over. If that syntax was desired,
it'd make more sense to create some sort of API for archive.module so
that other nodes can take advantage of the dated nav in their normal
pages (like node types, users, forums, etc.)
The added code supports term matches at any granularity:
# all node types that match tid 15000 ('The Front Porch')
http://www.nhpr.org/archive/term/15000
# all 2005 node types that match tid 20 ('Health')
http://www.nhpr.org/archive/2005/term/20
# all March, 2003 node types that match tid 9 ('Education')
http://www.nhpr.org/archive/2003/3/term/9
# all July 11, 2003 node types that match tid 49 ('Economy')
http://morbus.totalnetnh.net/nhpr/archive/2002/7/11/term/49
------------------------------------------------------------------------
Mon, 29 Aug 2005 20:27:26 +0000 : Tobias Maier
what does this mean?
"Story Archives of 'archives'
"
on http://www.nhpr.org/archive/term/15000
should this maybe named?
"Archive of 'The Front Porch'"
if I go to http://www.nhpr.org/archive/term/20
I can only read "archives"...
why is there a difference?
- I never tested this module on my test site, because I'm not at home
-
------------------------------------------------------------------------
Mon, 29 Aug 2005 20:29:34 +0000 : Morbus Iff
Tobias: that wouldn't be possible, at least not accurately. The new
archive.module supports browsing by year, month, and day, as you know.
archive/2005 loads up all the data from a particular year and starts
creating a pager out of it. Consider if you have 3 posts in December,
and 15 posts in November. It wouldn't be "right" to highlight December
because the pager display for the entire year would also include some
of November's entries (since 3 is less than the pager increment).
Likewise, if we ONLY showed the items from December, then we wouldn't
have a "pager by year" feature, only a "pager by month (defaulting to
December when none is selected)" feature.
------------------------------------------------------------------------
Mon, 29 Aug 2005 20:30:41 +0000 : Morbus Iff
Tobias: regarding #14, that's an artifact of the templates that I'm
using for NHPR, and has nothing to do with archive.module itself (in
fact, once the anonymous cache expires, you'll see that little oopsie
go away).
------------------------------------------------------------------------
Mon, 29 Aug 2005 20:31:47 +0000 : Tobias Maier
I can see your right :)
I hope it comes in HEAD before tomorrow :D
------------------------------------------------------------------------
Tue, 30 Aug 2005 00:20:12 +0000 : dtan
I apologize if this is already a known issue.
http://www.nhpr.org/archive/2005/9 does not create a link for september
1st, even though there are 2 nodes listed
(http://www.nhpr.org/archive/2005/9/1)
------------------------------------------------------------------------
Tue, 30 Aug 2005 17:11:21 +0000 : Morbus Iff
dtan: I'm pretty sure I know what this is - I'll address it either later
today or tomorrow.
------------------------------------------------------------------------
Tue, 30 Aug 2005 20:49:58 +0000 : Morbus Iff
Attachment: http://drupal.org/files/issues/archive_1.module (11.53 KB)
Alright, I've attached a new archive.module - this is the version WITH
term filtering enabled. I can make one without terms if necessary -
otherwise, I'll just work from this one for now. This version fixes the
bug that dtan saw, as a well as a bunch of other off-by-one errors. Of
primary importance, however, is that all mktime's that mattered have
been switched to gmmktime, which was one of the oft-reported Issues
with the old archive.module. I want to eyeball them all again and make
sure they're right though.
The URLs from #13 are still operational and the CSS from #10 is still
required.
------------------------------------------------------------------------
Wed, 31 Aug 2005 00:02:06 +0000 : Morbus Iff
In testing with a few people in #drupal, we've discovered a much bigger
problem, which affects this rewritten module as well as the current
core archive.module. In a nutshell, the node.created time is stored
with time(). PHP's time() bases itself on the server time, NOT on GMT.
Thus, for archive.module to work correctly, it must ALWAYS use mktime
(relative to server time) and never consider the $user->timezone
(relative to GMT). For archive.module, this would cause dates to always
be considered via server time, which isn't good, but is better than the
craziness going on now. Alternatively, we could try to convert server
time to GMT first, and then work with that.
The proper solution is to fix node.module to use gmmktime without any
arguments for node.created, then have an update path that modifies all
node .created and .modified values to GMT, not server time.
------------------------------------------------------------------------
Wed, 31 Aug 2005 05:53:51 +0000 : Junyor
Since that is also a problem with the old archive.module, I don't see
why it should stop this from getting into core.
------------------------------------------------------------------------
Wed, 31 Aug 2005 06:37:28 +0000 : stefan nagtegaal
"Since that is also a problem with the old archive.module, I don't see
why it should stop this from getting into core.
"
Well, I think it's better to only accept the best code rather than
accepting bugs getting in core.
------------------------------------------------------------------------
Wed, 31 Aug 2005 07:05:51 +0000 : Kobus
I am with Junyor on this. If this can be fixed, great, but if not, it's
not a train smash, as the old one exhibits the same problem.
I say add the new archive module, if there are no other ciritical bugs
with it. It is much more robust and usable than the old one. We
desperately need a new archive module.
I couldn't find any other bugs while testing with the links Morbus
posted. I don't have a HEAD installation anywhere, so can't test it
locally at this moment.
Regards,
Kobus
------------------------------------------------------------------------
Wed, 31 Aug 2005 07:07:49 +0000 : Kobus
BTW, code freeze means no new code added, right?
Can't this module put in Core as is for the code freeze and the bug
sorted out before the official release? Or is that just mean of me to
suggest that?
Kobus
------------------------------------------------------------------------
Wed, 31 Aug 2005 07:13:09 +0000 : Junyor
Stefan: The bug is already in core, since node.module is in core.
Archive.module (old and new!) just shows that bug.
------------------------------------------------------------------------
Wed, 31 Aug 2005 07:20:35 +0000 : Tobias Maier
I want to have it in core for 4.7, too!!!
------------------------------------------------------------------------
Wed, 31 Aug 2005 07:25:24 +0000 : stefan nagtegaal
Junyor: I know that.. Though I think it's not good to accept code which
we are aware of that it has bugs in it..
Offcourse this is very double, because drupal contains (probably) a lot
of bugs, only they weren't spotted yet..
But, accepting code which has bugs in unacceptable imo..
For example, the node revisions patch had almost 40 reviews/rewritings
from Gerhard and several others before it was accepted to be in core..
If we do not allow bugs to go into core, we don't have to bughunt and
fix later which is a good thing..
So, imo we should first sort out the problem, then discuss what the
best way is to fix the problem, and after that Squeeze that moron! ;-)
------------------------------------------------------------------------
Wed, 31 Aug 2005 09:11:06 +0000 : adrian
I vote we include this module, and open up a new issue for the bug.
It's not archive's fault that this occurs, it is just showing the data
it has access to. The bug already exists in core too.
------------------------------------------------------------------------
Wed, 31 Aug 2005 13:50:59 +0000 : Morbus Iff
Attachment: http://drupal.org/files/issues/archive_2.module (10.63 KB)
Attached is a new, and most likely final, version of the archive.module.
I've removed all user->timezone references - all date determinations are
based on server time, which is also the time used in the "created"
column of the node table. This is "more accurate" than what the core
archive.module currently does (which'll always be wrong because it's
treating server time as GMT, which isn't always the case). When
node.module does start saving times as GMT properly, archive.module
will have be to be tweaked with timezones and blah blah blah. I did
fiddle around with determining the server offset in an attempt to get
to a GMT base, but I didn't have much luck with that. The NHPR.org URLs
above are still valid for testing.
I need testers and reviewers.
------------------------------------------------------------------------
Wed, 31 Aug 2005 14:55:16 +0000 : m3avrck
I get these two PHP errors when I have *no* content in my Drupal install
(just did a clean install to test it):
warning: mktime() [<a href='function.mktime'>function.mktime</a>]:
Windows does not support negative values for this function in
websites\drupal_cvs\drupal\modules\archive.module on line 274.
warning: date() [<a href='function.date'>function.date</a>]: Windows
does not support dates prior to midnight (00:00:00), January 1, 1970 in
websites\drupal_cvs\drupal\modules\archive.module on line 274.
Once I add content, these go away. Need some better checks to make sure
if there is *no* content you don't get weird errors and what not :)
------------------------------------------------------------------------
Wed, 31 Aug 2005 14:55:45 +0000 : Morbus Iff
Attachment: http://drupal.org/files/issues/_p_29676_archive_css_0.patch (1.56 KB)
Updated drupal.css patch for HEAD.
------------------------------------------------------------------------
Wed, 31 Aug 2005 15:26:01 +0000 : Morbus Iff
Attachment: http://drupal.org/files/issues/archive_3.module (10.75 KB)
Attached is the complete module, fixed for m3avrck's #31.
------------------------------------------------------------------------
Wed, 31 Aug 2005 17:30:36 +0000 : m3avrck
Reviewed patch and further test, running great over here! Definetly +1
for this one!
------------------------------------------------------------------------
Wed, 31 Aug 2005 20:03:36 +0000 : Morbus Iff
Note: The NHPR folks preferred their archives to be sorted from earliest
to latest (SQL ASC vs. DESC) for month/day listings, so no longer use
the NHPR.org URLs above as representative of the module itself.
------------------------------------------------------------------------
Wed, 31 Aug 2005 21:26:37 +0000 : Morbus Iff
Attachment: http://drupal.org/files/issues/drupal.css (10.35 KB)
CVS updated for HEAD again.
------------------------------------------------------------------------
Wed, 31 Aug 2005 21:27:00 +0000 : Morbus Iff
Attachment: http://drupal.org/files/issues/_p_29676_archive_css_1.patch (1.56 KB)
GRRR.
------------------------------------------------------------------------
Thu, 08 Sep 2005 20:18:48 +0000 : m3avrck
Attachment: http://drupal.org/files/issues/archive_0.patch (20.72 KB)
Rerolled patch against head. Also created one patch that fixes both
archive.module and drupal.css so it's a clean and simple process now :)
------------------------------------------------------------------------
Thu, 08 Sep 2005 20:23:55 +0000 : m3avrck
Just retested with the latest patch I made, applies cleanly against HEAD
and *everything* works great and looks great too. No errors of any kind,
even works on PHP 5.0.5 with no call by reference errors, :D Let's get
this baby in!
------------------------------------------------------------------------
Thu, 08 Sep 2005 21:26:06 +0000 : Souvent22
+1. I like the new patch, makes things easier to patch. Very slick. I
like the break down of years, to months, to days. Very nice. Ready to
go I say.
1
0
[drupal-devel] [bug] theme_image() doesn't actually output width and height of image
by m3avrck 12 Sep '05
by m3avrck 12 Sep '05
12 Sep '05
Issue status update for
http://drupal.org/node/30935
Post a follow up:
http://drupal.org/project/comments/add/30935
Project: Drupal
Version: cvs
Component: theme system
Category: bug reports
Priority: normal
Assigned to: Anonymous
Reported by: m3avrck
Updated by: m3avrck
-Status: fixed
+Status: patch (ready to be committed)
Attachment: http://drupal.org/files/issues/system.module_10.patch (1.53 KB)
Dries, great catch! What prompted this originally was that the
screenshots on the theme page didn't have dimensions, didn't realize
that index [3] returned this. Anyways, this patch fixes the screen
shots and adds widths/heights.
m3avrck
Previous comments:
------------------------------------------------------------------------
Sun, 11 Sep 2005 16:22:28 +0000 : m3avrck
Function theme_image() doesn't actually return a width and height for an
image like it claims to do.
------------------------------------------------------------------------
Sun, 11 Sep 2005 19:30:35 +0000 : m3avrck
Attachment: http://drupal.org/files/issues/drupal_11.patch (2.74 KB)
Ok patched attached, which fixes this issue. Also, included a patch for
system.module which sets the screen shots to 'TRUE' so image dimensions
will also be outputted there as well (which they should be!).
------------------------------------------------------------------------
Sun, 11 Sep 2005 19:33:41 +0000 : m3avrck
Attachment: http://drupal.org/files/issues/drupal_12.patch (2.75 KB)
Fixed a tab issue.
------------------------------------------------------------------------
Sun, 11 Sep 2005 19:35:46 +0000 : m3avrck
Attachment: http://drupal.org/files/issues/drupal_13.patch (2.75 KB)
Fixed a spacing issue.
------------------------------------------------------------------------
Mon, 12 Sep 2005 14:18:32 +0000 : Souvent22
Used the patch, and did a quick test. Worked well for me. +1.
------------------------------------------------------------------------
Mon, 12 Sep 2005 16:21:16 +0000 : Robrecht Jacques
I don't see why this patch is needed, "theme_image" returns a img tag
with the width and height set if $getsize = TRUE.
Eg:
$node->body = theme('image', file_create_path('druplicon.png'), 'no
alt', 'no title', array(), TRUE) .
theme('image',
file_create_path('druplicon.png'), 'no alt', 'no title', array(),
FALSE)
will return:
<img src="files/druplicon.png" alt="no alt" title="no title" width="88"
height="100" />
<img src="files/druplicon.png" alt="no alt" title="no title" />
(if druplicon.png is copied to the files/ directory).
I don't see what you are fixing...
You are right about the use of theme('image') in system.module though.
The "false" should be "true".
------------------------------------------------------------------------
Mon, 12 Sep 2005 16:40:56 +0000 : m3avrck
Well the actual code in theme_image() returned this:
return '<img src="'. check_url($path) .'" alt="'. check_plain($alt) .'"
title="'. check_plain($title) .'" '. $image_attributes . $attributes
.'/>';
There is *no* mention of the $width and $height variables that are
assigned above, not used at all. I checked images in the themes
directory and none had this information, unless I was missing something
obvious, I see no way that is being generated... nothing in the above
img src about it.
------------------------------------------------------------------------
Mon, 12 Sep 2005 18:41:25 +0000 : Dries
Taken from http://php.net/getimagesize: "Index 3 is a text string with
the correct height="yyy" width="xxx" string that can be used directly
in an IMG tag.". $image_attributes contains this information. Marking
this fixed. Please reopen if not.
1
0
Did someone experiment with MySQL's memory storage engine (HEAP
tables)? If not, I'll add it to my TODO list. Sounds fun and from
the looks, the cache table would be a good candidate ... See http://
dev.mysql.com/doc/mysql/en/memory-storage-engine.html for more
information.
--
Dries Buytaert :: http://www.buytaert.net/
5
5
12 Sep '05
Issue status update for
http://drupal.org/node/31005
Post a follow up:
http://drupal.org/project/comments/add/31005
Project: Drupal
Version: cvs
Component: module system
Category: feature requests
Priority: normal
Assigned to: Anonymous
Reported by: nedjo
Updated by: nedjo
Status: patch (code needs review)
Attachment: http://drupal.org/files/issues/module_enable_hook.patch (1.05 KB)
A module often has some one-time setup initialization to do, some of
which can be easily automated (e.g., set a system variable), some of
which may require site admin input. But there's no available method to
detect and act on module enabling.
So the attached patch implements one possible approach: a new _enable()
hook, that would be called when a module is enabled.
I suppose an alternate approach would be simply to redirect to the
module's setting's page, if available; but, because multiple modules
can be enabled at the same time, that might be impractical.
I know, three days before code freeze is not the best time to be
bringing up new proposed hooks! I'll be happy to wait until next cycle
to work the idea through.
nedjo
2
1