Skip to:
Content

Opened 11 months ago

Last modified 5 months ago

#7590 new defect (bug)

Sometimes getting Notice: Uninitialized string offset: -1 while inserting activity

Reported by: bhargavbhandari90 Owned by:
Milestone: Awaiting Contributions Priority: normal
Severity: normal Version:
Component: Activity Keywords: needs-patch needs-unit-tests
Cc: bn.bhandari90@…

Description

Notice: Uninitialized string offset: -1 in /../wp-content/plugins/buddypress/bp-core/bp-core-template.php on line 1020

Attachments (1)

7590.patch (626 bytes) - added by bhargavbhandari90 11 months ago.

Download all attachments as: .zip

Change History (13)

#1 @bhargavbhandari90
11 months ago

  • Keywords needs-testing needs-patch added

#2 @r-a-y
11 months ago

  • Keywords has-patch reporter-feedback added; needs-patch removed
  • Version 2.9.0 deleted

Hi, @bhargavbhandari90, thanks for the patch!

Do you have an example of the content and arguments being passed to bp_create_excerpt() that is causing this notice?

#3 @bhargavbhandari90
11 months ago

@r-a-y I don't have any live setup for this. What I did on my localhost

  1. Install this plugin https://wordpress.org/plugins/buddypress-media/ and activate it.
  2. Go to rtMedia->Settings->Buddypress and enabled "Allow upload from activity stream".
  3. Then from the activity area and chose around 30 images and click on "Update Post"

Then you can see that notice.

Let me know if you face any problem.

#4 @bhargavbhandari90
11 months ago

  • Keywords reporter-feedback removed

#5 @r-a-y
11 months ago

Thanks for the steps, @bhargavbhandari90.

I'd rather not install a 3rd-party plugin.

Instead, can you run the following in your theme's functions.php or in wp-content/plugins/bp-custom.php?

add_filter( 'bp_create_excerpt', function( $retval, $text, $length, $options ) {
	error_log( 'excerpt text: ' . $text. "\n", 3, WP_CONTENT_DIR . '/uploads/excerpt.log' );
	error_log( 'excerpt options: ' . print_r( $options, true ) . "\n", 3, WP_CONTENT_DIR . '/uploads/excerpt.log' );

	return $retval;
}, 10, 4 );

Recreate the problem with rtMedia and then copy the contents of wp-content/uploads/excerpt.log to this ticket so we can see the problem.

#6 @bhargavbhandari90
11 months ago

@r-a-y Thanks for the snippet. Here is the content which I got

excerpt text: <div class="rtmedia-activity-container"><ul class="rtmedia-list rtm-activity-media-list rtmedia-activity-media-length-39"><li class="rtmedia-list-item media-type-photo"><a href="http://bnb.rtdemo.in/members/rtcamp/media/213/"><div class="rtmedia-item-thumbnail"><img alt="338097_280308248693246_1120014576_o" src="http://bnb.rtdemo.in/wp-content/uploads/rtMedia/users/1/2017/08/338097_280308248693246_1120014576_o-320x240.jpg" /></div><div class="rtmedia-item-title">338097_280308248693246_1120014576_o</div></a></li><li class="rtmedia-list-item media-type-photo"><a href="http://bnb.rtdemo.in/members/rtcamp/media/212/"><div class="rtmedia-item-thumbnail"><img alt="324215_293545734036164_1292056072_o" src="http://bnb.rtdemo.in/wp-content/uploads/rtMedia/users/1/2017/08/324215_293545734036164_1292056072_o-320x240.jpg" /></div><div class="rtmedia-item-title">324215_293545734036164_1292056072_o</div></a></li><li class="rtmedia-list-item media-type-photo"><a href="http://bnb.rtdemo.in/members/rtcamp/media/211/"><div class="rtmedia-item-thumbnail"><img alt="473045_377679005622836_1552828974_o" src="http://bnb.rtdemo.in/wp-content/uploads/rtMedia/users/1/2017/08/473045_377679005622836_1552828974_o-320x240.jpg" /></div><div class="rtmedia-item-title">473045_377679005622836_1552828974_o</div></a></li><li class="rtmedia-list-item media-type-photo"><a href="http://bnb.rtdemo.in/members/rtcamp/media/210/"><div class="rtmedia-item-thumbnail"><img alt="474990_380167752040628_1554169015_o" src="http://bnb.rtdemo.in/wp-content/uploads/rtMedia/users/1/2017/08/474990_380167752040628_1554169015_o-320x240.jpg" /></div><div class="rtmedia-item-title">474990_380167752040628_1554169015_o</div></a></li><li class="rtmedia-list-item media-type-photo"><a href="http://bnb.rtdemo.in/members/rtcamp/media/209/"><div class="rtmedia-item-thumbnail"><img alt="471481_389192264471510_31781347_o" src="http://bnb.rtdemo.in/wp-content/uploads/rtMedia/users/1/2017/08/471481_389192264471510_31781347_o-320x240.jpg" /></div><div class="rtmedia-item-title">471481_389192264471510_31781347_o</div></a></li><li class="rtmedia-list-item media-type-photo"><a href="http://bnb.rtdemo.in/members/rtcamp/media/208/"><div class="rtmedia-item-thumbnail"><img alt="411118_384943224896414_1947716931_o" src="http://bnb.rtdemo.in/wp-content/uploads/rtMedia/users/1/2017/08/411118_384943224896414_1947716931_o-320x240.jpg" /></div><div class="rtmedia-item-title">411118_384943224896414_1947716931_o</div></a></li><li class="rtmedia-list-item media-type-photo"><a href="http://bnb.rtdemo.in/members/rtcamp/media/207/"><div class="rtmedia-item-thumbnail"><img alt="416252_424282600962476_178902187_o" src="http://bnb.rtdemo.in/wp-content/uploads/rtMedia/users/1/2017/08/416252_424282600962476_178902187_o-320x240.jpg" /></div><div class="rtmedia-item-title">416252_424282600962476_178902187_o</div></a></li><li class="rtmedia-list-item media-type-photo"><a href="http://bnb.rtdemo.in/members/rtcamp/media/206/"><div class="rtmedia-item-thumbnail"><img alt="255463_418369288220474_356749062_n" src="http://bnb.rtdemo.in/wp-content/uploads/rtMedia/users/1/2017/08/255463_418369288220474_356749062_n-320x217.jpg" /></div><div class="rtmedia-item-title">255463_418369288220474_356749062_n</div></a></li><li class="rtmedia-list-item media-type-photo"><a href="http://bnb.rtdemo.in/members/rtcamp/media/205/"><div class="rtmedia-item-thumbnail"><img alt="240766_429582597099143_1841716216_o" src="http://bnb.rtdemo.in/wp-content/uploads/rtMedia/users/1/2017/08/240766_429582597099143_1841716216_o-320x240.jpg" /></div><div class="rtmedia-item-title">240766_429582597099143_1841716216_o</div></a></li><li class="rtmedia-list-item media-type-photo"><a href="http://bnb.rtdemo.in/members/rtcamp/media/204/"><div class="rtmedia-item-thumbnail"><img alt="793767_489113224479413_1768895377_o" src="http://bnb.rtdemo.in/wp-content/uploads/rtMedia/users/1/2017/08/793767_489113224479413_1768895377_o-320x240.jpg" /></div><div class="rtmedia-item-title">793767_489113224479413_1768895377_o</div></a></li><li class="rtmedia-list-item media-type-photo"><a href="http://bnb.rtdemo.in/members/rtcamp/media/203/"><div class="rtmedia-item-thumbnail"><img alt="382265_492148144175921_1096787721_n" src="http://bnb.rtdemo.in/wp-content/uploads/rtMedia/users/1/2017/08/382265_492148144175921_1096787721_n-320x240.jpg" /></div><div class="rtmedia-item-title">382265_492148144175921_1096787721_n</div></a></li><li class="rtmedia-list-item media-type-photo"><a href="http://bnb.rtdemo.in/members/rtcamp/media/202/"><div class="rtmedia-item-thumbnail"><img alt="977166_544739878916747_1307985417_o" src="http://bnb.rtdemo.in/wp-content/uploads/rtMedia/users/1/2017/08/977166_544739878916747_1307985417_o-320x240.jpg" /></div><div class="rtmedia-item-title">977166_544739878916747_1307985417_o</div></a></li><li class="rtmedia-list-item media-type-photo"><a href="http://bnb.rtdemo.in/members/rtcamp/media/200/"><div class="rtmedia-item-thumbnail"><img alt="965597_555726794484722_1411342412_o" src="http://bnb.rtdemo.in/wp-content/uploads/rtMedia/users/1/2017/08/965597_555726794484722_1411342412_o-320x240.jpg" /></div><div class="rtmedia-item-title">965597_555726794484722_1411342412_o</div></a></li><li class="rtmedia-list-item media-type-photo"><a href="http://bnb.rtdemo.in/members/rtcamp/media/201/"><div class="rtmedia-item-thumbnail"><img alt="1009316_553819654675436_1023949230_o" src="http://bnb.rtdemo.in/wp-content/uploads/rtMedia/users/1/2017/08/1009316_553819654675436_1023949230_o-320x240.jpg" /></div><div class="rtmedia-item-title">1009316_553819654675436_1023949230_o</div></a></li><li class="rtmedia-list-item media-type-photo"><a href="http://bnb.rtdemo.in/members/rtcamp/media/199/"><div class="rtmedia-item-thumbnail"><img alt="1016149_562672123790189_1487402728_n" src="http://bnb.rtdemo.in/wp-content/uploads/rtMedia/users/1/2017/08/1016149_562672123790189_1487402728_n-320x240.jpg" /></div><div class="rtmedia-item-title">1016149_562672123790189_1487402728_n</div></a></li><li class="rtmedia-list-item media-type-photo"><a href="http://bnb.rtdemo.in/members/rtcamp/media/198/"><div class="rtmedia-item-thumbnail"><img alt="1044770_562672173790184_1661254222_n" src="http://bnb.rtdemo.in/wp-content/uploads/rtMedia/users/1/2017/08/1044770_562672173790184_1661254222_n-320x240.jpg" /></div><div class="rtmedia-item-title">1044770_562672173790184_1661254222_n</div></a></li><li class="rtmedia-list-item media-type-photo"><a href="http://bnb.rtdemo.in/members/rtcamp/media/197/"><div class="rtmedia-item-thumbnail"><img alt="1070002_562672267123508_1457711246_n" src="http://bnb.rtdemo.in/wp-content/uploads/rtMedia/users/1/2017/08/1070002_562672267123508_1457711246_n-320x240.jpg" /></div><div class="rtmedia-item-title">1070002_562672267123508_1457711246_n</div></a></li><li class="rtmedia-list-item media-type-photo"><a href="http://bnb.rtdemo.in/members/rtcamp/media/196/"><div class="rtmedia-item-thumbnail"><img alt="1077768_574691735921561_1937663202_o" src="http://bnb.rtdemo.in/wp-content/uploads/rtMedia/users/1/2017/08/1077768_574691735921561_1937663202_o-320x240.jpg" /></div><div class="rtmedia-item-title">1077768_574691735921561_1937663202_o</div></a></li><li class="rtmedia-list-item media-type-photo"><a href="http://bnb.rtdemo.in/members/rtcamp/media/195/"><div class="rtmedia-item-thumbnail"><img alt="1269439_588235337900534_543994072_o" src="http://bnb.rtdemo.in/wp-content/uploads/rtMedia/users/1/2017/08/1269439_588235337900534_543994072_o-320x240.jpg" /></div><div class="rtmedia-item-title">1269439_588235337900534_543994072_o</div></a></li><li class="rtmedia-list-item media-type-photo"><a href="http://bnb.rtdemo.in/members/rtcamp/media/194/"><div class="rtmedia-item-thumbnail"><img alt="1425339_624663634257704_1027455124_o" src="http://bnb.rtdemo.in/wp-content/uploads/rtMedia/users/1/2017/08/1425339_624663634257704_1027455124_o-320x240.jpg" /></div><div class="rtmedia-item-title">1425339_624663634257704_1027455124_o</div></a></li><li class="rtmedia-list-item media-type-photo"><a href="http://bnb.rtdemo.in/members/rtcamp/media/193/"><div class="rtmedia-item-thumbnail"><img alt="574448_627931267264274_1623989895_n" src="http://bnb.rtdemo.in/wp-content/uploads/rtMedia/users/1/2017/08/574448_627931267264274_1623989895_n-320x240.jpg" /></div><div class="rtmedia-item-title">574448_627931267264274_1623989895_n</div></a></li><li class="rtmedia-list-item media-type-photo"><a href="http://bnb.rtdemo.in/members/rtcamp/media/192/"><div class="rtmedia-item-thumbnail"><img alt="1479475_641326705924730_2140690181_n" src="http://bnb.rtdemo.in/wp-content/uploads/rtMedia/users/1/2017/08/1479475_641326705924730_2140690181_n-320x240.jpg" /></div><div class="rtmedia-item-title">1479475_641326705924730_2140690181_n</div></a></li><li class="rtmedia-list-item media-type-photo"><a href="http://bnb.rtdemo.in/members/rtcamp/media/191/"><div class="rtmedia-item-thumbnail"><img alt="10496980_834037979986934_7381864706292351566_o" src="http://bnb.rtdemo.in/wp-content/uploads/rtMedia/users/1/2017/08/10496980_834037979986934_7381864706292351566_o-320x240.jpg" /></div><div class="rtmedia-item-title">10496980_834037979986934_7381864706292351566_o</div></a></li><li class="rtmedia-list-item media-type-photo"><a href="http://bnb.rtdemo.in/members/rtcamp/media/190/"><div class="rtmedia-item-thumbnail"><img alt="10371991_735983233125743_1099191110001122713_n" src="http://bnb.rtdemo.in/wp-content/uploads/rtMedia/users/1/2017/08/10371991_735983233125743_1099191110001122713_n-320x240.jpg" /></div><div class="rtmedia-item-title">10371991_735983233125743_1099191110001122713_n</div></a></li><li class="rtmedia-list-item media-type-photo"><a href="http://bnb.rtdemo.in/members/rtcamp/media/189/"><div class="rtmedia-item-thumbnail"><img alt="11953214_986408378083226_1792479879971508079_n" src="http://bnb.rtdemo.in/wp-content/uploads/rtMedia/users/1/2017/08/11953214_986408378083226_1792479879971508079_n-320x240.jpg" /></div><div class="rtmedia-item-title">11953214_986408378083226_1792479879971508079_n</div></a></li><li class="rtmedia-list-item media-type-photo"><a href="http://bnb.rtdemo.in/members/rtcamp/media/188/"><div class="rtmedia-item-thumbnail"><img alt="12028786_997463730311024_7330599619966172915_o" src="http://bnb.rtdemo.in/wp-content/uploads/rtMedia/users/1/2017/08/12028786_997463730311024_7330599619966172915_o-320x240.jpg" /></div><div class="rtmedia-item-title">12028786_997463730311024_7330599619966172915_o</div></a></li><li class="rtmedia-list-item media-type-photo"><a href="http://bnb.rtdemo.in/members/rtcamp/media/187/"><div class="rtmedia-item-thumbnail"><img alt="12138521_1005232302867500_1356658540509767890_o" src="http://bnb.rtdemo.in/wp-content/uploads/rtMedia/users/1/2017/08/12138521_1005232302867500_1356658540509767890_o-320x240.jpg" /></div><div class="rtmedia-item-title">12138521_1005232302867500_1356658540509767890_o</div></a></li><li class="rtmedia-list-item media-type-photo"><a href="http://bnb.rtdemo.in/members/rtcamp/media/186/"><div class="rtmedia-item-thumbnail"><img alt="12291291_1029881267069270_3857549714715332088_o" src="http://bnb.rtdemo.in/wp-content/uploads/rtMedia/users/1/2017/08/12291291_1029881267069270_3857549714715332088_o-320x240.jpg" /></div><div class="rtmedia-item-title">12291291_1029881267069270_3857549714715332088_o</div></a></li><li class="rtmedia-list-item media-type-photo"><a href="http://bnb.rtdemo.in/members/rtcamp/media/185/"><div class="rtmedia-item-thumbnail"><img alt="12107850_1010391609018236_3353441216186528732_n" src="http://bnb.rtdemo.in/wp-content/uploads/rtMedia/users/1/2017/08/12107850_1010391609018236_3353441216186528732_n-320x240.jpg" /></div><div class="rtmedia-item-title">12107850_1010391609018236_3353441216186528732_n</div></a></li><li class="rtmedia-list-item media-type-photo"><a href="http://bnb.rtdemo.in/members/rtcamp/media/184/"><div class="rtmedia-item-thumbnail"><img alt="12108775_1013160898741307_4798423896980046413_n" src="http://bnb.rtdemo.in/wp-content/uploads/rtMedia/users/1/2017/08/12108775_1013160898741307_4798423896980046413_n-320x240.jpg" /></div><div class="rtmedia-item-title">12108775_1013160898741307_4798423896980046413_n</div></a></li><li class="rtmedia-list-item media-type-photo"><a href="http://bnb.rtdemo.in/members/rtcamp/media/183/"><div class="rtmedia-item-thumbnail"><img alt="12301643_1030342383689825_2997453155260951658_n" src="http://bnb.rtdemo.in/wp-content/uploads/rtMedia/users/1/2017/08/12301643_1030342383689825_2997453155260951658_n-320x240.jpg" /></div><div class="rtmedia-item-title">12301643_1030342383689825_2997453155260951658_n</div></a></li><li class="rtmedia-list-item media-type-photo"><a href="http://bnb.rtdemo.in/members/rtcamp/media/182/"><div class="rtmedia-item-thumbnail"><img alt="12342283_1033091046748292_1510000760887346972_n" src="http://bnb.rtdemo.in/wp-content/uploads/rtMedia/users/1/2017/08/12342283_1033091046748292_1510000760887346972_n-320x240.jpg" /></div><div class="rtmedia-item-title">12342283_1033091046748292_1510000760887346972_n</div></a></li><li class="rtmedia-list-item media-type-photo"><a href="http://bnb.rtdemo.in/members/rtcamp/media/181/"><div class="rtmedia-item-thumbnail"><img alt="17621825_1419797008077692_3710591700028356730_o" src="http://bnb.rtdemo.in/wp-content/uploads/rtMedia/users/1/2017/08/17621825_1419797008077692_3710591700028356730_o-320x240.jpg" /></div><div class="rtmedia-item-title">17621825_1419797008077692_3710591700028356730_o</div></a></li><li class="rtmedia-list-item media-type-photo"><a href="http://bnb.rtdemo.in/members/rtcamp/media/179/"><div class="rtmedia-item-thumbnail"><img alt="17991046_1464104646980261_28608819535812972_n" src="http://bnb.rtdemo.in/wp-content/uploads/rtMedia/users/1/2017/08/17991046_1464104646980261_28608819535812972_n-320x200.jpg" /></div><div class="rtmedia-item-title">17991046_1464104646980261_28608819535812972_n</div></a></li><li class="rtmedia-list-item media-type-photo"><a href="http://bnb.rtdemo.in/members/rtcamp/media/180/"><div class="rtmedia-item-thumbnail"><img alt="16819134_1382400998483960_9137307927416350795_o" src="http://bnb.rtdemo.in/wp-content/uploads/rtMedia/users/1/2017/08/16819134_1382400998483960_9137307927416350795_o-320x240.jpg" /></div><div class="rtmedia-item-title">16819134_1382400998483960_9137307927416350795_o</div></a></li><li class="rtmedia-list-item media-type-photo"><a href="http://bnb.rtdemo.in/members/rtcamp/media/178/"><div class="rtmedia-item-thumbnail"><img alt="16835776_1382212198502840_8821004107030885859_o" src="http://bnb.rtdemo.in/wp-content/uploads/rtMedia/users/1/2017/08/16835776_1382212198502840_8821004107030885859_o-320x240.jpg" /></div><div class="rtmedia-item-title">16835776_1382212198502840_8821004107030885859_o</div></a></li><li class="rtmedia-list-item media-type-photo"><a href="http://bnb.rtdemo.in/members/rtcamp/media/177/"><div class="rtmedia-item-thumbnail"><img alt="12356955_1035771926480204_8165772503309037066_o" src="http://bnb.rtdemo.in/wp-content/uploads/rtMedia/users/1/2017/08/12356955_1035771926480204_8165772503309037066_o-320x240.jpg" /></div><div class="rtmedia-item-title">12356955_1035771926480204_8165772503309037066_o</div></a></li><li class="rtmedia-list-item media-type-photo"><a href="http://bnb.rtdemo.in/members/rtcamp/media/176/"><div class="rtmedia-item-thumbnail"><img alt="18519906_1471840056206720_3642473362067526396_n" src="http://bnb.rtdemo.in/wp-content/uploads/rtMedia/users/1/2017/08/18519906_1471840056206720_3642473362067526396_n-320x227.jpg" /></div><div class="rtmedia-item-title">18519906_1471840056206720_3642473362067526396_n</div></a></li><li class="rtmedia-list-item media-type-photo"><a href="http://bnb.rtdemo.in/members/rtcamp/media/175/"><div class="rtmedia-item-thumbnail"><img alt="18557519_1474307482626644_8470389049066135264_n" src="http://bnb.rtdemo.in/wp-content/uploads/rtMedia/users/1/2017/08/18557519_1474307482626644_8470389049066135264_n-320x240.jpg" /></div><div class="rtmedia-item-title">18557519_1474307482626644_8470389049066135264_n</div></a></li></ul></div>
excerpt options: Array
(
    [ending] => &hellip;
)

#7 @bhargavbhandari90
10 months ago

  • Keywords reporter-feedback added

#8 @DJPaul
10 months ago

  • Milestone changed from Awaiting Review to Under Consideration

@r-a-y are you following up on this?

#9 @bhargavbhandari90
8 months ago

@DJPaul @r-a-y Any updates on this?

#10 @DJPaul
8 months ago

  • Milestone changed from Under Consideration to 3.0

I was hoping we could re-sync this function from CakePHP's utility/text/truncate(), but ours has diverged too far to make that easy.

#11 @DJPaul
8 months ago

I would dearly like to understand where the logic in this is breaking, but it's beaten me so far. The issue is that $preceding_tag['start'] sometimes equals zero, and $truncate[-1] is unset.

A similar patch I have done is https://gist.github.com/0d4ecd6d8d7b7c1f981ee9834c2352a6

The smallest reproducible example that I've found which triggers this behaviour (I am testing via wp shell) is:

<b><a>1234567890123456789012345678901234567890123456</a></b><b><a>1234567890123456789012345678901234567890123456</a></b><b><a>1234567890123456789012345678901234567890123456</a></b><b><a>1234567890123456789012345678901234567890123456</a></b><b><a>1234567890123456789012345678901234567890123456</a></b>

The length of the strings isn't random, and the HTML tags are required (though they can be any actual tag). I suspect it's something to do with the multibyte string replacement code/regex, but I can't prove it.

If no-one figures this out properly by early January -- and by that, a description with a unit test -- I'll put one of these patches in for 3.0, but obviously a test makes it more likely we don't break it in the same way in the future.

Last edited 8 months ago by DJPaul (previous) (diff)

#12 @DJPaul
5 months ago

  • Keywords needs-patch needs-unit-tests added; needs-testing has-patch reporter-feedback removed
  • Milestone changed from 3.0 to Awaiting Contributions
Note: See TracTickets for help on using tickets.