I find it useful to have bulk updates noted in the watchdog logs, particularly when scheduling via cron (eg. per http://drupal.org/node/236304 ).

Attached is a patch against current cvs head which adds the watchdog logging.

Cheers,
Stephen

Comments

aufumy’s picture

StatusFileSize
new3.96 KB

+1

re-rolled the patch against latest cvs head.

aufumy’s picture

Status: Needs review » Reviewed & tested by the community
greggles’s picture

Version: 5.x-2.0 » 6.x-1.x-dev
Status: Reviewed & tested by the community » Needs work

That patch is fine for 5.x but not for 6.x. Can you create one for 6.x as well/first?

aufumy’s picture

StatusFileSize
new3.86 KB

Hi Greggles

Here is a patch for 6.x

Thanks
Audrey

aufumy’s picture

Status: Needs work » Needs review
Freso’s picture

Status: Needs review » Needs work

This won't do: watchdog('pathauto', $update_msg);. watchdog() should be fed the "raw", untranslated string and then handle the translation when displaying the message in the logs. I'm not sure how to handle plurals within watchdog() though, so this might have to be looked into.

Also, I'd vote for waiting with committing this for 6.x-2.x.

greggles’s picture

That was my concern as well about this being non-trivial for the new watchdog system.

And, yes, let's postpone this to 6.x-2.x.

aufumy’s picture

Status: Needs work » Needs review
StatusFileSize
new5.5 KB

re-worked with the new watchdog system.

Freso’s picture

Version: 6.x-1.x-dev » 7.x-1.x-dev
Freso’s picture

Status: Needs review » Needs work
    $update_msg = 'Bulk generation of index aliases completed, %aliases generated.';
    $aliases = format_plural($count, 'one alias', '@count aliases');

is a clear regression of the current code, where "one/@count alias(es)" was a part of the string. First of all, it's splitting one string into two strings, meaning that translators will have to translate some of it out of context. I could easily imagine how "alias" may have to be put differently, depending on what it's an alias of. This would not be possible with the previous patch. Second, it's handing a variable to t() instead of a string.

I'm still not sure how to handle plurals within the watchdog system though, but the way the patch currently does it, is not the way.

gábor hojtsy’s picture

The Drupal 6 watchdog system does not allow other callbacks but t() with watchdog. This might mean that you need to reformulate your text, like 'Bulk generation of index aliases completed (%aliases)' or 'Bulk generation of index aliases completed: %aliases' (I'd prefer the first) and then make %aliases the 'one alias' and '@count aliases'. Thus this breaks the sentence flow, so should be easier to translate.

Drupal 7 should allow arbitrary translation callbacks, such as the Drupal 6 menu system does. We unfortunately did not end up there in Drupal 6, so there are some dirty tricks to be used with plurals in Drupal 6 watchdog.

aufumy’s picture

StatusFileSize
new5.43 KB

Reworked the patch with suggestion 1 from Gabor.

The idea to break out the strings, was inspired from core modules, for example user.module:

$output = t('There is currently %members and %visitors online.',
             array('%members' => format_plural($authenticated_count, '1 user', '@count users'),
                   '%visitors' => format_plural($anonymous_count, '1 guest', '@count guests')));
Freso’s picture

Ah well. I bow before Gábor's knowledge of the t() system, though I think it's an ugly hack, but if there's no elegant way of doing it for 6.x... *sigh*

Anyway, there's still a small issue with the patch: most of the $update_msg's (all except one, actually) aren't rounded off by a full stop ("."). I believe they should be, unless there's a reason (e.g., a convention for watchdog messages that I'm not aware of) that the messages shouldn't be treated with proper English grammar. And even if so, the first instance shouldn't have it then. Consistency is King (or something).

aufumy’s picture

Status: Needs work » Needs review
StatusFileSize
new5.43 KB

Okay, patch includes full stops.

Freso’s picture

Status: Needs review » Needs work

For some reason, I missed this in my last comment. Sorry to keep you tossing patch versions about. :/ If you don't get around to it first, I'll fix the patch myself when I get around to test, but... the $update_msg instances really ought to be replaced with the string itself, as a PO/T extractor won't know what to work with, if it's given a variable instead of a string.

aufumy’s picture

StatusFileSize
new5.5 KB

While a little annoying, it is actually quite helpful for me, as I learn things I would not otherwise know about.

Also, it is a pleasure to work with module maintainers who are on top of the issue queue.

Freso’s picture

I think Greg will testify that I'm one of the Drupal devs who pick on the most nits (but really, I'm just trying aspiring to reach the level of Morbus, chx, et al). Greg has been hit by my nit-picking quite a few times by now. Both before and after he decided to make me a co-maintainer. :p

Anyway, the code looks good now. I can't find anything else to pick on off-hand, but I'd like to comment on the loveliness of drupal_set_message(t( and watchdog('pathauto', aligning perfectly. It's beautiful. :D

And just as I was about to send this off, I noticed an an " alias" which should probably read " $alias". (pathauto_taxonomy.inc, 2nd hunk) ;)

aufumy’s picture

Status: Needs work » Needs review
StatusFileSize
new5.51 KB

okay here it is...

aufumy’s picture

StatusFileSize
new5.52 KB

Diffed against current DRUPAL-6--1 branch.

greggles’s picture

Status: Needs review » Needs work

Any chance you could update this for 7.x-1.x-dev?

I'm sorry this took so long, but if we change strings we should do it in 7.x-1.x.

dave reid’s picture

Issue tags: +bulk

Tagging all the bulk alias issues for #713238: RFC: Pathauto Bulk module.

dave reid’s picture

Priority: Normal » Minor
mably’s picture

Issue summary: View changes
Status: Needs work » Closed (outdated)

Now that this issue is closed, review the contribution record.

As a contributor, attribute any organization that helped you, or if you volunteered your own time.

Maintainers, credit people who helped resolve this issue.