Upgrade to 0.9.6 rev2754
Linux - Apache/1.3.37 - PHP Version 5.1.6 (CGI)
Upgrade went smoothly but when saving a newly created document I get this error:
Warning: strtr() [function.strtr]: The second argument is not an array. in home/.../public_html/manager/processors/save_content.processor.php on line 858
The document is saved without an alias. This also happens when editing an existing document...
The cause as far as I can see was that I forgot to set the Character encoding to utf8 (It was set to Windows-1252). However this should not break things the way it does. In fact looking at the code again,.. the real cause is on line 573 in save_content.processor.php
//<?php
function stripAlias($alias) {
global $modx;
if (strtoupper($modx->config['modx_charset']) == 'UTF-8'){
//$alias = utf8_decode($alias);
//$alias = strtr($alias, array (chr(196) => 'Ae', chr(214) => 'Oe', chr(220) => 'Ue', chr(228) => 'ae', chr(246) => 'oe', chr(252) => 'ue', chr(223) => 'ss'));
// Convert accented characters to their non-accented counterparts. Idea originally from Brett Florio (thanks!) ... expanded list from Textpattern (double-thanks!)
$replace_array = array(
//REMOVED FOR BREVITY'S SAKE
);
$alias = strtr($alias, $replace_array);
}
$alias = strip_tags($alias);
$alias = preg_replace('/&.+?;/', '', $alias); // kill entities
$alias = preg_replace('/[^\.%A-Za-z0-9 _-]/', '', $alias);
//$alias = preg_replace('/\s+/', '-', $alias);
$alias = preg_replace('|-+|', '-', $alias);
$alias = trim($alias, '-');
return $alias;
}
//?>
The test for the character set is missing the { } brackets and as the $replace_array is the next statement it is not executed, any further lines however will be and hence the strtr($alias,$replace_array); causes a php warning;
The correct code I’m assuming would be:
//<?php
function stripAlias($alias) {
global $modx;
if (strtoupper($modx->config['modx_charset']) == 'UTF-8'){ //added bracket
//$alias = utf8_decode($alias);
//$alias = strtr($alias, array (chr(196) => 'Ae', chr(214) => 'Oe', chr(220) => 'Ue', chr(228) => 'ae', chr(246) => 'oe', chr(252) => 'ue', chr(223) => 'ss'));
// Convert accented characters to their non-accented counterparts. Idea originally from Brett Florio (thanks!) ... expanded list from Textpattern (double-thanks!)
$replace_array = array(
//REMOVED FOR BREVITY'S SAKE
);
$alias = strtr($alias, $replace_array);
} //added bracket
$alias = strip_tags($alias);
$alias = preg_replace('/&.+?;/', '', $alias); // kill entities
$alias = preg_replace('/[^\.%A-Za-z0-9 _-]/', '', $alias);
//$alias = preg_replace('/\s+/', '-', $alias);
$alias = preg_replace('|-+|', '-', $alias);
$alias = trim($alias, '-');
return $alias;
}
//?>
EDIT: committed in branches/0.9.6/ @ 2758
Added in bugtracker:
#874