Jump to content

ProcessWire 2.3 features


ryan

Recommended Posts

Enhanced debug mode

The dev branch also includes an enhanced debug mode in the admin. It's all been cleaned up to look better and provide more info. It also includes a new section that outlines all of the runtime attached hooks currently active in the system:

post-2-0-29285900-1367352958_thumb.png

  • Like 11
Link to comment
Share on other sites

I've got this feeling that hooks debug section is going to be my new best friend. That information could have prevented couple of very nasty situations already. Glad to have it here now, awesome stuff Ryan! :)

  • Like 3
Link to comment
Share on other sites

That also mean from now on PW doesn't work with prior php 5.3? I updated PW and got an error, but nothing logged or indicating what the error is. I finally also updated to php 5.3 and installed fresh PW and it now works. I'm also for going forward and php 5.3+ is cool, but there's some hostings that still run ~5.2 and I won't be able to update from now on, until they update php.

Edit: just seen my hoster has updated and I can run php in 4 different versions.  O0

Link to comment
Share on other sites

Ok, when I have php 5.3.8 with latest dev. I can't login and get this error on login page (login form isn't visible)

Compile Error: 
Can't inherit abstract function ConfigurableModule::__get() (previously declared abstract in WireHookable) (line 32 of /[removed]/wire/modules/Markup/MarkupCache.module) 
 
When I set php to 5.4.10 it works again.
Link to comment
Share on other sites

Soma, I did a quick test with PHP 5.3.10 + latest PW dev and my test site seems to be working ok, login works and so on. But there's no MarkupCache in use there, if that has anything to do with your problem (the error message doesn't necessarily have anything to do with MarkupCache being in use or not, I think).

Maybe some cache issue once again? site/assets/cache/Modules.* or APC?

Link to comment
Share on other sites

That also mean from now on PW doesn't work with prior php 5.3?

It should still work fine on PHP 5.2. You won't be able to use anonymous functions, but ProcessWire itself doesn't have any PHP 5.3 requirements yet. I'm thinking we shouldn't have that requirement until the next major version (PW 2.4). 

Can't inherit abstract function ConfigurableModule::__get() (previously declared abstract in WireHookable) (line 32 of /[removed]/wire/modules/Markup/MarkupCache.module) 

The error you are running into does sound a lot like a opcode cache error. Though it also could be a PHP 5.3.8 bug–it sounds like PHP doesn't like the fact that MarkupCache implements two interfaces that require a __get() method. That's not actually a problem, but will keep an eye out if anyone else runs into it. 

Link to comment
Share on other sites

ryan, on 02 May 2013 - 15:55, said:

It should still work fine on PHP 5.2. You won't be able to use anonymous functions, but ProcessWire itself doesn't have any PHP 5.3 requirements yet. I'm thinking we shouldn't have that requirement until the next major version (PW 2.4). 

After updating to latest dev all my local installs on php 5.2 stopped working without any error, well just the general

"Unable to complete this request due to an error."

No error logged in PW or in PHP. So I'm kinda lost here to what the problem might be. 

Link to comment
Share on other sites

I just tried upgrading a PHP 5.2.17 install and ran into the same issue as you did. Though the errors got logged for me, and I'm not clear why PHP 5.2 triggers these errors that PHP 5.3 doesn't, but it was easy to fix. I've pushed a couple of small fixes to dev so that it should work with 5.2 again. 

  • Like 1
Link to comment
Share on other sites

  • 2 weeks later...

A little bit of new fun stuff on the 2.3 dev branch: 

Anonymous functions and hooks

You can now use PHP 5.3+ anonymous functions when attaching hooks. All the syntax below will work either from your template files, modules, or any Wire derived class. If using outside of template files or Wire-derived classes, then replace $this with wire(). Though anywhere that you can use $this you can also use wire(), so syntax is also a matter of preference. 

I am testing these Anonymous functions and it seems to work on my php 5.4.6 installation, but giving error on 5.3.10. This is what I receive when trying simple hook init with anonymous function:

Error: Using $this when not in object context

This is the code that is generating the error:

$this->addHookBefore('InputfieldPage::findPagesCode', function($event) {
	$page = $this->pages->get($this->input->get("id"));
	$event->arguments(0, $page); 
});

// Yes, findPageCode is not hookable yet, but I have made local modification to it

These two installations are on two different servers, so it might be something else than PHP version.

Link to comment
Share on other sites

Ok, changing the code to this makes it work in 5.3 also:

$this->addHookBefore('InputfieldPage::findPagesCode', function($event) {
  $page = wire('pages')->get(wire('input')->get("id"));
  $event->arguments(0, $page);
});

It seems $this was removed from closures at some point (https://wiki.php.net/rfc/closures/removal-of-this) but introduced again (since it works in 5.4).

  • Like 1
Link to comment
Share on other sites

  • 5 years later...
22 hours ago, iNoize said:

Hello, 

how to fix the sitemap then?  The old Paths works fine but in the sitemap.xml  are the new paths and generate 404 Errors. 

Is it possible to generate also the old paths in there ? 

 

@iNoize, I cannot get the context between your question and this more then six years old thread. (?)

If you have posted here by accident, please tell us and I/we can move your post to the right direction.

Link to comment
Share on other sites

  • 2 years later...

Hi i've recently changed a bulk of pages using the API for name-id to name-lastname. Only to notice that all the old URL don't work anymore even though the module was installed. 

Is there a way to add to loop through the pages and set a custom redirect through the API? something like below (of course not a correct code)?

foreach($team as $team_member){
	$team_member->redirect($team_member-name.'-'.$team-member->id);
}

 

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...