WordPress.org

Make WordPress Core

Opened 3 years ago

Closed 3 years ago

Last modified 3 years ago

#31116 closed defect (bug) (fixed)

Infinite loop in the media load page, media-models.min.js

Reported by: Veritaserum Owned by: wonderboymusic
Milestone: 4.2 Priority: normal
Severity: normal Version: 4.1
Component: Media Keywords: reporter-feedback
Focuses: ui, administration Cc:

Description

The following bug causes infinite loop in the media library grid:

e.paged=Math.floor(this.length/e.posts_per_page)+1
if this.length = 159;
and e.posts_per_page = 40;
you will always return a e.paged = 4;

How is this done, the math before adding one is 3.975 at flooring comes to 3 then add 1.

Resolve this with Math.round(this.length/e.posts_per_page)+1 . This is the only way to be sure that the paged number is safe and will not repeat.

Change History (18)

#1 @SergeyBiryukov
3 years ago

  • Focuses accessibility removed
  • Milestone changed from Awaiting Review to 4.2

#2 follow-up: @SergeyBiryukov
3 years ago

Related: #30276

#3 @SergeyBiryukov
3 years ago

  • Summary changed from Infunitum loop in the media load page, media-models.min.js to Infinite loop in the media load page, media-models.min.js

#4 in reply to: ↑ 2 @Stagger Lee
3 years ago

Replying to SergeyBiryukov:

Related: #30276

Thanks again. This solved my last standing, and unpredictable, problems.

#5 @Stagger Lee
3 years ago

I dont know if this problem has something to to with this here. I changed on this website too this part of code and get almost 100% working sorting when making galleries.
Only small problem now (tested several times) is that first image I marked/clicked on, when selecting many od them, is allways FIRST image in galleries. But, I can live with that pitty one problem. Other are now sorted well as they sholud be.
You will maybe check it, here is link to forum topic:

https://wordpress.org/support/topic/media-manager-shuffle-images-all-the-time?replies=10

Trac entry is here: #30640

Last edited 3 years ago by SergeyBiryukov (previous) (diff)

#6 @SergeyBiryukov
3 years ago

#30276 was marked as a duplicate.

#7 @Stagger Lee
3 years ago

On one website 1071 images are reported in media library, modal box in post editing shows 1066.
On second website 698 images are reported in media library, modal box in post editing shows 681.

I will check all this following days a bit better.

#8 @wonderboymusic
3 years ago

  • Owner set to wonderboymusic
  • Resolution set to fixed
  • Status changed from new to closed

In 31406:

Use Math.round() instead of Math.floor() when determining page of attachments to query in wp.media.model.Query.sync.

This was causing an infinite loop of AJAX requests - so.... good catch!

Props Veritaserum.
Fixes #31116.

#9 @wonderboymusic
3 years ago

#31346 was marked as a duplicate.

#10 @Stagger Lee
3 years ago

Can we get some clear info if it is fixed in some version ? v4.1, v4.2 ?
As it is now I have no clue if I have to do it manually or not. Or maybe I cannot decode trac system here.

#11 @DrewAPicture
3 years ago

Hi @stagger-lee,

As I mentioned in comment:10:ticket:30276, this issue has been fixed and will ship with the next version (4.2).

#12 @dariodev
3 years ago

  • Resolution fixed deleted
  • Status changed from closed to reopened

I have the same issue on two websites but this fix does not solve.
On my first website I have 473 items in Media Library but Grid will display only first 20 images (mode list will display all). I applied "Math.round" and now Media Grid display 40 images.
On the site two (460 items) - I installed 4.2-alpha-31671 and now Media Grid display 41 images.

Last edited 3 years ago by dariodev (previous) (diff)

#13 @wonderboymusic
3 years ago

  • Keywords reporter-feedback added

@dariodev, I have 500 items in my media grid, and everything is working fine.... (just checked)

Can you check your JavaScript console for errors? Do you have all plugins turned off?

#14 @Stagger Lee
3 years ago

@wonderboymusic, I have one question. Related to this too, but more general.
Why dont you roll fixes like this with WordPress automatic updates ?

I dont see any possible way you could ruin someones website if you do it.

#15 @wonderboymusic
3 years ago

  • Resolution set to fixed
  • Status changed from reopened to closed

No feedback - please test using trunk, but this works for me.

@Stagger Lee - The automatic updates will happen if you are using bleeding-edge nightlies. Sometimes, fixes like this are rolled into minor releases. For now, we have to wait for a bundle of fixes to roll with a major or minor release. One day, we would like to be more like Chrome.

#16 @Pinoss
3 years ago

@wonderboymusic I try a lot of methods (media-models.min.js file, htacces, several functions.php snippets, deactivating plugins, changing wp-config.php) and there is no way to solve this problem. Any idea, trick or additional hack ?

Thanks in advance

Last edited 3 years ago by Pinoss (previous) (diff)

#17 follow-up: @boeloeboeloe
3 years ago

Updated to wordpress 4.2.1 where this problem must be fixed.
But the problem is still there...

#18 in reply to: ↑ 17 @SergeyBiryukov
3 years ago

Replying to boeloeboeloe:

Updated to wordpress 4.2.1 where this problem must be fixed.
But the problem is still there...

This ticket was closed on a completed milestone, please create a new one if there's still an issue. Make sure to include the steps to reproduce on a clean install.

Note: See TracTickets for help on using tickets.