Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

BUG: Post index not working properly on PHP 8.2 #3677

Closed
1 task done
jahid32 opened this issue Oct 3, 2023 · 1 comment
Closed
1 task done

BUG: Post index not working properly on PHP 8.2 #3677

jahid32 opened this issue Oct 3, 2023 · 1 comment
Labels
bug Something isn't working

Comments

@jahid32
Copy link

jahid32 commented Oct 3, 2023

Describe the bug

processed posts 700 - 1050 of 112107. Last Object ID: 577641
Processed posts 1050 - 1400 of 112107. Last Object ID: 572336
Processed posts 1400 - 1750 of 112107. Last Object ID: 570650
Processed posts 1750 - 2100 of 112107. Last Object ID: 569948
Processed posts 2100 - 2450 of 112107. Last Object ID: 569228
PHP Fatal error: Uncaught TypeError: Cannot access offset of type string on string in /public_html/wp-includes/media.php:2356
Stack trace:
#0/public_html/wp-includes/shortcodes.php(395): img_caption_shortcode()
#1 [internal function]: do_shortcode_tag()
#2/public_html/wp-includes/shortcodes.php(235): preg_replace_callback()
#3 /public_html/wp-includes/class-wp-hook.php(310): do_shortcode()
#4 /public_html/wp-includes/plugin.php(205): WP_Hook->apply_filters()
#5 /public_html/wp-content/plugins/elasticpress/includes/classes/Indexable/Post/Post.php(506): apply_filters()
#6 //public_html/wp-content/plugins/elasticpress/includes/classes/Indexable.php(339): ElasticPress\Indexable\Post\Post->prepare_document()
#7 /public_html/wp-content/plugins/elasticpress/includes/classes/IndexHelper.php(652): ElasticPress\Indexable->bulk_index()
#8 /public_html/wp-content/plugins/elasticpress/includes/classes/IndexHelper.php(436): ElasticPress\IndexHelper->index_next_batch()
#9 /public_html/wp-content/plugins/elasticpress/includes/classes/IndexHelper.php(324): ElasticPress\IndexHelper->index_objects()
#10 /public_html/wp-content/plugins/elasticpress/includes/classes/IndexHelper.php(95): ElasticPress\IndexHelper->process_sync_item()
#11 /public_html/wp-content/plugins/elasticpress/includes/classes/Command.php(838): ElasticPress\IndexHelper->full_index()
#12 /public_html/wp-content/plugins/elasticpress/includes/classes/DeprecatedCommand.php(158): ElasticPress\Command->sync()
#13 [internal function]: ElasticPress\Command->index()
#14 phar:///usr/local/bin/wp/vendor/wp-cli/wp-cli/php/WP_CLI/Dispatcher/CommandFactory.php(100): call_user_func()
#15 [internal function]: WP_CLI\Dispatcher\CommandFactory::WP_CLI\Dispatcher{closure}()
#16 phar:///usr/local/bin/wp/vendor/wp-cli/wp-cli/php/WP_CLI/Dispatcher/Subcommand.php(491): call_user_func()
#17 phar:///usr/local/bin/wp/vendor/wp-cli/wp-cli/php/WP_CLI/Runner.php(431): WP_CLI\Dispatcher\Subcommand->invoke()
#18 phar:///usr/local/bin/wp/vendor/wp-cli/wp-cli/php/WP_CLI/Runner.php(454): WP_CLI\Runner->run_command()
#19 phar:///usr/local/bin/wp/vendor/wp-cli/wp-cli/php/WP_CLI/Runner.php(1269): WP_CLI\Runner->run_command_and_exit()
#20 phar:///usr/local/bin/wp/vendor/wp-cli/wp-cli/php/WP_CLI/Bootstrap/LaunchRunner.php(28): WP_CLI\Runner->start()
#21 phar:///usr/local/bin/wp/vendor/wp-cli/wp-cli/php/bootstrap.php(83): WP_CLI\Bootstrap\LaunchRunner->process()
#22 phar:///usr/local/bin/wp/vendor/wp-cli/wp-cli/php/wp-cli.php(32): WP_CLI\bootstrap()
#23 phar:///usr/local/bin/wp/php/boot-phar.php(20): include('phar:///usr/loc...')
#24 /usr/local/bin/wp(4): include('phar:///usr/loc...')
#25 {main}
thrown in /public_html/wp-includes/media.php on line 2356
Fatal error: Uncaught TypeError: Cannot access offset of type string on string in /public_html/wp-includes/media.php:2356

Steps to Reproduce

PHP Version: 8.2
wp elasticpress sync --setup --force --show-errors
After running the following command for a few moments it gives an error.

If the post contains a WordPress classic block with the image it gives error

Screenshots, screen recording, code snippet

No response

Environment information

No response

WordPress and ElasticPress information

`

wp-core

version: 6.3.1
site_language: en_US
user_language: en_US
timezone: America/New_York
permalink: /%postname%/
https_status: true
multisite: false
user_registration: 0
blog_public: 1
default_comment_status: undefined
environment_type: production
user_count: 87
dotorg_communication: true

wp-server

server_architecture: Linux 4.19.0-22-cloud-amd64 x86_64
httpd_software: Apache/2.4.57 (Debian)
php_version: 8.2.10 64bit
php_sapi: fpm-fcgi
max_input_variables: 10000
time_limit: 750
memory_limit: 1024M
max_input_time: 256
upload_max_filesize: 512M
php_post_max_size: 512M
curl_version: 7.64.0 OpenSSL/1.1.1n
suhosin: false
imagick_availability: true
pretty_permalinks: true
htaccess_extra_rules: true
current: 2023-10-03T12:04:44+00:00
utc-time: Tuesday, 03-Oct-23 12:04:44 UTC
server-time: 2023-10-03T08:04:43-04:00

wp-database

extension: mysqli
server_version: 10.4.20-MariaDB-1:10.4.20+maria~buster-log
client_version: mysqlnd 8.2.10
max_allowed_packet: 134217728
max_connections: 29538

wp-filesystem

wordpress: writable
wp-content: writable
uploads: writable
plugins: writable
themes: writable
mu-plugins: writable

ep-last-sync

method: WP Dashboard
is_full_sync: No
start_date_time: 2023/10/03 7:43:51 am
end_date_time: 2023/10/03 7:45:34 am
total_time: 0 hours, 1 minute, 43 seconds
total: 112216
synced: 2800
skipped: undefined
failed: 109416
errors:
0: Uncaught TypeError: Cannot access offset of type string on string in /public_html/wp-includes/media.php:2356
Stack trace:
#0 /public_html/wp-includes/shortcodes.php(395): img_caption_shortcode()
#1 [internal function]: do_shortcode_tag()
#2 /public_html/wp-includes/shortcodes.php(235): preg_replace_callback()
#3 /public_html/wp-includes/class-wp-hook.php(310): do_shortcode()
#4 /public_html/wp-includes/plugin.php(205): WP_Hook->apply_filters()
#5 /public_html/wp-content/plugins/elasticpress/includes/classes/Indexable/Post/Post.php(506): apply_filters()
#6 /public_html/wp-content/plugins/elasticpress/includes/classes/Indexable.php(388): ElasticPress\Indexable\Post\Post->prepare_document()
#7 /public_html/wp-content/plugins/elasticpress/includes/classes/IndexHelper.php(654): ElasticPress\Indexable->bulk_index_dynamically()
#8 /public_html/wp-content/plugins/elasticpress/includes/classes/IndexHelper.php(436): ElasticPress\IndexHelper->index_next_batch()
#9 /public_html/wp-content/plugins/elasticpress/includes/classes/IndexHelper.php(324): ElasticPress\IndexHelper->index_objects()
#10 /public_html/wp-content/plugins/elasticpress/includes/classes/IndexHelper.php(95): ElasticPress\IndexHelper->process_sync_item()
#11 /public_html/wp-content/plugins/elasticpress/includes/classes/Screen/Sync.php(93): ElasticPress\IndexHelper->full_index()
#12 /public_html/wp-includes/class-wp-hook.php(310): ElasticPress\Screen\Sync->action_wp_ajax_ep_index()
#13 /public_html/wp-includes/class-wp-hook.php(334): WP_Hook->apply_filters()
#14 /public_html/wp-includes/plugin.php(517): WP_Hook->do_action()
#15 /public_html/wp-admin/admin-ajax.php(188): do_action()
#16 {main}
thrown

`

Code of Conduct

  • I agree to follow this project's Code of Conduct
@jahid32 jahid32 added the bug Something isn't working label Oct 3, 2023
@jahid32 jahid32 changed the title BUG: Post not index give error. BUG: Post index not working properly on PHP 8.2 Oct 3, 2023
@burhandodhy
Copy link
Contributor

Hi @jahid32,

I've identified the problem and was able to replicate it by following the steps you provided. Upon conducting an initial investigation, I discovered that this issue isn't associated with ElasticPress; instead, it's a bug related to WordPress 6.3. There is an opening ticket where you can find more details: https://core.trac.wordpress.org/ticket/59206

The error appears when there is no argument in the [caption] shortcode. We have to wait until WordPress Core fixes this issue. However, as a temporary workaround, you can fix the problem by adding the id attribute to the [caption] shortcode, for example, like this: [caption id="some-id"].

Since this issue is directly related to WordPress Core, there is no action we can take within the plugin to fix the issue. That's why I'm going to close this issue.

Regards,
Burhan

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants