29-Nov-2008

PHP problem – revisited
The error shows does show where it occurs and I took a look:

function _mb_strcut( $str, $start, $length=null, $encoding=null ) {
// the solution below, works only for utf-8, so in case of a different
// charset, just use built-in substr
$charset = get_option( 'blog_charset' );
if ( !in_array( $charset, array('utf8', 'utf-8', 'UTF8', 'UTF-8') ) ) {
return is_null( $length )? substr( $str, $start ) : substr( $str, $start, $length);
}
// use the regex unicode support to separate the UTF-8 characters into an array
preg_match_all( '/./us', $str, $match );
$chars = is_null( $length )? array_slice( $match[0], $start ) : array_slice( $match[0], $start, $length );
return implode( '', $chars );
}

The second part are the lines causing trouble:

94 preg_match_all( ‘/./us’, $str, $match );
95 $chars = is_null( $length )? array_slice( $match[0], $start ) : array_slice( $match[0], $start, $length );
96 return implode( ”, $chars );

These lines are called if the line in the OPTIONS table that carries BLOG_CHARSET, specified UTF-8. Which is the case….
After changing this to CP850 – the old Windows code page – these errors do no longer appear, but other porblems arise: It’s not possible to add an image. The three choises: Choose/Upload, Gallery and Media Library show up, but in the Gallary tab, the ‘show’ link that should come up with the properties is not displayed, IE 7 however mentions an error:
Line: 4
Char: 1
Error: Object doesn't support this property or Method
Code: 0
URL: https://(Site)/(blog)/wp-admin/media-upload.php?type=image&tab=gallery&post_id=7

In the media Library tab, ‘show’ does work but the Insert button does not return to the post. The screen is empty but some code has been sent to the browser:

<script type="text/javascript">
/* <![CDATA[ */
var win = window.dialogArguments || opener || parent || top;
win.send_to_editor('<a
href=\"https://(site)/(blog)/wp-content/uploads/2008/11/ff1.jpg\"><img
src=\"https://(site)/(blog)/wp-content/uploads/2008/11/ff1.jpg\"
alt=\"\" title=\"ff1\" width=\"140\" height=\"24\" class=\"alignleft
size-medium wp-image-9\" /></a>');
/* ]]> */
</script>

So adding an image still doesn’t work
Francesco didn’t run into this – I think he just uploaded files (which I haven’t retried yet) but he ran into another issue, when he supplies a caption:

Warning: Compilation failed: this version of PCRE is not compiled with
PCRE_UTF8 support at offset 0 in
/wordpress_ist_provablog/wp-includes/shortcodes.php on line 213

I looked into this code and found:

function shortcode_parse_atts($text) {
$atts = array();
$pattern = '/(\w+)\s*=\s*"([^"]*)"(?:\s|$)|(\w+)\s*=\s*\'([^\']*)\'(?:\
$text = preg_replace("/[\x{00a0}\x{200b}]+/u", " ", $text);
if ( preg_match_all($pattern, $text, $match, PREG_SET_ORDER) ) {

line 213 is the line:

$text = preg_replace(“/[\x{00a0}\x{200b}]+/u”, ” “, $text);

preg_replace is, like preg_match_all, array_slice and implode a basic PHP funtion, part of the PCRE module. Since the code is still available on Diana, I could de a search:

$ sea php_root:[000000...]*.c preg_match_all,array_slice,implode,preg_replace

******************************
PHP_ROOT:[000000.ext.pcre]php_pcre.c;1

#define PREG_REPLACE_EVAL (1< <0) case 'e': poptions |= PREG_REPLACE_EVAL; break; /* {{{ proto int preg_match_all(string pattern, string subject, array subpatterns [, int flags [, int offset]]) PHP_FUNCTION(preg_match_all) eval = preg_options & PREG_REPLACE_EVAL; /* {{{ preg_replace_impl static void preg_replace_impl(INTERNAL_FUNCTION_PARAMETERS, zend_bool is_callable_replace) /* {{{ proto string preg_replace(mixed regex, mixed replace, mixed subject [, int limit]) PHP_FUNCTION(preg_replace) preg_replace_impl(INTERNAL_FUNCTION_PARAM_PASSTHRU, 0); /* {{{ proto string preg_replace_callback(mixed regex, mixed callback, mixed subject [, int limit]) PHP_FUNCTION(preg_replace_callback) preg_replace_impl(INTERNAL_FUNCTION_PARAM_PASSTHRU, 1); PHP_FE(preg_match_all, third_arg_force_ref) PHP_FE(preg_replace, NULL) PHP_FE(preg_replace_callback, NULL) ****************************** PHP_ROOT:[000000.ext.standard]array.c;2 /* {{{ proto array array_slice(array input, int offset [, int length]) PHP_FUNCTION(array_slice) ****************************** PHP_ROOT:[000000.ext.standard]basic_functions.c;2 PHP_FE(implode, NULL) PHP_FALIAS(join, implode, NULL ) PHP_FE(array_slice, NULL) ****************************** PHP_ROOT:[000000.ext.standard]string.c;2 An alias for implode */ /* {{{ php_implode PHPAPI void php_implode(zval *delim, zval *arr, zval *return_value) /* {{{ proto string implode([string glue,] array pieces) PHP_FUNCTION(implode) php_error_docref(NULL TSRMLS_CC, E_WARNING, "Argument to implode must be an array."); php_implode(delim, arr, return_value); $

So I doubt there is no alternative as to reverse to a previous version of WP that didn't have these problems (like 2.6) or change the PHP code to bypass the problem...

WP update
WP 2.6.5 has been released - to bypass a bogus 2.6.4 that seems to float on the Internet, that version is bypassed. It will be installed soon.