bobbingwide / oik-shortcodes

Shortcode, block and API server
https://www.oik-plugins.com/oik-plugins/oik-shortcode-server/
GNU General Public License v2.0
1 stars 0 forks source link

Warning: Only the first byte will be assigned to the string offset in shortcodes/oik-api-importer.php line 1864 #89

Open bobbingwide opened 2 years ago

bobbingwide commented 2 years ago

Processing file: wordpress,wp-activate.php Continue to process file? ( y=yes/n=no/s=skip/g=go/q=quit )y Processing: wp-activate.php, wordpress, wordpress

Creating file: wp-activate.php

Warning: Only the first byte will be assigned to the string offset in /home/customer/www/bobbingwide.org.uk/public_html/wp-con tent/plugins/oik-shortcodes/shortcodes/oik-api-importer.php on line 1864

bobbingwide commented 1 year ago

I got it again for WordPress 6.3 on 9th August 2023

bobbingwide commented 1 year ago

And again for WordPress 6.4 on 8th November 2023. Reproduced in wp.a2z

The problem occurs for code such as

add_action( 'wp_head', 'do_activate_header' );

The token being processed is the closing parenthesis. The logic is supposed to be creating a link to the 'do_activate_header function. But the $key is the wrong value.


 [0] => (integer) 629
    [1] => (string) "do_activate_header"
    [2] => Array

...
[627] => Array

            [0] => (integer) 320
            [1] => (string) "'do_activate_header'"
            [2] => (integer) 82

        [628] => *RECURSION* 623 1
        [629] => (string) ")"
0. bw_lazy_backtrace C:\apache\htdocs\wordpress\wp-content\plugins\oik-bwtrace\libs\bwtrace.php:108 0
1. bw_backtrace C:\apache\htdocs\wordpress\wp-content\plugins\oik-bwtrace\includes\bwtrace-actions.php:293 0
2. bw_trace_error_handler(2,Only the first byte will be assigned to the string offset,C:\apache\htdocs\wordpress\wp-content\plugins\oik-shortcodes\shortcodes\oik-api-importer.php,1867) C:\apache\htdocs\wordpress\wp-content\plugins\oik-shortcodes\shortcodes\oik-api-importer.php:1867 4
3. oikai_handle_token_T_STRING(629,do_activate_header,array,) C:\apache\htdocs\wordpress\wp-content\plugins\oik-shortcodes\shortcodes\oik-api-importer.php:1711 4
4. oikai_handle_association(629,do_activate_header,array,61731) C:\apache\htdocs\wordpress\wp-content\plugins\oik-shortcodes\shortcodes\oik-api-importer.php:1758 4
5. oikai_handle_dummy_TCES(629,do_activate_header,array) C:\apache\htdocs\wordpress\wp-content\plugins\oik-shortcodes\shortcodes\oik-api-importer.php:2256 3
6. oikai_handle_char_comma(629,),array) C:\apache\htdocs\wordpress\wp-content\plugins\oik-shortcodes\shortcodes\oik-api-importer.php:2280 3
7. oikai_handle_char_rparen(629,),array) C:\apache\htdocs\wordpress\wp-content\plugins\oik-shortcodes\shortcodes\oik-api-importer.php:2215 3
8. oikai_handle_char(629,),array) C:\apache\htdocs\wordpress\wp-content\plugins\oik-shortcodes\shortcodes\oik-api-importer.php:2358 3

A pragmatic solution would be to check if the token we're trying to update is an array. If so, we can assign the value. If not, forget about it.

bobbingwide commented 2 days ago

Delivered in v1.41.5 but there's a problem with the link. The string in the link is not wrapped in quotes.

<span class="T_CONSTANT_ENCAPSED_STRING" id="161">
<a href="http://developer.wordpress.org/reference/functions/oiksc_wordpress_cache_redirect" 
title="WordPress API: oiksc_wordpress_cache_redirect()">
oiksc_wordpress_cache_redirect
</a>
</span>

This is due to different logic being used to generate the link oikai_link_to_wordpress( $value ) when it's an unknown "user" API. To correct the quotes part of the problem change the parameter to $token[$key][1].

To correct the link we need to either generate the API, if it's one of ours, or somehow determine whether or not it's a WordPress API.

This could all be unnecessary if we decide to implement #96