Skip to content

1.0.0b6

Latest
Compare
Choose a tag to compare
@boenrobot boenrobot released this 22 May 15:51

Util stuff, mostly.

  • BREAKING CHANGES:
    • Removed all $mode arguments from all Countable implementations (turns out no stable 5.6+ releases uses it...), and the COUNT_RECURSIVE implementations (which were mostly useless anyway). Util::count() has the $query argument as its first one, and a new $from argument as a second one.
    • All Util CRUD methods throw RouterErrorException when the router returns an error. Previously, you'd need to inspect the returned value to check if there's an error.
    • Util::edit() is no longer an alias of Util::set(). It's now its own method that can modify or unset a single specified property.
    • Util::fileGetContents() now throws RouterErrorException if the file doesn't exist or if there are other problems with getting its contents. Previously, it returned FALSE for such cases.
    • Util's escapeValue(), escapeString(), parseValue(), prepareScript() and appendScript() methods are now in their own new class called "Script", with the last two now being called just prepare() and append().
    • Script::escapeValue() now converts DateTime objects into a string having the "M/d/Y H:i:s" format (used across RouterOS), or just "M/d/Y" if the time is exactly midnight, and the timezone is UTC. The old behaviour can be achieved by "manually" adding the DateTime to new DateTime('@0').
  • New Util methods:
    • comment()
    • getCurrentTime()
    • newRequest()
  • Script::escapeString() no longer escapes bytes above 0x7F. This means that parameter string values are now influenced by charset settings, and thus no additional conversion is necessary. A new second argument can be set to TRUE to escape all bytes, including the previously untouched ASCII alphanumeric characters and underscores.
  • Stream parameters in Script::append() (and inherently, Script::prepare() and Util::exec()) now have ALL bytes escaped.
  • Script::escapeValue() converts NULL to "nil" instead of "nothing".
  • The $params array in Script::append() can declare variables with a value of type "nothing" by using numeric keys, and the variable names as values.
  • Script::parseValue() now supports letter notation for time (1h2m3s), not just double colon notation (01:02:03), modeled after RouterOS. Related to that is also that leading zeroes, and zero minutes and seconds are now optional (e.g. "1:" is a valid way of saying 1 hour). Sub-second information is rounded up to the nearest second on current PHP versions (future versions are expected to support sub-second information in DateInterval by allowing seconds to be a double; The code currently attempts to give DateInterval a double, falling back to rounding to a second).
  • Script::parseValue() now recognizes dates in the "M/d/Y H:i:s" format (used across RouterOS), and turns that into a DateTime object for that time (or midnight in UTC if the time part is omitted).
  • Util::getAll() now throws a NotSupportedException if the arguments "follow", "follow-only" or "count-only" are used. The first two, because PHP would hang (since Client::sendSync() is used under the hood), and the last one because it's unredable in the returned output (use Util::count() instead).
  • Util::setMenu() can now go back to the root menu.
  • Util::exec() and stream valued arguments in both Util and Client no longer cause a hang when using charset conversion.
  • Util::get() can now accept a query as an argument for $number
  • Util::get() can have $valueName set to NULL (as is now by default), in which case all properties are retrieved in an array, parsed with Script::parseValueToArray().
  • Util::get() no longer fallbacks automatically with a "print" request for buggy versions. You may "manually" call Util::getAll() if you suspect that's an issue.
  • Util::find() now works even when the underlying Client streams responses.
  • Util::move()'s second argument $destination is now optional, and without it (or if set to NULL), the item is moved at the bottom of the menu.
  • Client::login() consumes the !done or !fatal response even when called on an already logged in connection.
  • Client::sendAsync() no longer throws an exception if a request is canceled multiple times by the returned value of a callback.
  • The console now checks whether PEAR2_Console_CommandLine is installed, ensuring better error messages when this package is installed without its optional dependencies.