Jump to content

Call to undefined method DirectoryIterator::getExtension()


Outcydaz
 Share

Recommended Posts

Hello All,

I have an issue editing certain pages with specific templates. I noticed this issue after migrating from MAMP to a production server. Not sure if there's a relation there but just had to mention it.

'Error: Call to undefined method DirectoryIterator::getExtension() (line 104 of /var/www/vhosts/.../httpdocs/wire/core/Pageimages.php) 
This error message was shown because you are logged in as a Superuser. Error has been logged.'
 
When line 104 in Pageimages.php is commented out i'm able to edit the pages successfully.
 
Any help or information will be appreciated.
 
PW Version 2.5.25 DEV
 
Link to comment
Share on other sites

:() You're right! Once that was upgraded problem went away. Thank you.

Out of curiosity why would every other aspect of the site work just fine on 5.3.5.

There aren't any intentional restrictions on a PW site working on an older version of PHP, but if a required method etc is not available, then there will be a failure. I am surprised you didn't get a warning about it when you initially installed PW though.

  • Like 1
Link to comment
Share on other sites

  • 3 months later...
  • 8 months later...

Hi there,

we got the same issue (Processwire 2.7.2 / PHP 5.3.3) and made a workaround by commenting out the whole block "foreach(new DirectoryIterator($this->path()) as $file…" in PageImages.php.   (line 100 - line 130)

Now the backend works, can you tell us what this section does?

or if it will break something crucial…

Are the some other features in Processwire which are not ok with our Versions?

since we cannot upgrade php on our live-server for the time being we really need this workaround.

should this be too fragile, we will probably try to downgrade processwire on our production-server

best,

phi.l & tom

Link to comment
Share on other sites

Hi @Tom Walcher and welcome to the forums.

It is for getting variations of an image - cropped, resized, etc. So based on a quick look, you probably won't see these variations listed in your images field. Not ideal, but maybe not critical for you needs - hard to say.

The getExtension method for DirectoryIterator was added in PHP 5.3.6 so that is your key issue. There are other places it is used in the PW core though too: https://github.com/ryancramerdesign/ProcessWire/search?utf8=%E2%9C%93&q=%22-%3EgetExtension%22

So you might have other issues when viewing log files through Setup > Logs or dealing with multi-language stuff. It actually wouldn't be hard at all to replace this method with another approach to getting the file extension, but given that PHP 5.3.3 is 6 years old I think you might be better off hassling your hosting provider to update their system :)

  • Like 2
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
 Share

×
×
  • Create New...