/** * Adds a model package and base class path for including classes and/or maps from. * * @param string $pkg A package name to use when looking up classes/maps in xPDO. * @param string $path The root path for looking up classes in this package. * @param string|null $prefix Provide a string to define a package-specific table_prefix. * @return bool */ public function addPackage($pkg= '', $path= '', $prefix= null) { $added= false; if (is_string($pkg) && !empty($pkg)) { if (!is_string($path) || empty($path)) { $this->log(xPDO::LOG_LEVEL_ERROR, "Invalid path specified for package: {$pkg}; using default xpdo model path: " . XPDO_CORE_PATH . 'om/'); $path= XPDO_CORE_PATH . 'om/'; } if (!is_dir($path)) { $this->log(xPDO::LOG_LEVEL_ERROR, "Path specified for package {$pkg} is not a valid or accessible directory: {$path}"); } else { $prefix= !is_string($prefix) ? $this->config[xPDO::OPT_TABLE_PREFIX] : $prefix; if (!array_key_exists($pkg, $this->packages) || $this->packages[$pkg]['path'] !== $path || $this->packages[$pkg]['prefix'] !== $prefix) { $this->packages[$pkg]= array('path' => $path, 'prefix' => $prefix); $this->setPackageMeta($pkg, $path); } $added= true; } } else { $this->log(xPDO::LOG_LEVEL_ERROR, 'addPackage called with an invalid package name.'); } return $added; }
$prefix = 'xyz_'; $packagename = 'moarDataStuff'; $classname = 'Grows'; $packagepath = $modx->getOption($packagename . '.core_path', NULL, $modx->getOption('core_path') . 'components/' . $packagename . '/'); $modelpath = $packagepath . 'model/'; // The variable has been swapped out for a static string to make sure. $modx->addPackage('moarDataStuff', $modelpath, $prefix); $grow = $modx->getObject( $classname, array( 'grow_id' => $_GET['id'] ));
$this->log(xPDO::LOG_LEVEL_ERROR, 'addPackage called with an invalid package name: '.$pkg);
This question has been answered by markh. See the first response.
I've never seen anything like that. It's frustrating when you don't trust your server. You might look at the server's error logs.Nothing was in the error logs about it. I started getting mem allocation errors in excess of 512MB which made no sense either.
That's really weird. What happens when you modify the addPackage function to do a var_dump before the if check? The benefit of var_dump is that it shows the type of the variable, while putting it in the log statement will cast it to a string.After I had them reset the server it worked fine. Go figure. I had them put me on a different server and I had to reinstall.