Publisher does not support the Fluid field type. Please do not contact asking when support will be available.

If you purchased an add-on from expressionengine.com, be sure to visit boldminded.com/claim to add the license to your account here on boldminded.com.

Ticket: Pagination Links on Page 2+ Broken; PHP Error Line 954 ext.publisher.php

Status Resolved
Add-on / Version Publisher 1.2.2
Severity Critical
EE Version 2.7.2

Nick Benson

Mar 10, 2014

Upgraded to latest Structure/Publisher on an EE 2.7.2 build, and, pagination links on page 2+ of any section with pagination broke - the links generated on our production build are pointing to the staging server, and, the query strings are getting stripped away from the pagination links in our Low Search results area.

Initially I thought this was an issue with Structure, and had the following exchange with their support:

==== Start Structure Support Thread ====

Recently upgraded to Structure 3.3.14 (and Publisher 1.2.2) on our EE 2.7.2 install, and started running into an issue. When I set Publisher’s “Enabled Publisher” setting to “No,” the problem persisted, so, I’m positing it’s a Structure issue.

On page 2 and higher, pagination links all point to URLs our staging server (where the “run module updates” were run), rather than production. Furthermore, the contents of the query string on our Low Search results pages are getting lost on when viewing the pagination links on page 2 and above. All of the links, as far as I’ve seen so far, are working fine on page 1.

A few of the paginated sections have a pagination_base explicitly defined, but, that doesn’t appear to help with regards to this issue.

Paths to production URL’s are all defined in some conditionals in our config.php, and have been working reliably before this update; all other links on the site appear to be A-OK.

====

I would double check your system settings and config.php to make sure there
are no references to your staging site. Also, try clearing your caches,
Structure has to be getting those values from somewhere.

====

Cleared the EE cache on my dev build, and now I’m getting a Publisher error, which is odd, since I didn’t believe we were using any of EE’s caching mechanisms…

==== End Structure Support Thread ====

Link to thread there: http://structure.tenderapp.com/discussions/problems/6580-pagination-links-on-page-2-point-to-development-server-url

In any event, I did a Tools > Data > Clear Caching > All caches, and, in one of the sections with pagination (but not all of them) I’m seeing this:

Message: explode() expects parameter 2 to be string, array given
Filename: publisher/ext.publisher.php
Line Number: 954

Which is in the neighborhood of the pagination fix mentioned here:

https://boldminded.com/support/ticket/774

So, not sure what’s going on, exactly, but, that’s where we’re at. If EE 2.8.0 is stable enough for prime time, I think we could give upgrading a whirl, if it might help fix this, but, wouldn’t be my first choice at an attempt to resolve.

#1

Nick Benson

To clarify, clearing the cache didn’t resolve the staging URLs on production issue.

#2

BoldMinded (Brian)

Are you using Publisher Lite?

#3

Nick Benson

Negative; Publisher.

#4

BoldMinded (Brian)

And this is what the beginning of that function looks like in your version? https://www.evernote.com/shard/s9/sh/c328481e-b3c1-422c-a723-a59dbe25e91c/01917b3a8d536dfcfae8f151e292a7d2

#5

Nick Benson

Yes, although core_template_route starts on line 933 in the copy I’ve got; looks to match up otherwise…

<pre><code>public function core_template_route($uri_string) { $last_call = NULL;

    if (ee()->extensions->last_call)
    &#123;
        $uri_string = ee()->extensions->last_call;
        $last_call = $uri_string;
    &#125;

    // Don't muck with the URI or templates
    if (PUBLISHER_LITE && $last_call)
    &#123;
        return $last_call;
    &#125;

    if (PUBLISHER_LITE)
    &#123;
        return;
    &#125;

    $parts = explode('/', $uri_string);[/code]
#6

BoldMinded (Brian)

Change that explode line to this:

if (is_array($uri_string)) { $parts = $url_string; } else { $parts = explode(‘/’, $uri_string); }

#7

Nick Benson

Updated; New Error:

Message: Undefined variable: url_string Filename: publisher/ext.publisher.php Line Number: 956

Am I correct to assume it should be $parts = $uri_string, and not $url_string?

#8

BoldMinded (Brian)

Yes, sorry. uri_string. Make any difference?

#9

Nick Benson

Alright, have this in place now, and the PHP error is gone:

if (is_array($uri_string))
        {
            $parts = $uri_string; // changed from $url_string
        }
        else
        {
            $parts = explode('/', $uri_string);
        }

Still have the issue of the incorrect paths within the links though. Perhaps the path was cached somewhere? Have cache disabled and time set to 0, and am not using any template or tag caching.

#10

BoldMinded (Brian)

What do you mean the path is incorrect? What is it currently and what do you expect it to be?

#11

Nick Benson

We’re basically getting the {site_url} value for staging instead of production from the {pagination_url} tags in the {paginate} loop, but only on page 2 and beyond (if there’s a pagination segment in the URL of the template rendering the loop, it breaks, I think).

Our setup:

  • Dev: http://staging.example.com/~user/www/
  • Staging: http://staging.example.com/
  • Production: http://www.example.com/

On production, we’d want to get a link to this page:

  • http://www.example.com/news/P10/

Instead, we’re getting this:

  • http://staging.example.com/news/P10/

When I’m in my dev account (shares same DB as staging) I’m also getting the staging URL’s.

Hopefully that makes sense; the presence of the pagination_base parameter doesn’t make a difference, if that’s of any use.

#12

BoldMinded (Brian)

Thats definitely a configuration issue somewhere. Did you turn off Publisher’s cache? Try re-ordering the Structure tree on production, just drag something to a different spot, then drag it back. It’ll force a rebuild of the pages.

#13

Nick Benson

  • Publisher’s cache is disabled; set the time to 0 to be safe.

  • Re-ordered a page in Structure.

  • Cleared all caches in EE for good measure, although we’re not using any of EE’s tag/template caching.

… and still broken, unfortunately.

We are running a custom config with environment detection and path setting, but, it’s been working without any issues for a quite a while, and, our paths are fine everywhere except for the pagination links on page 2+.

#14

BoldMinded (Brian)

In ext.publisher.php there is a $debug var at the top. Set to TRUE and reload the page, then set it back to false and save it so other users dont see the debugging output. It’ll dump all the site pages arrays including the site_url.

#15

Nick Benson

The output there looks A-OK:

array(2) { [“open”]=> array(5) { [1]=> array(1) { [1]=> array(3) { [“uris”]=> array(710) { [524]=> string(8) “/contact”

… and so on. Where the URL is getting dumped out, I’m seeing the correct path: http://staging.example.com/~user/www/

There aren’t any problems with {site_url} anywhere; I was attempting to explain, perhaps poorly, that the “value of {site_url}” is what appears to be incorrect in the pagination links that are being generated.

Again, the issue is only with the value of {pagination_url}. {pagination_url} is pointing to an address on the staging server, not the production server. This only happens when the template is rendered at a URL including a pagination segment - /foo/ will build the {pagination_url} links just fine; when you go to /foo/P10, then all of the {pagination_url} links will point to the wrong server.

#16

BoldMinded (Brian)

Any other pagination related add-ons? Publisher doesn’t touch pagination specific code. If you disable Publisher the link is correct?

#17

Nick Benson

Per my original post to Structure’s support: “When I set Publisher’s “Enabled Publisher” setting to “No,” the problem persisted, so, I’m positing it’s a Structure issue.”

Tried disabling Publisher again, still no dice.

As far as other add-ons that might be interacting with pagination or pagination segments, we’ve got the following:

  • Seg 2 Cat (I think this has some category ID tag that URL helper didn’t, which is why I’ve got both)
  • URL Helper
  • Page Number ( https://github.com/tyssen/Page-Number.ee_addon )
  • Structure

I think that’s it; the pagination loops themselves are pretty vanilla.

The other dev here noticed that the page URL arrays in exp_publisher_site_pages contains the staging URL, and that there were potentially similar issues getting discussed here? - https://boldminded.com/support/ticket/503

Thoughts, any?

#18

BoldMinded (Brian)

The URL saved in that table may be incorrect, but if you look at publisher_site_pages.php line 821 or so in the get() method, near the end of it you’ll see that the URL is set based on the config setting, which is what you saw when turning on the $debug variable.

You can look in the Publisher_session.php file in the set_site_pages method and do some var_dump()’ing in there to see if the url is incorrect.

#19

Nick Benson

To followup, the place where the staging URL shows up in the DB, at least in plain text, is within exp_publisher_site_pages (for some reason I ran the update for Publisher while in the control panel for staging, and not development; while there are paths elsewhere in the DB, they’re all paths to my dev folder there).

I also updated my config.php to change the path to the staging server to see if that would alter the behavior - it didn’t.

But… when I uploaded an older version of Structure back to the server, the pagination links were fixed, so, appears this is on Structure’s end (possibly having trouble with data from Publisher, as I don’t know where else the staging URL could be coming from).

Appreciate the back and forth on this; at least we got that PHP bug fixed 😊

#20

BoldMinded (Brian)

No problem. Let me know what Jack comes back about this.

Login to reply