For some time now I’ve noticed that very long snippets, when I attempt to save them, fail, and I am presented with the 404 page from the front end.
I got round it by saving the code as something.php and doing an include. Good practice anyway, perhaps. Puzzling but no big deal. I made a desultory attempt to find out why, but can’t see anything here, or in JIRA.
Now, today, a very small snippet won’t save.
And it is something to do with "fclose".
Curious, no?
Here’s the snippet that won’t save:
<?php
global $modx;
$result=$modx->db->select('email','ccdnsw_web_user_attributes');
if( $modx->db->getRecordCount( $result ) >= 1 )
{
while( $row = $modx->db->getRow( $result ) )
{
$output .=$row['email'];
}
}
$fp=fopen("assets/upload/memberlist.csv", 'w');
foreach ($list as $line)
{
fputcsv($fp, split(',', $line));
}
echo debug1;
fclose($fp);
echo debug2;
?>
While this one saves perfectly:
<?php
global $modx;
$result=$modx->db->select('email','ccdnsw_web_user_attributes');
if( $modx->db->getRecordCount( $result ) >= 1 )
{
while( $row = $modx->db->getRow( $result ) )
{
$output .=$row['email'];
}
}
$fp=fopen("assets/upload/memberlist.csv", 'w');
foreach ($list as $line)
{
fputcsv($fp, split(',', $line));
}
echo debug1;
echo debug2;
?>
The only difference is the
fclose($fp);
statement at the end.
I know the script is broken - I wanted to correct it online - but I have to get MODx to save it before i can call it.
Is this a bug?
Evolution 1.0, r5601
PHP 5.2.5
MySQL 4.1.22
Browser Firefox 3.5.3