Closed (fixed)
Project:
Migrate
Version:
7.x-2.x-dev
Component:
Code
Priority:
Normal
Category:
Task
Assigned:
Unassigned
Reporter:
Created:
28 Feb 2012 at 09:51 UTC
Updated:
22 May 2012 at 20:20 UTC
/**
* Implementors are expected to return a count of IDs available to be migrated.
*
* @API: Commented out so not to break implementations which haven't implemented
* this yet - require it in the next API.
*
* @return int
*/
//abstract public function computeCount();
/**
* Deprecated - implement computeCount() instead
*/
//abstract public function count($refresh = TRUE);
And at runtime I get this error:
Fatal error: Call to undefined method MyListImplementation::count()
What should I do here? The documentation is seriously misleading! I will read the code and find out the truth, but you should definitely fix this broken implementation and documentation.
Any explaination is welcome, thanks!
Comments
Comment #1
pounardFound out:
You are keeping the
count()method for backward compatibility but supporting the new one by definingcomputeCount(), you are trying to maintain two different and conflicting API versions in the same code, which is a definite FTL (For The Fail) because the code is not self-documenting (no method signature is declared) and you are forced to do runtime checks.You may be able to drop either one of those and make the mandatory one abstract, or at least provide a default implementation without breaking it, but I don't see a clean solution here.
Comment #2
mikeryanOK, as long as we're doing some API breakage in the file area, maybe it's time to remove some long-deprecated stuff like this... I would hope by now any active custom source plugins should be using the current preferred computeCount method.
Comment #3
mikeryanOK, cleaned this up along with some other deprecated stuff.
Comment #4
pounardSimple question, why aren't you using just
count()here, using theCountableSPL interface, it would make sense?Comment #5
mikeryancount() is implemented in MigrateSource, and manages caching the counts. The computeCount() in the individual source classes is responsible for getting the real current count, and is called by count() only when actually needed.
Comment #6
pounardOh right ok, but there is no name colliding even keeping the Countable interface for both, right?