Textpattern CMS support forum
You are not logged in. Register | Login | Help
- Topics: Active | Unanswered
#1 2007-09-06 20:32:32
- guiguibonbon
- Member
- Registered: 2006-02-20
- Posts: 296
don't repeat form not found error
Sorry guys, been giving you a lot of work today :)
Is it really useful to have the ‘form not found error’ repeated for each article in lists, and the query repeated each time?
Suggestion :
function fetch_form($name)
{
static $forms = array();
if (@$forms[$name] == false)
return;
elseif (isset($forms[$name]))
$f = $forms[$name];
else {
$row = safe_row('Form', 'txp_form',"name='".doSlash($name)."'");
if (!$row) {
$forms[$name] = false;
trigger_error(gTxt('form_not_found').': '.$name);
return;
}
$f = $row['Form'];
$forms[$name] = $f;
}
trace_add('['.gTxt('form').': '.$name.']');
return $f;
}
this guy is freaking out.
Last edited by guiguibonbon (2007-09-06 20:40:17)
Offline
Re: don't repeat form not found error
I won’t fix that one. This is clearly a user error. The fact that it is pointed out more than once, just helps to point out that there is a problem. The user should fix the mistake and then the problem is solved.
Offline
#3 2007-09-06 21:11:45
- guiguibonbon
- Member
- Registered: 2006-02-20
- Posts: 296
Re: don't repeat form not found error
I almost agree, except it gives the impression you’ve used more than one article tag.
Or at least just don’t do the query again. That’s not very clean.
Or : do a trace_add instead of a trigger_error for the other errors.
Offline
Re: don't repeat form not found error
The extra queries are not a problem, because they disappear when the mistake is corrected. There’s an easier solution, btw: setting $forms[$name] to an empty string (when the form wasn’t found) has the same effect.
Offline
#5 2007-09-06 21:56:34
- guiguibonbon
- Member
- Registered: 2006-02-20
- Posts: 296
Re: don't repeat form not found error
oh, wouldn’t that return an empty form?
Gees, am I stupid at times.
Although… trace_add('['.gTxt('form').': '.$name.']');
would still have worked.
And you couldn’t do if ($forms[$name] == "")
since a user could for a reason or another use an empty form. I actually remember doing that way back for a reason or another. Ok, enough geek-talk for today :D
Last edited by guiguibonbon (2007-09-06 22:03:14)
Offline
Re: don't repeat form not found error
No, I mean, if the form can’t be found, assume it’s an empty form without adding any further “if” constructs.
Offline
#7 2007-09-07 13:49:37
- marios
- Archived Plugin Author
- Registered: 2005-03-12
- Posts: 1,253
Re: don't repeat form not found error
Apart from the repeated error strings ( which is ok for me),
couldn’t the debugging_output be wrapped inside the page source with pre code tags, or be dumped at a specified folder as a log file from prefs?
I think, that would be a usfull addition to crockery.
regards, marios
Last edited by marios (2007-09-07 13:51:28)
⌃ ⇧ < ⎋ ⌃ ⇧ >
Offline
Re: don't repeat form not found error
Actually, I was thinking about using <blink> tags to make them even more obvious.
Offline
#9 2007-09-07 15:36:33
- guiguibonbon
- Member
- Registered: 2006-02-20
- Posts: 296
Re: don't repeat form not found error
Hahahahahaaaaa.
I think they’re pretty ok, actually. They look even better with blueprint
It might be nice to add this to the default css :
pre {
color: #333;
margin-bottom: 1.3em;
background: #eee;
border:0.1em solid #ddd;
padding:1.5em;
text-align:center;
font-family:Consolas, "Bitstream Vera Sans Mono", "Courier New", Courier, monospace;
}
Last edited by guiguibonbon (2007-09-07 15:39:46)
Offline
#10 2007-09-07 16:54:31
- marios
- Archived Plugin Author
- Registered: 2005-03-12
- Posts: 1,253
Re: don't repeat form not found error
Or how about a Syntax hilighted version with LIne NUmbers, styled with Twilight in the header CSS.
regards, marios
Last edited by marios (2007-09-07 16:55:36)
⌃ ⇧ < ⎋ ⌃ ⇧ >
Offline
Re: don't repeat form not found error
IIRC, the errors are output above the doctype, so technically it’s not even a valid (X)HTML document. No point in trying to style that.
Offline
#12 2007-09-07 17:28:45
- guiguibonbon
- Member
- Registered: 2006-02-20
- Posts: 296
Re: don't repeat form not found error
Marios, I love that. I wonder if a plugin can do it. But how could two warnings be separated?
Offline