Jump to content

Recommended Posts

I had not seen that error before, but a little Googling and reading showed that it's popping up for others with other software.  Normally, PHP errors can be found with Google and see how others solve it.  My thought was that it was a string that needed to be cast, but i wasn't certain.  Most of the OSC code cast variables years ago, but addons don't have it.  Anyway, we both learned today and that's always a good thing. 


I'm not really a dog.

Share this post


Link to post
Share on other sites

Try this.  Did a little searching on StackOverflow and learned a little more.  Had to add the Hash class so I could experiment.  This yeilds an output now.

  function tep_random_name()
  {
    $letters = 'abcdefghijklmnopqrstuvwxyz';
    $dirname = '.';
    $length = floor(Hash::getRandomInt(16, 20));
    for ($i = 1; $i <= $length; $i++) {
      $q = floor(Hash::getRandomInt(1, 26));
      $dirname .= $letters[(int)$q];
    }
    return $dirname;
  }

 


I'm not really a dog.

Share this post


Link to post
Share on other sites

It only works when there's no z in the output.  I ran into this on another piece of Harald's code I was playing with.  I found a workaround, but it's not a good one and I'm not sure why it even works.  Putting a -1 after $q stops errors.

  function tep_random_name()
  {
    $letters = 'abcdefghijklmnopqrstuvwxyz';
    $dirname = '.';
    $length = floor(Hash::getRandomInt(16, 20));
    for ($i = 1; $i <= $length; $i++) {
      $q = floor(Hash::getRandomInt(1, 26));
      $dirname .= $letters[(int)$q-1];
    }
    return $dirname;
  }

 


I'm not really a dog.

Share this post


Link to post
Share on other sites

I was just talking about the hash functions used, but I don't really have an argument for it.  http://www.php.net/Hash

I just put the function into a test page and the errors went away after the (int) addition, but I was just testing the output of the function.  I did get the string offset errors at first.


I'm not really a dog.

Share this post


Link to post
Share on other sites

There are various functions around (e.g., tempnam, or possibly tmpfile) for creating unique temporary file names. It might be cleaner to use one of them. Also, when generating names, you have two problems:

  1. I don't see anything to prevent duplicates (unlikely, but still possible).
  2. Depending on who can see these names, some might be offensive. An easy way out of this to to drop the vowels and use only the 20 consonants.

Share this post


Link to post
Share on other sites
1 hour ago, Daniel204 said:

what about the PHP 7?

tried it, liked it


For a new install or if your store isn't mobile-friendly, get the community-supported responsive osCommerce (Phoenix).

here: on the official osc download page

Working on generalising bespoke solutions for Quickbooks integration, Easify integration and pay4later (DEKO) integration at 2.3.x

Share this post


Link to post
Share on other sites

Hi,

I had the same problem with my site after upgrading the server to php 7.  After upgraded from php7 all is good.

Have a nice day!

Edited by burt
remove spam url

Share this post


Link to post
Share on other sites

(At the risk of reviving an old thread, with a (perhaps) off-topic question ... )

Is there a problem with coding a shop to run under PHP 7.2, and actually running in under PHP 5.6?

The reason I ask is that I have several shop on my host's server. As I update each shop, I want to bring each up to be PHP 7.2 ready (even though my host currently only offers up to PHP 7.0), but leave all the shops at PHP 5.6 until all are upgraded. Will and PHP 7.2 specific code cause a problem under PHP 5.6?

TIA

M


Get the latest Responsive osCommerce CE (community edition) here .

Share this post


Link to post
Share on other sites

@ArtcoInc generally speaking, it shouldn't be a problem. There is syntax on 7-7.2 that isn't supported on 5.6 but you're probably not going to be using any of it in your new version... spaceships <=>, null coalescing ($action = $_GET['action'] ?? 'default'), anonymous classes, constant arrays and a bunch of other things that don't spring straight to mind.

The only bit of code I can think of that doesn't work across versions is something to do with error-handling on evals but you probably haven't got any of that anyway. The evaluation order in statements is the other way round (eg. when working out what $$class->$method($param[$$key]) means but that should have been fixed by putting in curly braces to make it expllicit in the statement.

The approach would be - get a set of code running without issue on 7 and then turn the version back down to 5.6 for a test.

hth


For a new install or if your store isn't mobile-friendly, get the community-supported responsive osCommerce (Phoenix).

here: on the official osc download page

Working on generalising bespoke solutions for Quickbooks integration, Easify integration and pay4later (DEKO) integration at 2.3.x

Share this post


Link to post
Share on other sites

Just updated my server to run PHP 7.3. Running live site now using it

No significant issues at all - just a Deprecated warning in PHPmailer which was easily fixed.

Various benchmarks suggest about a 10% speed improvement.

 

Share this post


Link to post
Share on other sites

I am using v2.3.4.

I guess I could replace the "boxes" with div based code but it would not change the hierarchy of the classes that caused the error.

Edited by bonbec
Spam link removed

Share this post


Link to post
Share on other sites
Posted (edited)

@BrockleyJohn @ArtcoInc @raiwa

Hi,

Anyone know how to solve the "undefined method objectInfo" error encountered in admin/catagories.php ? :

Fatal error: Uncaught Error: Call to undefined method objectInfo::objectInfo() in D:\wamp\www\admin\categories.php on line 775
Error: Call to undefined method objectInfo::objectInfo() in D:\wamp\www\admin\categories.php on line 775

Here is the class objectInfo :
 

  class objectInfo {

// class constructor
    function __construct($object_array) {
//      reset($object_array);
//      while (list($key, $value) = each($object_array)) {
	  foreach ($object_array as $key => $value) {
        $this->$key = tep_db_prepare_input($value);
      }
    }
  }
?>


Ok, I have found this fix https://github.com/gburton/CE-Phoenix/blob/master/admin/includes/classes/object_info.php?fbclid=IwAR0vd1Gx3ArEYkCm7SViCTKqHVlbl21vXmTbookJwjSjNMwf_nJxJ0Zl88s
 

<?php
/*
  $Id$
  osCommerce, Open Source E-Commerce Solutions
  http://www.oscommerce.com
  Copyright (c) 2003 osCommerce
  Released under the GNU General Public License
*/
  class objectInfo {
// class constructor
    function __construct($object_array) {
		  $this->objectInfo($object_array);
		}
    function objectInfo($object_array) {
      foreach($object_array as $key => $value) {
        $this->$key = tep_db_prepare_input($value);
      }
    }
  }
?>

 

Edited by milerwan

Osc v2.3.4 BS "custom"
PHP 7.3 compatible (710 modified files => o_O')

Share this post


Link to post
Share on other sites

@milerwan yes, use the version of the class from phoenix, frozen etc which has the proper fix for php7.

In this case you don't rename the constructor you add one and call the existing eponymous method because it's called directly.


For a new install or if your store isn't mobile-friendly, get the community-supported responsive osCommerce (Phoenix).

here: on the official osc download page

Working on generalising bespoke solutions for Quickbooks integration, Easify integration and pay4later (DEKO) integration at 2.3.x

Share this post


Link to post
Share on other sites

specificially:

function __construct($object_array) {
  $this->objectInfo($object_array);
}

 


For a new install or if your store isn't mobile-friendly, get the community-supported responsive osCommerce (Phoenix).

here: on the official osc download page

Working on generalising bespoke solutions for Quickbooks integration, Easify integration and pay4later (DEKO) integration at 2.3.x

Share this post


Link to post
Share on other sites
Posted (edited)
24 minutes ago, BrockleyJohn said:

@milerwan yes, use the version of the class from phoenix, frozen etc which has the proper fix for php7.

In this case you don't rename the constructor you add one and call the existing eponymous method because it's called directly.

@BrockleyJohn

Yes, thank you !

I have another issue from "checkout_shipping" page with strange errors.
Could you take a look on it, it is reported here :

NB: I have just tried to used Phoenix's "checkout_shipping.php" script too but same errors...

Thank for your help.

Edited by milerwan

Osc v2.3.4 BS "custom"
PHP 7.3 compatible (710 modified files => o_O')

Share this post


Link to post
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

×