Please upgrade here. These earlier versions are no longer being updated and have security issues.
HackerOne users: Testing against this community violates our program's Terms of Service and will result in your bounty being denied.

Function eregi() is deprecated

edited January 2010 in Vanilla 2.0 - 2.8
I get this error when freshly installed Vanilla on my server and signing up as a new user.

Deprecated: Function eregi() is deprecated in C:\wamp\www\xfm\library\Framework\Framework.Class.Validator.php on line 93

Anyway to fix it?

Comments

  • MarkMark Vanilla Staff
    Your server must be running php 5.3.0+. I tried looking for a replacement for it, but couldn't find a quick fix. Maybe @Dinoboff can help?
  • LincLinc Admin
    edited January 2010
    preg_match('/pattern/i', $subject);
    The 'i' after the pattern makes it case-insenitive. All the POSIX functions are deprecated in favor of their Perl-compatible cousins.

    Note that you probably can't copy/paste your pattern from the eregi function; it'll probably have to be re-written in Perl syntax (linked).
  • Most call to ereg functions have been removed by @subjunk in 1.1.10. But some were missed. It's probably fixed in the trunk now.

    Also, we should turn off warning message on production and probably the display of any error message. On production they should only appear in the log.
  • edited January 2010
    Thanks guys, this was an easy fix to achieve, out with the old in with the new.

    For anyone who needs a quick fix:
    Just replace on line 93 of root\library\Framework\Framework.Class.Validator.php

    if(!eregi($this->ValidationExpression, $this->Value)) {
      with:
    if(!preg_match("/{$this->ValidationExpression}/i", $this->Value)) {

    Thanks @ Lincoln I didn't know about the 'i'.
  • MarkMark Vanilla Staff
    Another thing you can do is add this to your functions file:
    if (!function_exists('eregi')) {
    function eregi($Expression, $Value) {
    return preg_match("/{$Expression}/i", $Value);
    }
    }
Sign In or Register to comment.