WP integration broken & possible fix

Zenphoto v. 1.4.5.7 - WP integration broken & possible fix
@ sbillard/acrylian
NOT A "BUG":
Fatal error: Cannot redeclare build_query() in... WordPress/Includes/functions.

I really appreciate all the work you have put into Zenphoto and love using it!

I do know that you are not usually concerned about problems/conflicts with WordPress, but it would be nice if I could retain the functionality you intended when you revised the zp-core/functions-basic.php to add some features (sometime after vers 1.4.4.8, which works fine)
.
I have been using the "Ruzee hack" for years and have a lot of effort invested in customizing your default theme to work with WP, and am very happy with the results.

So, my question is... is there some way for you (or me) to rewrite a couple of your newer functions so as to _NOT_ use the term "build_query"?

Any feedback you care to give will be greatly appreciated. References to the two functions follow:

Zenphoto v. 1.4.5.7 - PATH: zp-core/functions-basic.php

==/ STARTING ON LINE 1056 [note: "createsa" is your typo, not mine]
/**
* createsa query string from the array passed
* @param array $parts
* @return string
* COMMENT-OUT BY NEIL 2013-1217 ************************************************************
*/
/**
`//function build_query($parts) {

// $q = '';

// foreach ($parts as $name => $value) {

// $q .= $name . '=' . $value . '&';

// }

// return substr($q, 0, -1);

}`
*/

==/ LINE 1138
/*
` $parts['query'] = build_query($pairs);`
* * COMMENT-OUT BY NEIL 2013-1217 ************************************************************
*/

Thanks in advance for your time!
Neil - a big fan of Zenphoto

Comments

  • acrylian Administrator, Developer
    The note about broken integration mainly refer to the "zenphoot as a plugin" way that cannot work as WP (other than ZP) passes its theme files through scripts which "kills" all global contexts in Zenphoto.

    The problem with your suggestion is that most likely there will always be functon names that conflict with other CMS. It is not WP itself (I am using it as well to build websites). There are other CMS ZP is used with. If we start to change things for other CMS where do we stop?

    Best you open a ticket pointing here so the chief developer may decide to do this. I guess a simple "zp_" prefix would do it.
  • @ acrylian
    Thanks for your quick and thoughtful response. I like the "zp_" prefix solution.

    It is 3:30 am my local, so I am not at my best. I will be happy to open a ticket, but it is not clear (to me) from your post where "here" is :(

    I will be not back at the computer for several hours and look forward to further instructions.

    Thx,

    Neil
  • acrylian Administrator, Developer
    See the top of our site the Bugtracker link, that's it. Info about how and what to do via the "get involved" link right next to it. (Info is also in the forum rules).
  • Of course, a simple `wp_` prefix to the wordpress function would also solve this issue.

    Your example is simply one of many issues that may occur. Changing names of functions is fraught with peril for our current users. If they have used the function then you have broken their code.

    No real simple solution. But anyway, the proper solution is to use name spaces, but of course that is a bit of implementation and needed by both scripts.
  • acrylian Administrator, Developer
    Of course, a simple wp_ prefix to the wordpress function would also solve this issue.
    Just that we are the dwarf and WP is the giant :-) But I actually agree.

    I guess namespaces would be something for 1.5 or so (this could solve even the issue we had with the ApiGen doc generator complaining about same named classes, right?).
  • @acrylian
    I have not yet opened a ticket. Pls advise if, based upon prior developer comments, a ticket is still needed re this matter.
  • acrylian Administrator, Developer
    The chief has the final word and as it sounds we probably won't change anything.
  • @acrylian
    I was hoping that the zp_ prefix was a possibility. Thanks for your time - I know that you are very busy. BTW, I have reverted to 1.4.4.8.
    Unless others have comments, I will consider this thread closed.
    Neil
  • Please understand that significant security fixes have occurred since the release you reverted to.

    The zp_ prefix would be possible, but of course that will break any code that uses the old function name. Since you are apparently the only one requesting this it seems not an advisable change. Break many for the sake of one. Besides which I am not at all sure that the change is all that will be needed to make things work. Last time I looked the way WP loaded plugins was in conflict with Zenphoto. Remember that Zenphoto is primarily a stand-alone application.

    Of course you can apply this change to your copy of the code. Be sure you find and change all references. But you will need to remember to keep applying it on each update.
  • acrylian Administrator, Developer
    @sbillard: What you describe is actually the issue with the "zenphoto as a plugin" way which does not work because WP loads all theme files via functions killing all ZP contexts.

    The ruzee way is actually the other way round including the WP header/footer stuff within a ZP theme. I have never used or tried this so I no knowledge what else might be the problem. If I use WP for a site I mainly use it standalone.

    @avidre: I have to agree to my colleague that you being the only reporter of this issue is not enough demand to change such a significant thing. Sometimes we have to change things that break things for users but those are important issues (a conflict with another standalone CMS is not really, as there are probably some with other CMS as well - people tried unsuccessfully a bridge with Joomla as far as I know). We try to keep this to the necessary minimum to not break that much. That is why themes often require only minimum updates with new versions. WP has a similar, even stricter development policy.
  • Hi, I wanted to chime in. I ended up in this thread because I ran into the same issue as the OP. I originally installed Zenphoto years ago in a volunteer project and created a custom theme based on the rest of the (very simple) website. So far so good, I'm very happy with Zenphoto. Now, to make the maintenance of the website easier for the people in charge I changed the site to a WP blog format. I had to re-install the latest version of Zenphoto and am now looking at integrating it again, since the old theme understandably no longer works. So where do I go to find information about the integration? The Zenphoto website, right? But it seems this is a non-subject for everybody else because several of the tutorial links are obsolete. The one I found walked me right into the error mentioned above - outdated as well. I'll keep trying to find more information.

    I apologize for this long-winded post, but I wanted to let you know that there is someone else trying to integrate with WP in a dynamic way (not faking a static header). This is frustrating because I took a look at what is out there for photo gallery plugins for WP and I don't like any of them. You guys spoiled me. I like Zenphoto best, except it does not integrate easily (as far as I can tell).
  • acrylian Administrator, Developer
    Sorry for your problems. But Zenphoto is considered a standalone CMS just like WordPress is and has even its own blog feature. We don't create it to be integrated with other CMS be it WP or any of the dozens others nor do we think we should limit our development by aiming that. WordPress integration was never a feature actually.

    All know resource regarding WordPress are here:
    http://www.zenphoto.org/news/integrating-zenphoto-into-wordpress-tutorials
    Of course all are third party so we don't know if they still work.

    Beside that the general instructions here still apply:
    http://www.zenphoto.org/news/integration-with-existing-sites-and-other-cms

    The "zenphoto as a plugin" way as mentioned does not work anymore because of a change in WordPress.
  • xaphod Member
    @all -- it is pretty easy to fix this, because there is (so far, as of ZP 1.4.6) only one collision with standard WP (3.9.1). Just edit zp-core/functions-basic.php, and change "build_query" twice (there are 2 instances in the file) to something else, like "zpbuild_query".

    @acrylian and other ZP devs -- one of the reasons integrating into wordpress is useful, is because there are very advanced professional wordpress blogsite templates which people (like me) are purchasing for upwards of $300. If these blogsites had been built on ZP, then i'd just have gone that direction. Sadly that's not possible. So, supporting WP integration will get you integrated into better-looking more professional websites... that's a good thing for ZP right?
    I don't know PHP well enough... doesn't it support some namespacing functionality to get around this issue?
  • xaphod Member
    update: here is my ZP-inside-WP integration -- http://tim.picturebrothers.ch/booth/
    The title of the page is broken, but that's my WP theme doing that :)
  • acrylian Administrator, Developer
    We probably can rename the function on the next occasion. But still there might be other parts that bite with other CMS. My statement above still stands that our primary concern is not to work with other CMS. We simply don't and can't test that as there is more - hard to believe :-) - than WP out there.

    Zenphoto does not use namespaces yet. We eventually will do in the future but since that would require a lot of not pressingly needed changes that is not a priority right now.

    We are aware that we need better themes. Still there is only so much time to do things. We can't do everything ourselves so we are dependent on others to contribute 3rd party ones (they even could sell).

    And if you ever created your own site design/theme you will know that this is some work. I know it is a bit out of fashion to create own designs or hiring someone to do so (which is more expensive thatn $300) but instead rely on ready-made themes. Well, you don't always get what you wish for, do you? ;-)
  • xaphod Member
    Hi Acrylian,
    Sure I completely understand. I just happened to discover that there was only 1 collision in my case, which was simple to fix, and I thought that'd be helpful for future folk to know.
    I completely respect that "some assembly is required" if one wants to hack zenphoto inside another system like WP.
    Keep up the great work.
  • acrylian Administrator, Developer
    Sure, and we really appreciate that you let us know. I just explained because I didn't know your background and these things are not clear to anyone always.
Sign In or Register to comment.